babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. import { WebRequest } from "babylonjs/Misc/webRequest";
  1476. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1478. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1479. /** @hidden */
  1480. export class ShaderProcessor {
  1481. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1482. private static _ProcessPrecision;
  1483. private static _ExtractOperation;
  1484. private static _BuildSubExpression;
  1485. private static _BuildExpression;
  1486. private static _MoveCursorWithinIf;
  1487. private static _MoveCursor;
  1488. private static _EvaluatePreProcessors;
  1489. private static _PreparePreProcessors;
  1490. private static _ProcessShaderConversion;
  1491. private static _ProcessIncludes;
  1492. /**
  1493. * Loads a file from a url
  1494. * @param url url to load
  1495. * @param onSuccess callback called when the file successfully loads
  1496. * @param onProgress callback called while file is loading (if the server supports this mode)
  1497. * @param offlineProvider defines the offline provider for caching
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @returns a file request object
  1501. * @hidden
  1502. */
  1503. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1504. }
  1505. }
  1506. declare module "babylonjs/Maths/math.like" {
  1507. import { float, int, DeepImmutable } from "babylonjs/types";
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IColor4Like {
  1512. r: float;
  1513. g: float;
  1514. b: float;
  1515. a: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IColor3Like {
  1521. r: float;
  1522. g: float;
  1523. b: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IVector4Like {
  1529. x: float;
  1530. y: float;
  1531. z: float;
  1532. w: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IVector3Like {
  1538. x: float;
  1539. y: float;
  1540. z: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IVector2Like {
  1546. x: float;
  1547. y: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IMatrixLike {
  1553. toArray(): DeepImmutable<Float32Array>;
  1554. updateFlag: int;
  1555. }
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IViewportLike {
  1560. x: float;
  1561. y: float;
  1562. width: float;
  1563. height: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IPlaneLike {
  1569. normal: IVector3Like;
  1570. d: float;
  1571. normalize(): void;
  1572. }
  1573. }
  1574. declare module "babylonjs/Materials/iEffectFallbacks" {
  1575. import { Effect } from "babylonjs/Materials/effect";
  1576. /**
  1577. * Interface used to define common properties for effect fallbacks
  1578. */
  1579. export interface IEffectFallbacks {
  1580. /**
  1581. * Removes the defines that should be removed when falling back.
  1582. * @param currentDefines defines the current define statements for the shader.
  1583. * @param effect defines the current effect we try to compile
  1584. * @returns The resulting defines with defines of the current rank removed.
  1585. */
  1586. reduce(currentDefines: string, effect: Effect): string;
  1587. /**
  1588. * Removes the fallback from the bound mesh.
  1589. */
  1590. unBindMesh(): void;
  1591. /**
  1592. * Checks to see if more fallbacks are still availible.
  1593. */
  1594. hasMoreFallbacks: boolean;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1598. /**
  1599. * Class used to evalaute queries containing `and` and `or` operators
  1600. */
  1601. export class AndOrNotEvaluator {
  1602. /**
  1603. * Evaluate a query
  1604. * @param query defines the query to evaluate
  1605. * @param evaluateCallback defines the callback used to filter result
  1606. * @returns true if the query matches
  1607. */
  1608. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1609. private static _HandleParenthesisContent;
  1610. private static _SimplifyNegation;
  1611. }
  1612. }
  1613. declare module "babylonjs/Misc/tags" {
  1614. /**
  1615. * Class used to store custom tags
  1616. */
  1617. export class Tags {
  1618. /**
  1619. * Adds support for tags on the given object
  1620. * @param obj defines the object to use
  1621. */
  1622. static EnableFor(obj: any): void;
  1623. /**
  1624. * Removes tags support
  1625. * @param obj defines the object to use
  1626. */
  1627. static DisableFor(obj: any): void;
  1628. /**
  1629. * Gets a boolean indicating if the given object has tags
  1630. * @param obj defines the object to use
  1631. * @returns a boolean
  1632. */
  1633. static HasTags(obj: any): boolean;
  1634. /**
  1635. * Gets the tags available on a given object
  1636. * @param obj defines the object to use
  1637. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1638. * @returns the tags
  1639. */
  1640. static GetTags(obj: any, asString?: boolean): any;
  1641. /**
  1642. * Adds tags to an object
  1643. * @param obj defines the object to use
  1644. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1645. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1646. */
  1647. static AddTagsTo(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _AddTagTo(obj: any, tag: string): void;
  1652. /**
  1653. * Removes specific tags from a specific object
  1654. * @param obj defines the object to use
  1655. * @param tagsString defines the tags to remove
  1656. */
  1657. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1658. /**
  1659. * @hidden
  1660. */
  1661. static _RemoveTagFrom(obj: any, tag: string): void;
  1662. /**
  1663. * Defines if tags hosted on an object match a given query
  1664. * @param obj defines the object to use
  1665. * @param tagsQuery defines the tag query
  1666. * @returns a boolean
  1667. */
  1668. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1669. }
  1670. }
  1671. declare module "babylonjs/Maths/math.scalar" {
  1672. /**
  1673. * Scalar computation library
  1674. */
  1675. export class Scalar {
  1676. /**
  1677. * Two pi constants convenient for computation.
  1678. */
  1679. static TwoPi: number;
  1680. /**
  1681. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1682. * @param a number
  1683. * @param b number
  1684. * @param epsilon (default = 1.401298E-45)
  1685. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1686. */
  1687. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1688. /**
  1689. * Returns a string : the upper case translation of the number i to hexadecimal.
  1690. * @param i number
  1691. * @returns the upper case translation of the number i to hexadecimal.
  1692. */
  1693. static ToHex(i: number): string;
  1694. /**
  1695. * Returns -1 if value is negative and +1 is value is positive.
  1696. * @param value the value
  1697. * @returns the value itself if it's equal to zero.
  1698. */
  1699. static Sign(value: number): number;
  1700. /**
  1701. * Returns the value itself if it's between min and max.
  1702. * Returns min if the value is lower than min.
  1703. * Returns max if the value is greater than max.
  1704. * @param value the value to clmap
  1705. * @param min the min value to clamp to (default: 0)
  1706. * @param max the max value to clamp to (default: 1)
  1707. * @returns the clamped value
  1708. */
  1709. static Clamp(value: number, min?: number, max?: number): number;
  1710. /**
  1711. * the log2 of value.
  1712. * @param value the value to compute log2 of
  1713. * @returns the log2 of value.
  1714. */
  1715. static Log2(value: number): number;
  1716. /**
  1717. * Loops the value, so that it is never larger than length and never smaller than 0.
  1718. *
  1719. * This is similar to the modulo operator but it works with floating point numbers.
  1720. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1721. * With t = 5 and length = 2.5, the result would be 0.0.
  1722. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1723. * @param value the value
  1724. * @param length the length
  1725. * @returns the looped value
  1726. */
  1727. static Repeat(value: number, length: number): number;
  1728. /**
  1729. * Normalize the value between 0.0 and 1.0 using min and max values
  1730. * @param value value to normalize
  1731. * @param min max to normalize between
  1732. * @param max min to normalize between
  1733. * @returns the normalized value
  1734. */
  1735. static Normalize(value: number, min: number, max: number): number;
  1736. /**
  1737. * Denormalize the value from 0.0 and 1.0 using min and max values
  1738. * @param normalized value to denormalize
  1739. * @param min max to denormalize between
  1740. * @param max min to denormalize between
  1741. * @returns the denormalized value
  1742. */
  1743. static Denormalize(normalized: number, min: number, max: number): number;
  1744. /**
  1745. * Calculates the shortest difference between two given angles given in degrees.
  1746. * @param current current angle in degrees
  1747. * @param target target angle in degrees
  1748. * @returns the delta
  1749. */
  1750. static DeltaAngle(current: number, target: number): number;
  1751. /**
  1752. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1753. * @param tx value
  1754. * @param length length
  1755. * @returns The returned value will move back and forth between 0 and length
  1756. */
  1757. static PingPong(tx: number, length: number): number;
  1758. /**
  1759. * Interpolates between min and max with smoothing at the limits.
  1760. *
  1761. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1762. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1763. * @param from from
  1764. * @param to to
  1765. * @param tx value
  1766. * @returns the smooth stepped value
  1767. */
  1768. static SmoothStep(from: number, to: number, tx: number): number;
  1769. /**
  1770. * Moves a value current towards target.
  1771. *
  1772. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1773. * Negative values of maxDelta pushes the value away from target.
  1774. * @param current current value
  1775. * @param target target value
  1776. * @param maxDelta max distance to move
  1777. * @returns resulting value
  1778. */
  1779. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1780. /**
  1781. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. *
  1783. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1784. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1785. * @param current current value
  1786. * @param target target value
  1787. * @param maxDelta max distance to move
  1788. * @returns resulting angle
  1789. */
  1790. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1791. /**
  1792. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1793. * @param start start value
  1794. * @param end target value
  1795. * @param amount amount to lerp between
  1796. * @returns the lerped value
  1797. */
  1798. static Lerp(start: number, end: number, amount: number): number;
  1799. /**
  1800. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1801. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static LerpAngle(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1810. * @param a start value
  1811. * @param b target value
  1812. * @param value value between a and b
  1813. * @returns the inverseLerp value
  1814. */
  1815. static InverseLerp(a: number, b: number, value: number): number;
  1816. /**
  1817. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1818. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1819. * @param value1 spline value
  1820. * @param tangent1 spline value
  1821. * @param value2 spline value
  1822. * @param tangent2 spline value
  1823. * @param amount input value
  1824. * @returns hermite result
  1825. */
  1826. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1827. /**
  1828. * Returns a random float number between and min and max values
  1829. * @param min min value of random
  1830. * @param max max value of random
  1831. * @returns random value
  1832. */
  1833. static RandomRange(min: number, max: number): number;
  1834. /**
  1835. * This function returns percentage of a number in a given range.
  1836. *
  1837. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1838. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1839. * @param number to convert to percentage
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the percentage
  1843. */
  1844. static RangeToPercent(number: number, min: number, max: number): number;
  1845. /**
  1846. * This function returns number that corresponds to the percentage in a given range.
  1847. *
  1848. * PercentToRange(0.34,0,100) will return 34.
  1849. * @param percent to convert to number
  1850. * @param min min range
  1851. * @param max max range
  1852. * @returns the number
  1853. */
  1854. static PercentToRange(percent: number, min: number, max: number): number;
  1855. /**
  1856. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1857. * @param angle The angle to normalize in radian.
  1858. * @return The converted angle.
  1859. */
  1860. static NormalizeRadians(angle: number): number;
  1861. }
  1862. }
  1863. declare module "babylonjs/Maths/math.constants" {
  1864. /**
  1865. * Constant used to convert a value to gamma space
  1866. * @ignorenaming
  1867. */
  1868. export const ToGammaSpace: number;
  1869. /**
  1870. * Constant used to convert a value to linear space
  1871. * @ignorenaming
  1872. */
  1873. export const ToLinearSpace = 2.2;
  1874. /**
  1875. * Constant used to define the minimal number value in Babylon.js
  1876. * @ignorenaming
  1877. */
  1878. let Epsilon: number;
  1879. export { Epsilon };
  1880. }
  1881. declare module "babylonjs/Maths/math.viewport" {
  1882. /**
  1883. * Class used to represent a viewport on screen
  1884. */
  1885. export class Viewport {
  1886. /** viewport left coordinate */
  1887. x: number;
  1888. /** viewport top coordinate */
  1889. y: number;
  1890. /**viewport width */
  1891. width: number;
  1892. /** viewport height */
  1893. height: number;
  1894. /**
  1895. * Creates a Viewport object located at (x, y) and sized (width, height)
  1896. * @param x defines viewport left coordinate
  1897. * @param y defines viewport top coordinate
  1898. * @param width defines the viewport width
  1899. * @param height defines the viewport height
  1900. */
  1901. constructor(
  1902. /** viewport left coordinate */
  1903. x: number,
  1904. /** viewport top coordinate */
  1905. y: number,
  1906. /**viewport width */
  1907. width: number,
  1908. /** viewport height */
  1909. height: number);
  1910. /**
  1911. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1912. * @param renderWidth defines the rendering width
  1913. * @param renderHeight defines the rendering height
  1914. * @returns a new Viewport
  1915. */
  1916. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1917. /**
  1918. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1919. * @param renderWidth defines the rendering width
  1920. * @param renderHeight defines the rendering height
  1921. * @param ref defines the target viewport
  1922. * @returns the current viewport
  1923. */
  1924. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1925. /**
  1926. * Returns a new Viewport copied from the current one
  1927. * @returns a new Viewport
  1928. */
  1929. clone(): Viewport;
  1930. }
  1931. }
  1932. declare module "babylonjs/Misc/arrayTools" {
  1933. /**
  1934. * Class containing a set of static utilities functions for arrays.
  1935. */
  1936. export class ArrayTools {
  1937. /**
  1938. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1939. * @param size the number of element to construct and put in the array
  1940. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1941. * @returns a new array filled with new objects
  1942. */
  1943. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1944. }
  1945. }
  1946. declare module "babylonjs/Maths/math.vector" {
  1947. import { Viewport } from "babylonjs/Maths/math.viewport";
  1948. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1949. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1950. /**
  1951. * Class representing a vector containing 2 coordinates
  1952. */
  1953. export class Vector2 {
  1954. /** defines the first coordinate */
  1955. x: number;
  1956. /** defines the second coordinate */
  1957. y: number;
  1958. /**
  1959. * Creates a new Vector2 from the given x and y coordinates
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. */
  1963. constructor(
  1964. /** defines the first coordinate */
  1965. x?: number,
  1966. /** defines the second coordinate */
  1967. y?: number);
  1968. /**
  1969. * Gets a string with the Vector2 coordinates
  1970. * @returns a string with the Vector2 coordinates
  1971. */
  1972. toString(): string;
  1973. /**
  1974. * Gets class name
  1975. * @returns the string "Vector2"
  1976. */
  1977. getClassName(): string;
  1978. /**
  1979. * Gets current vector hash code
  1980. * @returns the Vector2 hash code as a number
  1981. */
  1982. getHashCode(): number;
  1983. /**
  1984. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1985. * @param array defines the source array
  1986. * @param index defines the offset in source array
  1987. * @returns the current Vector2
  1988. */
  1989. toArray(array: FloatArray, index?: number): Vector2;
  1990. /**
  1991. * Copy the current vector to an array
  1992. * @returns a new array with 2 elements: the Vector2 coordinates.
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1997. * @param source defines the source Vector2
  1998. * @returns the current updated Vector2
  1999. */
  2000. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2001. /**
  2002. * Sets the Vector2 coordinates with the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns the current updated Vector2
  2006. */
  2007. copyFromFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Sets the Vector2 coordinates with the given floats
  2010. * @param x defines the first coordinate
  2011. * @param y defines the second coordinate
  2012. * @returns the current updated Vector2
  2013. */
  2014. set(x: number, y: number): Vector2;
  2015. /**
  2016. * Add another vector with the current one
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2019. */
  2020. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2021. /**
  2022. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2023. * @param otherVector defines the other vector
  2024. * @param result defines the target vector
  2025. * @returns the unmodified current Vector2
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2028. /**
  2029. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2030. * @param otherVector defines the other vector
  2031. * @returns the current updated Vector2
  2032. */
  2033. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2034. /**
  2035. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns a new Vector2
  2038. */
  2039. addVector3(otherVector: Vector3): Vector2;
  2040. /**
  2041. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. subtract(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Multiplies in place the current Vector2 coordinates by the given ones
  2061. * @param otherVector defines the other vector
  2062. * @returns the current updated Vector2
  2063. */
  2064. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2065. /**
  2066. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @returns a new Vector2
  2069. */
  2070. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2071. /**
  2072. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2073. * @param otherVector defines the other vector
  2074. * @param result defines the target vector
  2075. * @returns the unmodified current Vector2
  2076. */
  2077. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2078. /**
  2079. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2080. * @param x defines the first coordinate
  2081. * @param y defines the second coordinate
  2082. * @returns a new Vector2
  2083. */
  2084. multiplyByFloats(x: number, y: number): Vector2;
  2085. /**
  2086. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2087. * @param otherVector defines the other vector
  2088. * @returns a new Vector2
  2089. */
  2090. divide(otherVector: Vector2): Vector2;
  2091. /**
  2092. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2093. * @param otherVector defines the other vector
  2094. * @param result defines the target vector
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2098. /**
  2099. * Divides the current Vector2 coordinates by the given ones
  2100. * @param otherVector defines the other vector
  2101. * @returns the current updated Vector2
  2102. */
  2103. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2104. /**
  2105. * Gets a new Vector2 with current Vector2 negated coordinates
  2106. * @returns a new Vector2
  2107. */
  2108. negate(): Vector2;
  2109. /**
  2110. * Negate this vector in place
  2111. * @returns this
  2112. */
  2113. negateInPlace(): Vector2;
  2114. /**
  2115. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2116. * @param result defines the Vector3 object where to store the result
  2117. * @returns the current Vector2
  2118. */
  2119. negateToRef(result: Vector2): Vector2;
  2120. /**
  2121. * Multiply the Vector2 coordinates by scale
  2122. * @param scale defines the scaling factor
  2123. * @returns the current updated Vector2
  2124. */
  2125. scaleInPlace(scale: number): Vector2;
  2126. /**
  2127. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2128. * @param scale defines the scaling factor
  2129. * @returns a new Vector2
  2130. */
  2131. scale(scale: number): Vector2;
  2132. /**
  2133. * Scale the current Vector2 values by a factor to a given Vector2
  2134. * @param scale defines the scale factor
  2135. * @param result defines the Vector2 object where to store the result
  2136. * @returns the unmodified current Vector2
  2137. */
  2138. scaleToRef(scale: number, result: Vector2): Vector2;
  2139. /**
  2140. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2141. * @param scale defines the scale factor
  2142. * @param result defines the Vector2 object where to store the result
  2143. * @returns the unmodified current Vector2
  2144. */
  2145. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2146. /**
  2147. * Gets a boolean if two vectors are equals
  2148. * @param otherVector defines the other vector
  2149. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2150. */
  2151. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2152. /**
  2153. * Gets a boolean if two vectors are equals (using an epsilon value)
  2154. * @param otherVector defines the other vector
  2155. * @param epsilon defines the minimal distance to consider equality
  2156. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2157. */
  2158. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2159. /**
  2160. * Gets a new Vector2 from current Vector2 floored values
  2161. * @returns a new Vector2
  2162. */
  2163. floor(): Vector2;
  2164. /**
  2165. * Gets a new Vector2 from current Vector2 floored values
  2166. * @returns a new Vector2
  2167. */
  2168. fract(): Vector2;
  2169. /**
  2170. * Gets the length of the vector
  2171. * @returns the vector length (float)
  2172. */
  2173. length(): number;
  2174. /**
  2175. * Gets the vector squared length
  2176. * @returns the vector squared length (float)
  2177. */
  2178. lengthSquared(): number;
  2179. /**
  2180. * Normalize the vector
  2181. * @returns the current updated Vector2
  2182. */
  2183. normalize(): Vector2;
  2184. /**
  2185. * Gets a new Vector2 copied from the Vector2
  2186. * @returns a new Vector2
  2187. */
  2188. clone(): Vector2;
  2189. /**
  2190. * Gets a new Vector2(0, 0)
  2191. * @returns a new Vector2
  2192. */
  2193. static Zero(): Vector2;
  2194. /**
  2195. * Gets a new Vector2(1, 1)
  2196. * @returns a new Vector2
  2197. */
  2198. static One(): Vector2;
  2199. /**
  2200. * Gets a new Vector2 set from the given index element of the given array
  2201. * @param array defines the data source
  2202. * @param offset defines the offset in the data source
  2203. * @returns a new Vector2
  2204. */
  2205. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2206. /**
  2207. * Sets "result" from the given index element of the given array
  2208. * @param array defines the data source
  2209. * @param offset defines the offset in the data source
  2210. * @param result defines the target vector
  2211. */
  2212. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2213. /**
  2214. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2215. * @param value1 defines 1st point of control
  2216. * @param value2 defines 2nd point of control
  2217. * @param value3 defines 3rd point of control
  2218. * @param value4 defines 4th point of control
  2219. * @param amount defines the interpolation factor
  2220. * @returns a new Vector2
  2221. */
  2222. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2223. /**
  2224. * 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".
  2225. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2226. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2227. * @param value defines the value to clamp
  2228. * @param min defines the lower limit
  2229. * @param max defines the upper limit
  2230. * @returns a new Vector2
  2231. */
  2232. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2235. * @param value1 defines the 1st control point
  2236. * @param tangent1 defines the outgoing tangent
  2237. * @param value2 defines the 2nd control point
  2238. * @param tangent2 defines the incoming tangent
  2239. * @param amount defines the interpolation factor
  2240. * @returns a new Vector2
  2241. */
  2242. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2243. /**
  2244. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2245. * @param start defines the start vector
  2246. * @param end defines the end vector
  2247. * @param amount defines the interpolation factor
  2248. * @returns a new Vector2
  2249. */
  2250. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2251. /**
  2252. * Gets the dot product of the vector "left" and the vector "right"
  2253. * @param left defines first vector
  2254. * @param right defines second vector
  2255. * @returns the dot product (float)
  2256. */
  2257. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2258. /**
  2259. * Returns a new Vector2 equal to the normalized given vector
  2260. * @param vector defines the vector to normalize
  2261. * @returns a new Vector2
  2262. */
  2263. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2264. /**
  2265. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2266. * @param left defines 1st vector
  2267. * @param right defines 2nd vector
  2268. * @returns a new Vector2
  2269. */
  2270. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2273. * @param left defines 1st vector
  2274. * @param right defines 2nd vector
  2275. * @returns a new Vector2
  2276. */
  2277. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2278. /**
  2279. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2280. * @param vector defines the vector to transform
  2281. * @param transformation defines the matrix to apply
  2282. * @returns a new Vector2
  2283. */
  2284. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2285. /**
  2286. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2287. * @param vector defines the vector to transform
  2288. * @param transformation defines the matrix to apply
  2289. * @param result defines the target vector
  2290. */
  2291. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2292. /**
  2293. * Determines if a given vector is included in a triangle
  2294. * @param p defines the vector to test
  2295. * @param p0 defines 1st triangle point
  2296. * @param p1 defines 2nd triangle point
  2297. * @param p2 defines 3rd triangle point
  2298. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2299. */
  2300. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2301. /**
  2302. * Gets the distance between the vectors "value1" and "value2"
  2303. * @param value1 defines first vector
  2304. * @param value2 defines second vector
  2305. * @returns the distance between vectors
  2306. */
  2307. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2308. /**
  2309. * Returns the squared distance between the vectors "value1" and "value2"
  2310. * @param value1 defines first vector
  2311. * @param value2 defines second vector
  2312. * @returns the squared distance between vectors
  2313. */
  2314. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2315. /**
  2316. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2317. * @param value1 defines first vector
  2318. * @param value2 defines second vector
  2319. * @returns a new Vector2
  2320. */
  2321. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2322. /**
  2323. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2324. * @param p defines the middle point
  2325. * @param segA defines one point of the segment
  2326. * @param segB defines the other point of the segment
  2327. * @returns the shortest distance
  2328. */
  2329. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2330. }
  2331. /**
  2332. * Class used to store (x,y,z) vector representation
  2333. * A Vector3 is the main object used in 3D geometry
  2334. * It can represent etiher the coordinates of a point the space, either a direction
  2335. * Reminder: js uses a left handed forward facing system
  2336. */
  2337. export class Vector3 {
  2338. /**
  2339. * Defines the first coordinates (on X axis)
  2340. */
  2341. x: number;
  2342. /**
  2343. * Defines the second coordinates (on Y axis)
  2344. */
  2345. y: number;
  2346. /**
  2347. * Defines the third coordinates (on Z axis)
  2348. */
  2349. z: number;
  2350. private static _UpReadOnly;
  2351. private static _ZeroReadOnly;
  2352. /**
  2353. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2354. * @param x defines the first coordinates (on X axis)
  2355. * @param y defines the second coordinates (on Y axis)
  2356. * @param z defines the third coordinates (on Z axis)
  2357. */
  2358. constructor(
  2359. /**
  2360. * Defines the first coordinates (on X axis)
  2361. */
  2362. x?: number,
  2363. /**
  2364. * Defines the second coordinates (on Y axis)
  2365. */
  2366. y?: number,
  2367. /**
  2368. * Defines the third coordinates (on Z axis)
  2369. */
  2370. z?: number);
  2371. /**
  2372. * Creates a string representation of the Vector3
  2373. * @returns a string with the Vector3 coordinates.
  2374. */
  2375. toString(): string;
  2376. /**
  2377. * Gets the class name
  2378. * @returns the string "Vector3"
  2379. */
  2380. getClassName(): string;
  2381. /**
  2382. * Creates the Vector3 hash code
  2383. * @returns a number which tends to be unique between Vector3 instances
  2384. */
  2385. getHashCode(): number;
  2386. /**
  2387. * Creates an array containing three elements : the coordinates of the Vector3
  2388. * @returns a new array of numbers
  2389. */
  2390. asArray(): number[];
  2391. /**
  2392. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2393. * @param array defines the destination array
  2394. * @param index defines the offset in the destination array
  2395. * @returns the current Vector3
  2396. */
  2397. toArray(array: FloatArray, index?: number): Vector3;
  2398. /**
  2399. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2400. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2401. */
  2402. toQuaternion(): Quaternion;
  2403. /**
  2404. * Adds the given vector to the current Vector3
  2405. * @param otherVector defines the second operand
  2406. * @returns the current updated Vector3
  2407. */
  2408. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2409. /**
  2410. * Adds the given coordinates to the current Vector3
  2411. * @param x defines the x coordinate of the operand
  2412. * @param y defines the y coordinate of the operand
  2413. * @param z defines the z coordinate of the operand
  2414. * @returns the current updated Vector3
  2415. */
  2416. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2417. /**
  2418. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2419. * @param otherVector defines the second operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2423. /**
  2424. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2430. /**
  2431. * Subtract the given vector from the current Vector3
  2432. * @param otherVector defines the second operand
  2433. * @returns the current updated Vector3
  2434. */
  2435. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2436. /**
  2437. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2438. * @param otherVector defines the second operand
  2439. * @returns the resulting Vector3
  2440. */
  2441. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2444. * @param otherVector defines the second operand
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2449. /**
  2450. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2451. * @param x defines the x coordinate of the operand
  2452. * @param y defines the y coordinate of the operand
  2453. * @param z defines the z coordinate of the operand
  2454. * @returns the resulting Vector3
  2455. */
  2456. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2457. /**
  2458. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2459. * @param x defines the x coordinate of the operand
  2460. * @param y defines the y coordinate of the operand
  2461. * @param z defines the z coordinate of the operand
  2462. * @param result defines the Vector3 object where to store the result
  2463. * @returns the current Vector3
  2464. */
  2465. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2466. /**
  2467. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2468. * @returns a new Vector3
  2469. */
  2470. negate(): Vector3;
  2471. /**
  2472. * Negate this vector in place
  2473. * @returns this
  2474. */
  2475. negateInPlace(): Vector3;
  2476. /**
  2477. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the current Vector3
  2480. */
  2481. negateToRef(result: Vector3): Vector3;
  2482. /**
  2483. * Multiplies the Vector3 coordinates by the float "scale"
  2484. * @param scale defines the multiplier factor
  2485. * @returns the current updated Vector3
  2486. */
  2487. scaleInPlace(scale: number): Vector3;
  2488. /**
  2489. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2490. * @param scale defines the multiplier factor
  2491. * @returns a new Vector3
  2492. */
  2493. scale(scale: number): Vector3;
  2494. /**
  2495. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2496. * @param scale defines the multiplier factor
  2497. * @param result defines the Vector3 object where to store the result
  2498. * @returns the current Vector3
  2499. */
  2500. scaleToRef(scale: number, result: Vector3): Vector3;
  2501. /**
  2502. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2503. * @param scale defines the scale factor
  2504. * @param result defines the Vector3 object where to store the result
  2505. * @returns the unmodified current Vector3
  2506. */
  2507. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2508. /**
  2509. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2510. * @param otherVector defines the second operand
  2511. * @returns true if both vectors are equals
  2512. */
  2513. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2514. /**
  2515. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2516. * @param otherVector defines the second operand
  2517. * @param epsilon defines the minimal distance to define values as equals
  2518. * @returns true if both vectors are distant less than epsilon
  2519. */
  2520. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2521. /**
  2522. * Returns true if the current Vector3 coordinates equals the given floats
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns true if both vectors are equals
  2527. */
  2528. equalsToFloats(x: number, y: number, z: number): boolean;
  2529. /**
  2530. * Multiplies the current Vector3 coordinates by the given ones
  2531. * @param otherVector defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2537. * @param otherVector defines the second operand
  2538. * @returns the new Vector3
  2539. */
  2540. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2541. /**
  2542. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2543. * @param otherVector defines the second operand
  2544. * @param result defines the Vector3 object where to store the result
  2545. * @returns the current Vector3
  2546. */
  2547. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2548. /**
  2549. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2550. * @param x defines the x coordinate of the operand
  2551. * @param y defines the y coordinate of the operand
  2552. * @param z defines the z coordinate of the operand
  2553. * @returns the new Vector3
  2554. */
  2555. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2556. /**
  2557. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2558. * @param otherVector defines the second operand
  2559. * @returns the new Vector3
  2560. */
  2561. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2562. /**
  2563. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2564. * @param otherVector defines the second operand
  2565. * @param result defines the Vector3 object where to store the result
  2566. * @returns the current Vector3
  2567. */
  2568. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2569. /**
  2570. * Divides the current Vector3 coordinates by the given ones.
  2571. * @param otherVector defines the second operand
  2572. * @returns the current updated Vector3
  2573. */
  2574. divideInPlace(otherVector: Vector3): Vector3;
  2575. /**
  2576. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2577. * @param other defines the second operand
  2578. * @returns the current updated Vector3
  2579. */
  2580. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2581. /**
  2582. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2583. * @param other defines the second operand
  2584. * @returns the current updated Vector3
  2585. */
  2586. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2587. /**
  2588. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2589. * @param x defines the x coordinate of the operand
  2590. * @param y defines the y coordinate of the operand
  2591. * @param z defines the z coordinate of the operand
  2592. * @returns the current updated Vector3
  2593. */
  2594. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2595. /**
  2596. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2597. * @param x defines the x coordinate of the operand
  2598. * @param y defines the y coordinate of the operand
  2599. * @param z defines the z coordinate of the operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2603. /**
  2604. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2605. * Check if is non uniform within a certain amount of decimal places to account for this
  2606. * @param epsilon the amount the values can differ
  2607. * @returns if the the vector is non uniform to a certain number of decimal places
  2608. */
  2609. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2610. /**
  2611. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2612. */
  2613. get isNonUniform(): boolean;
  2614. /**
  2615. * Gets a new Vector3 from current Vector3 floored values
  2616. * @returns a new Vector3
  2617. */
  2618. floor(): Vector3;
  2619. /**
  2620. * Gets a new Vector3 from current Vector3 floored values
  2621. * @returns a new Vector3
  2622. */
  2623. fract(): Vector3;
  2624. /**
  2625. * Gets the length of the Vector3
  2626. * @returns the length of the Vector3
  2627. */
  2628. length(): number;
  2629. /**
  2630. * Gets the squared length of the Vector3
  2631. * @returns squared length of the Vector3
  2632. */
  2633. lengthSquared(): number;
  2634. /**
  2635. * Normalize the current Vector3.
  2636. * Please note that this is an in place operation.
  2637. * @returns the current updated Vector3
  2638. */
  2639. normalize(): Vector3;
  2640. /**
  2641. * Reorders the x y z properties of the vector in place
  2642. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2643. * @returns the current updated vector
  2644. */
  2645. reorderInPlace(order: string): this;
  2646. /**
  2647. * Rotates the vector around 0,0,0 by a quaternion
  2648. * @param quaternion the rotation quaternion
  2649. * @param result vector to store the result
  2650. * @returns the resulting vector
  2651. */
  2652. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2653. /**
  2654. * Rotates a vector around a given point
  2655. * @param quaternion the rotation quaternion
  2656. * @param point the point to rotate around
  2657. * @param result vector to store the result
  2658. * @returns the resulting vector
  2659. */
  2660. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2661. /**
  2662. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2663. * The cross product is then orthogonal to both current and "other"
  2664. * @param other defines the right operand
  2665. * @returns the cross product
  2666. */
  2667. cross(other: Vector3): Vector3;
  2668. /**
  2669. * Normalize the current Vector3 with the given input length.
  2670. * Please note that this is an in place operation.
  2671. * @param len the length of the vector
  2672. * @returns the current updated Vector3
  2673. */
  2674. normalizeFromLength(len: number): Vector3;
  2675. /**
  2676. * Normalize the current Vector3 to a new vector
  2677. * @returns the new Vector3
  2678. */
  2679. normalizeToNew(): Vector3;
  2680. /**
  2681. * Normalize the current Vector3 to the reference
  2682. * @param reference define the Vector3 to update
  2683. * @returns the updated Vector3
  2684. */
  2685. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2686. /**
  2687. * Creates a new Vector3 copied from the current Vector3
  2688. * @returns the new Vector3
  2689. */
  2690. clone(): Vector3;
  2691. /**
  2692. * Copies the given vector coordinates to the current Vector3 ones
  2693. * @param source defines the source Vector3
  2694. * @returns the current updated Vector3
  2695. */
  2696. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Copies the given floats to the current Vector3 coordinates
  2699. * @param x defines the x coordinate of the operand
  2700. * @param y defines the y coordinate of the operand
  2701. * @param z defines the z coordinate of the operand
  2702. * @returns the current updated Vector3
  2703. */
  2704. copyFromFloats(x: number, y: number, z: number): Vector3;
  2705. /**
  2706. * Copies the given floats to the current Vector3 coordinates
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. set(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Copies the given float to the current Vector3 coordinates
  2715. * @param v defines the x, y and z coordinates of the operand
  2716. * @returns the current updated Vector3
  2717. */
  2718. setAll(v: number): Vector3;
  2719. /**
  2720. * Get the clip factor between two vectors
  2721. * @param vector0 defines the first operand
  2722. * @param vector1 defines the second operand
  2723. * @param axis defines the axis to use
  2724. * @param size defines the size along the axis
  2725. * @returns the clip factor
  2726. */
  2727. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2728. /**
  2729. * Get angle between two vectors
  2730. * @param vector0 angle between vector0 and vector1
  2731. * @param vector1 angle between vector0 and vector1
  2732. * @param normal direction of the normal
  2733. * @return the angle between vector0 and vector1
  2734. */
  2735. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2736. /**
  2737. * Returns a new Vector3 set from the index "offset" of the given array
  2738. * @param array defines the source array
  2739. * @param offset defines the offset in the source array
  2740. * @returns the new Vector3
  2741. */
  2742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2743. /**
  2744. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2745. * @param array defines the source array
  2746. * @param offset defines the offset in the source array
  2747. * @returns the new Vector3
  2748. * @deprecated Please use FromArray instead.
  2749. */
  2750. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2751. /**
  2752. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2753. * @param array defines the source array
  2754. * @param offset defines the offset in the source array
  2755. * @param result defines the Vector3 where to store the result
  2756. */
  2757. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2758. /**
  2759. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2760. * @param array defines the source array
  2761. * @param offset defines the offset in the source array
  2762. * @param result defines the Vector3 where to store the result
  2763. * @deprecated Please use FromArrayToRef instead.
  2764. */
  2765. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2766. /**
  2767. * Sets the given vector "result" with the given floats.
  2768. * @param x defines the x coordinate of the source
  2769. * @param y defines the y coordinate of the source
  2770. * @param z defines the z coordinate of the source
  2771. * @param result defines the Vector3 where to store the result
  2772. */
  2773. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2774. /**
  2775. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2776. * @returns a new empty Vector3
  2777. */
  2778. static Zero(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2781. * @returns a new unit Vector3
  2782. */
  2783. static One(): Vector3;
  2784. /**
  2785. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2786. * @returns a new up Vector3
  2787. */
  2788. static Up(): Vector3;
  2789. /**
  2790. * Gets a up Vector3 that must not be updated
  2791. */
  2792. static get UpReadOnly(): DeepImmutable<Vector3>;
  2793. /**
  2794. * Gets a zero Vector3 that must not be updated
  2795. */
  2796. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2797. /**
  2798. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2799. * @returns a new down Vector3
  2800. */
  2801. static Down(): Vector3;
  2802. /**
  2803. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2804. * @returns a new forward Vector3
  2805. */
  2806. static Forward(): Vector3;
  2807. /**
  2808. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2809. * @returns a new forward Vector3
  2810. */
  2811. static Backward(): Vector3;
  2812. /**
  2813. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2814. * @returns a new right Vector3
  2815. */
  2816. static Right(): Vector3;
  2817. /**
  2818. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2819. * @returns a new left Vector3
  2820. */
  2821. static Left(): Vector3;
  2822. /**
  2823. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2824. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2825. * @param vector defines the Vector3 to transform
  2826. * @param transformation defines the transformation matrix
  2827. * @returns the transformed Vector3
  2828. */
  2829. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2830. /**
  2831. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2832. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2833. * @param vector defines the Vector3 to transform
  2834. * @param transformation defines the transformation matrix
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2838. /**
  2839. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2840. * This method computes tranformed coordinates only, not transformed direction vectors
  2841. * @param x define the x coordinate of the source vector
  2842. * @param y define the y coordinate of the source vector
  2843. * @param z define the z coordinate of the source vector
  2844. * @param transformation defines the transformation matrix
  2845. * @param result defines the Vector3 where to store the result
  2846. */
  2847. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2848. /**
  2849. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2850. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2851. * @param vector defines the Vector3 to transform
  2852. * @param transformation defines the transformation matrix
  2853. * @returns the new Vector3
  2854. */
  2855. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2856. /**
  2857. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2858. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2859. * @param vector defines the Vector3 to transform
  2860. * @param transformation defines the transformation matrix
  2861. * @param result defines the Vector3 where to store the result
  2862. */
  2863. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2864. /**
  2865. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2866. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2867. * @param x define the x coordinate of the source vector
  2868. * @param y define the y coordinate of the source vector
  2869. * @param z define the z coordinate of the source vector
  2870. * @param transformation defines the transformation matrix
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2874. /**
  2875. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2876. * @param value1 defines the first control point
  2877. * @param value2 defines the second control point
  2878. * @param value3 defines the third control point
  2879. * @param value4 defines the fourth control point
  2880. * @param amount defines the amount on the spline to use
  2881. * @returns the new Vector3
  2882. */
  2883. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * 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"
  2886. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2887. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2888. * @param value defines the current value
  2889. * @param min defines the lower range value
  2890. * @param max defines the upper range value
  2891. * @returns the new Vector3
  2892. */
  2893. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2894. /**
  2895. * 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"
  2896. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2897. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2898. * @param value defines the current value
  2899. * @param min defines the lower range value
  2900. * @param max defines the upper range value
  2901. * @param result defines the Vector3 where to store the result
  2902. */
  2903. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2904. /**
  2905. * Checks if a given vector is inside a specific range
  2906. * @param v defines the vector to test
  2907. * @param min defines the minimum range
  2908. * @param max defines the maximum range
  2909. */
  2910. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2911. /**
  2912. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2913. * @param value1 defines the first control point
  2914. * @param tangent1 defines the first tangent vector
  2915. * @param value2 defines the second control point
  2916. * @param tangent2 defines the second tangent vector
  2917. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2918. * @returns the new Vector3
  2919. */
  2920. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2921. /**
  2922. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2923. * @param start defines the start value
  2924. * @param end defines the end value
  2925. * @param amount max defines amount between both (between 0 and 1)
  2926. * @returns the new Vector3
  2927. */
  2928. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2929. /**
  2930. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2931. * @param start defines the start value
  2932. * @param end defines the end value
  2933. * @param amount max defines amount between both (between 0 and 1)
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2937. /**
  2938. * Returns the dot product (float) between the vectors "left" and "right"
  2939. * @param left defines the left operand
  2940. * @param right defines the right operand
  2941. * @returns the dot product
  2942. */
  2943. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2944. /**
  2945. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2946. * The cross product is then orthogonal to both "left" and "right"
  2947. * @param left defines the left operand
  2948. * @param right defines the right operand
  2949. * @returns the cross product
  2950. */
  2951. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2952. /**
  2953. * Sets the given vector "result" with the cross product of "left" and "right"
  2954. * The cross product is then orthogonal to both "left" and "right"
  2955. * @param left defines the left operand
  2956. * @param right defines the right operand
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2960. /**
  2961. * Returns a new Vector3 as the normalization of the given vector
  2962. * @param vector defines the Vector3 to normalize
  2963. * @returns the new Vector3
  2964. */
  2965. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2966. /**
  2967. * Sets the given vector "result" with the normalization of the given first vector
  2968. * @param vector defines the Vector3 to normalize
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2972. /**
  2973. * Project a Vector3 onto screen space
  2974. * @param vector defines the Vector3 to project
  2975. * @param world defines the world matrix to use
  2976. * @param transform defines the transform (view x projection) matrix to use
  2977. * @param viewport defines the screen viewport to use
  2978. * @returns the new Vector3
  2979. */
  2980. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2981. /** @hidden */
  2982. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Unproject from screen space to object space
  2985. * @param source defines the screen space Vector3 to use
  2986. * @param viewportWidth defines the current width of the viewport
  2987. * @param viewportHeight defines the current height of the viewport
  2988. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2989. * @param transform defines the transform (view x projection) matrix to use
  2990. * @returns the new Vector3
  2991. */
  2992. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2993. /**
  2994. * Unproject from screen space to object space
  2995. * @param source defines the screen space Vector3 to use
  2996. * @param viewportWidth defines the current width of the viewport
  2997. * @param viewportHeight defines the current height of the viewport
  2998. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2999. * @param view defines the view matrix to use
  3000. * @param projection defines the projection matrix to use
  3001. * @returns the new Vector3
  3002. */
  3003. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3004. /**
  3005. * Unproject from screen space to object space
  3006. * @param source defines the screen space Vector3 to use
  3007. * @param viewportWidth defines the current width of the viewport
  3008. * @param viewportHeight defines the current height of the viewport
  3009. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3010. * @param view defines the view matrix to use
  3011. * @param projection defines the projection matrix to use
  3012. * @param result defines the Vector3 where to store the result
  3013. */
  3014. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3015. /**
  3016. * Unproject from screen space to object space
  3017. * @param sourceX defines the screen space x coordinate to use
  3018. * @param sourceY defines the screen space y coordinate to use
  3019. * @param sourceZ defines the screen space z coordinate to use
  3020. * @param viewportWidth defines the current width of the viewport
  3021. * @param viewportHeight defines the current height of the viewport
  3022. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3023. * @param view defines the view matrix to use
  3024. * @param projection defines the projection matrix to use
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Gets the minimal coordinate values between two Vector3
  3030. * @param left defines the first operand
  3031. * @param right defines the second operand
  3032. * @returns the new Vector3
  3033. */
  3034. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3035. /**
  3036. * Gets the maximal coordinate values between two Vector3
  3037. * @param left defines the first operand
  3038. * @param right defines the second operand
  3039. * @returns the new Vector3
  3040. */
  3041. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3042. /**
  3043. * Returns the distance between the vectors "value1" and "value2"
  3044. * @param value1 defines the first operand
  3045. * @param value2 defines the second operand
  3046. * @returns the distance
  3047. */
  3048. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3049. /**
  3050. * Returns the squared distance between the vectors "value1" and "value2"
  3051. * @param value1 defines the first operand
  3052. * @param value2 defines the second operand
  3053. * @returns the squared distance
  3054. */
  3055. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3056. /**
  3057. * Returns a new Vector3 located at the center between "value1" and "value2"
  3058. * @param value1 defines the first operand
  3059. * @param value2 defines the second operand
  3060. * @returns the new Vector3
  3061. */
  3062. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3063. /**
  3064. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3065. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3066. * to something in order to rotate it from its local system to the given target system
  3067. * Note: axis1, axis2 and axis3 are normalized during this operation
  3068. * @param axis1 defines the first axis
  3069. * @param axis2 defines the second axis
  3070. * @param axis3 defines the third axis
  3071. * @returns a new Vector3
  3072. */
  3073. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3074. /**
  3075. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3076. * @param axis1 defines the first axis
  3077. * @param axis2 defines the second axis
  3078. * @param axis3 defines the third axis
  3079. * @param ref defines the Vector3 where to store the result
  3080. */
  3081. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3082. }
  3083. /**
  3084. * Vector4 class created for EulerAngle class conversion to Quaternion
  3085. */
  3086. export class Vector4 {
  3087. /** x value of the vector */
  3088. x: number;
  3089. /** y value of the vector */
  3090. y: number;
  3091. /** z value of the vector */
  3092. z: number;
  3093. /** w value of the vector */
  3094. w: number;
  3095. /**
  3096. * Creates a Vector4 object from the given floats.
  3097. * @param x x value of the vector
  3098. * @param y y value of the vector
  3099. * @param z z value of the vector
  3100. * @param w w value of the vector
  3101. */
  3102. constructor(
  3103. /** x value of the vector */
  3104. x: number,
  3105. /** y value of the vector */
  3106. y: number,
  3107. /** z value of the vector */
  3108. z: number,
  3109. /** w value of the vector */
  3110. w: number);
  3111. /**
  3112. * Returns the string with the Vector4 coordinates.
  3113. * @returns a string containing all the vector values
  3114. */
  3115. toString(): string;
  3116. /**
  3117. * Returns the string "Vector4".
  3118. * @returns "Vector4"
  3119. */
  3120. getClassName(): string;
  3121. /**
  3122. * Returns the Vector4 hash code.
  3123. * @returns a unique hash code
  3124. */
  3125. getHashCode(): number;
  3126. /**
  3127. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3128. * @returns the resulting array
  3129. */
  3130. asArray(): number[];
  3131. /**
  3132. * Populates the given array from the given index with the Vector4 coordinates.
  3133. * @param array array to populate
  3134. * @param index index of the array to start at (default: 0)
  3135. * @returns the Vector4.
  3136. */
  3137. toArray(array: FloatArray, index?: number): Vector4;
  3138. /**
  3139. * Adds the given vector to the current Vector4.
  3140. * @param otherVector the vector to add
  3141. * @returns the updated Vector4.
  3142. */
  3143. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3144. /**
  3145. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3146. * @param otherVector the vector to add
  3147. * @returns the resulting vector
  3148. */
  3149. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3150. /**
  3151. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3152. * @param otherVector the vector to add
  3153. * @param result the vector to store the result
  3154. * @returns the current Vector4.
  3155. */
  3156. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3157. /**
  3158. * Subtract in place the given vector from the current Vector4.
  3159. * @param otherVector the vector to subtract
  3160. * @returns the updated Vector4.
  3161. */
  3162. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3163. /**
  3164. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3165. * @param otherVector the vector to add
  3166. * @returns the new vector with the result
  3167. */
  3168. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3169. /**
  3170. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3171. * @param otherVector the vector to subtract
  3172. * @param result the vector to store the result
  3173. * @returns the current Vector4.
  3174. */
  3175. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3176. /**
  3177. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3178. */
  3179. /**
  3180. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3181. * @param x value to subtract
  3182. * @param y value to subtract
  3183. * @param z value to subtract
  3184. * @param w value to subtract
  3185. * @returns new vector containing the result
  3186. */
  3187. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3188. /**
  3189. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3190. * @param x value to subtract
  3191. * @param y value to subtract
  3192. * @param z value to subtract
  3193. * @param w value to subtract
  3194. * @param result the vector to store the result in
  3195. * @returns the current Vector4.
  3196. */
  3197. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3198. /**
  3199. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3200. * @returns a new vector with the negated values
  3201. */
  3202. negate(): Vector4;
  3203. /**
  3204. * Negate this vector in place
  3205. * @returns this
  3206. */
  3207. negateInPlace(): Vector4;
  3208. /**
  3209. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3210. * @param result defines the Vector3 object where to store the result
  3211. * @returns the current Vector4
  3212. */
  3213. negateToRef(result: Vector4): Vector4;
  3214. /**
  3215. * Multiplies the current Vector4 coordinates by scale (float).
  3216. * @param scale the number to scale with
  3217. * @returns the updated Vector4.
  3218. */
  3219. scaleInPlace(scale: number): Vector4;
  3220. /**
  3221. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3222. * @param scale the number to scale with
  3223. * @returns a new vector with the result
  3224. */
  3225. scale(scale: number): Vector4;
  3226. /**
  3227. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3228. * @param scale the number to scale with
  3229. * @param result a vector to store the result in
  3230. * @returns the current Vector4.
  3231. */
  3232. scaleToRef(scale: number, result: Vector4): Vector4;
  3233. /**
  3234. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3235. * @param scale defines the scale factor
  3236. * @param result defines the Vector4 object where to store the result
  3237. * @returns the unmodified current Vector4
  3238. */
  3239. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3240. /**
  3241. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3242. * @param otherVector the vector to compare against
  3243. * @returns true if they are equal
  3244. */
  3245. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3246. /**
  3247. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3248. * @param otherVector vector to compare against
  3249. * @param epsilon (Default: very small number)
  3250. * @returns true if they are equal
  3251. */
  3252. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3253. /**
  3254. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3255. * @param x x value to compare against
  3256. * @param y y value to compare against
  3257. * @param z z value to compare against
  3258. * @param w w value to compare against
  3259. * @returns true if equal
  3260. */
  3261. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3262. /**
  3263. * Multiplies in place the current Vector4 by the given one.
  3264. * @param otherVector vector to multiple with
  3265. * @returns the updated Vector4.
  3266. */
  3267. multiplyInPlace(otherVector: Vector4): Vector4;
  3268. /**
  3269. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3270. * @param otherVector vector to multiple with
  3271. * @returns resulting new vector
  3272. */
  3273. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3274. /**
  3275. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3276. * @param otherVector vector to multiple with
  3277. * @param result vector to store the result
  3278. * @returns the current Vector4.
  3279. */
  3280. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3281. /**
  3282. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3283. * @param x x value multiply with
  3284. * @param y y value multiply with
  3285. * @param z z value multiply with
  3286. * @param w w value multiply with
  3287. * @returns resulting new vector
  3288. */
  3289. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3290. /**
  3291. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3292. * @param otherVector vector to devide with
  3293. * @returns resulting new vector
  3294. */
  3295. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3296. /**
  3297. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3298. * @param otherVector vector to devide with
  3299. * @param result vector to store the result
  3300. * @returns the current Vector4.
  3301. */
  3302. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3303. /**
  3304. * Divides the current Vector3 coordinates by the given ones.
  3305. * @param otherVector vector to devide with
  3306. * @returns the updated Vector3.
  3307. */
  3308. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3309. /**
  3310. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3311. * @param other defines the second operand
  3312. * @returns the current updated Vector4
  3313. */
  3314. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3317. * @param other defines the second operand
  3318. * @returns the current updated Vector4
  3319. */
  3320. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Gets a new Vector4 from current Vector4 floored values
  3323. * @returns a new Vector4
  3324. */
  3325. floor(): Vector4;
  3326. /**
  3327. * Gets a new Vector4 from current Vector3 floored values
  3328. * @returns a new Vector4
  3329. */
  3330. fract(): Vector4;
  3331. /**
  3332. * Returns the Vector4 length (float).
  3333. * @returns the length
  3334. */
  3335. length(): number;
  3336. /**
  3337. * Returns the Vector4 squared length (float).
  3338. * @returns the length squared
  3339. */
  3340. lengthSquared(): number;
  3341. /**
  3342. * Normalizes in place the Vector4.
  3343. * @returns the updated Vector4.
  3344. */
  3345. normalize(): Vector4;
  3346. /**
  3347. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3348. * @returns this converted to a new vector3
  3349. */
  3350. toVector3(): Vector3;
  3351. /**
  3352. * Returns a new Vector4 copied from the current one.
  3353. * @returns the new cloned vector
  3354. */
  3355. clone(): Vector4;
  3356. /**
  3357. * Updates the current Vector4 with the given one coordinates.
  3358. * @param source the source vector to copy from
  3359. * @returns the updated Vector4.
  3360. */
  3361. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3362. /**
  3363. * Updates the current Vector4 coordinates with the given floats.
  3364. * @param x float to copy from
  3365. * @param y float to copy from
  3366. * @param z float to copy from
  3367. * @param w float to copy from
  3368. * @returns the updated Vector4.
  3369. */
  3370. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3371. /**
  3372. * Updates the current Vector4 coordinates with the given floats.
  3373. * @param x float to set from
  3374. * @param y float to set from
  3375. * @param z float to set from
  3376. * @param w float to set from
  3377. * @returns the updated Vector4.
  3378. */
  3379. set(x: number, y: number, z: number, w: number): Vector4;
  3380. /**
  3381. * Copies the given float to the current Vector3 coordinates
  3382. * @param v defines the x, y, z and w coordinates of the operand
  3383. * @returns the current updated Vector3
  3384. */
  3385. setAll(v: number): Vector4;
  3386. /**
  3387. * Returns a new Vector4 set from the starting index of the given array.
  3388. * @param array the array to pull values from
  3389. * @param offset the offset into the array to start at
  3390. * @returns the new vector
  3391. */
  3392. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3393. /**
  3394. * Updates the given vector "result" from the starting index of the given array.
  3395. * @param array the array to pull values from
  3396. * @param offset the offset into the array to start at
  3397. * @param result the vector to store the result in
  3398. */
  3399. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3400. /**
  3401. * Updates the given vector "result" from the starting index of the given Float32Array.
  3402. * @param array the array to pull values from
  3403. * @param offset the offset into the array to start at
  3404. * @param result the vector to store the result in
  3405. */
  3406. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3407. /**
  3408. * Updates the given vector "result" coordinates from the given floats.
  3409. * @param x float to set from
  3410. * @param y float to set from
  3411. * @param z float to set from
  3412. * @param w float to set from
  3413. * @param result the vector to the floats in
  3414. */
  3415. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3416. /**
  3417. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3418. * @returns the new vector
  3419. */
  3420. static Zero(): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3423. * @returns the new vector
  3424. */
  3425. static One(): Vector4;
  3426. /**
  3427. * Returns a new normalized Vector4 from the given one.
  3428. * @param vector the vector to normalize
  3429. * @returns the vector
  3430. */
  3431. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the given vector "result" from the normalization of the given one.
  3434. * @param vector the vector to normalize
  3435. * @param result the vector to store the result in
  3436. */
  3437. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3438. /**
  3439. * Returns a vector with the minimum values from the left and right vectors
  3440. * @param left left vector to minimize
  3441. * @param right right vector to minimize
  3442. * @returns a new vector with the minimum of the left and right vector values
  3443. */
  3444. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Returns a vector with the maximum values from the left and right vectors
  3447. * @param left left vector to maximize
  3448. * @param right right vector to maximize
  3449. * @returns a new vector with the maximum of the left and right vector values
  3450. */
  3451. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3452. /**
  3453. * Returns the distance (float) between the vectors "value1" and "value2".
  3454. * @param value1 value to calulate the distance between
  3455. * @param value2 value to calulate the distance between
  3456. * @return the distance between the two vectors
  3457. */
  3458. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3459. /**
  3460. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3461. * @param value1 value to calulate the distance between
  3462. * @param value2 value to calulate the distance between
  3463. * @return the distance between the two vectors squared
  3464. */
  3465. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3466. /**
  3467. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3468. * @param value1 value to calulate the center between
  3469. * @param value2 value to calulate the center between
  3470. * @return the center between the two vectors
  3471. */
  3472. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3473. /**
  3474. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3475. * This methods computes transformed normalized direction vectors only.
  3476. * @param vector the vector to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @returns the new vector
  3479. */
  3480. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3481. /**
  3482. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3483. * This methods computes transformed normalized direction vectors only.
  3484. * @param vector the vector to transform
  3485. * @param transformation the transformation matrix to apply
  3486. * @param result the vector to store the result in
  3487. */
  3488. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3489. /**
  3490. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3491. * This methods computes transformed normalized direction vectors only.
  3492. * @param x value to transform
  3493. * @param y value to transform
  3494. * @param z value to transform
  3495. * @param w value to transform
  3496. * @param transformation the transformation matrix to apply
  3497. * @param result the vector to store the results in
  3498. */
  3499. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3500. /**
  3501. * Creates a new Vector4 from a Vector3
  3502. * @param source defines the source data
  3503. * @param w defines the 4th component (default is 0)
  3504. * @returns a new Vector4
  3505. */
  3506. static FromVector3(source: Vector3, w?: number): Vector4;
  3507. }
  3508. /**
  3509. * Class used to store quaternion data
  3510. * @see https://en.wikipedia.org/wiki/Quaternion
  3511. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3512. */
  3513. export class Quaternion {
  3514. /** defines the first component (0 by default) */
  3515. x: number;
  3516. /** defines the second component (0 by default) */
  3517. y: number;
  3518. /** defines the third component (0 by default) */
  3519. z: number;
  3520. /** defines the fourth component (1.0 by default) */
  3521. w: number;
  3522. /**
  3523. * Creates a new Quaternion from the given floats
  3524. * @param x defines the first component (0 by default)
  3525. * @param y defines the second component (0 by default)
  3526. * @param z defines the third component (0 by default)
  3527. * @param w defines the fourth component (1.0 by default)
  3528. */
  3529. constructor(
  3530. /** defines the first component (0 by default) */
  3531. x?: number,
  3532. /** defines the second component (0 by default) */
  3533. y?: number,
  3534. /** defines the third component (0 by default) */
  3535. z?: number,
  3536. /** defines the fourth component (1.0 by default) */
  3537. w?: number);
  3538. /**
  3539. * Gets a string representation for the current quaternion
  3540. * @returns a string with the Quaternion coordinates
  3541. */
  3542. toString(): string;
  3543. /**
  3544. * Gets the class name of the quaternion
  3545. * @returns the string "Quaternion"
  3546. */
  3547. getClassName(): string;
  3548. /**
  3549. * Gets a hash code for this quaternion
  3550. * @returns the quaternion hash code
  3551. */
  3552. getHashCode(): number;
  3553. /**
  3554. * Copy the quaternion to an array
  3555. * @returns a new array populated with 4 elements from the quaternion coordinates
  3556. */
  3557. asArray(): number[];
  3558. /**
  3559. * Check if two quaternions are equals
  3560. * @param otherQuaternion defines the second operand
  3561. * @return true if the current quaternion and the given one coordinates are strictly equals
  3562. */
  3563. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3564. /**
  3565. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3566. * @param otherQuaternion defines the other quaternion
  3567. * @param epsilon defines the minimal distance to consider equality
  3568. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3569. */
  3570. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3571. /**
  3572. * Clone the current quaternion
  3573. * @returns a new quaternion copied from the current one
  3574. */
  3575. clone(): Quaternion;
  3576. /**
  3577. * Copy a quaternion to the current one
  3578. * @param other defines the other quaternion
  3579. * @returns the updated current quaternion
  3580. */
  3581. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Updates the current quaternion with the given float coordinates
  3584. * @param x defines the x coordinate
  3585. * @param y defines the y coordinate
  3586. * @param z defines the z coordinate
  3587. * @param w defines the w coordinate
  3588. * @returns the updated current quaternion
  3589. */
  3590. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3591. /**
  3592. * Updates the current quaternion from the given float coordinates
  3593. * @param x defines the x coordinate
  3594. * @param y defines the y coordinate
  3595. * @param z defines the z coordinate
  3596. * @param w defines the w coordinate
  3597. * @returns the updated current quaternion
  3598. */
  3599. set(x: number, y: number, z: number, w: number): Quaternion;
  3600. /**
  3601. * Adds two quaternions
  3602. * @param other defines the second operand
  3603. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3604. */
  3605. add(other: DeepImmutable<Quaternion>): Quaternion;
  3606. /**
  3607. * Add a quaternion to the current one
  3608. * @param other defines the quaternion to add
  3609. * @returns the current quaternion
  3610. */
  3611. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3612. /**
  3613. * Subtract two quaternions
  3614. * @param other defines the second operand
  3615. * @returns a new quaternion as the subtraction result of the given one from the current one
  3616. */
  3617. subtract(other: Quaternion): Quaternion;
  3618. /**
  3619. * Multiplies the current quaternion by a scale factor
  3620. * @param value defines the scale factor
  3621. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3622. */
  3623. scale(value: number): Quaternion;
  3624. /**
  3625. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3626. * @param scale defines the scale factor
  3627. * @param result defines the Quaternion object where to store the result
  3628. * @returns the unmodified current quaternion
  3629. */
  3630. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3631. /**
  3632. * Multiplies in place the current quaternion by a scale factor
  3633. * @param value defines the scale factor
  3634. * @returns the current modified quaternion
  3635. */
  3636. scaleInPlace(value: number): Quaternion;
  3637. /**
  3638. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3639. * @param scale defines the scale factor
  3640. * @param result defines the Quaternion object where to store the result
  3641. * @returns the unmodified current quaternion
  3642. */
  3643. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3644. /**
  3645. * Multiplies two quaternions
  3646. * @param q1 defines the second operand
  3647. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3648. */
  3649. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3650. /**
  3651. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3652. * @param q1 defines the second operand
  3653. * @param result defines the target quaternion
  3654. * @returns the current quaternion
  3655. */
  3656. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3657. /**
  3658. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3659. * @param q1 defines the second operand
  3660. * @returns the currentupdated quaternion
  3661. */
  3662. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3665. * @param ref defines the target quaternion
  3666. * @returns the current quaternion
  3667. */
  3668. conjugateToRef(ref: Quaternion): Quaternion;
  3669. /**
  3670. * Conjugates in place (1-q) the current quaternion
  3671. * @returns the current updated quaternion
  3672. */
  3673. conjugateInPlace(): Quaternion;
  3674. /**
  3675. * Conjugates in place (1-q) the current quaternion
  3676. * @returns a new quaternion
  3677. */
  3678. conjugate(): Quaternion;
  3679. /**
  3680. * Gets length of current quaternion
  3681. * @returns the quaternion length (float)
  3682. */
  3683. length(): number;
  3684. /**
  3685. * Normalize in place the current quaternion
  3686. * @returns the current updated quaternion
  3687. */
  3688. normalize(): Quaternion;
  3689. /**
  3690. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3691. * @param order is a reserved parameter and is ignore for now
  3692. * @returns a new Vector3 containing the Euler angles
  3693. */
  3694. toEulerAngles(order?: string): Vector3;
  3695. /**
  3696. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3697. * @param result defines the vector which will be filled with the Euler angles
  3698. * @param order is a reserved parameter and is ignore for now
  3699. * @returns the current unchanged quaternion
  3700. */
  3701. toEulerAnglesToRef(result: Vector3): Quaternion;
  3702. /**
  3703. * Updates the given rotation matrix with the current quaternion values
  3704. * @param result defines the target matrix
  3705. * @returns the current unchanged quaternion
  3706. */
  3707. toRotationMatrix(result: Matrix): Quaternion;
  3708. /**
  3709. * Updates the current quaternion from the given rotation matrix values
  3710. * @param matrix defines the source matrix
  3711. * @returns the current updated quaternion
  3712. */
  3713. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3714. /**
  3715. * Creates a new quaternion from a rotation matrix
  3716. * @param matrix defines the source matrix
  3717. * @returns a new quaternion created from the given rotation matrix values
  3718. */
  3719. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3720. /**
  3721. * Updates the given quaternion with the given rotation matrix values
  3722. * @param matrix defines the source matrix
  3723. * @param result defines the target quaternion
  3724. */
  3725. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3726. /**
  3727. * Returns the dot product (float) between the quaternions "left" and "right"
  3728. * @param left defines the left operand
  3729. * @param right defines the right operand
  3730. * @returns the dot product
  3731. */
  3732. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3733. /**
  3734. * Checks if the two quaternions are close to each other
  3735. * @param quat0 defines the first quaternion to check
  3736. * @param quat1 defines the second quaternion to check
  3737. * @returns true if the two quaternions are close to each other
  3738. */
  3739. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3740. /**
  3741. * Creates an empty quaternion
  3742. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3743. */
  3744. static Zero(): Quaternion;
  3745. /**
  3746. * Inverse a given quaternion
  3747. * @param q defines the source quaternion
  3748. * @returns a new quaternion as the inverted current quaternion
  3749. */
  3750. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3751. /**
  3752. * Inverse a given quaternion
  3753. * @param q defines the source quaternion
  3754. * @param result the quaternion the result will be stored in
  3755. * @returns the result quaternion
  3756. */
  3757. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates an identity quaternion
  3760. * @returns the identity quaternion
  3761. */
  3762. static Identity(): Quaternion;
  3763. /**
  3764. * Gets a boolean indicating if the given quaternion is identity
  3765. * @param quaternion defines the quaternion to check
  3766. * @returns true if the quaternion is identity
  3767. */
  3768. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3769. /**
  3770. * Creates a quaternion from a rotation around an axis
  3771. * @param axis defines the axis to use
  3772. * @param angle defines the angle to use
  3773. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3774. */
  3775. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3776. /**
  3777. * Creates a rotation around an axis and stores it into the given quaternion
  3778. * @param axis defines the axis to use
  3779. * @param angle defines the angle to use
  3780. * @param result defines the target quaternion
  3781. * @returns the target quaternion
  3782. */
  3783. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3784. /**
  3785. * Creates a new quaternion from data stored into an array
  3786. * @param array defines the data source
  3787. * @param offset defines the offset in the source array where the data starts
  3788. * @returns a new quaternion
  3789. */
  3790. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3791. /**
  3792. * Create a quaternion from Euler rotation angles
  3793. * @param x Pitch
  3794. * @param y Yaw
  3795. * @param z Roll
  3796. * @returns the new Quaternion
  3797. */
  3798. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3799. /**
  3800. * Updates a quaternion from Euler rotation angles
  3801. * @param x Pitch
  3802. * @param y Yaw
  3803. * @param z Roll
  3804. * @param result the quaternion to store the result
  3805. * @returns the updated quaternion
  3806. */
  3807. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Create a quaternion from Euler rotation vector
  3810. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3811. * @returns the new Quaternion
  3812. */
  3813. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3814. /**
  3815. * Updates a quaternion from Euler rotation vector
  3816. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3817. * @param result the quaternion to store the result
  3818. * @returns the updated quaternion
  3819. */
  3820. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3821. /**
  3822. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3823. * @param yaw defines the rotation around Y axis
  3824. * @param pitch defines the rotation around X axis
  3825. * @param roll defines the rotation around Z axis
  3826. * @returns the new quaternion
  3827. */
  3828. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3829. /**
  3830. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3831. * @param yaw defines the rotation around Y axis
  3832. * @param pitch defines the rotation around X axis
  3833. * @param roll defines the rotation around Z axis
  3834. * @param result defines the target quaternion
  3835. */
  3836. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3837. /**
  3838. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3839. * @param alpha defines the rotation around first axis
  3840. * @param beta defines the rotation around second axis
  3841. * @param gamma defines the rotation around third axis
  3842. * @returns the new quaternion
  3843. */
  3844. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3845. /**
  3846. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3847. * @param alpha defines the rotation around first axis
  3848. * @param beta defines the rotation around second axis
  3849. * @param gamma defines the rotation around third axis
  3850. * @param result defines the target quaternion
  3851. */
  3852. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3853. /**
  3854. * 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)
  3855. * @param axis1 defines the first axis
  3856. * @param axis2 defines the second axis
  3857. * @param axis3 defines the third axis
  3858. * @returns the new quaternion
  3859. */
  3860. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3861. /**
  3862. * 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
  3863. * @param axis1 defines the first axis
  3864. * @param axis2 defines the second axis
  3865. * @param axis3 defines the third axis
  3866. * @param ref defines the target quaternion
  3867. */
  3868. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3869. /**
  3870. * Interpolates between two quaternions
  3871. * @param left defines first quaternion
  3872. * @param right defines second quaternion
  3873. * @param amount defines the gradient to use
  3874. * @returns the new interpolated quaternion
  3875. */
  3876. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3877. /**
  3878. * Interpolates between two quaternions and stores it into a target quaternion
  3879. * @param left defines first quaternion
  3880. * @param right defines second quaternion
  3881. * @param amount defines the gradient to use
  3882. * @param result defines the target quaternion
  3883. */
  3884. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3885. /**
  3886. * Interpolate between two quaternions using Hermite interpolation
  3887. * @param value1 defines first quaternion
  3888. * @param tangent1 defines the incoming tangent
  3889. * @param value2 defines second quaternion
  3890. * @param tangent2 defines the outgoing tangent
  3891. * @param amount defines the target quaternion
  3892. * @returns the new interpolated quaternion
  3893. */
  3894. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3895. }
  3896. /**
  3897. * Class used to store matrix data (4x4)
  3898. */
  3899. export class Matrix {
  3900. private static _updateFlagSeed;
  3901. private static _identityReadOnly;
  3902. private _isIdentity;
  3903. private _isIdentityDirty;
  3904. private _isIdentity3x2;
  3905. private _isIdentity3x2Dirty;
  3906. /**
  3907. * Gets the update flag of the matrix which is an unique number for the matrix.
  3908. * It will be incremented every time the matrix data change.
  3909. * You can use it to speed the comparison between two versions of the same matrix.
  3910. */
  3911. updateFlag: number;
  3912. private readonly _m;
  3913. /**
  3914. * Gets the internal data of the matrix
  3915. */
  3916. get m(): DeepImmutable<Float32Array>;
  3917. /** @hidden */
  3918. _markAsUpdated(): void;
  3919. /** @hidden */
  3920. private _updateIdentityStatus;
  3921. /**
  3922. * Creates an empty matrix (filled with zeros)
  3923. */
  3924. constructor();
  3925. /**
  3926. * Check if the current matrix is identity
  3927. * @returns true is the matrix is the identity matrix
  3928. */
  3929. isIdentity(): boolean;
  3930. /**
  3931. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3932. * @returns true is the matrix is the identity matrix
  3933. */
  3934. isIdentityAs3x2(): boolean;
  3935. /**
  3936. * Gets the determinant of the matrix
  3937. * @returns the matrix determinant
  3938. */
  3939. determinant(): number;
  3940. /**
  3941. * Returns the matrix as a Float32Array
  3942. * @returns the matrix underlying array
  3943. */
  3944. toArray(): DeepImmutable<Float32Array>;
  3945. /**
  3946. * Returns the matrix as a Float32Array
  3947. * @returns the matrix underlying array.
  3948. */
  3949. asArray(): DeepImmutable<Float32Array>;
  3950. /**
  3951. * Inverts the current matrix in place
  3952. * @returns the current inverted matrix
  3953. */
  3954. invert(): Matrix;
  3955. /**
  3956. * Sets all the matrix elements to zero
  3957. * @returns the current matrix
  3958. */
  3959. reset(): Matrix;
  3960. /**
  3961. * Adds the current matrix with a second one
  3962. * @param other defines the matrix to add
  3963. * @returns a new matrix as the addition of the current matrix and the given one
  3964. */
  3965. add(other: DeepImmutable<Matrix>): Matrix;
  3966. /**
  3967. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3968. * @param other defines the matrix to add
  3969. * @param result defines the target matrix
  3970. * @returns the current matrix
  3971. */
  3972. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3973. /**
  3974. * Adds in place the given matrix to the current matrix
  3975. * @param other defines the second operand
  3976. * @returns the current updated matrix
  3977. */
  3978. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3979. /**
  3980. * Sets the given matrix to the current inverted Matrix
  3981. * @param other defines the target matrix
  3982. * @returns the unmodified current matrix
  3983. */
  3984. invertToRef(other: Matrix): Matrix;
  3985. /**
  3986. * add a value at the specified position in the current Matrix
  3987. * @param index the index of the value within the matrix. between 0 and 15.
  3988. * @param value the value to be added
  3989. * @returns the current updated matrix
  3990. */
  3991. addAtIndex(index: number, value: number): Matrix;
  3992. /**
  3993. * mutiply the specified position in the current Matrix by a value
  3994. * @param index the index of the value within the matrix. between 0 and 15.
  3995. * @param value the value to be added
  3996. * @returns the current updated matrix
  3997. */
  3998. multiplyAtIndex(index: number, value: number): Matrix;
  3999. /**
  4000. * Inserts the translation vector (using 3 floats) in the current matrix
  4001. * @param x defines the 1st component of the translation
  4002. * @param y defines the 2nd component of the translation
  4003. * @param z defines the 3rd component of the translation
  4004. * @returns the current updated matrix
  4005. */
  4006. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4007. /**
  4008. * Adds the translation vector (using 3 floats) in the current matrix
  4009. * @param x defines the 1st component of the translation
  4010. * @param y defines the 2nd component of the translation
  4011. * @param z defines the 3rd component of the translation
  4012. * @returns the current updated matrix
  4013. */
  4014. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4015. /**
  4016. * Inserts the translation vector in the current matrix
  4017. * @param vector3 defines the translation to insert
  4018. * @returns the current updated matrix
  4019. */
  4020. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4021. /**
  4022. * Gets the translation value of the current matrix
  4023. * @returns a new Vector3 as the extracted translation from the matrix
  4024. */
  4025. getTranslation(): Vector3;
  4026. /**
  4027. * Fill a Vector3 with the extracted translation from the matrix
  4028. * @param result defines the Vector3 where to store the translation
  4029. * @returns the current matrix
  4030. */
  4031. getTranslationToRef(result: Vector3): Matrix;
  4032. /**
  4033. * Remove rotation and scaling part from the matrix
  4034. * @returns the updated matrix
  4035. */
  4036. removeRotationAndScaling(): Matrix;
  4037. /**
  4038. * Multiply two matrices
  4039. * @param other defines the second operand
  4040. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4041. */
  4042. multiply(other: DeepImmutable<Matrix>): Matrix;
  4043. /**
  4044. * Copy the current matrix from the given one
  4045. * @param other defines the source matrix
  4046. * @returns the current updated matrix
  4047. */
  4048. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4049. /**
  4050. * Populates the given array from the starting index with the current matrix values
  4051. * @param array defines the target array
  4052. * @param offset defines the offset in the target array where to start storing values
  4053. * @returns the current matrix
  4054. */
  4055. copyToArray(array: Float32Array, offset?: number): Matrix;
  4056. /**
  4057. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4058. * @param other defines the second operand
  4059. * @param result defines the matrix where to store the multiplication
  4060. * @returns the current matrix
  4061. */
  4062. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4063. /**
  4064. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4065. * @param other defines the second operand
  4066. * @param result defines the array where to store the multiplication
  4067. * @param offset defines the offset in the target array where to start storing values
  4068. * @returns the current matrix
  4069. */
  4070. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4071. /**
  4072. * Check equality between this matrix and a second one
  4073. * @param value defines the second matrix to compare
  4074. * @returns true is the current matrix and the given one values are strictly equal
  4075. */
  4076. equals(value: DeepImmutable<Matrix>): boolean;
  4077. /**
  4078. * Clone the current matrix
  4079. * @returns a new matrix from the current matrix
  4080. */
  4081. clone(): Matrix;
  4082. /**
  4083. * Returns the name of the current matrix class
  4084. * @returns the string "Matrix"
  4085. */
  4086. getClassName(): string;
  4087. /**
  4088. * Gets the hash code of the current matrix
  4089. * @returns the hash code
  4090. */
  4091. getHashCode(): number;
  4092. /**
  4093. * Decomposes the current Matrix into a translation, rotation and scaling components
  4094. * @param scale defines the scale vector3 given as a reference to update
  4095. * @param rotation defines the rotation quaternion given as a reference to update
  4096. * @param translation defines the translation vector3 given as a reference to update
  4097. * @returns true if operation was successful
  4098. */
  4099. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4100. /**
  4101. * Gets specific row of the matrix
  4102. * @param index defines the number of the row to get
  4103. * @returns the index-th row of the current matrix as a new Vector4
  4104. */
  4105. getRow(index: number): Nullable<Vector4>;
  4106. /**
  4107. * Sets the index-th row of the current matrix to the vector4 values
  4108. * @param index defines the number of the row to set
  4109. * @param row defines the target vector4
  4110. * @returns the updated current matrix
  4111. */
  4112. setRow(index: number, row: Vector4): Matrix;
  4113. /**
  4114. * Compute the transpose of the matrix
  4115. * @returns the new transposed matrix
  4116. */
  4117. transpose(): Matrix;
  4118. /**
  4119. * Compute the transpose of the matrix and store it in a given matrix
  4120. * @param result defines the target matrix
  4121. * @returns the current matrix
  4122. */
  4123. transposeToRef(result: Matrix): Matrix;
  4124. /**
  4125. * Sets the index-th row of the current matrix with the given 4 x float values
  4126. * @param index defines the row index
  4127. * @param x defines the x component to set
  4128. * @param y defines the y component to set
  4129. * @param z defines the z component to set
  4130. * @param w defines the w component to set
  4131. * @returns the updated current matrix
  4132. */
  4133. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4134. /**
  4135. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4136. * @param scale defines the scale factor
  4137. * @returns a new matrix
  4138. */
  4139. scale(scale: number): Matrix;
  4140. /**
  4141. * Scale the current matrix values by a factor to a given result matrix
  4142. * @param scale defines the scale factor
  4143. * @param result defines the matrix to store the result
  4144. * @returns the current matrix
  4145. */
  4146. scaleToRef(scale: number, result: Matrix): Matrix;
  4147. /**
  4148. * Scale the current matrix values by a factor and add the result to a given matrix
  4149. * @param scale defines the scale factor
  4150. * @param result defines the Matrix to store the result
  4151. * @returns the current matrix
  4152. */
  4153. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4154. /**
  4155. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4156. * @param ref matrix to store the result
  4157. */
  4158. toNormalMatrix(ref: Matrix): void;
  4159. /**
  4160. * Gets only rotation part of the current matrix
  4161. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4162. */
  4163. getRotationMatrix(): Matrix;
  4164. /**
  4165. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4166. * @param result defines the target matrix to store data to
  4167. * @returns the current matrix
  4168. */
  4169. getRotationMatrixToRef(result: Matrix): Matrix;
  4170. /**
  4171. * Toggles model matrix from being right handed to left handed in place and vice versa
  4172. */
  4173. toggleModelMatrixHandInPlace(): void;
  4174. /**
  4175. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4176. */
  4177. toggleProjectionMatrixHandInPlace(): void;
  4178. /**
  4179. * Creates a matrix from an array
  4180. * @param array defines the source array
  4181. * @param offset defines an offset in the source array
  4182. * @returns a new Matrix set from the starting index of the given array
  4183. */
  4184. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4185. /**
  4186. * Copy the content of an array into a given matrix
  4187. * @param array defines the source array
  4188. * @param offset defines an offset in the source array
  4189. * @param result defines the target matrix
  4190. */
  4191. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4192. /**
  4193. * Stores an array into a matrix after having multiplied each component by a given factor
  4194. * @param array defines the source array
  4195. * @param offset defines the offset in the source array
  4196. * @param scale defines the scaling factor
  4197. * @param result defines the target matrix
  4198. */
  4199. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4200. /**
  4201. * Gets an identity matrix that must not be updated
  4202. */
  4203. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4204. /**
  4205. * Stores a list of values (16) inside a given matrix
  4206. * @param initialM11 defines 1st value of 1st row
  4207. * @param initialM12 defines 2nd value of 1st row
  4208. * @param initialM13 defines 3rd value of 1st row
  4209. * @param initialM14 defines 4th value of 1st row
  4210. * @param initialM21 defines 1st value of 2nd row
  4211. * @param initialM22 defines 2nd value of 2nd row
  4212. * @param initialM23 defines 3rd value of 2nd row
  4213. * @param initialM24 defines 4th value of 2nd row
  4214. * @param initialM31 defines 1st value of 3rd row
  4215. * @param initialM32 defines 2nd value of 3rd row
  4216. * @param initialM33 defines 3rd value of 3rd row
  4217. * @param initialM34 defines 4th value of 3rd row
  4218. * @param initialM41 defines 1st value of 4th row
  4219. * @param initialM42 defines 2nd value of 4th row
  4220. * @param initialM43 defines 3rd value of 4th row
  4221. * @param initialM44 defines 4th value of 4th row
  4222. * @param result defines the target matrix
  4223. */
  4224. 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;
  4225. /**
  4226. * Creates new matrix from a list of values (16)
  4227. * @param initialM11 defines 1st value of 1st row
  4228. * @param initialM12 defines 2nd value of 1st row
  4229. * @param initialM13 defines 3rd value of 1st row
  4230. * @param initialM14 defines 4th value of 1st row
  4231. * @param initialM21 defines 1st value of 2nd row
  4232. * @param initialM22 defines 2nd value of 2nd row
  4233. * @param initialM23 defines 3rd value of 2nd row
  4234. * @param initialM24 defines 4th value of 2nd row
  4235. * @param initialM31 defines 1st value of 3rd row
  4236. * @param initialM32 defines 2nd value of 3rd row
  4237. * @param initialM33 defines 3rd value of 3rd row
  4238. * @param initialM34 defines 4th value of 3rd row
  4239. * @param initialM41 defines 1st value of 4th row
  4240. * @param initialM42 defines 2nd value of 4th row
  4241. * @param initialM43 defines 3rd value of 4th row
  4242. * @param initialM44 defines 4th value of 4th row
  4243. * @returns the new matrix
  4244. */
  4245. 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;
  4246. /**
  4247. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4248. * @param scale defines the scale vector3
  4249. * @param rotation defines the rotation quaternion
  4250. * @param translation defines the translation vector3
  4251. * @returns a new matrix
  4252. */
  4253. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4254. /**
  4255. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4256. * @param scale defines the scale vector3
  4257. * @param rotation defines the rotation quaternion
  4258. * @param translation defines the translation vector3
  4259. * @param result defines the target matrix
  4260. */
  4261. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4262. /**
  4263. * Creates a new identity matrix
  4264. * @returns a new identity matrix
  4265. */
  4266. static Identity(): Matrix;
  4267. /**
  4268. * Creates a new identity matrix and stores the result in a given matrix
  4269. * @param result defines the target matrix
  4270. */
  4271. static IdentityToRef(result: Matrix): void;
  4272. /**
  4273. * Creates a new zero matrix
  4274. * @returns a new zero matrix
  4275. */
  4276. static Zero(): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis
  4279. * @param angle defines the angle (in radians) to use
  4280. * @return the new matrix
  4281. */
  4282. static RotationX(angle: number): Matrix;
  4283. /**
  4284. * Creates a new matrix as the invert of a given matrix
  4285. * @param source defines the source matrix
  4286. * @returns the new matrix
  4287. */
  4288. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the X 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 RotationXToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Y axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationY(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Y 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 RotationYToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the Z axis
  4309. * @param angle defines the angle (in radians) to use
  4310. * @return the new matrix
  4311. */
  4312. static RotationZ(angle: number): Matrix;
  4313. /**
  4314. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4315. * @param angle defines the angle (in radians) to use
  4316. * @param result defines the target matrix
  4317. */
  4318. static RotationZToRef(angle: number, result: Matrix): void;
  4319. /**
  4320. * Creates a new rotation matrix for "angle" radians around the given axis
  4321. * @param axis defines the axis to use
  4322. * @param angle defines the angle (in radians) to use
  4323. * @return the new matrix
  4324. */
  4325. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4326. /**
  4327. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4328. * @param axis defines the axis to use
  4329. * @param angle defines the angle (in radians) to use
  4330. * @param result defines the target matrix
  4331. */
  4332. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4333. /**
  4334. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4335. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4336. * @param from defines the vector to align
  4337. * @param to defines the vector to align to
  4338. * @param result defines the target matrix
  4339. */
  4340. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4341. /**
  4342. * Creates a rotation matrix
  4343. * @param yaw defines the yaw angle in radians (Y axis)
  4344. * @param pitch defines the pitch angle in radians (X axis)
  4345. * @param roll defines the roll angle in radians (X axis)
  4346. * @returns the new rotation matrix
  4347. */
  4348. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4349. /**
  4350. * Creates a rotation matrix and stores it in a given matrix
  4351. * @param yaw defines the yaw angle in radians (Y axis)
  4352. * @param pitch defines the pitch angle in radians (X axis)
  4353. * @param roll defines the roll angle in radians (X axis)
  4354. * @param result defines the target matrix
  4355. */
  4356. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4357. /**
  4358. * Creates a scaling matrix
  4359. * @param x defines the scale factor on X axis
  4360. * @param y defines the scale factor on Y axis
  4361. * @param z defines the scale factor on Z axis
  4362. * @returns the new matrix
  4363. */
  4364. static Scaling(x: number, y: number, z: number): Matrix;
  4365. /**
  4366. * Creates a scaling matrix and stores it in a given matrix
  4367. * @param x defines the scale factor on X axis
  4368. * @param y defines the scale factor on Y axis
  4369. * @param z defines the scale factor on Z axis
  4370. * @param result defines the target matrix
  4371. */
  4372. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4373. /**
  4374. * Creates a translation matrix
  4375. * @param x defines the translation on X axis
  4376. * @param y defines the translation on Y axis
  4377. * @param z defines the translationon Z axis
  4378. * @returns the new matrix
  4379. */
  4380. static Translation(x: number, y: number, z: number): Matrix;
  4381. /**
  4382. * Creates a translation matrix and stores it in a given matrix
  4383. * @param x defines the translation on X axis
  4384. * @param y defines the translation on Y axis
  4385. * @param z defines the translationon Z axis
  4386. * @param result defines the target matrix
  4387. */
  4388. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4389. /**
  4390. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4391. * @param startValue defines the start value
  4392. * @param endValue defines the end value
  4393. * @param gradient defines the gradient factor
  4394. * @returns the new matrix
  4395. */
  4396. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4397. /**
  4398. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4399. * @param startValue defines the start value
  4400. * @param endValue defines the end value
  4401. * @param gradient defines the gradient factor
  4402. * @param result defines the Matrix object where to store data
  4403. */
  4404. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4405. /**
  4406. * Builds a new matrix whose values are computed by:
  4407. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4408. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4409. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4410. * @param startValue defines the first matrix
  4411. * @param endValue defines the second matrix
  4412. * @param gradient defines the gradient between the two matrices
  4413. * @returns the new matrix
  4414. */
  4415. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4416. /**
  4417. * Update a matrix to values which are computed by:
  4418. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4419. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4420. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4421. * @param startValue defines the first matrix
  4422. * @param endValue defines the second matrix
  4423. * @param gradient defines the gradient between the two matrices
  4424. * @param result defines the target matrix
  4425. */
  4426. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4427. /**
  4428. * 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"
  4429. * This function works in left handed mode
  4430. * @param eye defines the final position of the entity
  4431. * @param target defines where the entity should look at
  4432. * @param up defines the up vector for the entity
  4433. * @returns the new matrix
  4434. */
  4435. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4436. /**
  4437. * 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".
  4438. * This function works in left handed mode
  4439. * @param eye defines the final position of the entity
  4440. * @param target defines where the entity should look at
  4441. * @param up defines the up vector for the entity
  4442. * @param result defines the target matrix
  4443. */
  4444. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4445. /**
  4446. * 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"
  4447. * This function works in right handed mode
  4448. * @param eye defines the final position of the entity
  4449. * @param target defines where the entity should look at
  4450. * @param up defines the up vector for the entity
  4451. * @returns the new matrix
  4452. */
  4453. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4454. /**
  4455. * 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".
  4456. * This function works in right handed mode
  4457. * @param eye defines the final position of the entity
  4458. * @param target defines where the entity should look at
  4459. * @param up defines the up vector for the entity
  4460. * @param result defines the target matrix
  4461. */
  4462. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4463. /**
  4464. * Create a left-handed orthographic projection matrix
  4465. * @param width defines the viewport width
  4466. * @param height defines the viewport height
  4467. * @param znear defines the near clip plane
  4468. * @param zfar defines the far clip plane
  4469. * @returns a new matrix as a left-handed orthographic projection matrix
  4470. */
  4471. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4472. /**
  4473. * Store a left-handed orthographic projection to a given matrix
  4474. * @param width defines the viewport width
  4475. * @param height defines the viewport height
  4476. * @param znear defines the near clip plane
  4477. * @param zfar defines the far clip plane
  4478. * @param result defines the target matrix
  4479. */
  4480. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4481. /**
  4482. * Create a left-handed orthographic projection matrix
  4483. * @param left defines the viewport left coordinate
  4484. * @param right defines the viewport right coordinate
  4485. * @param bottom defines the viewport bottom coordinate
  4486. * @param top defines the viewport top coordinate
  4487. * @param znear defines the near clip plane
  4488. * @param zfar defines the far clip plane
  4489. * @returns a new matrix as a left-handed orthographic projection matrix
  4490. */
  4491. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4492. /**
  4493. * Stores a left-handed orthographic projection into a given matrix
  4494. * @param left defines the viewport left coordinate
  4495. * @param right defines the viewport right coordinate
  4496. * @param bottom defines the viewport bottom coordinate
  4497. * @param top defines the viewport top coordinate
  4498. * @param znear defines the near clip plane
  4499. * @param zfar defines the far clip plane
  4500. * @param result defines the target matrix
  4501. */
  4502. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4503. /**
  4504. * Creates a right-handed orthographic projection matrix
  4505. * @param left defines the viewport left coordinate
  4506. * @param right defines the viewport right coordinate
  4507. * @param bottom defines the viewport bottom coordinate
  4508. * @param top defines the viewport top coordinate
  4509. * @param znear defines the near clip plane
  4510. * @param zfar defines the far clip plane
  4511. * @returns a new matrix as a right-handed orthographic projection matrix
  4512. */
  4513. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4514. /**
  4515. * Stores a right-handed orthographic projection into a given matrix
  4516. * @param left defines the viewport left coordinate
  4517. * @param right defines the viewport right coordinate
  4518. * @param bottom defines the viewport bottom coordinate
  4519. * @param top defines the viewport top coordinate
  4520. * @param znear defines the near clip plane
  4521. * @param zfar defines the far clip plane
  4522. * @param result defines the target matrix
  4523. */
  4524. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4525. /**
  4526. * Creates a left-handed perspective projection matrix
  4527. * @param width defines the viewport width
  4528. * @param height defines the viewport height
  4529. * @param znear defines the near clip plane
  4530. * @param zfar defines the far clip plane
  4531. * @returns a new matrix as a left-handed perspective projection matrix
  4532. */
  4533. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4534. /**
  4535. * Creates a left-handed perspective projection matrix
  4536. * @param fov defines the horizontal field of view
  4537. * @param aspect defines the aspect ratio
  4538. * @param znear defines the near clip plane
  4539. * @param zfar defines the far clip plane
  4540. * @returns a new matrix as a left-handed perspective projection matrix
  4541. */
  4542. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4543. /**
  4544. * Stores a left-handed perspective projection into a given matrix
  4545. * @param fov defines the horizontal field of view
  4546. * @param aspect defines the aspect ratio
  4547. * @param znear defines the near clip plane
  4548. * @param zfar defines the far clip plane
  4549. * @param result defines the target matrix
  4550. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4551. */
  4552. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4553. /**
  4554. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4555. * @param fov defines the horizontal field of view
  4556. * @param aspect defines the aspect ratio
  4557. * @param znear defines the near clip plane
  4558. * @param zfar not used as infinity is used as far clip
  4559. * @param result defines the target matrix
  4560. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4561. */
  4562. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4563. /**
  4564. * Creates a right-handed perspective projection matrix
  4565. * @param fov defines the horizontal field of view
  4566. * @param aspect defines the aspect ratio
  4567. * @param znear defines the near clip plane
  4568. * @param zfar defines the far clip plane
  4569. * @returns a new matrix as a right-handed perspective projection matrix
  4570. */
  4571. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4572. /**
  4573. * Stores a right-handed perspective projection into a given matrix
  4574. * @param fov defines the horizontal field of view
  4575. * @param aspect defines the aspect ratio
  4576. * @param znear defines the near clip plane
  4577. * @param zfar defines the far clip plane
  4578. * @param result defines the target matrix
  4579. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4580. */
  4581. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4582. /**
  4583. * Stores a right-handed perspective projection into a given matrix
  4584. * @param fov defines the horizontal field of view
  4585. * @param aspect defines the aspect ratio
  4586. * @param znear defines the near clip plane
  4587. * @param zfar not used as infinity is used as far clip
  4588. * @param result defines the target matrix
  4589. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4590. */
  4591. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4592. /**
  4593. * Stores a perspective projection for WebVR info a given matrix
  4594. * @param fov defines the field of view
  4595. * @param znear defines the near clip plane
  4596. * @param zfar defines the far clip plane
  4597. * @param result defines the target matrix
  4598. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4599. */
  4600. static PerspectiveFovWebVRToRef(fov: {
  4601. upDegrees: number;
  4602. downDegrees: number;
  4603. leftDegrees: number;
  4604. rightDegrees: number;
  4605. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4606. /**
  4607. * Computes a complete transformation matrix
  4608. * @param viewport defines the viewport to use
  4609. * @param world defines the world matrix
  4610. * @param view defines the view matrix
  4611. * @param projection defines the projection matrix
  4612. * @param zmin defines the near clip plane
  4613. * @param zmax defines the far clip plane
  4614. * @returns the transformation matrix
  4615. */
  4616. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4617. /**
  4618. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4619. * @param matrix defines the matrix to use
  4620. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4621. */
  4622. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4623. /**
  4624. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4625. * @param matrix defines the matrix to use
  4626. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4627. */
  4628. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4629. /**
  4630. * Compute the transpose of a given matrix
  4631. * @param matrix defines the matrix to transpose
  4632. * @returns the new matrix
  4633. */
  4634. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4635. /**
  4636. * Compute the transpose of a matrix and store it in a target matrix
  4637. * @param matrix defines the matrix to transpose
  4638. * @param result defines the target matrix
  4639. */
  4640. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4641. /**
  4642. * Computes a reflection matrix from a plane
  4643. * @param plane defines the reflection plane
  4644. * @returns a new matrix
  4645. */
  4646. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4647. /**
  4648. * Computes a reflection matrix from a plane
  4649. * @param plane defines the reflection plane
  4650. * @param result defines the target matrix
  4651. */
  4652. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4653. /**
  4654. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4655. * @param xaxis defines the value of the 1st axis
  4656. * @param yaxis defines the value of the 2nd axis
  4657. * @param zaxis defines the value of the 3rd axis
  4658. * @param result defines the target matrix
  4659. */
  4660. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4661. /**
  4662. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4663. * @param quat defines the quaternion to use
  4664. * @param result defines the target matrix
  4665. */
  4666. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4667. }
  4668. /**
  4669. * @hidden
  4670. */
  4671. export class TmpVectors {
  4672. static Vector2: Vector2[];
  4673. static Vector3: Vector3[];
  4674. static Vector4: Vector4[];
  4675. static Quaternion: Quaternion[];
  4676. static Matrix: Matrix[];
  4677. }
  4678. }
  4679. declare module "babylonjs/Maths/math.path" {
  4680. import { DeepImmutable, Nullable } from "babylonjs/types";
  4681. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4682. /**
  4683. * Defines potential orientation for back face culling
  4684. */
  4685. export enum Orientation {
  4686. /**
  4687. * Clockwise
  4688. */
  4689. CW = 0,
  4690. /** Counter clockwise */
  4691. CCW = 1
  4692. }
  4693. /** Class used to represent a Bezier curve */
  4694. export class BezierCurve {
  4695. /**
  4696. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4697. * @param t defines the time
  4698. * @param x1 defines the left coordinate on X axis
  4699. * @param y1 defines the left coordinate on Y axis
  4700. * @param x2 defines the right coordinate on X axis
  4701. * @param y2 defines the right coordinate on Y axis
  4702. * @returns the interpolated value
  4703. */
  4704. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4705. }
  4706. /**
  4707. * Defines angle representation
  4708. */
  4709. export class Angle {
  4710. private _radians;
  4711. /**
  4712. * Creates an Angle object of "radians" radians (float).
  4713. * @param radians the angle in radians
  4714. */
  4715. constructor(radians: number);
  4716. /**
  4717. * Get value in degrees
  4718. * @returns the Angle value in degrees (float)
  4719. */
  4720. degrees(): number;
  4721. /**
  4722. * Get value in radians
  4723. * @returns the Angle value in radians (float)
  4724. */
  4725. radians(): number;
  4726. /**
  4727. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4728. * @param a defines first vector
  4729. * @param b defines second vector
  4730. * @returns a new Angle
  4731. */
  4732. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4733. /**
  4734. * Gets a new Angle object from the given float in radians
  4735. * @param radians defines the angle value in radians
  4736. * @returns a new Angle
  4737. */
  4738. static FromRadians(radians: number): Angle;
  4739. /**
  4740. * Gets a new Angle object from the given float in degrees
  4741. * @param degrees defines the angle value in degrees
  4742. * @returns a new Angle
  4743. */
  4744. static FromDegrees(degrees: number): Angle;
  4745. }
  4746. /**
  4747. * This represents an arc in a 2d space.
  4748. */
  4749. export class Arc2 {
  4750. /** Defines the start point of the arc */
  4751. startPoint: Vector2;
  4752. /** Defines the mid point of the arc */
  4753. midPoint: Vector2;
  4754. /** Defines the end point of the arc */
  4755. endPoint: Vector2;
  4756. /**
  4757. * Defines the center point of the arc.
  4758. */
  4759. centerPoint: Vector2;
  4760. /**
  4761. * Defines the radius of the arc.
  4762. */
  4763. radius: number;
  4764. /**
  4765. * Defines the angle of the arc (from mid point to end point).
  4766. */
  4767. angle: Angle;
  4768. /**
  4769. * Defines the start angle of the arc (from start point to middle point).
  4770. */
  4771. startAngle: Angle;
  4772. /**
  4773. * Defines the orientation of the arc (clock wise/counter clock wise).
  4774. */
  4775. orientation: Orientation;
  4776. /**
  4777. * Creates an Arc object from the three given points : start, middle and end.
  4778. * @param startPoint Defines the start point of the arc
  4779. * @param midPoint Defines the midlle point of the arc
  4780. * @param endPoint Defines the end point of the arc
  4781. */
  4782. constructor(
  4783. /** Defines the start point of the arc */
  4784. startPoint: Vector2,
  4785. /** Defines the mid point of the arc */
  4786. midPoint: Vector2,
  4787. /** Defines the end point of the arc */
  4788. endPoint: Vector2);
  4789. }
  4790. /**
  4791. * Represents a 2D path made up of multiple 2D points
  4792. */
  4793. export class Path2 {
  4794. private _points;
  4795. private _length;
  4796. /**
  4797. * If the path start and end point are the same
  4798. */
  4799. closed: boolean;
  4800. /**
  4801. * Creates a Path2 object from the starting 2D coordinates x and y.
  4802. * @param x the starting points x value
  4803. * @param y the starting points y value
  4804. */
  4805. constructor(x: number, y: number);
  4806. /**
  4807. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4808. * @param x the added points x value
  4809. * @param y the added points y value
  4810. * @returns the updated Path2.
  4811. */
  4812. addLineTo(x: number, y: number): Path2;
  4813. /**
  4814. * 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.
  4815. * @param midX middle point x value
  4816. * @param midY middle point y value
  4817. * @param endX end point x value
  4818. * @param endY end point y value
  4819. * @param numberOfSegments (default: 36)
  4820. * @returns the updated Path2.
  4821. */
  4822. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4823. /**
  4824. * Closes the Path2.
  4825. * @returns the Path2.
  4826. */
  4827. close(): Path2;
  4828. /**
  4829. * Gets the sum of the distance between each sequential point in the path
  4830. * @returns the Path2 total length (float).
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Gets the points which construct the path
  4835. * @returns the Path2 internal array of points.
  4836. */
  4837. getPoints(): Vector2[];
  4838. /**
  4839. * Retreives the point at the distance aways from the starting point
  4840. * @param normalizedLengthPosition the length along the path to retreive the point from
  4841. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4842. */
  4843. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4844. /**
  4845. * Creates a new path starting from an x and y position
  4846. * @param x starting x value
  4847. * @param y starting y value
  4848. * @returns a new Path2 starting at the coordinates (x, y).
  4849. */
  4850. static StartingAt(x: number, y: number): Path2;
  4851. }
  4852. /**
  4853. * Represents a 3D path made up of multiple 3D points
  4854. */
  4855. export class Path3D {
  4856. /**
  4857. * an array of Vector3, the curve axis of the Path3D
  4858. */
  4859. path: Vector3[];
  4860. private _curve;
  4861. private _distances;
  4862. private _tangents;
  4863. private _normals;
  4864. private _binormals;
  4865. private _raw;
  4866. private _alignTangentsWithPath;
  4867. private readonly _pointAtData;
  4868. /**
  4869. * new Path3D(path, normal, raw)
  4870. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4871. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4872. * @param path an array of Vector3, the curve axis of the Path3D
  4873. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4874. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4875. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4876. */
  4877. constructor(
  4878. /**
  4879. * an array of Vector3, the curve axis of the Path3D
  4880. */
  4881. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4882. /**
  4883. * Returns the Path3D array of successive Vector3 designing its curve.
  4884. * @returns the Path3D array of successive Vector3 designing its curve.
  4885. */
  4886. getCurve(): Vector3[];
  4887. /**
  4888. * Returns the Path3D array of successive Vector3 designing its curve.
  4889. * @returns the Path3D array of successive Vector3 designing its curve.
  4890. */
  4891. getPoints(): Vector3[];
  4892. /**
  4893. * @returns the computed length (float) of the path.
  4894. */
  4895. length(): number;
  4896. /**
  4897. * Returns an array populated with tangent vectors on each Path3D curve point.
  4898. * @returns an array populated with tangent vectors on each Path3D curve point.
  4899. */
  4900. getTangents(): Vector3[];
  4901. /**
  4902. * Returns an array populated with normal vectors on each Path3D curve point.
  4903. * @returns an array populated with normal vectors on each Path3D curve point.
  4904. */
  4905. getNormals(): Vector3[];
  4906. /**
  4907. * Returns an array populated with binormal vectors on each Path3D curve point.
  4908. * @returns an array populated with binormal vectors on each Path3D curve point.
  4909. */
  4910. getBinormals(): Vector3[];
  4911. /**
  4912. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4913. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4914. */
  4915. getDistances(): number[];
  4916. /**
  4917. * Returns an interpolated point along this path
  4918. * @param position the position of the point along this path, from 0.0 to 1.0
  4919. * @returns a new Vector3 as the point
  4920. */
  4921. getPointAt(position: number): Vector3;
  4922. /**
  4923. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4924. * @param position the position of the point along this path, from 0.0 to 1.0
  4925. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4926. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4927. */
  4928. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4929. /**
  4930. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4931. * @param position the position of the point along this path, from 0.0 to 1.0
  4932. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4933. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4934. */
  4935. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4936. /**
  4937. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4938. * @param position the position of the point along this path, from 0.0 to 1.0
  4939. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4940. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4941. */
  4942. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4943. /**
  4944. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4945. * @param position the position of the point along this path, from 0.0 to 1.0
  4946. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4947. */
  4948. getDistanceAt(position: number): number;
  4949. /**
  4950. * Returns the array index of the previous point of an interpolated point along this path
  4951. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4952. * @returns the array index
  4953. */
  4954. getPreviousPointIndexAt(position: number): number;
  4955. /**
  4956. * 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)
  4957. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4958. * @returns the sub position
  4959. */
  4960. getSubPositionAt(position: number): number;
  4961. /**
  4962. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4963. * @param target the vector of which to get the closest position to
  4964. * @returns the position of the closest virtual point on this path to the target vector
  4965. */
  4966. getClosestPositionTo(target: Vector3): number;
  4967. /**
  4968. * Returns a sub path (slice) of this path
  4969. * @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
  4970. * @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
  4971. * @returns a sub path (slice) of this path
  4972. */
  4973. slice(start?: number, end?: number): Path3D;
  4974. /**
  4975. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4976. * @param path path which all values are copied into the curves points
  4977. * @param firstNormal which should be projected onto the curve
  4978. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4979. * @returns the same object updated.
  4980. */
  4981. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4982. private _compute;
  4983. private _getFirstNonNullVector;
  4984. private _getLastNonNullVector;
  4985. private _normalVector;
  4986. /**
  4987. * Updates the point at data for an interpolated point along this curve
  4988. * @param position the position of the point along this curve, from 0.0 to 1.0
  4989. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4990. * @returns the (updated) point at data
  4991. */
  4992. private _updatePointAtData;
  4993. /**
  4994. * Updates the point at data from the specified parameters
  4995. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4996. * @param point the interpolated point
  4997. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4998. */
  4999. private _setPointAtData;
  5000. /**
  5001. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5002. */
  5003. private _updateInterpolationMatrix;
  5004. }
  5005. /**
  5006. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5007. * A Curve3 is designed from a series of successive Vector3.
  5008. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5009. */
  5010. export class Curve3 {
  5011. private _points;
  5012. private _length;
  5013. /**
  5014. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5015. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5016. * @param v1 (Vector3) the control point
  5017. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5018. * @param nbPoints (integer) the wanted number of points in the curve
  5019. * @returns the created Curve3
  5020. */
  5021. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5022. /**
  5023. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5024. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5025. * @param v1 (Vector3) the first control point
  5026. * @param v2 (Vector3) the second control point
  5027. * @param v3 (Vector3) the end point of the Cubic Bezier
  5028. * @param nbPoints (integer) the wanted number of points in the curve
  5029. * @returns the created Curve3
  5030. */
  5031. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5032. /**
  5033. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5034. * @param p1 (Vector3) the origin point of the Hermite Spline
  5035. * @param t1 (Vector3) the tangent vector at the origin point
  5036. * @param p2 (Vector3) the end point of the Hermite Spline
  5037. * @param t2 (Vector3) the tangent vector at the end point
  5038. * @param nbPoints (integer) the wanted number of points in the curve
  5039. * @returns the created Curve3
  5040. */
  5041. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5042. /**
  5043. * Returns a Curve3 object along a CatmullRom Spline curve :
  5044. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5045. * @param nbPoints (integer) the wanted number of points between each curve control points
  5046. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5047. * @returns the created Curve3
  5048. */
  5049. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5050. /**
  5051. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5052. * A Curve3 is designed from a series of successive Vector3.
  5053. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5054. * @param points points which make up the curve
  5055. */
  5056. constructor(points: Vector3[]);
  5057. /**
  5058. * @returns the Curve3 stored array of successive Vector3
  5059. */
  5060. getPoints(): Vector3[];
  5061. /**
  5062. * @returns the computed length (float) of the curve.
  5063. */
  5064. length(): number;
  5065. /**
  5066. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5067. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5068. * curveA and curveB keep unchanged.
  5069. * @param curve the curve to continue from this curve
  5070. * @returns the newly constructed curve
  5071. */
  5072. continue(curve: DeepImmutable<Curve3>): Curve3;
  5073. private _computeLength;
  5074. }
  5075. }
  5076. declare module "babylonjs/Animations/easing" {
  5077. /**
  5078. * This represents the main contract an easing function should follow.
  5079. * Easing functions are used throughout the animation system.
  5080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5081. */
  5082. export interface IEasingFunction {
  5083. /**
  5084. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5085. * of the easing function.
  5086. * The link below provides some of the most common examples of easing functions.
  5087. * @see https://easings.net/
  5088. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5089. * @returns the corresponding value on the curve defined by the easing function
  5090. */
  5091. ease(gradient: number): number;
  5092. }
  5093. /**
  5094. * Base class used for every default easing function.
  5095. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5096. */
  5097. export class EasingFunction implements IEasingFunction {
  5098. /**
  5099. * Interpolation follows the mathematical formula associated with the easing function.
  5100. */
  5101. static readonly EASINGMODE_EASEIN: number;
  5102. /**
  5103. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5104. */
  5105. static readonly EASINGMODE_EASEOUT: number;
  5106. /**
  5107. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5108. */
  5109. static readonly EASINGMODE_EASEINOUT: number;
  5110. private _easingMode;
  5111. /**
  5112. * Sets the easing mode of the current function.
  5113. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5114. */
  5115. setEasingMode(easingMode: number): void;
  5116. /**
  5117. * Gets the current easing mode.
  5118. * @returns the easing mode
  5119. */
  5120. getEasingMode(): number;
  5121. /**
  5122. * @hidden
  5123. */
  5124. easeInCore(gradient: number): number;
  5125. /**
  5126. * Given an input gradient between 0 and 1, this returns the corresponding value
  5127. * of the easing function.
  5128. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5129. * @returns the corresponding value on the curve defined by the easing function
  5130. */
  5131. ease(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with a circle shape (see link below).
  5135. * @see https://easings.net/#easeInCirc
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class CircleEase extends EasingFunction implements IEasingFunction {
  5139. /** @hidden */
  5140. easeInCore(gradient: number): number;
  5141. }
  5142. /**
  5143. * Easing function with a ease back shape (see link below).
  5144. * @see https://easings.net/#easeInBack
  5145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5146. */
  5147. export class BackEase extends EasingFunction implements IEasingFunction {
  5148. /** Defines the amplitude of the function */
  5149. amplitude: number;
  5150. /**
  5151. * Instantiates a back ease easing
  5152. * @see https://easings.net/#easeInBack
  5153. * @param amplitude Defines the amplitude of the function
  5154. */
  5155. constructor(
  5156. /** Defines the amplitude of the function */
  5157. amplitude?: number);
  5158. /** @hidden */
  5159. easeInCore(gradient: number): number;
  5160. }
  5161. /**
  5162. * Easing function with a bouncing shape (see link below).
  5163. * @see https://easings.net/#easeInBounce
  5164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5165. */
  5166. export class BounceEase extends EasingFunction implements IEasingFunction {
  5167. /** Defines the number of bounces */
  5168. bounces: number;
  5169. /** Defines the amplitude of the bounce */
  5170. bounciness: number;
  5171. /**
  5172. * Instantiates a bounce easing
  5173. * @see https://easings.net/#easeInBounce
  5174. * @param bounces Defines the number of bounces
  5175. * @param bounciness Defines the amplitude of the bounce
  5176. */
  5177. constructor(
  5178. /** Defines the number of bounces */
  5179. bounces?: number,
  5180. /** Defines the amplitude of the bounce */
  5181. bounciness?: number);
  5182. /** @hidden */
  5183. easeInCore(gradient: number): number;
  5184. }
  5185. /**
  5186. * Easing function with a power of 3 shape (see link below).
  5187. * @see https://easings.net/#easeInCubic
  5188. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5189. */
  5190. export class CubicEase extends EasingFunction implements IEasingFunction {
  5191. /** @hidden */
  5192. easeInCore(gradient: number): number;
  5193. }
  5194. /**
  5195. * Easing function with an elastic shape (see link below).
  5196. * @see https://easings.net/#easeInElastic
  5197. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5198. */
  5199. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5200. /** Defines the number of oscillations*/
  5201. oscillations: number;
  5202. /** Defines the amplitude of the oscillations*/
  5203. springiness: number;
  5204. /**
  5205. * Instantiates an elastic easing function
  5206. * @see https://easings.net/#easeInElastic
  5207. * @param oscillations Defines the number of oscillations
  5208. * @param springiness Defines the amplitude of the oscillations
  5209. */
  5210. constructor(
  5211. /** Defines the number of oscillations*/
  5212. oscillations?: number,
  5213. /** Defines the amplitude of the oscillations*/
  5214. springiness?: number);
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with an exponential shape (see link below).
  5220. * @see https://easings.net/#easeInExpo
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5224. /** Defines the exponent of the function */
  5225. exponent: number;
  5226. /**
  5227. * Instantiates an exponential easing function
  5228. * @see https://easings.net/#easeInExpo
  5229. * @param exponent Defines the exponent of the function
  5230. */
  5231. constructor(
  5232. /** Defines the exponent of the function */
  5233. exponent?: number);
  5234. /** @hidden */
  5235. easeInCore(gradient: number): number;
  5236. }
  5237. /**
  5238. * Easing function with a power shape (see link below).
  5239. * @see https://easings.net/#easeInQuad
  5240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5241. */
  5242. export class PowerEase extends EasingFunction implements IEasingFunction {
  5243. /** Defines the power of the function */
  5244. power: number;
  5245. /**
  5246. * Instantiates an power base easing function
  5247. * @see https://easings.net/#easeInQuad
  5248. * @param power Defines the power of the function
  5249. */
  5250. constructor(
  5251. /** Defines the power of the function */
  5252. power?: number);
  5253. /** @hidden */
  5254. easeInCore(gradient: number): number;
  5255. }
  5256. /**
  5257. * Easing function with a power of 2 shape (see link below).
  5258. * @see https://easings.net/#easeInQuad
  5259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5260. */
  5261. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5262. /** @hidden */
  5263. easeInCore(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a power of 4 shape (see link below).
  5267. * @see https://easings.net/#easeInQuart
  5268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a power of 5 shape (see link below).
  5276. * @see https://easings.net/#easeInQuint
  5277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5280. /** @hidden */
  5281. easeInCore(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a sin shape (see link below).
  5285. * @see https://easings.net/#easeInSine
  5286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class SineEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a bezier shape (see link below).
  5294. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the x component of the start tangent in the bezier curve */
  5299. x1: number;
  5300. /** Defines the y component of the start tangent in the bezier curve */
  5301. y1: number;
  5302. /** Defines the x component of the end tangent in the bezier curve */
  5303. x2: number;
  5304. /** Defines the y component of the end tangent in the bezier curve */
  5305. y2: number;
  5306. /**
  5307. * Instantiates a bezier function
  5308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5309. * @param x1 Defines the x component of the start tangent in the bezier curve
  5310. * @param y1 Defines the y component of the start tangent in the bezier curve
  5311. * @param x2 Defines the x component of the end tangent in the bezier curve
  5312. * @param y2 Defines the y component of the end tangent in the bezier curve
  5313. */
  5314. constructor(
  5315. /** Defines the x component of the start tangent in the bezier curve */
  5316. x1?: number,
  5317. /** Defines the y component of the start tangent in the bezier curve */
  5318. y1?: number,
  5319. /** Defines the x component of the end tangent in the bezier curve */
  5320. x2?: number,
  5321. /** Defines the y component of the end tangent in the bezier curve */
  5322. y2?: number);
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Maths/math.color" {
  5328. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5329. /**
  5330. * Class used to hold a RBG color
  5331. */
  5332. export class Color3 {
  5333. /**
  5334. * Defines the red component (between 0 and 1, default is 0)
  5335. */
  5336. r: number;
  5337. /**
  5338. * Defines the green component (between 0 and 1, default is 0)
  5339. */
  5340. g: number;
  5341. /**
  5342. * Defines the blue component (between 0 and 1, default is 0)
  5343. */
  5344. b: number;
  5345. /**
  5346. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5347. * @param r defines the red component (between 0 and 1, default is 0)
  5348. * @param g defines the green component (between 0 and 1, default is 0)
  5349. * @param b defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. constructor(
  5352. /**
  5353. * Defines the red component (between 0 and 1, default is 0)
  5354. */
  5355. r?: number,
  5356. /**
  5357. * Defines the green component (between 0 and 1, default is 0)
  5358. */
  5359. g?: number,
  5360. /**
  5361. * Defines the blue component (between 0 and 1, default is 0)
  5362. */
  5363. b?: number);
  5364. /**
  5365. * Creates a string with the Color3 current values
  5366. * @returns the string representation of the Color3 object
  5367. */
  5368. toString(): string;
  5369. /**
  5370. * Returns the string "Color3"
  5371. * @returns "Color3"
  5372. */
  5373. getClassName(): string;
  5374. /**
  5375. * Compute the Color3 hash code
  5376. * @returns an unique number that can be used to hash Color3 objects
  5377. */
  5378. getHashCode(): number;
  5379. /**
  5380. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5381. * @param array defines the array where to store the r,g,b components
  5382. * @param index defines an optional index in the target array to define where to start storing values
  5383. * @returns the current Color3 object
  5384. */
  5385. toArray(array: FloatArray, index?: number): Color3;
  5386. /**
  5387. * Returns a new Color4 object from the current Color3 and the given alpha
  5388. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5389. * @returns a new Color4 object
  5390. */
  5391. toColor4(alpha?: number): Color4;
  5392. /**
  5393. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5394. * @returns the new array
  5395. */
  5396. asArray(): number[];
  5397. /**
  5398. * Returns the luminance value
  5399. * @returns a float value
  5400. */
  5401. toLuminance(): number;
  5402. /**
  5403. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5404. * @param otherColor defines the second operand
  5405. * @returns the new Color3 object
  5406. */
  5407. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5408. /**
  5409. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5410. * @param otherColor defines the second operand
  5411. * @param result defines the Color3 object where to store the result
  5412. * @returns the current Color3
  5413. */
  5414. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5415. /**
  5416. * Determines equality between Color3 objects
  5417. * @param otherColor defines the second operand
  5418. * @returns true if the rgb values are equal to the given ones
  5419. */
  5420. equals(otherColor: DeepImmutable<Color3>): boolean;
  5421. /**
  5422. * Determines equality between the current Color3 object and a set of r,b,g values
  5423. * @param r defines the red component to check
  5424. * @param g defines the green component to check
  5425. * @param b defines the blue component to check
  5426. * @returns true if the rgb values are equal to the given ones
  5427. */
  5428. equalsFloats(r: number, g: number, b: number): boolean;
  5429. /**
  5430. * Multiplies in place each rgb value by scale
  5431. * @param scale defines the scaling factor
  5432. * @returns the updated Color3
  5433. */
  5434. scale(scale: number): Color3;
  5435. /**
  5436. * Multiplies the rgb values by scale and stores the result into "result"
  5437. * @param scale defines the scaling factor
  5438. * @param result defines the Color3 object where to store the result
  5439. * @returns the unmodified current Color3
  5440. */
  5441. scaleToRef(scale: number, result: Color3): Color3;
  5442. /**
  5443. * Scale the current Color3 values by a factor and add the result to a given Color3
  5444. * @param scale defines the scale factor
  5445. * @param result defines color to store the result into
  5446. * @returns the unmodified current Color3
  5447. */
  5448. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5449. /**
  5450. * Clamps the rgb values by the min and max values and stores the result into "result"
  5451. * @param min defines minimum clamping value (default is 0)
  5452. * @param max defines maximum clamping value (default is 1)
  5453. * @param result defines color to store the result into
  5454. * @returns the original Color3
  5455. */
  5456. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5457. /**
  5458. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5459. * @param otherColor defines the second operand
  5460. * @returns the new Color3
  5461. */
  5462. add(otherColor: DeepImmutable<Color3>): Color3;
  5463. /**
  5464. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5465. * @param otherColor defines the second operand
  5466. * @param result defines Color3 object to store the result into
  5467. * @returns the unmodified current Color3
  5468. */
  5469. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5470. /**
  5471. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5472. * @param otherColor defines the second operand
  5473. * @returns the new Color3
  5474. */
  5475. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5476. /**
  5477. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5478. * @param otherColor defines the second operand
  5479. * @param result defines Color3 object to store the result into
  5480. * @returns the unmodified current Color3
  5481. */
  5482. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5483. /**
  5484. * Copy the current object
  5485. * @returns a new Color3 copied the current one
  5486. */
  5487. clone(): Color3;
  5488. /**
  5489. * Copies the rgb values from the source in the current Color3
  5490. * @param source defines the source Color3 object
  5491. * @returns the updated Color3 object
  5492. */
  5493. copyFrom(source: DeepImmutable<Color3>): Color3;
  5494. /**
  5495. * Updates the Color3 rgb values from the given floats
  5496. * @param r defines the red component to read from
  5497. * @param g defines the green component to read from
  5498. * @param b defines the blue component to read from
  5499. * @returns the current Color3 object
  5500. */
  5501. copyFromFloats(r: number, g: number, b: number): Color3;
  5502. /**
  5503. * Updates the Color3 rgb values from the given floats
  5504. * @param r defines the red component to read from
  5505. * @param g defines the green component to read from
  5506. * @param b defines the blue component to read from
  5507. * @returns the current Color3 object
  5508. */
  5509. set(r: number, g: number, b: number): Color3;
  5510. /**
  5511. * Compute the Color3 hexadecimal code as a string
  5512. * @returns a string containing the hexadecimal representation of the Color3 object
  5513. */
  5514. toHexString(): string;
  5515. /**
  5516. * Computes a new Color3 converted from the current one to linear space
  5517. * @returns a new Color3 object
  5518. */
  5519. toLinearSpace(): Color3;
  5520. /**
  5521. * Converts current color in rgb space to HSV values
  5522. * @returns a new color3 representing the HSV values
  5523. */
  5524. toHSV(): Color3;
  5525. /**
  5526. * Converts current color in rgb space to HSV values
  5527. * @param result defines the Color3 where to store the HSV values
  5528. */
  5529. toHSVToRef(result: Color3): void;
  5530. /**
  5531. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5532. * @param convertedColor defines the Color3 object where to store the linear space version
  5533. * @returns the unmodified Color3
  5534. */
  5535. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5536. /**
  5537. * Computes a new Color3 converted from the current one to gamma space
  5538. * @returns a new Color3 object
  5539. */
  5540. toGammaSpace(): Color3;
  5541. /**
  5542. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5543. * @param convertedColor defines the Color3 object where to store the gamma space version
  5544. * @returns the unmodified Color3
  5545. */
  5546. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5547. private static _BlackReadOnly;
  5548. /**
  5549. * Convert Hue, saturation and value to a Color3 (RGB)
  5550. * @param hue defines the hue
  5551. * @param saturation defines the saturation
  5552. * @param value defines the value
  5553. * @param result defines the Color3 where to store the RGB values
  5554. */
  5555. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5556. /**
  5557. * Creates a new Color3 from the string containing valid hexadecimal values
  5558. * @param hex defines a string containing valid hexadecimal values
  5559. * @returns a new Color3 object
  5560. */
  5561. static FromHexString(hex: string): Color3;
  5562. /**
  5563. * Creates a new Color3 from the starting index of the given array
  5564. * @param array defines the source array
  5565. * @param offset defines an offset in the source array
  5566. * @returns a new Color3 object
  5567. */
  5568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5569. /**
  5570. * Creates a new Color3 from integer values (< 256)
  5571. * @param r defines the red component to read from (value between 0 and 255)
  5572. * @param g defines the green component to read from (value between 0 and 255)
  5573. * @param b defines the blue component to read from (value between 0 and 255)
  5574. * @returns a new Color3 object
  5575. */
  5576. static FromInts(r: number, g: number, b: number): Color3;
  5577. /**
  5578. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5579. * @param start defines the start Color3 value
  5580. * @param end defines the end Color3 value
  5581. * @param amount defines the gradient value between start and end
  5582. * @returns a new Color3 object
  5583. */
  5584. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5585. /**
  5586. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5587. * @param left defines the start value
  5588. * @param right defines the end value
  5589. * @param amount defines the gradient factor
  5590. * @param result defines the Color3 object where to store the result
  5591. */
  5592. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5593. /**
  5594. * Returns a Color3 value containing a red color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Red(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a green color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Green(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a blue color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Blue(): Color3;
  5608. /**
  5609. * Returns a Color3 value containing a black color
  5610. * @returns a new Color3 object
  5611. */
  5612. static Black(): Color3;
  5613. /**
  5614. * Gets a Color3 value containing a black color that must not be updated
  5615. */
  5616. static get BlackReadOnly(): DeepImmutable<Color3>;
  5617. /**
  5618. * Returns a Color3 value containing a white color
  5619. * @returns a new Color3 object
  5620. */
  5621. static White(): Color3;
  5622. /**
  5623. * Returns a Color3 value containing a purple color
  5624. * @returns a new Color3 object
  5625. */
  5626. static Purple(): Color3;
  5627. /**
  5628. * Returns a Color3 value containing a magenta color
  5629. * @returns a new Color3 object
  5630. */
  5631. static Magenta(): Color3;
  5632. /**
  5633. * Returns a Color3 value containing a yellow color
  5634. * @returns a new Color3 object
  5635. */
  5636. static Yellow(): Color3;
  5637. /**
  5638. * Returns a Color3 value containing a gray color
  5639. * @returns a new Color3 object
  5640. */
  5641. static Gray(): Color3;
  5642. /**
  5643. * Returns a Color3 value containing a teal color
  5644. * @returns a new Color3 object
  5645. */
  5646. static Teal(): Color3;
  5647. /**
  5648. * Returns a Color3 value containing a random color
  5649. * @returns a new Color3 object
  5650. */
  5651. static Random(): Color3;
  5652. }
  5653. /**
  5654. * Class used to hold a RBGA color
  5655. */
  5656. export class Color4 {
  5657. /**
  5658. * Defines the red component (between 0 and 1, default is 0)
  5659. */
  5660. r: number;
  5661. /**
  5662. * Defines the green component (between 0 and 1, default is 0)
  5663. */
  5664. g: number;
  5665. /**
  5666. * Defines the blue component (between 0 and 1, default is 0)
  5667. */
  5668. b: number;
  5669. /**
  5670. * Defines the alpha component (between 0 and 1, default is 1)
  5671. */
  5672. a: number;
  5673. /**
  5674. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5675. * @param r defines the red component (between 0 and 1, default is 0)
  5676. * @param g defines the green component (between 0 and 1, default is 0)
  5677. * @param b defines the blue component (between 0 and 1, default is 0)
  5678. * @param a defines the alpha component (between 0 and 1, default is 1)
  5679. */
  5680. constructor(
  5681. /**
  5682. * Defines the red component (between 0 and 1, default is 0)
  5683. */
  5684. r?: number,
  5685. /**
  5686. * Defines the green component (between 0 and 1, default is 0)
  5687. */
  5688. g?: number,
  5689. /**
  5690. * Defines the blue component (between 0 and 1, default is 0)
  5691. */
  5692. b?: number,
  5693. /**
  5694. * Defines the alpha component (between 0 and 1, default is 1)
  5695. */
  5696. a?: number);
  5697. /**
  5698. * Adds in place the given Color4 values to the current Color4 object
  5699. * @param right defines the second operand
  5700. * @returns the current updated Color4 object
  5701. */
  5702. addInPlace(right: DeepImmutable<Color4>): Color4;
  5703. /**
  5704. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5705. * @returns the new array
  5706. */
  5707. asArray(): number[];
  5708. /**
  5709. * Stores from the starting index in the given array the Color4 successive values
  5710. * @param array defines the array where to store the r,g,b components
  5711. * @param index defines an optional index in the target array to define where to start storing values
  5712. * @returns the current Color4 object
  5713. */
  5714. toArray(array: number[], index?: number): Color4;
  5715. /**
  5716. * Determines equality between Color4 objects
  5717. * @param otherColor defines the second operand
  5718. * @returns true if the rgba values are equal to the given ones
  5719. */
  5720. equals(otherColor: DeepImmutable<Color4>): boolean;
  5721. /**
  5722. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5723. * @param right defines the second operand
  5724. * @returns a new Color4 object
  5725. */
  5726. add(right: DeepImmutable<Color4>): Color4;
  5727. /**
  5728. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5729. * @param right defines the second operand
  5730. * @returns a new Color4 object
  5731. */
  5732. subtract(right: DeepImmutable<Color4>): Color4;
  5733. /**
  5734. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5735. * @param right defines the second operand
  5736. * @param result defines the Color4 object where to store the result
  5737. * @returns the current Color4 object
  5738. */
  5739. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5740. /**
  5741. * Creates a new Color4 with the current Color4 values multiplied by scale
  5742. * @param scale defines the scaling factor to apply
  5743. * @returns a new Color4 object
  5744. */
  5745. scale(scale: number): Color4;
  5746. /**
  5747. * Multiplies the current Color4 values by scale and stores the result in "result"
  5748. * @param scale defines the scaling factor to apply
  5749. * @param result defines the Color4 object where to store the result
  5750. * @returns the current unmodified Color4
  5751. */
  5752. scaleToRef(scale: number, result: Color4): Color4;
  5753. /**
  5754. * Scale the current Color4 values by a factor and add the result to a given Color4
  5755. * @param scale defines the scale factor
  5756. * @param result defines the Color4 object where to store the result
  5757. * @returns the unmodified current Color4
  5758. */
  5759. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5760. /**
  5761. * Clamps the rgb values by the min and max values and stores the result into "result"
  5762. * @param min defines minimum clamping value (default is 0)
  5763. * @param max defines maximum clamping value (default is 1)
  5764. * @param result defines color to store the result into.
  5765. * @returns the cuurent Color4
  5766. */
  5767. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5768. /**
  5769. * Multipy an Color4 value by another and return a new Color4 object
  5770. * @param color defines the Color4 value to multiply by
  5771. * @returns a new Color4 object
  5772. */
  5773. multiply(color: Color4): Color4;
  5774. /**
  5775. * Multipy a Color4 value by another and push the result in a reference value
  5776. * @param color defines the Color4 value to multiply by
  5777. * @param result defines the Color4 to fill the result in
  5778. * @returns the result Color4
  5779. */
  5780. multiplyToRef(color: Color4, result: Color4): Color4;
  5781. /**
  5782. * Creates a string with the Color4 current values
  5783. * @returns the string representation of the Color4 object
  5784. */
  5785. toString(): string;
  5786. /**
  5787. * Returns the string "Color4"
  5788. * @returns "Color4"
  5789. */
  5790. getClassName(): string;
  5791. /**
  5792. * Compute the Color4 hash code
  5793. * @returns an unique number that can be used to hash Color4 objects
  5794. */
  5795. getHashCode(): number;
  5796. /**
  5797. * Creates a new Color4 copied from the current one
  5798. * @returns a new Color4 object
  5799. */
  5800. clone(): Color4;
  5801. /**
  5802. * Copies the given Color4 values into the current one
  5803. * @param source defines the source Color4 object
  5804. * @returns the current updated Color4 object
  5805. */
  5806. copyFrom(source: Color4): Color4;
  5807. /**
  5808. * Copies the given float values into the current one
  5809. * @param r defines the red component to read from
  5810. * @param g defines the green component to read from
  5811. * @param b defines the blue component to read from
  5812. * @param a defines the alpha component to read from
  5813. * @returns the current updated Color4 object
  5814. */
  5815. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5816. /**
  5817. * Copies the given float values into the current one
  5818. * @param r defines the red component to read from
  5819. * @param g defines the green component to read from
  5820. * @param b defines the blue component to read from
  5821. * @param a defines the alpha component to read from
  5822. * @returns the current updated Color4 object
  5823. */
  5824. set(r: number, g: number, b: number, a: number): Color4;
  5825. /**
  5826. * Compute the Color4 hexadecimal code as a string
  5827. * @returns a string containing the hexadecimal representation of the Color4 object
  5828. */
  5829. toHexString(): string;
  5830. /**
  5831. * Computes a new Color4 converted from the current one to linear space
  5832. * @returns a new Color4 object
  5833. */
  5834. toLinearSpace(): Color4;
  5835. /**
  5836. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5837. * @param convertedColor defines the Color4 object where to store the linear space version
  5838. * @returns the unmodified Color4
  5839. */
  5840. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5841. /**
  5842. * Computes a new Color4 converted from the current one to gamma space
  5843. * @returns a new Color4 object
  5844. */
  5845. toGammaSpace(): Color4;
  5846. /**
  5847. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5848. * @param convertedColor defines the Color4 object where to store the gamma space version
  5849. * @returns the unmodified Color4
  5850. */
  5851. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5852. /**
  5853. * Creates a new Color4 from the string containing valid hexadecimal values
  5854. * @param hex defines a string containing valid hexadecimal values
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromHexString(hex: string): Color4;
  5858. /**
  5859. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5860. * @param left defines the start value
  5861. * @param right defines the end value
  5862. * @param amount defines the gradient factor
  5863. * @returns a new Color4 object
  5864. */
  5865. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5866. /**
  5867. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5868. * @param left defines the start value
  5869. * @param right defines the end value
  5870. * @param amount defines the gradient factor
  5871. * @param result defines the Color4 object where to store data
  5872. */
  5873. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5874. /**
  5875. * Creates a new Color4 from a Color3 and an alpha value
  5876. * @param color3 defines the source Color3 to read from
  5877. * @param alpha defines the alpha component (1.0 by default)
  5878. * @returns a new Color4 object
  5879. */
  5880. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5881. /**
  5882. * Creates a new Color4 from the starting index element of the given array
  5883. * @param array defines the source array to read from
  5884. * @param offset defines the offset in the source array
  5885. * @returns a new Color4 object
  5886. */
  5887. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5888. /**
  5889. * Creates a new Color3 from integer values (< 256)
  5890. * @param r defines the red component to read from (value between 0 and 255)
  5891. * @param g defines the green component to read from (value between 0 and 255)
  5892. * @param b defines the blue component to read from (value between 0 and 255)
  5893. * @param a defines the alpha component to read from (value between 0 and 255)
  5894. * @returns a new Color3 object
  5895. */
  5896. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5897. /**
  5898. * Check the content of a given array and convert it to an array containing RGBA data
  5899. * If the original array was already containing count * 4 values then it is returned directly
  5900. * @param colors defines the array to check
  5901. * @param count defines the number of RGBA data to expect
  5902. * @returns an array containing count * 4 values (RGBA)
  5903. */
  5904. static CheckColors4(colors: number[], count: number): number[];
  5905. }
  5906. /**
  5907. * @hidden
  5908. */
  5909. export class TmpColors {
  5910. static Color3: Color3[];
  5911. static Color4: Color4[];
  5912. }
  5913. }
  5914. declare module "babylonjs/Animations/animationKey" {
  5915. /**
  5916. * Defines an interface which represents an animation key frame
  5917. */
  5918. export interface IAnimationKey {
  5919. /**
  5920. * Frame of the key frame
  5921. */
  5922. frame: number;
  5923. /**
  5924. * Value at the specifies key frame
  5925. */
  5926. value: any;
  5927. /**
  5928. * The input tangent for the cubic hermite spline
  5929. */
  5930. inTangent?: any;
  5931. /**
  5932. * The output tangent for the cubic hermite spline
  5933. */
  5934. outTangent?: any;
  5935. /**
  5936. * The animation interpolation type
  5937. */
  5938. interpolation?: AnimationKeyInterpolation;
  5939. }
  5940. /**
  5941. * Enum for the animation key frame interpolation type
  5942. */
  5943. export enum AnimationKeyInterpolation {
  5944. /**
  5945. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5946. */
  5947. STEP = 1
  5948. }
  5949. }
  5950. declare module "babylonjs/Animations/animationRange" {
  5951. /**
  5952. * Represents the range of an animation
  5953. */
  5954. export class AnimationRange {
  5955. /**The name of the animation range**/
  5956. name: string;
  5957. /**The starting frame of the animation */
  5958. from: number;
  5959. /**The ending frame of the animation*/
  5960. to: number;
  5961. /**
  5962. * Initializes the range of an animation
  5963. * @param name The name of the animation range
  5964. * @param from The starting frame of the animation
  5965. * @param to The ending frame of the animation
  5966. */
  5967. constructor(
  5968. /**The name of the animation range**/
  5969. name: string,
  5970. /**The starting frame of the animation */
  5971. from: number,
  5972. /**The ending frame of the animation*/
  5973. to: number);
  5974. /**
  5975. * Makes a copy of the animation range
  5976. * @returns A copy of the animation range
  5977. */
  5978. clone(): AnimationRange;
  5979. }
  5980. }
  5981. declare module "babylonjs/Animations/animationEvent" {
  5982. /**
  5983. * Composed of a frame, and an action function
  5984. */
  5985. export class AnimationEvent {
  5986. /** The frame for which the event is triggered **/
  5987. frame: number;
  5988. /** The event to perform when triggered **/
  5989. action: (currentFrame: number) => void;
  5990. /** Specifies if the event should be triggered only once**/
  5991. onlyOnce?: boolean | undefined;
  5992. /**
  5993. * Specifies if the animation event is done
  5994. */
  5995. isDone: boolean;
  5996. /**
  5997. * Initializes the animation event
  5998. * @param frame The frame for which the event is triggered
  5999. * @param action The event to perform when triggered
  6000. * @param onlyOnce Specifies if the event should be triggered only once
  6001. */
  6002. constructor(
  6003. /** The frame for which the event is triggered **/
  6004. frame: number,
  6005. /** The event to perform when triggered **/
  6006. action: (currentFrame: number) => void,
  6007. /** Specifies if the event should be triggered only once**/
  6008. onlyOnce?: boolean | undefined);
  6009. /** @hidden */
  6010. _clone(): AnimationEvent;
  6011. }
  6012. }
  6013. declare module "babylonjs/Behaviors/behavior" {
  6014. import { Nullable } from "babylonjs/types";
  6015. /**
  6016. * Interface used to define a behavior
  6017. */
  6018. export interface Behavior<T> {
  6019. /** gets or sets behavior's name */
  6020. name: string;
  6021. /**
  6022. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6023. */
  6024. init(): void;
  6025. /**
  6026. * Called when the behavior is attached to a target
  6027. * @param target defines the target where the behavior is attached to
  6028. */
  6029. attach(target: T): void;
  6030. /**
  6031. * Called when the behavior is detached from its target
  6032. */
  6033. detach(): void;
  6034. }
  6035. /**
  6036. * Interface implemented by classes supporting behaviors
  6037. */
  6038. export interface IBehaviorAware<T> {
  6039. /**
  6040. * Attach a behavior
  6041. * @param behavior defines the behavior to attach
  6042. * @returns the current host
  6043. */
  6044. addBehavior(behavior: Behavior<T>): T;
  6045. /**
  6046. * Remove a behavior from the current object
  6047. * @param behavior defines the behavior to detach
  6048. * @returns the current host
  6049. */
  6050. removeBehavior(behavior: Behavior<T>): T;
  6051. /**
  6052. * Gets a behavior using its name to search
  6053. * @param name defines the name to search
  6054. * @returns the behavior or null if not found
  6055. */
  6056. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6057. }
  6058. }
  6059. declare module "babylonjs/Misc/smartArray" {
  6060. /**
  6061. * Defines an array and its length.
  6062. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6063. */
  6064. export interface ISmartArrayLike<T> {
  6065. /**
  6066. * The data of the array.
  6067. */
  6068. data: Array<T>;
  6069. /**
  6070. * The active length of the array.
  6071. */
  6072. length: number;
  6073. }
  6074. /**
  6075. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6076. */
  6077. export class SmartArray<T> implements ISmartArrayLike<T> {
  6078. /**
  6079. * The full set of data from the array.
  6080. */
  6081. data: Array<T>;
  6082. /**
  6083. * The active length of the array.
  6084. */
  6085. length: number;
  6086. protected _id: number;
  6087. /**
  6088. * Instantiates a Smart Array.
  6089. * @param capacity defines the default capacity of the array.
  6090. */
  6091. constructor(capacity: number);
  6092. /**
  6093. * Pushes a value at the end of the active data.
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Iterates over the active data and apply the lambda to them.
  6099. * @param func defines the action to apply on each value.
  6100. */
  6101. forEach(func: (content: T) => void): void;
  6102. /**
  6103. * Sorts the full sets of data.
  6104. * @param compareFn defines the comparison function to apply.
  6105. */
  6106. sort(compareFn: (a: T, b: T) => number): void;
  6107. /**
  6108. * Resets the active data to an empty array.
  6109. */
  6110. reset(): void;
  6111. /**
  6112. * Releases all the data from the array as well as the array.
  6113. */
  6114. dispose(): void;
  6115. /**
  6116. * Concats the active data with a given array.
  6117. * @param array defines the data to concatenate with.
  6118. */
  6119. concat(array: any): void;
  6120. /**
  6121. * Returns the position of a value in the active data.
  6122. * @param value defines the value to find the index for
  6123. * @returns the index if found in the active data otherwise -1
  6124. */
  6125. indexOf(value: T): number;
  6126. /**
  6127. * Returns whether an element is part of the active data.
  6128. * @param value defines the value to look for
  6129. * @returns true if found in the active data otherwise false
  6130. */
  6131. contains(value: T): boolean;
  6132. private static _GlobalId;
  6133. }
  6134. /**
  6135. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6136. * The data in this array can only be present once
  6137. */
  6138. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6139. private _duplicateId;
  6140. /**
  6141. * Pushes a value at the end of the active data.
  6142. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6143. * @param value defines the object to push in the array.
  6144. */
  6145. push(value: T): void;
  6146. /**
  6147. * Pushes a value at the end of the active data.
  6148. * If the data is already present, it won t be added again
  6149. * @param value defines the object to push in the array.
  6150. * @returns true if added false if it was already present
  6151. */
  6152. pushNoDuplicate(value: T): boolean;
  6153. /**
  6154. * Resets the active data to an empty array.
  6155. */
  6156. reset(): void;
  6157. /**
  6158. * Concats the active data with a given array.
  6159. * This ensures no dupplicate will be present in the result.
  6160. * @param array defines the data to concatenate with.
  6161. */
  6162. concatWithNoDuplicate(array: any): void;
  6163. }
  6164. }
  6165. declare module "babylonjs/Cameras/cameraInputsManager" {
  6166. import { Nullable } from "babylonjs/types";
  6167. import { Camera } from "babylonjs/Cameras/camera";
  6168. /**
  6169. * @ignore
  6170. * This is a list of all the different input types that are available in the application.
  6171. * Fo instance: ArcRotateCameraGamepadInput...
  6172. */
  6173. export var CameraInputTypes: {};
  6174. /**
  6175. * This is the contract to implement in order to create a new input class.
  6176. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6177. */
  6178. export interface ICameraInput<TCamera extends Camera> {
  6179. /**
  6180. * Defines the camera the input is attached to.
  6181. */
  6182. camera: Nullable<TCamera>;
  6183. /**
  6184. * Gets the class name of the current intput.
  6185. * @returns the class name
  6186. */
  6187. getClassName(): string;
  6188. /**
  6189. * Get the friendly name associated with the input class.
  6190. * @returns the input friendly name
  6191. */
  6192. getSimpleName(): string;
  6193. /**
  6194. * Attach the input controls to a specific dom element to get the input from.
  6195. * @param element Defines the element the controls should be listened from
  6196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6197. */
  6198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6199. /**
  6200. * Detach the current controls from the specified dom element.
  6201. * @param element Defines the element to stop listening the inputs from
  6202. */
  6203. detachControl(element: Nullable<HTMLElement>): void;
  6204. /**
  6205. * Update the current camera state depending on the inputs that have been used this frame.
  6206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6207. */
  6208. checkInputs?: () => void;
  6209. }
  6210. /**
  6211. * Represents a map of input types to input instance or input index to input instance.
  6212. */
  6213. export interface CameraInputsMap<TCamera extends Camera> {
  6214. /**
  6215. * Accessor to the input by input type.
  6216. */
  6217. [name: string]: ICameraInput<TCamera>;
  6218. /**
  6219. * Accessor to the input by input index.
  6220. */
  6221. [idx: number]: ICameraInput<TCamera>;
  6222. }
  6223. /**
  6224. * This represents the input manager used within a camera.
  6225. * It helps dealing with all the different kind of input attached to a camera.
  6226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6227. */
  6228. export class CameraInputsManager<TCamera extends Camera> {
  6229. /**
  6230. * Defines the list of inputs attahed to the camera.
  6231. */
  6232. attached: CameraInputsMap<TCamera>;
  6233. /**
  6234. * Defines the dom element the camera is collecting inputs from.
  6235. * This is null if the controls have not been attached.
  6236. */
  6237. attachedElement: Nullable<HTMLElement>;
  6238. /**
  6239. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6240. */
  6241. noPreventDefault: boolean;
  6242. /**
  6243. * Defined the camera the input manager belongs to.
  6244. */
  6245. camera: TCamera;
  6246. /**
  6247. * Update the current camera state depending on the inputs that have been used this frame.
  6248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6249. */
  6250. checkInputs: () => void;
  6251. /**
  6252. * Instantiate a new Camera Input Manager.
  6253. * @param camera Defines the camera the input manager blongs to
  6254. */
  6255. constructor(camera: TCamera);
  6256. /**
  6257. * Add an input method to a camera
  6258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6259. * @param input camera input method
  6260. */
  6261. add(input: ICameraInput<TCamera>): void;
  6262. /**
  6263. * Remove a specific input method from a camera
  6264. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6265. * @param inputToRemove camera input method
  6266. */
  6267. remove(inputToRemove: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Remove a specific input type from a camera
  6270. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6271. * @param inputType the type of the input to remove
  6272. */
  6273. removeByType(inputType: string): void;
  6274. private _addCheckInputs;
  6275. /**
  6276. * Attach the input controls to the currently attached dom element to listen the events from.
  6277. * @param input Defines the input to attach
  6278. */
  6279. attachInput(input: ICameraInput<TCamera>): void;
  6280. /**
  6281. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6282. * @param element Defines the dom element to collect the events from
  6283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6284. */
  6285. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6286. /**
  6287. * Detach the current manager inputs controls from a specific dom element.
  6288. * @param element Defines the dom element to collect the events from
  6289. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6290. */
  6291. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6292. /**
  6293. * Rebuild the dynamic inputCheck function from the current list of
  6294. * defined inputs in the manager.
  6295. */
  6296. rebuildInputCheck(): void;
  6297. /**
  6298. * Remove all attached input methods from a camera
  6299. */
  6300. clear(): void;
  6301. /**
  6302. * Serialize the current input manager attached to a camera.
  6303. * This ensures than once parsed,
  6304. * the input associated to the camera will be identical to the current ones
  6305. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6306. */
  6307. serialize(serializedCamera: any): void;
  6308. /**
  6309. * Parses an input manager serialized JSON to restore the previous list of inputs
  6310. * and states associated to a camera.
  6311. * @param parsedCamera Defines the JSON to parse
  6312. */
  6313. parse(parsedCamera: any): void;
  6314. }
  6315. }
  6316. declare module "babylonjs/Meshes/buffer" {
  6317. import { Nullable, DataArray } from "babylonjs/types";
  6318. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6319. /**
  6320. * Class used to store data that will be store in GPU memory
  6321. */
  6322. export class Buffer {
  6323. private _engine;
  6324. private _buffer;
  6325. /** @hidden */
  6326. _data: Nullable<DataArray>;
  6327. private _updatable;
  6328. private _instanced;
  6329. private _divisor;
  6330. /**
  6331. * Gets the byte stride.
  6332. */
  6333. readonly byteStride: number;
  6334. /**
  6335. * Constructor
  6336. * @param engine the engine
  6337. * @param data the data to use for this buffer
  6338. * @param updatable whether the data is updatable
  6339. * @param stride the stride (optional)
  6340. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6341. * @param instanced whether the buffer is instanced (optional)
  6342. * @param useBytes set to true if the stride in in bytes (optional)
  6343. * @param divisor sets an optional divisor for instances (1 by default)
  6344. */
  6345. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6346. /**
  6347. * Create a new VertexBuffer based on the current buffer
  6348. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6349. * @param offset defines offset in the buffer (0 by default)
  6350. * @param size defines the size in floats of attributes (position is 3 for instance)
  6351. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6352. * @param instanced defines if the vertex buffer contains indexed data
  6353. * @param useBytes defines if the offset and stride are in bytes *
  6354. * @param divisor sets an optional divisor for instances (1 by default)
  6355. * @returns the new vertex buffer
  6356. */
  6357. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6358. /**
  6359. * Gets a boolean indicating if the Buffer is updatable?
  6360. * @returns true if the buffer is updatable
  6361. */
  6362. isUpdatable(): boolean;
  6363. /**
  6364. * Gets current buffer's data
  6365. * @returns a DataArray or null
  6366. */
  6367. getData(): Nullable<DataArray>;
  6368. /**
  6369. * Gets underlying native buffer
  6370. * @returns underlying native buffer
  6371. */
  6372. getBuffer(): Nullable<DataBuffer>;
  6373. /**
  6374. * Gets the stride in float32 units (i.e. byte stride / 4).
  6375. * May not be an integer if the byte stride is not divisible by 4.
  6376. * @returns the stride in float32 units
  6377. * @deprecated Please use byteStride instead.
  6378. */
  6379. getStrideSize(): number;
  6380. /**
  6381. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6382. * @param data defines the data to store
  6383. */
  6384. create(data?: Nullable<DataArray>): void;
  6385. /** @hidden */
  6386. _rebuild(): void;
  6387. /**
  6388. * Update current buffer data
  6389. * @param data defines the data to store
  6390. */
  6391. update(data: DataArray): void;
  6392. /**
  6393. * Updates the data directly.
  6394. * @param data the new data
  6395. * @param offset the new offset
  6396. * @param vertexCount the vertex count (optional)
  6397. * @param useBytes set to true if the offset is in bytes
  6398. */
  6399. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6400. /**
  6401. * Release all resources
  6402. */
  6403. dispose(): void;
  6404. }
  6405. /**
  6406. * Specialized buffer used to store vertex data
  6407. */
  6408. export class VertexBuffer {
  6409. /** @hidden */
  6410. _buffer: Buffer;
  6411. private _kind;
  6412. private _size;
  6413. private _ownsBuffer;
  6414. private _instanced;
  6415. private _instanceDivisor;
  6416. /**
  6417. * The byte type.
  6418. */
  6419. static readonly BYTE: number;
  6420. /**
  6421. * The unsigned byte type.
  6422. */
  6423. static readonly UNSIGNED_BYTE: number;
  6424. /**
  6425. * The short type.
  6426. */
  6427. static readonly SHORT: number;
  6428. /**
  6429. * The unsigned short type.
  6430. */
  6431. static readonly UNSIGNED_SHORT: number;
  6432. /**
  6433. * The integer type.
  6434. */
  6435. static readonly INT: number;
  6436. /**
  6437. * The unsigned integer type.
  6438. */
  6439. static readonly UNSIGNED_INT: number;
  6440. /**
  6441. * The float type.
  6442. */
  6443. static readonly FLOAT: number;
  6444. /**
  6445. * Gets or sets the instance divisor when in instanced mode
  6446. */
  6447. get instanceDivisor(): number;
  6448. set instanceDivisor(value: number);
  6449. /**
  6450. * Gets the byte stride.
  6451. */
  6452. readonly byteStride: number;
  6453. /**
  6454. * Gets the byte offset.
  6455. */
  6456. readonly byteOffset: number;
  6457. /**
  6458. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6459. */
  6460. readonly normalized: boolean;
  6461. /**
  6462. * Gets the data type of each component in the array.
  6463. */
  6464. readonly type: number;
  6465. /**
  6466. * Constructor
  6467. * @param engine the engine
  6468. * @param data the data to use for this vertex buffer
  6469. * @param kind the vertex buffer kind
  6470. * @param updatable whether the data is updatable
  6471. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6472. * @param stride the stride (optional)
  6473. * @param instanced whether the buffer is instanced (optional)
  6474. * @param offset the offset of the data (optional)
  6475. * @param size the number of components (optional)
  6476. * @param type the type of the component (optional)
  6477. * @param normalized whether the data contains normalized data (optional)
  6478. * @param useBytes set to true if stride and offset are in bytes (optional)
  6479. * @param divisor defines the instance divisor to use (1 by default)
  6480. */
  6481. 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);
  6482. /** @hidden */
  6483. _rebuild(): void;
  6484. /**
  6485. * Returns the kind of the VertexBuffer (string)
  6486. * @returns a string
  6487. */
  6488. getKind(): string;
  6489. /**
  6490. * Gets a boolean indicating if the VertexBuffer is updatable?
  6491. * @returns true if the buffer is updatable
  6492. */
  6493. isUpdatable(): boolean;
  6494. /**
  6495. * Gets current buffer's data
  6496. * @returns a DataArray or null
  6497. */
  6498. getData(): Nullable<DataArray>;
  6499. /**
  6500. * Gets underlying native buffer
  6501. * @returns underlying native buffer
  6502. */
  6503. getBuffer(): Nullable<DataBuffer>;
  6504. /**
  6505. * Gets the stride in float32 units (i.e. byte stride / 4).
  6506. * May not be an integer if the byte stride is not divisible by 4.
  6507. * @returns the stride in float32 units
  6508. * @deprecated Please use byteStride instead.
  6509. */
  6510. getStrideSize(): number;
  6511. /**
  6512. * Returns the offset as a multiple of the type byte length.
  6513. * @returns the offset in bytes
  6514. * @deprecated Please use byteOffset instead.
  6515. */
  6516. getOffset(): number;
  6517. /**
  6518. * Returns the number of components per vertex attribute (integer)
  6519. * @returns the size in float
  6520. */
  6521. getSize(): number;
  6522. /**
  6523. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6524. * @returns true if this buffer is instanced
  6525. */
  6526. getIsInstanced(): boolean;
  6527. /**
  6528. * Returns the instancing divisor, zero for non-instanced (integer).
  6529. * @returns a number
  6530. */
  6531. getInstanceDivisor(): number;
  6532. /**
  6533. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6534. * @param data defines the data to store
  6535. */
  6536. create(data?: DataArray): void;
  6537. /**
  6538. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6539. * This function will create a new buffer if the current one is not updatable
  6540. * @param data defines the data to store
  6541. */
  6542. update(data: DataArray): void;
  6543. /**
  6544. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6545. * Returns the directly updated WebGLBuffer.
  6546. * @param data the new data
  6547. * @param offset the new offset
  6548. * @param useBytes set to true if the offset is in bytes
  6549. */
  6550. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6551. /**
  6552. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6553. */
  6554. dispose(): void;
  6555. /**
  6556. * Enumerates each value of this vertex buffer as numbers.
  6557. * @param count the number of values to enumerate
  6558. * @param callback the callback function called for each value
  6559. */
  6560. forEach(count: number, callback: (value: number, index: number) => void): void;
  6561. /**
  6562. * Positions
  6563. */
  6564. static readonly PositionKind: string;
  6565. /**
  6566. * Normals
  6567. */
  6568. static readonly NormalKind: string;
  6569. /**
  6570. * Tangents
  6571. */
  6572. static readonly TangentKind: string;
  6573. /**
  6574. * Texture coordinates
  6575. */
  6576. static readonly UVKind: string;
  6577. /**
  6578. * Texture coordinates 2
  6579. */
  6580. static readonly UV2Kind: string;
  6581. /**
  6582. * Texture coordinates 3
  6583. */
  6584. static readonly UV3Kind: string;
  6585. /**
  6586. * Texture coordinates 4
  6587. */
  6588. static readonly UV4Kind: string;
  6589. /**
  6590. * Texture coordinates 5
  6591. */
  6592. static readonly UV5Kind: string;
  6593. /**
  6594. * Texture coordinates 6
  6595. */
  6596. static readonly UV6Kind: string;
  6597. /**
  6598. * Colors
  6599. */
  6600. static readonly ColorKind: string;
  6601. /**
  6602. * Matrix indices (for bones)
  6603. */
  6604. static readonly MatricesIndicesKind: string;
  6605. /**
  6606. * Matrix weights (for bones)
  6607. */
  6608. static readonly MatricesWeightsKind: string;
  6609. /**
  6610. * Additional matrix indices (for bones)
  6611. */
  6612. static readonly MatricesIndicesExtraKind: string;
  6613. /**
  6614. * Additional matrix weights (for bones)
  6615. */
  6616. static readonly MatricesWeightsExtraKind: string;
  6617. /**
  6618. * Deduces the stride given a kind.
  6619. * @param kind The kind string to deduce
  6620. * @returns The deduced stride
  6621. */
  6622. static DeduceStride(kind: string): number;
  6623. /**
  6624. * Gets the byte length of the given type.
  6625. * @param type the type
  6626. * @returns the number of bytes
  6627. */
  6628. static GetTypeByteLength(type: number): number;
  6629. /**
  6630. * Enumerates each value of the given parameters as numbers.
  6631. * @param data the data to enumerate
  6632. * @param byteOffset the byte offset of the data
  6633. * @param byteStride the byte stride of the data
  6634. * @param componentCount the number of components per element
  6635. * @param componentType the type of the component
  6636. * @param count the number of values to enumerate
  6637. * @param normalized whether the data is normalized
  6638. * @param callback the callback function called for each value
  6639. */
  6640. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6641. private static _GetFloatValue;
  6642. }
  6643. }
  6644. declare module "babylonjs/Collisions/intersectionInfo" {
  6645. import { Nullable } from "babylonjs/types";
  6646. /**
  6647. * @hidden
  6648. */
  6649. export class IntersectionInfo {
  6650. bu: Nullable<number>;
  6651. bv: Nullable<number>;
  6652. distance: number;
  6653. faceId: number;
  6654. subMeshId: number;
  6655. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6656. }
  6657. }
  6658. declare module "babylonjs/Maths/math.plane" {
  6659. import { DeepImmutable } from "babylonjs/types";
  6660. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6661. /**
  6662. * Represens a plane by the equation ax + by + cz + d = 0
  6663. */
  6664. export class Plane {
  6665. private static _TmpMatrix;
  6666. /**
  6667. * Normal of the plane (a,b,c)
  6668. */
  6669. normal: Vector3;
  6670. /**
  6671. * d component of the plane
  6672. */
  6673. d: number;
  6674. /**
  6675. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6676. * @param a a component of the plane
  6677. * @param b b component of the plane
  6678. * @param c c component of the plane
  6679. * @param d d component of the plane
  6680. */
  6681. constructor(a: number, b: number, c: number, d: number);
  6682. /**
  6683. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6684. */
  6685. asArray(): number[];
  6686. /**
  6687. * @returns a new plane copied from the current Plane.
  6688. */
  6689. clone(): Plane;
  6690. /**
  6691. * @returns the string "Plane".
  6692. */
  6693. getClassName(): string;
  6694. /**
  6695. * @returns the Plane hash code.
  6696. */
  6697. getHashCode(): number;
  6698. /**
  6699. * Normalize the current Plane in place.
  6700. * @returns the updated Plane.
  6701. */
  6702. normalize(): Plane;
  6703. /**
  6704. * Applies a transformation the plane and returns the result
  6705. * @param transformation the transformation matrix to be applied to the plane
  6706. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6707. */
  6708. transform(transformation: DeepImmutable<Matrix>): Plane;
  6709. /**
  6710. * Calcualtte the dot product between the point and the plane normal
  6711. * @param point point to calculate the dot product with
  6712. * @returns the dot product (float) of the point coordinates and the plane normal.
  6713. */
  6714. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6715. /**
  6716. * Updates the current Plane from the plane defined by the three given points.
  6717. * @param point1 one of the points used to contruct the plane
  6718. * @param point2 one of the points used to contruct the plane
  6719. * @param point3 one of the points used to contruct the plane
  6720. * @returns the updated Plane.
  6721. */
  6722. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6723. /**
  6724. * Checks if the plane is facing a given direction
  6725. * @param direction the direction to check if the plane is facing
  6726. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6727. * @returns True is the vector "direction" is the same side than the plane normal.
  6728. */
  6729. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6730. /**
  6731. * Calculates the distance to a point
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance (float) from the given point to the Plane.
  6734. */
  6735. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6736. /**
  6737. * Creates a plane from an array
  6738. * @param array the array to create a plane from
  6739. * @returns a new Plane from the given array.
  6740. */
  6741. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6742. /**
  6743. * Creates a plane from three points
  6744. * @param point1 point used to create the plane
  6745. * @param point2 point used to create the plane
  6746. * @param point3 point used to create the plane
  6747. * @returns a new Plane defined by the three given points.
  6748. */
  6749. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6750. /**
  6751. * Creates a plane from an origin point and a normal
  6752. * @param origin origin of the plane to be constructed
  6753. * @param normal normal of the plane to be constructed
  6754. * @returns a new Plane the normal vector to this plane at the given origin point.
  6755. * Note : the vector "normal" is updated because normalized.
  6756. */
  6757. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6758. /**
  6759. * Calculates the distance from a plane and a point
  6760. * @param origin origin of the plane to be constructed
  6761. * @param normal normal of the plane to be constructed
  6762. * @param point point to calculate distance to
  6763. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6764. */
  6765. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6766. }
  6767. }
  6768. declare module "babylonjs/Culling/boundingSphere" {
  6769. import { DeepImmutable } from "babylonjs/types";
  6770. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6771. import { Plane } from "babylonjs/Maths/math.plane";
  6772. /**
  6773. * Class used to store bounding sphere information
  6774. */
  6775. export class BoundingSphere {
  6776. /**
  6777. * Gets the center of the bounding sphere in local space
  6778. */
  6779. readonly center: Vector3;
  6780. /**
  6781. * Radius of the bounding sphere in local space
  6782. */
  6783. radius: number;
  6784. /**
  6785. * Gets the center of the bounding sphere in world space
  6786. */
  6787. readonly centerWorld: Vector3;
  6788. /**
  6789. * Radius of the bounding sphere in world space
  6790. */
  6791. radiusWorld: number;
  6792. /**
  6793. * Gets the minimum vector in local space
  6794. */
  6795. readonly minimum: Vector3;
  6796. /**
  6797. * Gets the maximum vector in local space
  6798. */
  6799. readonly maximum: Vector3;
  6800. private _worldMatrix;
  6801. private static readonly TmpVector3;
  6802. /**
  6803. * Creates a new bounding sphere
  6804. * @param min defines the minimum vector (in local space)
  6805. * @param max defines the maximum vector (in local space)
  6806. * @param worldMatrix defines the new world matrix
  6807. */
  6808. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6809. /**
  6810. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6811. * @param min defines the new minimum vector (in local space)
  6812. * @param max defines the new maximum vector (in local space)
  6813. * @param worldMatrix defines the new world matrix
  6814. */
  6815. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6816. /**
  6817. * Scale the current bounding sphere by applying a scale factor
  6818. * @param factor defines the scale factor to apply
  6819. * @returns the current bounding box
  6820. */
  6821. scale(factor: number): BoundingSphere;
  6822. /**
  6823. * Gets the world matrix of the bounding box
  6824. * @returns a matrix
  6825. */
  6826. getWorldMatrix(): DeepImmutable<Matrix>;
  6827. /** @hidden */
  6828. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6829. /**
  6830. * Tests if the bounding sphere is intersecting the frustum planes
  6831. * @param frustumPlanes defines the frustum planes to test
  6832. * @returns true if there is an intersection
  6833. */
  6834. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6835. /**
  6836. * Tests if the bounding sphere center is in between the frustum planes.
  6837. * Used for optimistic fast inclusion.
  6838. * @param frustumPlanes defines the frustum planes to test
  6839. * @returns true if the sphere center is in between the frustum planes
  6840. */
  6841. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6842. /**
  6843. * Tests if a point is inside the bounding sphere
  6844. * @param point defines the point to test
  6845. * @returns true if the point is inside the bounding sphere
  6846. */
  6847. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6848. /**
  6849. * Checks if two sphere intersct
  6850. * @param sphere0 sphere 0
  6851. * @param sphere1 sphere 1
  6852. * @returns true if the speres intersect
  6853. */
  6854. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6855. }
  6856. }
  6857. declare module "babylonjs/Culling/boundingBox" {
  6858. import { DeepImmutable } from "babylonjs/types";
  6859. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6860. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6861. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6862. import { Plane } from "babylonjs/Maths/math.plane";
  6863. /**
  6864. * Class used to store bounding box information
  6865. */
  6866. export class BoundingBox implements ICullable {
  6867. /**
  6868. * Gets the 8 vectors representing the bounding box in local space
  6869. */
  6870. readonly vectors: Vector3[];
  6871. /**
  6872. * Gets the center of the bounding box in local space
  6873. */
  6874. readonly center: Vector3;
  6875. /**
  6876. * Gets the center of the bounding box in world space
  6877. */
  6878. readonly centerWorld: Vector3;
  6879. /**
  6880. * Gets the extend size in local space
  6881. */
  6882. readonly extendSize: Vector3;
  6883. /**
  6884. * Gets the extend size in world space
  6885. */
  6886. readonly extendSizeWorld: Vector3;
  6887. /**
  6888. * Gets the OBB (object bounding box) directions
  6889. */
  6890. readonly directions: Vector3[];
  6891. /**
  6892. * Gets the 8 vectors representing the bounding box in world space
  6893. */
  6894. readonly vectorsWorld: Vector3[];
  6895. /**
  6896. * Gets the minimum vector in world space
  6897. */
  6898. readonly minimumWorld: Vector3;
  6899. /**
  6900. * Gets the maximum vector in world space
  6901. */
  6902. readonly maximumWorld: Vector3;
  6903. /**
  6904. * Gets the minimum vector in local space
  6905. */
  6906. readonly minimum: Vector3;
  6907. /**
  6908. * Gets the maximum vector in local space
  6909. */
  6910. readonly maximum: Vector3;
  6911. private _worldMatrix;
  6912. private static readonly TmpVector3;
  6913. /**
  6914. * @hidden
  6915. */
  6916. _tag: number;
  6917. /**
  6918. * Creates a new bounding box
  6919. * @param min defines the minimum vector (in local space)
  6920. * @param max defines the maximum vector (in local space)
  6921. * @param worldMatrix defines the new world matrix
  6922. */
  6923. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6924. /**
  6925. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6926. * @param min defines the new minimum vector (in local space)
  6927. * @param max defines the new maximum vector (in local space)
  6928. * @param worldMatrix defines the new world matrix
  6929. */
  6930. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Scale the current bounding box by applying a scale factor
  6933. * @param factor defines the scale factor to apply
  6934. * @returns the current bounding box
  6935. */
  6936. scale(factor: number): BoundingBox;
  6937. /**
  6938. * Gets the world matrix of the bounding box
  6939. * @returns a matrix
  6940. */
  6941. getWorldMatrix(): DeepImmutable<Matrix>;
  6942. /** @hidden */
  6943. _update(world: DeepImmutable<Matrix>): void;
  6944. /**
  6945. * Tests if the bounding box is intersecting the frustum planes
  6946. * @param frustumPlanes defines the frustum planes to test
  6947. * @returns true if there is an intersection
  6948. */
  6949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6950. /**
  6951. * Tests if the bounding box is entirely inside the frustum planes
  6952. * @param frustumPlanes defines the frustum planes to test
  6953. * @returns true if there is an inclusion
  6954. */
  6955. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6956. /**
  6957. * Tests if a point is inside the bounding box
  6958. * @param point defines the point to test
  6959. * @returns true if the point is inside the bounding box
  6960. */
  6961. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6962. /**
  6963. * Tests if the bounding box intersects with a bounding sphere
  6964. * @param sphere defines the sphere to test
  6965. * @returns true if there is an intersection
  6966. */
  6967. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6968. /**
  6969. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6970. * @param min defines the min vector to use
  6971. * @param max defines the max vector to use
  6972. * @returns true if there is an intersection
  6973. */
  6974. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6975. /**
  6976. * Tests if two bounding boxes are intersections
  6977. * @param box0 defines the first box to test
  6978. * @param box1 defines the second box to test
  6979. * @returns true if there is an intersection
  6980. */
  6981. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6982. /**
  6983. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6984. * @param minPoint defines the minimum vector of the bounding box
  6985. * @param maxPoint defines the maximum vector of the bounding box
  6986. * @param sphereCenter defines the sphere center
  6987. * @param sphereRadius defines the sphere radius
  6988. * @returns true if there is an intersection
  6989. */
  6990. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6991. /**
  6992. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6993. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6994. * @param frustumPlanes defines the frustum planes to test
  6995. * @return true if there is an inclusion
  6996. */
  6997. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6998. /**
  6999. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7000. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7001. * @param frustumPlanes defines the frustum planes to test
  7002. * @return true if there is an intersection
  7003. */
  7004. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Collisions/collider" {
  7008. import { Nullable, IndicesArray } from "babylonjs/types";
  7009. import { Vector3 } from "babylonjs/Maths/math.vector";
  7010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7011. import { Plane } from "babylonjs/Maths/math.plane";
  7012. /** @hidden */
  7013. export class Collider {
  7014. /** Define if a collision was found */
  7015. collisionFound: boolean;
  7016. /**
  7017. * Define last intersection point in local space
  7018. */
  7019. intersectionPoint: Vector3;
  7020. /**
  7021. * Define last collided mesh
  7022. */
  7023. collidedMesh: Nullable<AbstractMesh>;
  7024. private _collisionPoint;
  7025. private _planeIntersectionPoint;
  7026. private _tempVector;
  7027. private _tempVector2;
  7028. private _tempVector3;
  7029. private _tempVector4;
  7030. private _edge;
  7031. private _baseToVertex;
  7032. private _destinationPoint;
  7033. private _slidePlaneNormal;
  7034. private _displacementVector;
  7035. /** @hidden */
  7036. _radius: Vector3;
  7037. /** @hidden */
  7038. _retry: number;
  7039. private _velocity;
  7040. private _basePoint;
  7041. private _epsilon;
  7042. /** @hidden */
  7043. _velocityWorldLength: number;
  7044. /** @hidden */
  7045. _basePointWorld: Vector3;
  7046. private _velocityWorld;
  7047. private _normalizedVelocity;
  7048. /** @hidden */
  7049. _initialVelocity: Vector3;
  7050. /** @hidden */
  7051. _initialPosition: Vector3;
  7052. private _nearestDistance;
  7053. private _collisionMask;
  7054. get collisionMask(): number;
  7055. set collisionMask(mask: number);
  7056. /**
  7057. * Gets the plane normal used to compute the sliding response (in local space)
  7058. */
  7059. get slidePlaneNormal(): Vector3;
  7060. /** @hidden */
  7061. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7062. /** @hidden */
  7063. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7064. /** @hidden */
  7065. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7066. /** @hidden */
  7067. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7068. /** @hidden */
  7069. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7070. /** @hidden */
  7071. _getResponse(pos: Vector3, vel: Vector3): void;
  7072. }
  7073. }
  7074. declare module "babylonjs/Culling/boundingInfo" {
  7075. import { DeepImmutable } from "babylonjs/types";
  7076. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7077. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7078. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7079. import { Plane } from "babylonjs/Maths/math.plane";
  7080. import { Collider } from "babylonjs/Collisions/collider";
  7081. /**
  7082. * Interface for cullable objects
  7083. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7084. */
  7085. export interface ICullable {
  7086. /**
  7087. * Checks if the object or part of the object is in the frustum
  7088. * @param frustumPlanes Camera near/planes
  7089. * @returns true if the object is in frustum otherwise false
  7090. */
  7091. isInFrustum(frustumPlanes: Plane[]): boolean;
  7092. /**
  7093. * Checks if a cullable object (mesh...) is in the camera frustum
  7094. * Unlike isInFrustum this cheks the full bounding box
  7095. * @param frustumPlanes Camera near/planes
  7096. * @returns true if the object is in frustum otherwise false
  7097. */
  7098. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7099. }
  7100. /**
  7101. * Info for a bounding data of a mesh
  7102. */
  7103. export class BoundingInfo implements ICullable {
  7104. /**
  7105. * Bounding box for the mesh
  7106. */
  7107. readonly boundingBox: BoundingBox;
  7108. /**
  7109. * Bounding sphere for the mesh
  7110. */
  7111. readonly boundingSphere: BoundingSphere;
  7112. private _isLocked;
  7113. private static readonly TmpVector3;
  7114. /**
  7115. * Constructs bounding info
  7116. * @param minimum min vector of the bounding box/sphere
  7117. * @param maximum max vector of the bounding box/sphere
  7118. * @param worldMatrix defines the new world matrix
  7119. */
  7120. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7121. /**
  7122. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7123. * @param min defines the new minimum vector (in local space)
  7124. * @param max defines the new maximum vector (in local space)
  7125. * @param worldMatrix defines the new world matrix
  7126. */
  7127. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7128. /**
  7129. * min vector of the bounding box/sphere
  7130. */
  7131. get minimum(): Vector3;
  7132. /**
  7133. * max vector of the bounding box/sphere
  7134. */
  7135. get maximum(): Vector3;
  7136. /**
  7137. * If the info is locked and won't be updated to avoid perf overhead
  7138. */
  7139. get isLocked(): boolean;
  7140. set isLocked(value: boolean);
  7141. /**
  7142. * Updates the bounding sphere and box
  7143. * @param world world matrix to be used to update
  7144. */
  7145. update(world: DeepImmutable<Matrix>): void;
  7146. /**
  7147. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7148. * @param center New center of the bounding info
  7149. * @param extend New extend of the bounding info
  7150. * @returns the current bounding info
  7151. */
  7152. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7153. /**
  7154. * Scale the current bounding info by applying a scale factor
  7155. * @param factor defines the scale factor to apply
  7156. * @returns the current bounding info
  7157. */
  7158. scale(factor: number): BoundingInfo;
  7159. /**
  7160. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7161. * @param frustumPlanes defines the frustum to test
  7162. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7163. * @returns true if the bounding info is in the frustum planes
  7164. */
  7165. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7166. /**
  7167. * Gets the world distance between the min and max points of the bounding box
  7168. */
  7169. get diagonalLength(): number;
  7170. /**
  7171. * Checks if a cullable object (mesh...) is in the camera frustum
  7172. * Unlike isInFrustum this cheks the full bounding box
  7173. * @param frustumPlanes Camera near/planes
  7174. * @returns true if the object is in frustum otherwise false
  7175. */
  7176. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7177. /** @hidden */
  7178. _checkCollision(collider: Collider): boolean;
  7179. /**
  7180. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7181. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7182. * @param point the point to check intersection with
  7183. * @returns if the point intersects
  7184. */
  7185. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7186. /**
  7187. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7188. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7189. * @param boundingInfo the bounding info to check intersection with
  7190. * @param precise if the intersection should be done using OBB
  7191. * @returns if the bounding info intersects
  7192. */
  7193. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7194. }
  7195. }
  7196. declare module "babylonjs/Maths/math.functions" {
  7197. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7198. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7199. /**
  7200. * Extracts minimum and maximum values from a list of indexed positions
  7201. * @param positions defines the positions to use
  7202. * @param indices defines the indices to the positions
  7203. * @param indexStart defines the start index
  7204. * @param indexCount defines the end index
  7205. * @param bias defines bias value to add to the result
  7206. * @return minimum and maximum values
  7207. */
  7208. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7209. minimum: Vector3;
  7210. maximum: Vector3;
  7211. };
  7212. /**
  7213. * Extracts minimum and maximum values from a list of positions
  7214. * @param positions defines the positions to use
  7215. * @param start defines the start index in the positions array
  7216. * @param count defines the number of positions to handle
  7217. * @param bias defines bias value to add to the result
  7218. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7219. * @return minimum and maximum values
  7220. */
  7221. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7222. minimum: Vector3;
  7223. maximum: Vector3;
  7224. };
  7225. }
  7226. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7227. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7228. /** @hidden */
  7229. export class WebGLDataBuffer extends DataBuffer {
  7230. private _buffer;
  7231. constructor(resource: WebGLBuffer);
  7232. get underlyingResource(): any;
  7233. }
  7234. }
  7235. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7236. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7237. import { Nullable } from "babylonjs/types";
  7238. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7239. /** @hidden */
  7240. export class WebGLPipelineContext implements IPipelineContext {
  7241. engine: ThinEngine;
  7242. program: Nullable<WebGLProgram>;
  7243. context?: WebGLRenderingContext;
  7244. vertexShader?: WebGLShader;
  7245. fragmentShader?: WebGLShader;
  7246. isParallelCompiled: boolean;
  7247. onCompiled?: () => void;
  7248. transformFeedback?: WebGLTransformFeedback | null;
  7249. vertexCompilationError: Nullable<string>;
  7250. fragmentCompilationError: Nullable<string>;
  7251. programLinkError: Nullable<string>;
  7252. programValidationError: Nullable<string>;
  7253. get isAsync(): boolean;
  7254. get isReady(): boolean;
  7255. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7259. import { FloatArray, Nullable } from "babylonjs/types";
  7260. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7261. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7262. module "babylonjs/Engines/thinEngine" {
  7263. interface ThinEngine {
  7264. /**
  7265. * Create an uniform buffer
  7266. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7267. * @param elements defines the content of the uniform buffer
  7268. * @returns the webGL uniform buffer
  7269. */
  7270. createUniformBuffer(elements: FloatArray): DataBuffer;
  7271. /**
  7272. * Create a dynamic uniform buffer
  7273. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7274. * @param elements defines the content of the uniform buffer
  7275. * @returns the webGL uniform buffer
  7276. */
  7277. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7278. /**
  7279. * Update an existing uniform buffer
  7280. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7281. * @param uniformBuffer defines the target uniform buffer
  7282. * @param elements defines the content to update
  7283. * @param offset defines the offset in the uniform buffer where update should start
  7284. * @param count defines the size of the data to update
  7285. */
  7286. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7287. /**
  7288. * Bind an uniform buffer to the current webGL context
  7289. * @param buffer defines the buffer to bind
  7290. */
  7291. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7292. /**
  7293. * Bind a buffer to the current webGL context at a given location
  7294. * @param buffer defines the buffer to bind
  7295. * @param location defines the index where to bind the buffer
  7296. */
  7297. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7298. /**
  7299. * Bind a specific block at a given index in a specific shader program
  7300. * @param pipelineContext defines the pipeline context to use
  7301. * @param blockName defines the block name
  7302. * @param index defines the index where to bind the block
  7303. */
  7304. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7305. }
  7306. }
  7307. }
  7308. declare module "babylonjs/Materials/uniformBuffer" {
  7309. import { Nullable, FloatArray } from "babylonjs/types";
  7310. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7311. import { Engine } from "babylonjs/Engines/engine";
  7312. import { Effect } from "babylonjs/Materials/effect";
  7313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7315. import { Color3 } from "babylonjs/Maths/math.color";
  7316. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7317. /**
  7318. * Uniform buffer objects.
  7319. *
  7320. * Handles blocks of uniform on the GPU.
  7321. *
  7322. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7323. *
  7324. * For more information, please refer to :
  7325. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7326. */
  7327. export class UniformBuffer {
  7328. private _engine;
  7329. private _buffer;
  7330. private _data;
  7331. private _bufferData;
  7332. private _dynamic?;
  7333. private _uniformLocations;
  7334. private _uniformSizes;
  7335. private _uniformLocationPointer;
  7336. private _needSync;
  7337. private _noUBO;
  7338. private _currentEffect;
  7339. /** @hidden */
  7340. _alreadyBound: boolean;
  7341. private static _MAX_UNIFORM_SIZE;
  7342. private static _tempBuffer;
  7343. /**
  7344. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7349. /**
  7350. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7355. /**
  7356. * Lambda to Update a single float in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateFloat: (name: string, x: number) => void;
  7361. /**
  7362. * Lambda to Update a vec2 of float in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7367. /**
  7368. * Lambda to Update a vec3 of float in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update a vec4 of float in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7379. /**
  7380. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateMatrix: (name: string, mat: Matrix) => void;
  7385. /**
  7386. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateVector3: (name: string, vector: Vector3) => void;
  7391. /**
  7392. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateVector4: (name: string, vector: Vector4) => void;
  7397. /**
  7398. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7399. * This is dynamic to allow compat with webgl 1 and 2.
  7400. * You will need to pass the name of the uniform as well as the value.
  7401. */
  7402. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7403. /**
  7404. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7405. * This is dynamic to allow compat with webgl 1 and 2.
  7406. * You will need to pass the name of the uniform as well as the value.
  7407. */
  7408. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7409. /**
  7410. * Instantiates a new Uniform buffer objects.
  7411. *
  7412. * Handles blocks of uniform on the GPU.
  7413. *
  7414. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7415. *
  7416. * For more information, please refer to :
  7417. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7418. * @param engine Define the engine the buffer is associated with
  7419. * @param data Define the data contained in the buffer
  7420. * @param dynamic Define if the buffer is updatable
  7421. */
  7422. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7423. /**
  7424. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7425. * or just falling back on setUniformXXX calls.
  7426. */
  7427. get useUbo(): boolean;
  7428. /**
  7429. * Indicates if the WebGL underlying uniform buffer is in sync
  7430. * with the javascript cache data.
  7431. */
  7432. get isSync(): boolean;
  7433. /**
  7434. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7435. * Also, a dynamic UniformBuffer will disable cache verification and always
  7436. * update the underlying WebGL uniform buffer to the GPU.
  7437. * @returns if Dynamic, otherwise false
  7438. */
  7439. isDynamic(): boolean;
  7440. /**
  7441. * The data cache on JS side.
  7442. * @returns the underlying data as a float array
  7443. */
  7444. getData(): Float32Array;
  7445. /**
  7446. * The underlying WebGL Uniform buffer.
  7447. * @returns the webgl buffer
  7448. */
  7449. getBuffer(): Nullable<DataBuffer>;
  7450. /**
  7451. * std140 layout specifies how to align data within an UBO structure.
  7452. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7453. * for specs.
  7454. */
  7455. private _fillAlignment;
  7456. /**
  7457. * Adds an uniform in the buffer.
  7458. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7459. * for the layout to be correct !
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param size Data size, or data directly.
  7462. */
  7463. addUniform(name: string, size: number | number[]): void;
  7464. /**
  7465. * Adds a Matrix 4x4 to the uniform buffer.
  7466. * @param name Name of the uniform, as used in the uniform block in the shader.
  7467. * @param mat A 4x4 matrix.
  7468. */
  7469. addMatrix(name: string, mat: Matrix): void;
  7470. /**
  7471. * Adds a vec2 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param x Define the x component value of the vec2
  7474. * @param y Define the y component value of the vec2
  7475. */
  7476. addFloat2(name: string, x: number, y: number): void;
  7477. /**
  7478. * Adds a vec3 to the uniform buffer.
  7479. * @param name Name of the uniform, as used in the uniform block in the shader.
  7480. * @param x Define the x component value of the vec3
  7481. * @param y Define the y component value of the vec3
  7482. * @param z Define the z component value of the vec3
  7483. */
  7484. addFloat3(name: string, x: number, y: number, z: number): void;
  7485. /**
  7486. * Adds a vec3 to the uniform buffer.
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param color Define the vec3 from a Color
  7489. */
  7490. addColor3(name: string, color: Color3): void;
  7491. /**
  7492. * Adds a vec4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param color Define the rgb components from a Color
  7495. * @param alpha Define the a component of the vec4
  7496. */
  7497. addColor4(name: string, color: Color3, alpha: number): void;
  7498. /**
  7499. * Adds a vec3 to the uniform buffer.
  7500. * @param name Name of the uniform, as used in the uniform block in the shader.
  7501. * @param vector Define the vec3 components from a Vector
  7502. */
  7503. addVector3(name: string, vector: Vector3): void;
  7504. /**
  7505. * Adds a Matrix 3x3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. */
  7508. addMatrix3x3(name: string): void;
  7509. /**
  7510. * Adds a Matrix 2x2 to the uniform buffer.
  7511. * @param name Name of the uniform, as used in the uniform block in the shader.
  7512. */
  7513. addMatrix2x2(name: string): void;
  7514. /**
  7515. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7516. */
  7517. create(): void;
  7518. /** @hidden */
  7519. _rebuild(): void;
  7520. /**
  7521. * Updates the WebGL Uniform Buffer on the GPU.
  7522. * If the `dynamic` flag is set to true, no cache comparison is done.
  7523. * Otherwise, the buffer will be updated only if the cache differs.
  7524. */
  7525. update(): void;
  7526. /**
  7527. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7528. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7529. * @param data Define the flattened data
  7530. * @param size Define the size of the data.
  7531. */
  7532. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7533. private _valueCache;
  7534. private _cacheMatrix;
  7535. private _updateMatrix3x3ForUniform;
  7536. private _updateMatrix3x3ForEffect;
  7537. private _updateMatrix2x2ForEffect;
  7538. private _updateMatrix2x2ForUniform;
  7539. private _updateFloatForEffect;
  7540. private _updateFloatForUniform;
  7541. private _updateFloat2ForEffect;
  7542. private _updateFloat2ForUniform;
  7543. private _updateFloat3ForEffect;
  7544. private _updateFloat3ForUniform;
  7545. private _updateFloat4ForEffect;
  7546. private _updateFloat4ForUniform;
  7547. private _updateMatrixForEffect;
  7548. private _updateMatrixForUniform;
  7549. private _updateVector3ForEffect;
  7550. private _updateVector3ForUniform;
  7551. private _updateVector4ForEffect;
  7552. private _updateVector4ForUniform;
  7553. private _updateColor3ForEffect;
  7554. private _updateColor3ForUniform;
  7555. private _updateColor4ForEffect;
  7556. private _updateColor4ForUniform;
  7557. /**
  7558. * Sets a sampler uniform on the effect.
  7559. * @param name Define the name of the sampler.
  7560. * @param texture Define the texture to set in the sampler
  7561. */
  7562. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7563. /**
  7564. * Directly updates the value of the uniform in the cache AND on the GPU.
  7565. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7566. * @param data Define the flattened data
  7567. */
  7568. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7569. /**
  7570. * Binds this uniform buffer to an effect.
  7571. * @param effect Define the effect to bind the buffer to
  7572. * @param name Name of the uniform block in the shader.
  7573. */
  7574. bindToEffect(effect: Effect, name: string): void;
  7575. /**
  7576. * Disposes the uniform buffer.
  7577. */
  7578. dispose(): void;
  7579. }
  7580. }
  7581. declare module "babylonjs/Misc/iInspectable" {
  7582. /**
  7583. * Enum that determines the text-wrapping mode to use.
  7584. */
  7585. export enum InspectableType {
  7586. /**
  7587. * Checkbox for booleans
  7588. */
  7589. Checkbox = 0,
  7590. /**
  7591. * Sliders for numbers
  7592. */
  7593. Slider = 1,
  7594. /**
  7595. * Vector3
  7596. */
  7597. Vector3 = 2,
  7598. /**
  7599. * Quaternions
  7600. */
  7601. Quaternion = 3,
  7602. /**
  7603. * Color3
  7604. */
  7605. Color3 = 4,
  7606. /**
  7607. * String
  7608. */
  7609. String = 5
  7610. }
  7611. /**
  7612. * Interface used to define custom inspectable properties.
  7613. * This interface is used by the inspector to display custom property grids
  7614. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7615. */
  7616. export interface IInspectable {
  7617. /**
  7618. * Gets the label to display
  7619. */
  7620. label: string;
  7621. /**
  7622. * Gets the name of the property to edit
  7623. */
  7624. propertyName: string;
  7625. /**
  7626. * Gets the type of the editor to use
  7627. */
  7628. type: InspectableType;
  7629. /**
  7630. * Gets the minimum value of the property when using in "slider" mode
  7631. */
  7632. min?: number;
  7633. /**
  7634. * Gets the maximum value of the property when using in "slider" mode
  7635. */
  7636. max?: number;
  7637. /**
  7638. * Gets the setp to use when using in "slider" mode
  7639. */
  7640. step?: number;
  7641. }
  7642. }
  7643. declare module "babylonjs/Misc/timingTools" {
  7644. /**
  7645. * Class used to provide helper for timing
  7646. */
  7647. export class TimingTools {
  7648. /**
  7649. * Polyfill for setImmediate
  7650. * @param action defines the action to execute after the current execution block
  7651. */
  7652. static SetImmediate(action: () => void): void;
  7653. }
  7654. }
  7655. declare module "babylonjs/Misc/instantiationTools" {
  7656. /**
  7657. * Class used to enable instatition of objects by class name
  7658. */
  7659. export class InstantiationTools {
  7660. /**
  7661. * Use this object to register external classes like custom textures or material
  7662. * to allow the laoders to instantiate them
  7663. */
  7664. static RegisteredExternalClasses: {
  7665. [key: string]: Object;
  7666. };
  7667. /**
  7668. * Tries to instantiate a new object from a given class name
  7669. * @param className defines the class name to instantiate
  7670. * @returns the new object or null if the system was not able to do the instantiation
  7671. */
  7672. static Instantiate(className: string): any;
  7673. }
  7674. }
  7675. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7676. /**
  7677. * Define options used to create a depth texture
  7678. */
  7679. export class DepthTextureCreationOptions {
  7680. /** Specifies whether or not a stencil should be allocated in the texture */
  7681. generateStencil?: boolean;
  7682. /** Specifies whether or not bilinear filtering is enable on the texture */
  7683. bilinearFiltering?: boolean;
  7684. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7685. comparisonFunction?: number;
  7686. /** Specifies if the created texture is a cube texture */
  7687. isCube?: boolean;
  7688. }
  7689. }
  7690. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7692. import { Nullable } from "babylonjs/types";
  7693. import { Scene } from "babylonjs/scene";
  7694. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7695. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7696. module "babylonjs/Engines/thinEngine" {
  7697. interface ThinEngine {
  7698. /**
  7699. * Creates a depth stencil cube texture.
  7700. * This is only available in WebGL 2.
  7701. * @param size The size of face edge in the cube texture.
  7702. * @param options The options defining the cube texture.
  7703. * @returns The cube texture
  7704. */
  7705. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7706. /**
  7707. * Creates a cube texture
  7708. * @param rootUrl defines the url where the files to load is located
  7709. * @param scene defines the current scene
  7710. * @param files defines the list of files to load (1 per face)
  7711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7712. * @param onLoad defines an optional callback raised when the texture is loaded
  7713. * @param onError defines an optional callback raised if there is an issue to load the texture
  7714. * @param format defines the format of the data
  7715. * @param forcedExtension defines the extension to use to pick the right loader
  7716. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7717. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7718. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7719. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7720. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7721. * @returns the cube texture as an InternalTexture
  7722. */
  7723. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7724. /**
  7725. * Creates a cube texture
  7726. * @param rootUrl defines the url where the files to load is located
  7727. * @param scene defines the current scene
  7728. * @param files defines the list of files to load (1 per face)
  7729. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7730. * @param onLoad defines an optional callback raised when the texture is loaded
  7731. * @param onError defines an optional callback raised if there is an issue to load the texture
  7732. * @param format defines the format of the data
  7733. * @param forcedExtension defines the extension to use to pick the right loader
  7734. * @returns the cube texture as an InternalTexture
  7735. */
  7736. 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;
  7737. /**
  7738. * Creates a cube texture
  7739. * @param rootUrl defines the url where the files to load is located
  7740. * @param scene defines the current scene
  7741. * @param files defines the list of files to load (1 per face)
  7742. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7743. * @param onLoad defines an optional callback raised when the texture is loaded
  7744. * @param onError defines an optional callback raised if there is an issue to load the texture
  7745. * @param format defines the format of the data
  7746. * @param forcedExtension defines the extension to use to pick the right loader
  7747. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7748. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7749. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7750. * @returns the cube texture as an InternalTexture
  7751. */
  7752. 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;
  7753. /** @hidden */
  7754. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7755. /** @hidden */
  7756. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7757. /** @hidden */
  7758. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7759. /** @hidden */
  7760. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7761. /**
  7762. * @hidden
  7763. */
  7764. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7765. }
  7766. }
  7767. }
  7768. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7769. import { Nullable } from "babylonjs/types";
  7770. import { Scene } from "babylonjs/scene";
  7771. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7772. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7773. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7774. /**
  7775. * Class for creating a cube texture
  7776. */
  7777. export class CubeTexture extends BaseTexture {
  7778. private _delayedOnLoad;
  7779. /**
  7780. * The url of the texture
  7781. */
  7782. url: string;
  7783. /**
  7784. * Gets or sets the center of the bounding box associated with the cube texture.
  7785. * It must define where the camera used to render the texture was set
  7786. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7787. */
  7788. boundingBoxPosition: Vector3;
  7789. private _boundingBoxSize;
  7790. /**
  7791. * Gets or sets the size of the bounding box associated with the cube texture
  7792. * When defined, the cubemap will switch to local mode
  7793. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7794. * @example https://www.babylonjs-playground.com/#RNASML
  7795. */
  7796. set boundingBoxSize(value: Vector3);
  7797. /**
  7798. * Returns the bounding box size
  7799. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7800. */
  7801. get boundingBoxSize(): Vector3;
  7802. protected _rotationY: number;
  7803. /**
  7804. * Sets texture matrix rotation angle around Y axis in radians.
  7805. */
  7806. set rotationY(value: number);
  7807. /**
  7808. * Gets texture matrix rotation angle around Y axis radians.
  7809. */
  7810. get rotationY(): number;
  7811. /**
  7812. * Are mip maps generated for this texture or not.
  7813. */
  7814. get noMipmap(): boolean;
  7815. private _noMipmap;
  7816. private _files;
  7817. protected _forcedExtension: Nullable<string>;
  7818. private _extensions;
  7819. private _textureMatrix;
  7820. private _format;
  7821. private _createPolynomials;
  7822. /** @hidden */
  7823. _prefiltered: boolean;
  7824. /**
  7825. * Creates a cube texture from an array of image urls
  7826. * @param files defines an array of image urls
  7827. * @param scene defines the hosting scene
  7828. * @param noMipmap specifies if mip maps are not used
  7829. * @returns a cube texture
  7830. */
  7831. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7832. /**
  7833. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7834. * @param url defines the url of the prefiltered texture
  7835. * @param scene defines the scene the texture is attached to
  7836. * @param forcedExtension defines the extension of the file if different from the url
  7837. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7838. * @return the prefiltered texture
  7839. */
  7840. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7841. /**
  7842. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7843. * as prefiltered data.
  7844. * @param rootUrl defines the url of the texture or the root name of the six images
  7845. * @param scene defines the scene the texture is attached to
  7846. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7847. * @param noMipmap defines if mipmaps should be created or not
  7848. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7849. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7850. * @param onError defines a callback triggered in case of error during load
  7851. * @param format defines the internal format to use for the texture once loaded
  7852. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7853. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7854. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @return the cube texture
  7858. */
  7859. 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);
  7860. /**
  7861. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7862. */
  7863. get isPrefiltered(): boolean;
  7864. /**
  7865. * Get the current class name of the texture useful for serialization or dynamic coding.
  7866. * @returns "CubeTexture"
  7867. */
  7868. getClassName(): string;
  7869. /**
  7870. * Update the url (and optional buffer) of this texture if url was null during construction.
  7871. * @param url the url of the texture
  7872. * @param forcedExtension defines the extension to use
  7873. * @param onLoad callback called when the texture is loaded (defaults to null)
  7874. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7875. */
  7876. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7877. /**
  7878. * Delays loading of the cube texture
  7879. * @param forcedExtension defines the extension to use
  7880. */
  7881. delayLoad(forcedExtension?: string): void;
  7882. /**
  7883. * Returns the reflection texture matrix
  7884. * @returns the reflection texture matrix
  7885. */
  7886. getReflectionTextureMatrix(): Matrix;
  7887. /**
  7888. * Sets the reflection texture matrix
  7889. * @param value Reflection texture matrix
  7890. */
  7891. setReflectionTextureMatrix(value: Matrix): void;
  7892. /**
  7893. * Parses text to create a cube texture
  7894. * @param parsedTexture define the serialized text to read from
  7895. * @param scene defines the hosting scene
  7896. * @param rootUrl defines the root url of the cube texture
  7897. * @returns a cube texture
  7898. */
  7899. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7900. /**
  7901. * Makes a clone, or deep copy, of the cube texture
  7902. * @returns a new cube texture
  7903. */
  7904. clone(): CubeTexture;
  7905. }
  7906. }
  7907. declare module "babylonjs/Materials/materialDefines" {
  7908. /**
  7909. * Manages the defines for the Material
  7910. */
  7911. export class MaterialDefines {
  7912. /** @hidden */
  7913. protected _keys: string[];
  7914. private _isDirty;
  7915. /** @hidden */
  7916. _renderId: number;
  7917. /** @hidden */
  7918. _areLightsDirty: boolean;
  7919. /** @hidden */
  7920. _areLightsDisposed: boolean;
  7921. /** @hidden */
  7922. _areAttributesDirty: boolean;
  7923. /** @hidden */
  7924. _areTexturesDirty: boolean;
  7925. /** @hidden */
  7926. _areFresnelDirty: boolean;
  7927. /** @hidden */
  7928. _areMiscDirty: boolean;
  7929. /** @hidden */
  7930. _areImageProcessingDirty: boolean;
  7931. /** @hidden */
  7932. _normals: boolean;
  7933. /** @hidden */
  7934. _uvs: boolean;
  7935. /** @hidden */
  7936. _needNormals: boolean;
  7937. /** @hidden */
  7938. _needUVs: boolean;
  7939. [id: string]: any;
  7940. /**
  7941. * Specifies if the material needs to be re-calculated
  7942. */
  7943. get isDirty(): boolean;
  7944. /**
  7945. * Marks the material to indicate that it has been re-calculated
  7946. */
  7947. markAsProcessed(): void;
  7948. /**
  7949. * Marks the material to indicate that it needs to be re-calculated
  7950. */
  7951. markAsUnprocessed(): void;
  7952. /**
  7953. * Marks the material to indicate all of its defines need to be re-calculated
  7954. */
  7955. markAllAsDirty(): void;
  7956. /**
  7957. * Marks the material to indicate that image processing needs to be re-calculated
  7958. */
  7959. markAsImageProcessingDirty(): void;
  7960. /**
  7961. * Marks the material to indicate the lights need to be re-calculated
  7962. * @param disposed Defines whether the light is dirty due to dispose or not
  7963. */
  7964. markAsLightDirty(disposed?: boolean): void;
  7965. /**
  7966. * Marks the attribute state as changed
  7967. */
  7968. markAsAttributesDirty(): void;
  7969. /**
  7970. * Marks the texture state as changed
  7971. */
  7972. markAsTexturesDirty(): void;
  7973. /**
  7974. * Marks the fresnel state as changed
  7975. */
  7976. markAsFresnelDirty(): void;
  7977. /**
  7978. * Marks the misc state as changed
  7979. */
  7980. markAsMiscDirty(): void;
  7981. /**
  7982. * Rebuilds the material defines
  7983. */
  7984. rebuild(): void;
  7985. /**
  7986. * Specifies if two material defines are equal
  7987. * @param other - A material define instance to compare to
  7988. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7989. */
  7990. isEqual(other: MaterialDefines): boolean;
  7991. /**
  7992. * Clones this instance's defines to another instance
  7993. * @param other - material defines to clone values to
  7994. */
  7995. cloneTo(other: MaterialDefines): void;
  7996. /**
  7997. * Resets the material define values
  7998. */
  7999. reset(): void;
  8000. /**
  8001. * Converts the material define values to a string
  8002. * @returns - String of material define information
  8003. */
  8004. toString(): string;
  8005. }
  8006. }
  8007. declare module "babylonjs/Materials/colorCurves" {
  8008. import { Effect } from "babylonjs/Materials/effect";
  8009. /**
  8010. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8011. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8012. * 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;
  8013. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8014. */
  8015. export class ColorCurves {
  8016. private _dirty;
  8017. private _tempColor;
  8018. private _globalCurve;
  8019. private _highlightsCurve;
  8020. private _midtonesCurve;
  8021. private _shadowsCurve;
  8022. private _positiveCurve;
  8023. private _negativeCurve;
  8024. private _globalHue;
  8025. private _globalDensity;
  8026. private _globalSaturation;
  8027. private _globalExposure;
  8028. /**
  8029. * Gets the global Hue value.
  8030. * 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).
  8031. */
  8032. get globalHue(): number;
  8033. /**
  8034. * Sets the global Hue value.
  8035. * 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).
  8036. */
  8037. set globalHue(value: number);
  8038. /**
  8039. * Gets the global Density value.
  8040. * 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.
  8041. * Values less than zero provide a filter of opposite hue.
  8042. */
  8043. get globalDensity(): number;
  8044. /**
  8045. * Sets the global Density value.
  8046. * 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.
  8047. * Values less than zero provide a filter of opposite hue.
  8048. */
  8049. set globalDensity(value: number);
  8050. /**
  8051. * Gets the global Saturation value.
  8052. * 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.
  8053. */
  8054. get globalSaturation(): number;
  8055. /**
  8056. * Sets the global Saturation value.
  8057. * 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.
  8058. */
  8059. set globalSaturation(value: number);
  8060. /**
  8061. * Gets the global Exposure value.
  8062. * 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.
  8063. */
  8064. get globalExposure(): number;
  8065. /**
  8066. * Sets the global Exposure value.
  8067. * 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.
  8068. */
  8069. set globalExposure(value: number);
  8070. private _highlightsHue;
  8071. private _highlightsDensity;
  8072. private _highlightsSaturation;
  8073. private _highlightsExposure;
  8074. /**
  8075. * Gets the highlights Hue value.
  8076. * 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).
  8077. */
  8078. get highlightsHue(): number;
  8079. /**
  8080. * Sets the highlights Hue value.
  8081. * 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).
  8082. */
  8083. set highlightsHue(value: number);
  8084. /**
  8085. * Gets the highlights Density value.
  8086. * 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.
  8087. * Values less than zero provide a filter of opposite hue.
  8088. */
  8089. get highlightsDensity(): number;
  8090. /**
  8091. * Sets the highlights Density value.
  8092. * 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.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. set highlightsDensity(value: number);
  8096. /**
  8097. * Gets the highlights Saturation value.
  8098. * 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.
  8099. */
  8100. get highlightsSaturation(): number;
  8101. /**
  8102. * Sets the highlights Saturation value.
  8103. * 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.
  8104. */
  8105. set highlightsSaturation(value: number);
  8106. /**
  8107. * Gets the highlights Exposure value.
  8108. * 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.
  8109. */
  8110. get highlightsExposure(): number;
  8111. /**
  8112. * Sets the highlights Exposure value.
  8113. * 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.
  8114. */
  8115. set highlightsExposure(value: number);
  8116. private _midtonesHue;
  8117. private _midtonesDensity;
  8118. private _midtonesSaturation;
  8119. private _midtonesExposure;
  8120. /**
  8121. * Gets the midtones Hue value.
  8122. * 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).
  8123. */
  8124. get midtonesHue(): number;
  8125. /**
  8126. * Sets the midtones Hue value.
  8127. * 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).
  8128. */
  8129. set midtonesHue(value: number);
  8130. /**
  8131. * Gets the midtones Density value.
  8132. * 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.
  8133. * Values less than zero provide a filter of opposite hue.
  8134. */
  8135. get midtonesDensity(): number;
  8136. /**
  8137. * Sets the midtones Density value.
  8138. * 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.
  8139. * Values less than zero provide a filter of opposite hue.
  8140. */
  8141. set midtonesDensity(value: number);
  8142. /**
  8143. * Gets the midtones Saturation value.
  8144. * 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.
  8145. */
  8146. get midtonesSaturation(): number;
  8147. /**
  8148. * Sets the midtones Saturation value.
  8149. * 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.
  8150. */
  8151. set midtonesSaturation(value: number);
  8152. /**
  8153. * Gets the midtones Exposure value.
  8154. * 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.
  8155. */
  8156. get midtonesExposure(): number;
  8157. /**
  8158. * Sets the midtones Exposure value.
  8159. * 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.
  8160. */
  8161. set midtonesExposure(value: number);
  8162. private _shadowsHue;
  8163. private _shadowsDensity;
  8164. private _shadowsSaturation;
  8165. private _shadowsExposure;
  8166. /**
  8167. * Gets the shadows Hue value.
  8168. * 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).
  8169. */
  8170. get shadowsHue(): number;
  8171. /**
  8172. * Sets the shadows Hue value.
  8173. * 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).
  8174. */
  8175. set shadowsHue(value: number);
  8176. /**
  8177. * Gets the shadows Density value.
  8178. * 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.
  8179. * Values less than zero provide a filter of opposite hue.
  8180. */
  8181. get shadowsDensity(): number;
  8182. /**
  8183. * Sets the shadows Density value.
  8184. * 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.
  8185. * Values less than zero provide a filter of opposite hue.
  8186. */
  8187. set shadowsDensity(value: number);
  8188. /**
  8189. * Gets the shadows Saturation value.
  8190. * 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.
  8191. */
  8192. get shadowsSaturation(): number;
  8193. /**
  8194. * Sets the shadows Saturation value.
  8195. * 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.
  8196. */
  8197. set shadowsSaturation(value: number);
  8198. /**
  8199. * Gets the shadows Exposure value.
  8200. * 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.
  8201. */
  8202. get shadowsExposure(): number;
  8203. /**
  8204. * Sets the shadows Exposure value.
  8205. * 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.
  8206. */
  8207. set shadowsExposure(value: number);
  8208. /**
  8209. * Returns the class name
  8210. * @returns The class name
  8211. */
  8212. getClassName(): string;
  8213. /**
  8214. * Binds the color curves to the shader.
  8215. * @param colorCurves The color curve to bind
  8216. * @param effect The effect to bind to
  8217. * @param positiveUniform The positive uniform shader parameter
  8218. * @param neutralUniform The neutral uniform shader parameter
  8219. * @param negativeUniform The negative uniform shader parameter
  8220. */
  8221. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8222. /**
  8223. * Prepare the list of uniforms associated with the ColorCurves effects.
  8224. * @param uniformsList The list of uniforms used in the effect
  8225. */
  8226. static PrepareUniforms(uniformsList: string[]): void;
  8227. /**
  8228. * Returns color grading data based on a hue, density, saturation and exposure value.
  8229. * @param filterHue The hue of the color filter.
  8230. * @param filterDensity The density of the color filter.
  8231. * @param saturation The saturation.
  8232. * @param exposure The exposure.
  8233. * @param result The result data container.
  8234. */
  8235. private getColorGradingDataToRef;
  8236. /**
  8237. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8238. * @param value The input slider value in range [-100,100].
  8239. * @returns Adjusted value.
  8240. */
  8241. private static applyColorGradingSliderNonlinear;
  8242. /**
  8243. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8244. * @param hue The hue (H) input.
  8245. * @param saturation The saturation (S) input.
  8246. * @param brightness The brightness (B) input.
  8247. * @result An RGBA color represented as Vector4.
  8248. */
  8249. private static fromHSBToRef;
  8250. /**
  8251. * Returns a value clamped between min and max
  8252. * @param value The value to clamp
  8253. * @param min The minimum of value
  8254. * @param max The maximum of value
  8255. * @returns The clamped value.
  8256. */
  8257. private static clamp;
  8258. /**
  8259. * Clones the current color curve instance.
  8260. * @return The cloned curves
  8261. */
  8262. clone(): ColorCurves;
  8263. /**
  8264. * Serializes the current color curve instance to a json representation.
  8265. * @return a JSON representation
  8266. */
  8267. serialize(): any;
  8268. /**
  8269. * Parses the color curve from a json representation.
  8270. * @param source the JSON source to parse
  8271. * @return The parsed curves
  8272. */
  8273. static Parse(source: any): ColorCurves;
  8274. }
  8275. }
  8276. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8277. import { Observable } from "babylonjs/Misc/observable";
  8278. import { Nullable } from "babylonjs/types";
  8279. import { Color4 } from "babylonjs/Maths/math.color";
  8280. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8281. import { Effect } from "babylonjs/Materials/effect";
  8282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8283. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8284. /**
  8285. * Interface to follow in your material defines to integrate easily the
  8286. * Image proccessing functions.
  8287. * @hidden
  8288. */
  8289. export interface IImageProcessingConfigurationDefines {
  8290. IMAGEPROCESSING: boolean;
  8291. VIGNETTE: boolean;
  8292. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8293. VIGNETTEBLENDMODEOPAQUE: boolean;
  8294. TONEMAPPING: boolean;
  8295. TONEMAPPING_ACES: boolean;
  8296. CONTRAST: boolean;
  8297. EXPOSURE: boolean;
  8298. COLORCURVES: boolean;
  8299. COLORGRADING: boolean;
  8300. COLORGRADING3D: boolean;
  8301. SAMPLER3DGREENDEPTH: boolean;
  8302. SAMPLER3DBGRMAP: boolean;
  8303. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8304. }
  8305. /**
  8306. * @hidden
  8307. */
  8308. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8309. IMAGEPROCESSING: boolean;
  8310. VIGNETTE: boolean;
  8311. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8312. VIGNETTEBLENDMODEOPAQUE: boolean;
  8313. TONEMAPPING: boolean;
  8314. TONEMAPPING_ACES: boolean;
  8315. CONTRAST: boolean;
  8316. COLORCURVES: boolean;
  8317. COLORGRADING: boolean;
  8318. COLORGRADING3D: boolean;
  8319. SAMPLER3DGREENDEPTH: boolean;
  8320. SAMPLER3DBGRMAP: boolean;
  8321. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8322. EXPOSURE: boolean;
  8323. constructor();
  8324. }
  8325. /**
  8326. * This groups together the common properties used for image processing either in direct forward pass
  8327. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8328. * or not.
  8329. */
  8330. export class ImageProcessingConfiguration {
  8331. /**
  8332. * Default tone mapping applied in BabylonJS.
  8333. */
  8334. static readonly TONEMAPPING_STANDARD: number;
  8335. /**
  8336. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8337. * to other engines rendering to increase portability.
  8338. */
  8339. static readonly TONEMAPPING_ACES: number;
  8340. /**
  8341. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8342. */
  8343. colorCurves: Nullable<ColorCurves>;
  8344. private _colorCurvesEnabled;
  8345. /**
  8346. * Gets wether the color curves effect is enabled.
  8347. */
  8348. get colorCurvesEnabled(): boolean;
  8349. /**
  8350. * Sets wether the color curves effect is enabled.
  8351. */
  8352. set colorCurvesEnabled(value: boolean);
  8353. private _colorGradingTexture;
  8354. /**
  8355. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8356. */
  8357. get colorGradingTexture(): Nullable<BaseTexture>;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. set colorGradingTexture(value: Nullable<BaseTexture>);
  8362. private _colorGradingEnabled;
  8363. /**
  8364. * Gets wether the color grading effect is enabled.
  8365. */
  8366. get colorGradingEnabled(): boolean;
  8367. /**
  8368. * Sets wether the color grading effect is enabled.
  8369. */
  8370. set colorGradingEnabled(value: boolean);
  8371. private _colorGradingWithGreenDepth;
  8372. /**
  8373. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8374. */
  8375. get colorGradingWithGreenDepth(): boolean;
  8376. /**
  8377. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. set colorGradingWithGreenDepth(value: boolean);
  8380. private _colorGradingBGR;
  8381. /**
  8382. * Gets wether the color grading texture contains BGR values.
  8383. */
  8384. get colorGradingBGR(): boolean;
  8385. /**
  8386. * Sets wether the color grading texture contains BGR values.
  8387. */
  8388. set colorGradingBGR(value: boolean);
  8389. /** @hidden */
  8390. _exposure: number;
  8391. /**
  8392. * Gets the Exposure used in the effect.
  8393. */
  8394. get exposure(): number;
  8395. /**
  8396. * Sets the Exposure used in the effect.
  8397. */
  8398. set exposure(value: number);
  8399. private _toneMappingEnabled;
  8400. /**
  8401. * Gets wether the tone mapping effect is enabled.
  8402. */
  8403. get toneMappingEnabled(): boolean;
  8404. /**
  8405. * Sets wether the tone mapping effect is enabled.
  8406. */
  8407. set toneMappingEnabled(value: boolean);
  8408. private _toneMappingType;
  8409. /**
  8410. * Gets the type of tone mapping effect.
  8411. */
  8412. get toneMappingType(): number;
  8413. /**
  8414. * Sets the type of tone mapping effect used in BabylonJS.
  8415. */
  8416. set toneMappingType(value: number);
  8417. protected _contrast: number;
  8418. /**
  8419. * Gets the contrast used in the effect.
  8420. */
  8421. get contrast(): number;
  8422. /**
  8423. * Sets the contrast used in the effect.
  8424. */
  8425. set contrast(value: number);
  8426. /**
  8427. * Vignette stretch size.
  8428. */
  8429. vignetteStretch: number;
  8430. /**
  8431. * Vignette centre X Offset.
  8432. */
  8433. vignetteCentreX: number;
  8434. /**
  8435. * Vignette centre Y Offset.
  8436. */
  8437. vignetteCentreY: number;
  8438. /**
  8439. * Vignette weight or intensity of the vignette effect.
  8440. */
  8441. vignetteWeight: number;
  8442. /**
  8443. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8444. * if vignetteEnabled is set to true.
  8445. */
  8446. vignetteColor: Color4;
  8447. /**
  8448. * Camera field of view used by the Vignette effect.
  8449. */
  8450. vignetteCameraFov: number;
  8451. private _vignetteBlendMode;
  8452. /**
  8453. * Gets the vignette blend mode allowing different kind of effect.
  8454. */
  8455. get vignetteBlendMode(): number;
  8456. /**
  8457. * Sets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. set vignetteBlendMode(value: number);
  8460. private _vignetteEnabled;
  8461. /**
  8462. * Gets wether the vignette effect is enabled.
  8463. */
  8464. get vignetteEnabled(): boolean;
  8465. /**
  8466. * Sets wether the vignette effect is enabled.
  8467. */
  8468. set vignetteEnabled(value: boolean);
  8469. private _applyByPostProcess;
  8470. /**
  8471. * Gets wether the image processing is applied through a post process or not.
  8472. */
  8473. get applyByPostProcess(): boolean;
  8474. /**
  8475. * Sets wether the image processing is applied through a post process or not.
  8476. */
  8477. set applyByPostProcess(value: boolean);
  8478. private _isEnabled;
  8479. /**
  8480. * Gets wether the image processing is enabled or not.
  8481. */
  8482. get isEnabled(): boolean;
  8483. /**
  8484. * Sets wether the image processing is enabled or not.
  8485. */
  8486. set isEnabled(value: boolean);
  8487. /**
  8488. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8489. */
  8490. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8491. /**
  8492. * Method called each time the image processing information changes requires to recompile the effect.
  8493. */
  8494. protected _updateParameters(): void;
  8495. /**
  8496. * Gets the current class name.
  8497. * @return "ImageProcessingConfiguration"
  8498. */
  8499. getClassName(): string;
  8500. /**
  8501. * Prepare the list of uniforms associated with the Image Processing effects.
  8502. * @param uniforms The list of uniforms used in the effect
  8503. * @param defines the list of defines currently in use
  8504. */
  8505. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8506. /**
  8507. * Prepare the list of samplers associated with the Image Processing effects.
  8508. * @param samplersList The list of uniforms used in the effect
  8509. * @param defines the list of defines currently in use
  8510. */
  8511. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8512. /**
  8513. * Prepare the list of defines associated to the shader.
  8514. * @param defines the list of defines to complete
  8515. * @param forPostProcess Define if we are currently in post process mode or not
  8516. */
  8517. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8518. /**
  8519. * Returns true if all the image processing information are ready.
  8520. * @returns True if ready, otherwise, false
  8521. */
  8522. isReady(): boolean;
  8523. /**
  8524. * Binds the image processing to the shader.
  8525. * @param effect The effect to bind to
  8526. * @param overrideAspectRatio Override the aspect ratio of the effect
  8527. */
  8528. bind(effect: Effect, overrideAspectRatio?: number): void;
  8529. /**
  8530. * Clones the current image processing instance.
  8531. * @return The cloned image processing
  8532. */
  8533. clone(): ImageProcessingConfiguration;
  8534. /**
  8535. * Serializes the current image processing instance to a json representation.
  8536. * @return a JSON representation
  8537. */
  8538. serialize(): any;
  8539. /**
  8540. * Parses the image processing from a json representation.
  8541. * @param source the JSON source to parse
  8542. * @return The parsed image processing
  8543. */
  8544. static Parse(source: any): ImageProcessingConfiguration;
  8545. private static _VIGNETTEMODE_MULTIPLY;
  8546. private static _VIGNETTEMODE_OPAQUE;
  8547. /**
  8548. * Used to apply the vignette as a mix with the pixel color.
  8549. */
  8550. static get VIGNETTEMODE_MULTIPLY(): number;
  8551. /**
  8552. * Used to apply the vignette as a replacement of the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_OPAQUE(): number;
  8555. }
  8556. }
  8557. declare module "babylonjs/Shaders/postprocess.vertex" {
  8558. /** @hidden */
  8559. export var postprocessVertexShader: {
  8560. name: string;
  8561. shader: string;
  8562. };
  8563. }
  8564. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8566. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8567. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8568. module "babylonjs/Engines/thinEngine" {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. }
  8602. declare module "babylonjs/Maths/math.axis" {
  8603. import { Vector3 } from "babylonjs/Maths/math.vector";
  8604. /** Defines supported spaces */
  8605. export enum Space {
  8606. /** Local (object) space */
  8607. LOCAL = 0,
  8608. /** World space */
  8609. WORLD = 1,
  8610. /** Bone space */
  8611. BONE = 2
  8612. }
  8613. /** Defines the 3 main axes */
  8614. export class Axis {
  8615. /** X axis */
  8616. static X: Vector3;
  8617. /** Y axis */
  8618. static Y: Vector3;
  8619. /** Z axis */
  8620. static Z: Vector3;
  8621. }
  8622. }
  8623. declare module "babylonjs/Cameras/targetCamera" {
  8624. import { Nullable } from "babylonjs/types";
  8625. import { Camera } from "babylonjs/Cameras/camera";
  8626. import { Scene } from "babylonjs/scene";
  8627. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8628. /**
  8629. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8630. * This is the base of the follow, arc rotate cameras and Free camera
  8631. * @see http://doc.babylonjs.com/features/cameras
  8632. */
  8633. export class TargetCamera extends Camera {
  8634. private static _RigCamTransformMatrix;
  8635. private static _TargetTransformMatrix;
  8636. private static _TargetFocalPoint;
  8637. /**
  8638. * Define the current direction the camera is moving to
  8639. */
  8640. cameraDirection: Vector3;
  8641. /**
  8642. * Define the current rotation the camera is rotating to
  8643. */
  8644. cameraRotation: Vector2;
  8645. /**
  8646. * When set, the up vector of the camera will be updated by the rotation of the camera
  8647. */
  8648. updateUpVectorFromRotation: boolean;
  8649. private _tmpQuaternion;
  8650. /**
  8651. * Define the current rotation of the camera
  8652. */
  8653. rotation: Vector3;
  8654. /**
  8655. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8656. */
  8657. rotationQuaternion: Quaternion;
  8658. /**
  8659. * Define the current speed of the camera
  8660. */
  8661. speed: number;
  8662. /**
  8663. * Add constraint to the camera to prevent it to move freely in all directions and
  8664. * around all axis.
  8665. */
  8666. noRotationConstraint: boolean;
  8667. /**
  8668. * Define the current target of the camera as an object or a position.
  8669. */
  8670. lockedTarget: any;
  8671. /** @hidden */
  8672. _currentTarget: Vector3;
  8673. /** @hidden */
  8674. _initialFocalDistance: number;
  8675. /** @hidden */
  8676. _viewMatrix: Matrix;
  8677. /** @hidden */
  8678. _camMatrix: Matrix;
  8679. /** @hidden */
  8680. _cameraTransformMatrix: Matrix;
  8681. /** @hidden */
  8682. _cameraRotationMatrix: Matrix;
  8683. /** @hidden */
  8684. _referencePoint: Vector3;
  8685. /** @hidden */
  8686. _transformedReferencePoint: Vector3;
  8687. protected _globalCurrentTarget: Vector3;
  8688. protected _globalCurrentUpVector: Vector3;
  8689. /** @hidden */
  8690. _reset: () => void;
  8691. private _defaultUp;
  8692. /**
  8693. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8694. * This is the base of the follow, arc rotate cameras and Free camera
  8695. * @see http://doc.babylonjs.com/features/cameras
  8696. * @param name Defines the name of the camera in the scene
  8697. * @param position Defines the start position of the camera in the scene
  8698. * @param scene Defines the scene the camera belongs to
  8699. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8700. */
  8701. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8702. /**
  8703. * Gets the position in front of the camera at a given distance.
  8704. * @param distance The distance from the camera we want the position to be
  8705. * @returns the position
  8706. */
  8707. getFrontPosition(distance: number): Vector3;
  8708. /** @hidden */
  8709. _getLockedTargetPosition(): Nullable<Vector3>;
  8710. private _storedPosition;
  8711. private _storedRotation;
  8712. private _storedRotationQuaternion;
  8713. /**
  8714. * Store current camera state of the camera (fov, position, rotation, etc..)
  8715. * @returns the camera
  8716. */
  8717. storeState(): Camera;
  8718. /**
  8719. * Restored camera state. You must call storeState() first
  8720. * @returns whether it was successful or not
  8721. * @hidden
  8722. */
  8723. _restoreStateValues(): boolean;
  8724. /** @hidden */
  8725. _initCache(): void;
  8726. /** @hidden */
  8727. _updateCache(ignoreParentClass?: boolean): void;
  8728. /** @hidden */
  8729. _isSynchronizedViewMatrix(): boolean;
  8730. /** @hidden */
  8731. _computeLocalCameraSpeed(): number;
  8732. /**
  8733. * Defines the target the camera should look at.
  8734. * @param target Defines the new target as a Vector or a mesh
  8735. */
  8736. setTarget(target: Vector3): void;
  8737. /**
  8738. * Return the current target position of the camera. This value is expressed in local space.
  8739. * @returns the target position
  8740. */
  8741. getTarget(): Vector3;
  8742. /** @hidden */
  8743. _decideIfNeedsToMove(): boolean;
  8744. /** @hidden */
  8745. _updatePosition(): void;
  8746. /** @hidden */
  8747. _checkInputs(): void;
  8748. protected _updateCameraRotationMatrix(): void;
  8749. /**
  8750. * 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)
  8751. * @returns the current camera
  8752. */
  8753. private _rotateUpVectorWithCameraRotationMatrix;
  8754. private _cachedRotationZ;
  8755. private _cachedQuaternionRotationZ;
  8756. /** @hidden */
  8757. _getViewMatrix(): Matrix;
  8758. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8759. /**
  8760. * @hidden
  8761. */
  8762. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8763. /**
  8764. * @hidden
  8765. */
  8766. _updateRigCameras(): void;
  8767. private _getRigCamPositionAndTarget;
  8768. /**
  8769. * Gets the current object class name.
  8770. * @return the class name
  8771. */
  8772. getClassName(): string;
  8773. }
  8774. }
  8775. declare module "babylonjs/Events/keyboardEvents" {
  8776. /**
  8777. * Gather the list of keyboard event types as constants.
  8778. */
  8779. export class KeyboardEventTypes {
  8780. /**
  8781. * The keydown event is fired when a key becomes active (pressed).
  8782. */
  8783. static readonly KEYDOWN: number;
  8784. /**
  8785. * The keyup event is fired when a key has been released.
  8786. */
  8787. static readonly KEYUP: number;
  8788. }
  8789. /**
  8790. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8791. */
  8792. export class KeyboardInfo {
  8793. /**
  8794. * Defines the type of event (KeyboardEventTypes)
  8795. */
  8796. type: number;
  8797. /**
  8798. * Defines the related dom event
  8799. */
  8800. event: KeyboardEvent;
  8801. /**
  8802. * Instantiates a new keyboard info.
  8803. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8804. * @param type Defines the type of event (KeyboardEventTypes)
  8805. * @param event Defines the related dom event
  8806. */
  8807. constructor(
  8808. /**
  8809. * Defines the type of event (KeyboardEventTypes)
  8810. */
  8811. type: number,
  8812. /**
  8813. * Defines the related dom event
  8814. */
  8815. event: KeyboardEvent);
  8816. }
  8817. /**
  8818. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8819. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8820. */
  8821. export class KeyboardInfoPre extends KeyboardInfo {
  8822. /**
  8823. * Defines the type of event (KeyboardEventTypes)
  8824. */
  8825. type: number;
  8826. /**
  8827. * Defines the related dom event
  8828. */
  8829. event: KeyboardEvent;
  8830. /**
  8831. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8832. */
  8833. skipOnPointerObservable: boolean;
  8834. /**
  8835. * Instantiates a new keyboard pre info.
  8836. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8837. * @param type Defines the type of event (KeyboardEventTypes)
  8838. * @param event Defines the related dom event
  8839. */
  8840. constructor(
  8841. /**
  8842. * Defines the type of event (KeyboardEventTypes)
  8843. */
  8844. type: number,
  8845. /**
  8846. * Defines the related dom event
  8847. */
  8848. event: KeyboardEvent);
  8849. }
  8850. }
  8851. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8852. import { Nullable } from "babylonjs/types";
  8853. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8854. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8855. /**
  8856. * Manage the keyboard inputs to control the movement of a free camera.
  8857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8858. */
  8859. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8860. /**
  8861. * Defines the camera the input is attached to.
  8862. */
  8863. camera: FreeCamera;
  8864. /**
  8865. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8866. */
  8867. keysUp: number[];
  8868. /**
  8869. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8870. */
  8871. keysDown: number[];
  8872. /**
  8873. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8874. */
  8875. keysLeft: number[];
  8876. /**
  8877. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8878. */
  8879. keysRight: number[];
  8880. private _keys;
  8881. private _onCanvasBlurObserver;
  8882. private _onKeyboardObserver;
  8883. private _engine;
  8884. private _scene;
  8885. /**
  8886. * Attach the input controls to a specific dom element to get the input from.
  8887. * @param element Defines the element the controls should be listened from
  8888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8889. */
  8890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8891. /**
  8892. * Detach the current controls from the specified dom element.
  8893. * @param element Defines the element to stop listening the inputs from
  8894. */
  8895. detachControl(element: Nullable<HTMLElement>): void;
  8896. /**
  8897. * Update the current camera state depending on the inputs that have been used this frame.
  8898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8899. */
  8900. checkInputs(): void;
  8901. /**
  8902. * Gets the class name of the current intput.
  8903. * @returns the class name
  8904. */
  8905. getClassName(): string;
  8906. /** @hidden */
  8907. _onLostFocus(): void;
  8908. /**
  8909. * Get the friendly name associated with the input class.
  8910. * @returns the input friendly name
  8911. */
  8912. getSimpleName(): string;
  8913. }
  8914. }
  8915. declare module "babylonjs/Lights/shadowLight" {
  8916. import { Camera } from "babylonjs/Cameras/camera";
  8917. import { Scene } from "babylonjs/scene";
  8918. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8920. import { Light } from "babylonjs/Lights/light";
  8921. /**
  8922. * Interface describing all the common properties and methods a shadow light needs to implement.
  8923. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8924. * as well as binding the different shadow properties to the effects.
  8925. */
  8926. export interface IShadowLight extends Light {
  8927. /**
  8928. * The light id in the scene (used in scene.findLighById for instance)
  8929. */
  8930. id: string;
  8931. /**
  8932. * The position the shdow will be casted from.
  8933. */
  8934. position: Vector3;
  8935. /**
  8936. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8937. */
  8938. direction: Vector3;
  8939. /**
  8940. * The transformed position. Position of the light in world space taking parenting in account.
  8941. */
  8942. transformedPosition: Vector3;
  8943. /**
  8944. * The transformed direction. Direction of the light in world space taking parenting in account.
  8945. */
  8946. transformedDirection: Vector3;
  8947. /**
  8948. * The friendly name of the light in the scene.
  8949. */
  8950. name: string;
  8951. /**
  8952. * Defines the shadow projection clipping minimum z value.
  8953. */
  8954. shadowMinZ: number;
  8955. /**
  8956. * Defines the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8961. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8962. */
  8963. computeTransformedInformation(): boolean;
  8964. /**
  8965. * Gets the scene the light belongs to.
  8966. * @returns The scene
  8967. */
  8968. getScene(): Scene;
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8976. * @param matrix The materix to updated with the projection information
  8977. * @param viewMatrix The transform matrix of the light
  8978. * @param renderList The list of mesh to render in the map
  8979. * @returns The current light
  8980. */
  8981. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8982. /**
  8983. * Gets the current depth scale used in ESM.
  8984. * @returns The scale
  8985. */
  8986. getDepthScale(): number;
  8987. /**
  8988. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8989. * @returns true if a cube texture needs to be use
  8990. */
  8991. needCube(): boolean;
  8992. /**
  8993. * Detects if the projection matrix requires to be recomputed this frame.
  8994. * @returns true if it requires to be recomputed otherwise, false.
  8995. */
  8996. needProjectionMatrixCompute(): boolean;
  8997. /**
  8998. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8999. */
  9000. forceProjectionMatrixCompute(): void;
  9001. /**
  9002. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9003. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9004. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9005. */
  9006. getShadowDirection(faceIndex?: number): Vector3;
  9007. /**
  9008. * Gets the minZ used for shadow according to both the scene and the light.
  9009. * @param activeCamera The camera we are returning the min for
  9010. * @returns the depth min z
  9011. */
  9012. getDepthMinZ(activeCamera: Camera): number;
  9013. /**
  9014. * Gets the maxZ used for shadow according to both the scene and the light.
  9015. * @param activeCamera The camera we are returning the max for
  9016. * @returns the depth max z
  9017. */
  9018. getDepthMaxZ(activeCamera: Camera): number;
  9019. }
  9020. /**
  9021. * Base implementation IShadowLight
  9022. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9023. */
  9024. export abstract class ShadowLight extends Light implements IShadowLight {
  9025. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9026. protected _position: Vector3;
  9027. protected _setPosition(value: Vector3): void;
  9028. /**
  9029. * Sets the position the shadow will be casted from. Also use as the light position for both
  9030. * point and spot lights.
  9031. */
  9032. get position(): Vector3;
  9033. /**
  9034. * Sets the position the shadow will be casted from. Also use as the light position for both
  9035. * point and spot lights.
  9036. */
  9037. set position(value: Vector3);
  9038. protected _direction: Vector3;
  9039. protected _setDirection(value: Vector3): void;
  9040. /**
  9041. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9042. * Also use as the light direction on spot and directional lights.
  9043. */
  9044. get direction(): Vector3;
  9045. /**
  9046. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9047. * Also use as the light direction on spot and directional lights.
  9048. */
  9049. set direction(value: Vector3);
  9050. protected _shadowMinZ: number;
  9051. /**
  9052. * Gets the shadow projection clipping minimum z value.
  9053. */
  9054. get shadowMinZ(): number;
  9055. /**
  9056. * Sets the shadow projection clipping minimum z value.
  9057. */
  9058. set shadowMinZ(value: number);
  9059. protected _shadowMaxZ: number;
  9060. /**
  9061. * Sets the shadow projection clipping maximum z value.
  9062. */
  9063. get shadowMaxZ(): number;
  9064. /**
  9065. * Gets the shadow projection clipping maximum z value.
  9066. */
  9067. set shadowMaxZ(value: number);
  9068. /**
  9069. * Callback defining a custom Projection Matrix Builder.
  9070. * This can be used to override the default projection matrix computation.
  9071. */
  9072. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9073. /**
  9074. * The transformed position. Position of the light in world space taking parenting in account.
  9075. */
  9076. transformedPosition: Vector3;
  9077. /**
  9078. * The transformed direction. Direction of the light in world space taking parenting in account.
  9079. */
  9080. transformedDirection: Vector3;
  9081. private _needProjectionMatrixCompute;
  9082. /**
  9083. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9084. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9085. */
  9086. computeTransformedInformation(): boolean;
  9087. /**
  9088. * Return the depth scale used for the shadow map.
  9089. * @returns the depth scale.
  9090. */
  9091. getDepthScale(): number;
  9092. /**
  9093. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9094. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9095. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9096. */
  9097. getShadowDirection(faceIndex?: number): Vector3;
  9098. /**
  9099. * Returns the ShadowLight absolute position in the World.
  9100. * @returns the position vector in world space
  9101. */
  9102. getAbsolutePosition(): Vector3;
  9103. /**
  9104. * Sets the ShadowLight direction toward the passed target.
  9105. * @param target The point to target in local space
  9106. * @returns the updated ShadowLight direction
  9107. */
  9108. setDirectionToTarget(target: Vector3): Vector3;
  9109. /**
  9110. * Returns the light rotation in euler definition.
  9111. * @returns the x y z rotation in local space.
  9112. */
  9113. getRotation(): Vector3;
  9114. /**
  9115. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9116. * @returns true if a cube texture needs to be use
  9117. */
  9118. needCube(): boolean;
  9119. /**
  9120. * Detects if the projection matrix requires to be recomputed this frame.
  9121. * @returns true if it requires to be recomputed otherwise, false.
  9122. */
  9123. needProjectionMatrixCompute(): boolean;
  9124. /**
  9125. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9126. */
  9127. forceProjectionMatrixCompute(): void;
  9128. /** @hidden */
  9129. _initCache(): void;
  9130. /** @hidden */
  9131. _isSynchronized(): boolean;
  9132. /**
  9133. * Computes the world matrix of the node
  9134. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9135. * @returns the world matrix
  9136. */
  9137. computeWorldMatrix(force?: boolean): Matrix;
  9138. /**
  9139. * Gets the minZ used for shadow according to both the scene and the light.
  9140. * @param activeCamera The camera we are returning the min for
  9141. * @returns the depth min z
  9142. */
  9143. getDepthMinZ(activeCamera: Camera): number;
  9144. /**
  9145. * Gets the maxZ used for shadow according to both the scene and the light.
  9146. * @param activeCamera The camera we are returning the max for
  9147. * @returns the depth max z
  9148. */
  9149. getDepthMaxZ(activeCamera: Camera): number;
  9150. /**
  9151. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9152. * @param matrix The materix to updated with the projection information
  9153. * @param viewMatrix The transform matrix of the light
  9154. * @param renderList The list of mesh to render in the map
  9155. * @returns The current light
  9156. */
  9157. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9158. }
  9159. }
  9160. declare module "babylonjs/Materials/effectFallbacks" {
  9161. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9162. import { Effect } from "babylonjs/Materials/effect";
  9163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9164. /**
  9165. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9166. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9167. */
  9168. export class EffectFallbacks implements IEffectFallbacks {
  9169. private _defines;
  9170. private _currentRank;
  9171. private _maxRank;
  9172. private _mesh;
  9173. /**
  9174. * Removes the fallback from the bound mesh.
  9175. */
  9176. unBindMesh(): void;
  9177. /**
  9178. * Adds a fallback on the specified property.
  9179. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9180. * @param define The name of the define in the shader
  9181. */
  9182. addFallback(rank: number, define: string): void;
  9183. /**
  9184. * Sets the mesh to use CPU skinning when needing to fallback.
  9185. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9186. * @param mesh The mesh to use the fallbacks.
  9187. */
  9188. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9189. /**
  9190. * Checks to see if more fallbacks are still availible.
  9191. */
  9192. get hasMoreFallbacks(): boolean;
  9193. /**
  9194. * Removes the defines that should be removed when falling back.
  9195. * @param currentDefines defines the current define statements for the shader.
  9196. * @param effect defines the current effect we try to compile
  9197. * @returns The resulting defines with defines of the current rank removed.
  9198. */
  9199. reduce(currentDefines: string, effect: Effect): string;
  9200. }
  9201. }
  9202. declare module "babylonjs/Materials/materialHelper" {
  9203. import { Nullable } from "babylonjs/types";
  9204. import { Scene } from "babylonjs/scene";
  9205. import { Engine } from "babylonjs/Engines/engine";
  9206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9207. import { Light } from "babylonjs/Lights/light";
  9208. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9209. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9210. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9211. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9212. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9213. /**
  9214. * "Static Class" containing the most commonly used helper while dealing with material for
  9215. * rendering purpose.
  9216. *
  9217. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9218. *
  9219. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9220. */
  9221. export class MaterialHelper {
  9222. /**
  9223. * Bind the current view position to an effect.
  9224. * @param effect The effect to be bound
  9225. * @param scene The scene the eyes position is used from
  9226. */
  9227. static BindEyePosition(effect: Effect, scene: Scene): void;
  9228. /**
  9229. * Helps preparing the defines values about the UVs in used in the effect.
  9230. * UVs are shared as much as we can accross channels in the shaders.
  9231. * @param texture The texture we are preparing the UVs for
  9232. * @param defines The defines to update
  9233. * @param key The channel key "diffuse", "specular"... used in the shader
  9234. */
  9235. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9236. /**
  9237. * Binds a texture matrix value to its corrsponding uniform
  9238. * @param texture The texture to bind the matrix for
  9239. * @param uniformBuffer The uniform buffer receivin the data
  9240. * @param key The channel key "diffuse", "specular"... used in the shader
  9241. */
  9242. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9243. /**
  9244. * Gets the current status of the fog (should it be enabled?)
  9245. * @param mesh defines the mesh to evaluate for fog support
  9246. * @param scene defines the hosting scene
  9247. * @returns true if fog must be enabled
  9248. */
  9249. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9250. /**
  9251. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9252. * @param mesh defines the current mesh
  9253. * @param scene defines the current scene
  9254. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9255. * @param pointsCloud defines if point cloud rendering has to be turned on
  9256. * @param fogEnabled defines if fog has to be turned on
  9257. * @param alphaTest defines if alpha testing has to be turned on
  9258. * @param defines defines the current list of defines
  9259. */
  9260. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9261. /**
  9262. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9263. * @param scene defines the current scene
  9264. * @param engine defines the current engine
  9265. * @param defines specifies the list of active defines
  9266. * @param useInstances defines if instances have to be turned on
  9267. * @param useClipPlane defines if clip plane have to be turned on
  9268. */
  9269. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9270. /**
  9271. * Prepares the defines for bones
  9272. * @param mesh The mesh containing the geometry data we will draw
  9273. * @param defines The defines to update
  9274. */
  9275. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9276. /**
  9277. * Prepares the defines for morph targets
  9278. * @param mesh The mesh containing the geometry data we will draw
  9279. * @param defines The defines to update
  9280. */
  9281. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9282. /**
  9283. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9284. * @param mesh The mesh containing the geometry data we will draw
  9285. * @param defines The defines to update
  9286. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9287. * @param useBones Precise whether bones should be used or not (override mesh info)
  9288. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9289. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9290. * @returns false if defines are considered not dirty and have not been checked
  9291. */
  9292. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9293. /**
  9294. * Prepares the defines related to multiview
  9295. * @param scene The scene we are intending to draw
  9296. * @param defines The defines to update
  9297. */
  9298. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9299. /**
  9300. * Prepares the defines related to the light information passed in parameter
  9301. * @param scene The scene we are intending to draw
  9302. * @param mesh The mesh the effect is compiling for
  9303. * @param light The light the effect is compiling for
  9304. * @param lightIndex The index of the light
  9305. * @param defines The defines to update
  9306. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9307. * @param state Defines the current state regarding what is needed (normals, etc...)
  9308. */
  9309. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9310. needNormals: boolean;
  9311. needRebuild: boolean;
  9312. shadowEnabled: boolean;
  9313. specularEnabled: boolean;
  9314. lightmapMode: boolean;
  9315. }): void;
  9316. /**
  9317. * Prepares the defines related to the light information passed in parameter
  9318. * @param scene The scene we are intending to draw
  9319. * @param mesh The mesh the effect is compiling for
  9320. * @param defines The defines to update
  9321. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9322. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9323. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9324. * @returns true if normals will be required for the rest of the effect
  9325. */
  9326. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9327. /**
  9328. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9329. * @param lightIndex defines the light index
  9330. * @param uniformsList The uniform list
  9331. * @param samplersList The sampler list
  9332. * @param projectedLightTexture defines if projected texture must be used
  9333. * @param uniformBuffersList defines an optional list of uniform buffers
  9334. */
  9335. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9336. /**
  9337. * Prepares the uniforms and samplers list to be used in the effect
  9338. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9339. * @param samplersList The sampler list
  9340. * @param defines The defines helping in the list generation
  9341. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9342. */
  9343. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9344. /**
  9345. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9346. * @param defines The defines to update while falling back
  9347. * @param fallbacks The authorized effect fallbacks
  9348. * @param maxSimultaneousLights The maximum number of lights allowed
  9349. * @param rank the current rank of the Effect
  9350. * @returns The newly affected rank
  9351. */
  9352. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9353. private static _TmpMorphInfluencers;
  9354. /**
  9355. * Prepares the list of attributes required for morph targets according to the effect defines.
  9356. * @param attribs The current list of supported attribs
  9357. * @param mesh The mesh to prepare the morph targets attributes for
  9358. * @param influencers The number of influencers
  9359. */
  9360. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9361. /**
  9362. * Prepares the list of attributes required for morph targets according to the effect defines.
  9363. * @param attribs The current list of supported attribs
  9364. * @param mesh The mesh to prepare the morph targets attributes for
  9365. * @param defines The current Defines of the effect
  9366. */
  9367. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9368. /**
  9369. * Prepares the list of attributes required for bones according to the effect defines.
  9370. * @param attribs The current list of supported attribs
  9371. * @param mesh The mesh to prepare the bones attributes for
  9372. * @param defines The current Defines of the effect
  9373. * @param fallbacks The current efffect fallback strategy
  9374. */
  9375. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9376. /**
  9377. * Check and prepare the list of attributes required for instances according to the effect defines.
  9378. * @param attribs The current list of supported attribs
  9379. * @param defines The current MaterialDefines of the effect
  9380. */
  9381. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9382. /**
  9383. * Add the list of attributes required for instances to the attribs array.
  9384. * @param attribs The current list of supported attribs
  9385. */
  9386. static PushAttributesForInstances(attribs: string[]): void;
  9387. /**
  9388. * Binds the light information to the effect.
  9389. * @param light The light containing the generator
  9390. * @param effect The effect we are binding the data to
  9391. * @param lightIndex The light index in the effect used to render
  9392. */
  9393. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9394. /**
  9395. * Binds the lights information from the scene to the effect for the given mesh.
  9396. * @param light Light to bind
  9397. * @param lightIndex Light index
  9398. * @param scene The scene where the light belongs to
  9399. * @param effect The effect we are binding the data to
  9400. * @param useSpecular Defines if specular is supported
  9401. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9402. */
  9403. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9404. /**
  9405. * Binds the lights information from the scene to the effect for the given mesh.
  9406. * @param scene The scene the lights belongs to
  9407. * @param mesh The mesh we are binding the information to render
  9408. * @param effect The effect we are binding the data to
  9409. * @param defines The generated defines for the effect
  9410. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9411. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9412. */
  9413. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9414. private static _tempFogColor;
  9415. /**
  9416. * Binds the fog information from the scene to the effect for the given mesh.
  9417. * @param scene The scene the lights belongs to
  9418. * @param mesh The mesh we are binding the information to render
  9419. * @param effect The effect we are binding the data to
  9420. * @param linearSpace Defines if the fog effect is applied in linear space
  9421. */
  9422. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9423. /**
  9424. * Binds the bones information from the mesh to the effect.
  9425. * @param mesh The mesh we are binding the information to render
  9426. * @param effect The effect we are binding the data to
  9427. */
  9428. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9429. /**
  9430. * Binds the morph targets information from the mesh to the effect.
  9431. * @param abstractMesh The mesh we are binding the information to render
  9432. * @param effect The effect we are binding the data to
  9433. */
  9434. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9435. /**
  9436. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9437. * @param defines The generated defines used in the effect
  9438. * @param effect The effect we are binding the data to
  9439. * @param scene The scene we are willing to render with logarithmic scale for
  9440. */
  9441. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9442. /**
  9443. * Binds the clip plane information from the scene to the effect.
  9444. * @param scene The scene the clip plane information are extracted from
  9445. * @param effect The effect we are binding the data to
  9446. */
  9447. static BindClipPlane(effect: Effect, scene: Scene): void;
  9448. }
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9451. /** @hidden */
  9452. export var packingFunctions: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9458. /** @hidden */
  9459. export var clipPlaneFragmentDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9465. /** @hidden */
  9466. export var clipPlaneFragment: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9472. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9473. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9474. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9475. /** @hidden */
  9476. export var shadowMapPixelShader: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9482. /** @hidden */
  9483. export var bonesDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9489. /** @hidden */
  9490. export var morphTargetsVertexGlobalDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9496. /** @hidden */
  9497. export var morphTargetsVertexDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9503. /** @hidden */
  9504. export var instancesDeclaration: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9510. /** @hidden */
  9511. export var helperFunctions: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9517. /** @hidden */
  9518. export var clipPlaneVertexDeclaration: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9524. /** @hidden */
  9525. export var morphTargetsVertex: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9531. /** @hidden */
  9532. export var instancesVertex: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9538. /** @hidden */
  9539. export var bonesVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9545. /** @hidden */
  9546. export var clipPlaneVertex: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9552. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9553. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9554. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9555. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9557. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9558. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9559. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9560. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9561. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9562. /** @hidden */
  9563. export var shadowMapVertexShader: {
  9564. name: string;
  9565. shader: string;
  9566. };
  9567. }
  9568. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9569. /** @hidden */
  9570. export var depthBoxBlurPixelShader: {
  9571. name: string;
  9572. shader: string;
  9573. };
  9574. }
  9575. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9576. import { SmartArray } from "babylonjs/Misc/smartArray";
  9577. import { Nullable } from "babylonjs/types";
  9578. import { Scene } from "babylonjs/scene";
  9579. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9580. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9582. import { Mesh } from "babylonjs/Meshes/mesh";
  9583. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9584. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9585. import { Effect } from "babylonjs/Materials/effect";
  9586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9587. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  9588. import "babylonjs/Shaders/shadowMap.fragment";
  9589. import "babylonjs/Shaders/shadowMap.vertex";
  9590. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9591. import { Observable } from "babylonjs/Misc/observable";
  9592. /**
  9593. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9594. */
  9595. export interface ICustomShaderOptions {
  9596. /**
  9597. * Gets or sets the custom shader name to use
  9598. */
  9599. shaderName: string;
  9600. /**
  9601. * The list of attribute names used in the shader
  9602. */
  9603. attributes?: string[];
  9604. /**
  9605. * The list of unifrom names used in the shader
  9606. */
  9607. uniforms?: string[];
  9608. /**
  9609. * The list of sampler names used in the shader
  9610. */
  9611. samplers?: string[];
  9612. /**
  9613. * The list of defines used in the shader
  9614. */
  9615. defines?: string[];
  9616. }
  9617. /**
  9618. * Interface to implement to create a shadow generator compatible with BJS.
  9619. */
  9620. export interface IShadowGenerator {
  9621. /**
  9622. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9623. * @returns The render target texture if present otherwise, null
  9624. */
  9625. getShadowMap(): Nullable<RenderTargetTexture>;
  9626. /**
  9627. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9628. * @param subMesh The submesh we want to render in the shadow map
  9629. * @param useInstances Defines wether will draw in the map using instances
  9630. * @returns true if ready otherwise, false
  9631. */
  9632. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9633. /**
  9634. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9635. * @param defines Defines of the material we want to update
  9636. * @param lightIndex Index of the light in the enabled light list of the material
  9637. */
  9638. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9639. /**
  9640. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9641. * defined in the generator but impacting the effect).
  9642. * It implies the unifroms available on the materials are the standard BJS ones.
  9643. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9644. * @param effect The effect we are binfing the information for
  9645. */
  9646. bindShadowLight(lightIndex: string, effect: Effect): void;
  9647. /**
  9648. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9649. * (eq to shadow prjection matrix * light transform matrix)
  9650. * @returns The transform matrix used to create the shadow map
  9651. */
  9652. getTransformMatrix(): Matrix;
  9653. /**
  9654. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9655. * Cube and 2D textures for instance.
  9656. */
  9657. recreateShadowMap(): void;
  9658. /**
  9659. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9660. * @param onCompiled Callback triggered at the and of the effects compilation
  9661. * @param options Sets of optional options forcing the compilation with different modes
  9662. */
  9663. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9664. useInstances: boolean;
  9665. }>): void;
  9666. /**
  9667. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9668. * @param options Sets of optional options forcing the compilation with different modes
  9669. * @returns A promise that resolves when the compilation completes
  9670. */
  9671. forceCompilationAsync(options?: Partial<{
  9672. useInstances: boolean;
  9673. }>): Promise<void>;
  9674. /**
  9675. * Serializes the shadow generator setup to a json object.
  9676. * @returns The serialized JSON object
  9677. */
  9678. serialize(): any;
  9679. /**
  9680. * Disposes the Shadow map and related Textures and effects.
  9681. */
  9682. dispose(): void;
  9683. }
  9684. /**
  9685. * Default implementation IShadowGenerator.
  9686. * This is the main object responsible of generating shadows in the framework.
  9687. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9688. */
  9689. export class ShadowGenerator implements IShadowGenerator {
  9690. /**
  9691. * Name of the shadow generator class
  9692. */
  9693. static CLASSNAME: string;
  9694. /**
  9695. * Shadow generator mode None: no filtering applied.
  9696. */
  9697. static readonly FILTER_NONE: number;
  9698. /**
  9699. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9700. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9701. */
  9702. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9703. /**
  9704. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9705. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9706. */
  9707. static readonly FILTER_POISSONSAMPLING: number;
  9708. /**
  9709. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9710. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9711. */
  9712. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9713. /**
  9714. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9715. * edge artifacts on steep falloff.
  9716. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9717. */
  9718. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9719. /**
  9720. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9721. * edge artifacts on steep falloff.
  9722. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9723. */
  9724. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9725. /**
  9726. * Shadow generator mode PCF: Percentage Closer Filtering
  9727. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9728. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9729. */
  9730. static readonly FILTER_PCF: number;
  9731. /**
  9732. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9733. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9734. * Contact Hardening
  9735. */
  9736. static readonly FILTER_PCSS: number;
  9737. /**
  9738. * Reserved for PCF and PCSS
  9739. * Highest Quality.
  9740. *
  9741. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9742. *
  9743. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9744. */
  9745. static readonly QUALITY_HIGH: number;
  9746. /**
  9747. * Reserved for PCF and PCSS
  9748. * Good tradeoff for quality/perf cross devices
  9749. *
  9750. * Execute PCF on a 3*3 kernel.
  9751. *
  9752. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9753. */
  9754. static readonly QUALITY_MEDIUM: number;
  9755. /**
  9756. * Reserved for PCF and PCSS
  9757. * The lowest quality but the fastest.
  9758. *
  9759. * Execute PCF on a 1*1 kernel.
  9760. *
  9761. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9762. */
  9763. static readonly QUALITY_LOW: number;
  9764. /** Gets or sets the custom shader name to use */
  9765. customShaderOptions: ICustomShaderOptions;
  9766. /**
  9767. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9768. */
  9769. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9770. /**
  9771. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9772. */
  9773. onAfterShadowMapRenderObservable: Observable<Effect>;
  9774. /**
  9775. * Observable triggered before a mesh is rendered in the shadow map.
  9776. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9777. */
  9778. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9779. /**
  9780. * Observable triggered after a mesh is rendered in the shadow map.
  9781. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9782. */
  9783. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9784. protected _bias: number;
  9785. /**
  9786. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9787. */
  9788. get bias(): number;
  9789. /**
  9790. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9791. */
  9792. set bias(bias: number);
  9793. protected _normalBias: number;
  9794. /**
  9795. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9796. */
  9797. get normalBias(): number;
  9798. /**
  9799. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9800. */
  9801. set normalBias(normalBias: number);
  9802. protected _blurBoxOffset: number;
  9803. /**
  9804. * Gets the blur box offset: offset applied during the blur pass.
  9805. * Only useful if useKernelBlur = false
  9806. */
  9807. get blurBoxOffset(): number;
  9808. /**
  9809. * Sets the blur box offset: offset applied during the blur pass.
  9810. * Only useful if useKernelBlur = false
  9811. */
  9812. set blurBoxOffset(value: number);
  9813. protected _blurScale: number;
  9814. /**
  9815. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9816. * 2 means half of the size.
  9817. */
  9818. get blurScale(): number;
  9819. /**
  9820. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9821. * 2 means half of the size.
  9822. */
  9823. set blurScale(value: number);
  9824. protected _blurKernel: number;
  9825. /**
  9826. * Gets the blur kernel: kernel size of the blur pass.
  9827. * Only useful if useKernelBlur = true
  9828. */
  9829. get blurKernel(): number;
  9830. /**
  9831. * Sets the blur kernel: kernel size of the blur pass.
  9832. * Only useful if useKernelBlur = true
  9833. */
  9834. set blurKernel(value: number);
  9835. protected _useKernelBlur: boolean;
  9836. /**
  9837. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9838. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9839. */
  9840. get useKernelBlur(): boolean;
  9841. /**
  9842. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9843. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9844. */
  9845. set useKernelBlur(value: boolean);
  9846. protected _depthScale: number;
  9847. /**
  9848. * Gets the depth scale used in ESM mode.
  9849. */
  9850. get depthScale(): number;
  9851. /**
  9852. * Sets the depth scale used in ESM mode.
  9853. * This can override the scale stored on the light.
  9854. */
  9855. set depthScale(value: number);
  9856. protected _validateFilter(filter: number): number;
  9857. protected _filter: number;
  9858. /**
  9859. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9860. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9861. */
  9862. get filter(): number;
  9863. /**
  9864. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9865. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9866. */
  9867. set filter(value: number);
  9868. /**
  9869. * Gets if the current filter is set to Poisson Sampling.
  9870. */
  9871. get usePoissonSampling(): boolean;
  9872. /**
  9873. * Sets the current filter to Poisson Sampling.
  9874. */
  9875. set usePoissonSampling(value: boolean);
  9876. /**
  9877. * Gets if the current filter is set to ESM.
  9878. */
  9879. get useExponentialShadowMap(): boolean;
  9880. /**
  9881. * Sets the current filter is to ESM.
  9882. */
  9883. set useExponentialShadowMap(value: boolean);
  9884. /**
  9885. * Gets if the current filter is set to filtered ESM.
  9886. */
  9887. get useBlurExponentialShadowMap(): boolean;
  9888. /**
  9889. * Gets if the current filter is set to filtered ESM.
  9890. */
  9891. set useBlurExponentialShadowMap(value: boolean);
  9892. /**
  9893. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9894. * exponential to prevent steep falloff artifacts).
  9895. */
  9896. get useCloseExponentialShadowMap(): boolean;
  9897. /**
  9898. * Sets the current filter to "close ESM" (using the inverse of the
  9899. * exponential to prevent steep falloff artifacts).
  9900. */
  9901. set useCloseExponentialShadowMap(value: boolean);
  9902. /**
  9903. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9904. * exponential to prevent steep falloff artifacts).
  9905. */
  9906. get useBlurCloseExponentialShadowMap(): boolean;
  9907. /**
  9908. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9909. * exponential to prevent steep falloff artifacts).
  9910. */
  9911. set useBlurCloseExponentialShadowMap(value: boolean);
  9912. /**
  9913. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9914. */
  9915. get usePercentageCloserFiltering(): boolean;
  9916. /**
  9917. * Sets the current filter to "PCF" (percentage closer filtering).
  9918. */
  9919. set usePercentageCloserFiltering(value: boolean);
  9920. protected _filteringQuality: number;
  9921. /**
  9922. * Gets the PCF or PCSS Quality.
  9923. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9924. */
  9925. get filteringQuality(): number;
  9926. /**
  9927. * Sets the PCF or PCSS Quality.
  9928. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9929. */
  9930. set filteringQuality(filteringQuality: number);
  9931. /**
  9932. * Gets if the current filter is set to "PCSS" (contact hardening).
  9933. */
  9934. get useContactHardeningShadow(): boolean;
  9935. /**
  9936. * Sets the current filter to "PCSS" (contact hardening).
  9937. */
  9938. set useContactHardeningShadow(value: boolean);
  9939. protected _contactHardeningLightSizeUVRatio: number;
  9940. /**
  9941. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9942. * Using a ratio helps keeping shape stability independently of the map size.
  9943. *
  9944. * It does not account for the light projection as it was having too much
  9945. * instability during the light setup or during light position changes.
  9946. *
  9947. * Only valid if useContactHardeningShadow is true.
  9948. */
  9949. get contactHardeningLightSizeUVRatio(): number;
  9950. /**
  9951. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9952. * Using a ratio helps keeping shape stability independently of the map size.
  9953. *
  9954. * It does not account for the light projection as it was having too much
  9955. * instability during the light setup or during light position changes.
  9956. *
  9957. * Only valid if useContactHardeningShadow is true.
  9958. */
  9959. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9960. protected _darkness: number;
  9961. /** Gets or sets the actual darkness of a shadow */
  9962. get darkness(): number;
  9963. set darkness(value: number);
  9964. /**
  9965. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9966. * 0 means strongest and 1 would means no shadow.
  9967. * @returns the darkness.
  9968. */
  9969. getDarkness(): number;
  9970. /**
  9971. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9972. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9973. * @returns the shadow generator allowing fluent coding.
  9974. */
  9975. setDarkness(darkness: number): ShadowGenerator;
  9976. protected _transparencyShadow: boolean;
  9977. /** Gets or sets the ability to have transparent shadow */
  9978. get transparencyShadow(): boolean;
  9979. set transparencyShadow(value: boolean);
  9980. /**
  9981. * Sets the ability to have transparent shadow (boolean).
  9982. * @param transparent True if transparent else False
  9983. * @returns the shadow generator allowing fluent coding
  9984. */
  9985. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9986. protected _shadowMap: Nullable<RenderTargetTexture>;
  9987. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9988. /**
  9989. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9990. * @returns The render target texture if present otherwise, null
  9991. */
  9992. getShadowMap(): Nullable<RenderTargetTexture>;
  9993. /**
  9994. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9995. * @returns The render target texture if the shadow map is present otherwise, null
  9996. */
  9997. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9998. /**
  9999. * Gets the class name of that object
  10000. * @returns "ShadowGenerator"
  10001. */
  10002. getClassName(): string;
  10003. /**
  10004. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10005. * @param mesh Mesh to add
  10006. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10007. * @returns the Shadow Generator itself
  10008. */
  10009. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10010. /**
  10011. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10012. * @param mesh Mesh to remove
  10013. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10014. * @returns the Shadow Generator itself
  10015. */
  10016. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10017. /**
  10018. * Controls the extent to which the shadows fade out at the edge of the frustum
  10019. */
  10020. frustumEdgeFalloff: number;
  10021. protected _light: IShadowLight;
  10022. /**
  10023. * Returns the associated light object.
  10024. * @returns the light generating the shadow
  10025. */
  10026. getLight(): IShadowLight;
  10027. /**
  10028. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10029. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10030. * It might on the other hand introduce peter panning.
  10031. */
  10032. forceBackFacesOnly: boolean;
  10033. protected _scene: Scene;
  10034. protected _lightDirection: Vector3;
  10035. protected _effect: Effect;
  10036. protected _viewMatrix: Matrix;
  10037. protected _projectionMatrix: Matrix;
  10038. protected _transformMatrix: Matrix;
  10039. protected _cachedPosition: Vector3;
  10040. protected _cachedDirection: Vector3;
  10041. protected _cachedDefines: string;
  10042. protected _currentRenderID: number;
  10043. protected _boxBlurPostprocess: Nullable<PostProcess>;
  10044. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  10045. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  10046. protected _blurPostProcesses: PostProcess[];
  10047. protected _mapSize: number;
  10048. protected _currentFaceIndex: number;
  10049. protected _currentFaceIndexCache: number;
  10050. protected _textureType: number;
  10051. protected _defaultTextureMatrix: Matrix;
  10052. protected _storedUniqueId: Nullable<number>;
  10053. /** @hidden */
  10054. static _SceneComponentInitialization: (scene: Scene) => void;
  10055. /**
  10056. * Creates a ShadowGenerator object.
  10057. * A ShadowGenerator is the required tool to use the shadows.
  10058. * Each light casting shadows needs to use its own ShadowGenerator.
  10059. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10060. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10061. * @param light The light object generating the shadows.
  10062. * @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.
  10063. */
  10064. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10065. protected _initializeGenerator(): void;
  10066. protected _createTargetRenderTexture(): void;
  10067. protected _initializeShadowMap(): void;
  10068. protected _initializeBlurRTTAndPostProcesses(): void;
  10069. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  10070. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  10071. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  10072. protected _applyFilterValues(): void;
  10073. /**
  10074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10075. * @param onCompiled Callback triggered at the and of the effects compilation
  10076. * @param options Sets of optional options forcing the compilation with different modes
  10077. */
  10078. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  10079. useInstances: boolean;
  10080. }>): void;
  10081. /**
  10082. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10083. * @param options Sets of optional options forcing the compilation with different modes
  10084. * @returns A promise that resolves when the compilation completes
  10085. */
  10086. forceCompilationAsync(options?: Partial<{
  10087. useInstances: boolean;
  10088. }>): Promise<void>;
  10089. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  10090. /**
  10091. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10092. * @param subMesh The submesh we want to render in the shadow map
  10093. * @param useInstances Defines wether will draw in the map using instances
  10094. * @returns true if ready otherwise, false
  10095. */
  10096. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10097. /**
  10098. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10099. * @param defines Defines of the material we want to update
  10100. * @param lightIndex Index of the light in the enabled light list of the material
  10101. */
  10102. prepareDefines(defines: any, lightIndex: number): void;
  10103. /**
  10104. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10105. * defined in the generator but impacting the effect).
  10106. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10107. * @param effect The effect we are binfing the information for
  10108. */
  10109. bindShadowLight(lightIndex: string, effect: Effect): void;
  10110. /**
  10111. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10112. * (eq to shadow prjection matrix * light transform matrix)
  10113. * @returns The transform matrix used to create the shadow map
  10114. */
  10115. getTransformMatrix(): Matrix;
  10116. /**
  10117. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10118. * Cube and 2D textures for instance.
  10119. */
  10120. recreateShadowMap(): void;
  10121. protected _disposeBlurPostProcesses(): void;
  10122. protected _disposeRTTandPostProcesses(): void;
  10123. /**
  10124. * Disposes the ShadowGenerator.
  10125. * Returns nothing.
  10126. */
  10127. dispose(): void;
  10128. /**
  10129. * Serializes the shadow generator setup to a json object.
  10130. * @returns The serialized JSON object
  10131. */
  10132. serialize(): any;
  10133. /**
  10134. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10135. * @param parsedShadowGenerator The JSON object to parse
  10136. * @param scene The scene to create the shadow map for
  10137. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  10138. * @returns The parsed shadow generator
  10139. */
  10140. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  10141. }
  10142. }
  10143. declare module "babylonjs/Lights/light" {
  10144. import { Nullable } from "babylonjs/types";
  10145. import { Scene } from "babylonjs/scene";
  10146. import { Vector3 } from "babylonjs/Maths/math.vector";
  10147. import { Color3 } from "babylonjs/Maths/math.color";
  10148. import { Node } from "babylonjs/node";
  10149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10150. import { Effect } from "babylonjs/Materials/effect";
  10151. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10152. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10153. /**
  10154. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10155. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10156. * 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.
  10157. */
  10158. export abstract class Light extends Node {
  10159. /**
  10160. * Falloff Default: light is falling off following the material specification:
  10161. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10162. */
  10163. static readonly FALLOFF_DEFAULT: number;
  10164. /**
  10165. * Falloff Physical: light is falling off following the inverse squared distance law.
  10166. */
  10167. static readonly FALLOFF_PHYSICAL: number;
  10168. /**
  10169. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10170. * to enhance interoperability with other engines.
  10171. */
  10172. static readonly FALLOFF_GLTF: number;
  10173. /**
  10174. * Falloff Standard: light is falling off like in the standard material
  10175. * to enhance interoperability with other materials.
  10176. */
  10177. static readonly FALLOFF_STANDARD: number;
  10178. /**
  10179. * If every light affecting the material is in this lightmapMode,
  10180. * material.lightmapTexture adds or multiplies
  10181. * (depends on material.useLightmapAsShadowmap)
  10182. * after every other light calculations.
  10183. */
  10184. static readonly LIGHTMAP_DEFAULT: number;
  10185. /**
  10186. * material.lightmapTexture as only diffuse lighting from this light
  10187. * adds only specular lighting from this light
  10188. * adds dynamic shadows
  10189. */
  10190. static readonly LIGHTMAP_SPECULAR: number;
  10191. /**
  10192. * material.lightmapTexture as only lighting
  10193. * no light calculation from this light
  10194. * only adds dynamic shadows from this light
  10195. */
  10196. static readonly LIGHTMAP_SHADOWSONLY: number;
  10197. /**
  10198. * Each light type uses the default quantity according to its type:
  10199. * point/spot lights use luminous intensity
  10200. * directional lights use illuminance
  10201. */
  10202. static readonly INTENSITYMODE_AUTOMATIC: number;
  10203. /**
  10204. * lumen (lm)
  10205. */
  10206. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10207. /**
  10208. * candela (lm/sr)
  10209. */
  10210. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10211. /**
  10212. * lux (lm/m^2)
  10213. */
  10214. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10215. /**
  10216. * nit (cd/m^2)
  10217. */
  10218. static readonly INTENSITYMODE_LUMINANCE: number;
  10219. /**
  10220. * Light type const id of the point light.
  10221. */
  10222. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10223. /**
  10224. * Light type const id of the directional light.
  10225. */
  10226. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10227. /**
  10228. * Light type const id of the spot light.
  10229. */
  10230. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10231. /**
  10232. * Light type const id of the hemispheric light.
  10233. */
  10234. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10235. /**
  10236. * Diffuse gives the basic color to an object.
  10237. */
  10238. diffuse: Color3;
  10239. /**
  10240. * Specular produces a highlight color on an object.
  10241. * Note: This is note affecting PBR materials.
  10242. */
  10243. specular: Color3;
  10244. /**
  10245. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10246. * falling off base on range or angle.
  10247. * This can be set to any values in Light.FALLOFF_x.
  10248. *
  10249. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10250. * other types of materials.
  10251. */
  10252. falloffType: number;
  10253. /**
  10254. * Strength of the light.
  10255. * Note: By default it is define in the framework own unit.
  10256. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10257. */
  10258. intensity: number;
  10259. private _range;
  10260. protected _inverseSquaredRange: number;
  10261. /**
  10262. * Defines how far from the source the light is impacting in scene units.
  10263. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10264. */
  10265. get range(): number;
  10266. /**
  10267. * Defines how far from the source the light is impacting in scene units.
  10268. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10269. */
  10270. set range(value: number);
  10271. /**
  10272. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10273. * of light.
  10274. */
  10275. private _photometricScale;
  10276. private _intensityMode;
  10277. /**
  10278. * Gets the photometric scale used to interpret the intensity.
  10279. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10280. */
  10281. get intensityMode(): number;
  10282. /**
  10283. * Sets the photometric scale used to interpret the intensity.
  10284. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10285. */
  10286. set intensityMode(value: number);
  10287. private _radius;
  10288. /**
  10289. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10290. */
  10291. get radius(): number;
  10292. /**
  10293. * sets the light radius used by PBR Materials to simulate soft area lights.
  10294. */
  10295. set radius(value: number);
  10296. private _renderPriority;
  10297. /**
  10298. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10299. * exceeding the number allowed of the materials.
  10300. */
  10301. renderPriority: number;
  10302. private _shadowEnabled;
  10303. /**
  10304. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10305. * the current shadow generator.
  10306. */
  10307. get shadowEnabled(): boolean;
  10308. /**
  10309. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10310. * the current shadow generator.
  10311. */
  10312. set shadowEnabled(value: boolean);
  10313. private _includedOnlyMeshes;
  10314. /**
  10315. * Gets the only meshes impacted by this light.
  10316. */
  10317. get includedOnlyMeshes(): AbstractMesh[];
  10318. /**
  10319. * Sets the only meshes impacted by this light.
  10320. */
  10321. set includedOnlyMeshes(value: AbstractMesh[]);
  10322. private _excludedMeshes;
  10323. /**
  10324. * Gets the meshes not impacted by this light.
  10325. */
  10326. get excludedMeshes(): AbstractMesh[];
  10327. /**
  10328. * Sets the meshes not impacted by this light.
  10329. */
  10330. set excludedMeshes(value: AbstractMesh[]);
  10331. private _excludeWithLayerMask;
  10332. /**
  10333. * Gets the layer id use to find what meshes are not impacted by the light.
  10334. * Inactive if 0
  10335. */
  10336. get excludeWithLayerMask(): number;
  10337. /**
  10338. * Sets the layer id use to find what meshes are not impacted by the light.
  10339. * Inactive if 0
  10340. */
  10341. set excludeWithLayerMask(value: number);
  10342. private _includeOnlyWithLayerMask;
  10343. /**
  10344. * Gets the layer id use to find what meshes are impacted by the light.
  10345. * Inactive if 0
  10346. */
  10347. get includeOnlyWithLayerMask(): number;
  10348. /**
  10349. * Sets the layer id use to find what meshes are impacted by the light.
  10350. * Inactive if 0
  10351. */
  10352. set includeOnlyWithLayerMask(value: number);
  10353. private _lightmapMode;
  10354. /**
  10355. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10356. */
  10357. get lightmapMode(): number;
  10358. /**
  10359. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10360. */
  10361. set lightmapMode(value: number);
  10362. /**
  10363. * Shadow generator associted to the light.
  10364. * @hidden Internal use only.
  10365. */
  10366. _shadowGenerator: Nullable<IShadowGenerator>;
  10367. /**
  10368. * @hidden Internal use only.
  10369. */
  10370. _excludedMeshesIds: string[];
  10371. /**
  10372. * @hidden Internal use only.
  10373. */
  10374. _includedOnlyMeshesIds: string[];
  10375. /**
  10376. * The current light unifom buffer.
  10377. * @hidden Internal use only.
  10378. */
  10379. _uniformBuffer: UniformBuffer;
  10380. /** @hidden */
  10381. _renderId: number;
  10382. /**
  10383. * Creates a Light object in the scene.
  10384. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10385. * @param name The firendly name of the light
  10386. * @param scene The scene the light belongs too
  10387. */
  10388. constructor(name: string, scene: Scene);
  10389. protected abstract _buildUniformLayout(): void;
  10390. /**
  10391. * Sets the passed Effect "effect" with the Light information.
  10392. * @param effect The effect to update
  10393. * @param lightIndex The index of the light in the effect to update
  10394. * @returns The light
  10395. */
  10396. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10397. /**
  10398. * Sets the passed Effect "effect" with the Light textures.
  10399. * @param effect The effect to update
  10400. * @param lightIndex The index of the light in the effect to update
  10401. * @returns The light
  10402. */
  10403. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10404. /**
  10405. * Binds the lights information from the scene to the effect for the given mesh.
  10406. * @param lightIndex Light index
  10407. * @param scene The scene where the light belongs to
  10408. * @param effect The effect we are binding the data to
  10409. * @param useSpecular Defines if specular is supported
  10410. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10411. */
  10412. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10413. /**
  10414. * Sets the passed Effect "effect" with the Light information.
  10415. * @param effect The effect to update
  10416. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10417. * @returns The light
  10418. */
  10419. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10420. /**
  10421. * Returns the string "Light".
  10422. * @returns the class name
  10423. */
  10424. getClassName(): string;
  10425. /** @hidden */
  10426. readonly _isLight: boolean;
  10427. /**
  10428. * Converts the light information to a readable string for debug purpose.
  10429. * @param fullDetails Supports for multiple levels of logging within scene loading
  10430. * @returns the human readable light info
  10431. */
  10432. toString(fullDetails?: boolean): string;
  10433. /** @hidden */
  10434. protected _syncParentEnabledState(): void;
  10435. /**
  10436. * Set the enabled state of this node.
  10437. * @param value - the new enabled state
  10438. */
  10439. setEnabled(value: boolean): void;
  10440. /**
  10441. * Returns the Light associated shadow generator if any.
  10442. * @return the associated shadow generator.
  10443. */
  10444. getShadowGenerator(): Nullable<IShadowGenerator>;
  10445. /**
  10446. * Returns a Vector3, the absolute light position in the World.
  10447. * @returns the world space position of the light
  10448. */
  10449. getAbsolutePosition(): Vector3;
  10450. /**
  10451. * Specifies if the light will affect the passed mesh.
  10452. * @param mesh The mesh to test against the light
  10453. * @return true the mesh is affected otherwise, false.
  10454. */
  10455. canAffectMesh(mesh: AbstractMesh): boolean;
  10456. /**
  10457. * Sort function to order lights for rendering.
  10458. * @param a First Light object to compare to second.
  10459. * @param b Second Light object to compare first.
  10460. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10461. */
  10462. static CompareLightsPriority(a: Light, b: Light): number;
  10463. /**
  10464. * Releases resources associated with this node.
  10465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10467. */
  10468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10469. /**
  10470. * Returns the light type ID (integer).
  10471. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10472. */
  10473. getTypeID(): number;
  10474. /**
  10475. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10476. * @returns the scaled intensity in intensity mode unit
  10477. */
  10478. getScaledIntensity(): number;
  10479. /**
  10480. * Returns a new Light object, named "name", from the current one.
  10481. * @param name The name of the cloned light
  10482. * @returns the new created light
  10483. */
  10484. clone(name: string): Nullable<Light>;
  10485. /**
  10486. * Serializes the current light into a Serialization object.
  10487. * @returns the serialized object.
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10492. * This new light is named "name" and added to the passed scene.
  10493. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10494. * @param name The friendly name of the light
  10495. * @param scene The scene the new light will belong to
  10496. * @returns the constructor function
  10497. */
  10498. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10499. /**
  10500. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10501. * @param parsedLight The JSON representation of the light
  10502. * @param scene The scene to create the parsed light in
  10503. * @returns the created light after parsing
  10504. */
  10505. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10506. private _hookArrayForExcluded;
  10507. private _hookArrayForIncludedOnly;
  10508. private _resyncMeshes;
  10509. /**
  10510. * Forces the meshes to update their light related information in their rendering used effects
  10511. * @hidden Internal Use Only
  10512. */
  10513. _markMeshesAsLightDirty(): void;
  10514. /**
  10515. * Recomputes the cached photometric scale if needed.
  10516. */
  10517. private _computePhotometricScale;
  10518. /**
  10519. * Returns the Photometric Scale according to the light type and intensity mode.
  10520. */
  10521. private _getPhotometricScale;
  10522. /**
  10523. * Reorder the light in the scene according to their defined priority.
  10524. * @hidden Internal Use Only
  10525. */
  10526. _reorderLightsInScene(): void;
  10527. /**
  10528. * Prepares the list of defines specific to the light type.
  10529. * @param defines the list of defines
  10530. * @param lightIndex defines the index of the light for the effect
  10531. */
  10532. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10533. }
  10534. }
  10535. declare module "babylonjs/Actions/action" {
  10536. import { Observable } from "babylonjs/Misc/observable";
  10537. import { Condition } from "babylonjs/Actions/condition";
  10538. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10539. import { ActionManager } from "babylonjs/Actions/actionManager";
  10540. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10541. /**
  10542. * Interface used to define Action
  10543. */
  10544. export interface IAction {
  10545. /**
  10546. * Trigger for the action
  10547. */
  10548. trigger: number;
  10549. /** Options of the trigger */
  10550. triggerOptions: any;
  10551. /**
  10552. * Gets the trigger parameters
  10553. * @returns the trigger parameters
  10554. */
  10555. getTriggerParameter(): any;
  10556. /**
  10557. * Internal only - executes current action event
  10558. * @hidden
  10559. */
  10560. _executeCurrent(evt?: ActionEvent): void;
  10561. /**
  10562. * Serialize placeholder for child classes
  10563. * @param parent of child
  10564. * @returns the serialized object
  10565. */
  10566. serialize(parent: any): any;
  10567. /**
  10568. * Internal only
  10569. * @hidden
  10570. */
  10571. _prepare(): void;
  10572. /**
  10573. * Internal only - manager for action
  10574. * @hidden
  10575. */
  10576. _actionManager: AbstractActionManager;
  10577. /**
  10578. * Adds action to chain of actions, may be a DoNothingAction
  10579. * @param action defines the next action to execute
  10580. * @returns The action passed in
  10581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10582. */
  10583. then(action: IAction): IAction;
  10584. }
  10585. /**
  10586. * The action to be carried out following a trigger
  10587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10588. */
  10589. export class Action implements IAction {
  10590. /** the trigger, with or without parameters, for the action */
  10591. triggerOptions: any;
  10592. /**
  10593. * Trigger for the action
  10594. */
  10595. trigger: number;
  10596. /**
  10597. * Internal only - manager for action
  10598. * @hidden
  10599. */
  10600. _actionManager: ActionManager;
  10601. private _nextActiveAction;
  10602. private _child;
  10603. private _condition?;
  10604. private _triggerParameter;
  10605. /**
  10606. * An event triggered prior to action being executed.
  10607. */
  10608. onBeforeExecuteObservable: Observable<Action>;
  10609. /**
  10610. * Creates a new Action
  10611. * @param triggerOptions the trigger, with or without parameters, for the action
  10612. * @param condition an optional determinant of action
  10613. */
  10614. constructor(
  10615. /** the trigger, with or without parameters, for the action */
  10616. triggerOptions: any, condition?: Condition);
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. _prepare(): void;
  10622. /**
  10623. * Gets the trigger parameters
  10624. * @returns the trigger parameters
  10625. */
  10626. getTriggerParameter(): any;
  10627. /**
  10628. * Internal only - executes current action event
  10629. * @hidden
  10630. */
  10631. _executeCurrent(evt?: ActionEvent): void;
  10632. /**
  10633. * Execute placeholder for child classes
  10634. * @param evt optional action event
  10635. */
  10636. execute(evt?: ActionEvent): void;
  10637. /**
  10638. * Skips to next active action
  10639. */
  10640. skipToNextActiveAction(): void;
  10641. /**
  10642. * Adds action to chain of actions, may be a DoNothingAction
  10643. * @param action defines the next action to execute
  10644. * @returns The action passed in
  10645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10646. */
  10647. then(action: Action): Action;
  10648. /**
  10649. * Internal only
  10650. * @hidden
  10651. */
  10652. _getProperty(propertyPath: string): string;
  10653. /**
  10654. * Internal only
  10655. * @hidden
  10656. */
  10657. _getEffectiveTarget(target: any, propertyPath: string): any;
  10658. /**
  10659. * Serialize placeholder for child classes
  10660. * @param parent of child
  10661. * @returns the serialized object
  10662. */
  10663. serialize(parent: any): any;
  10664. /**
  10665. * Internal only called by serialize
  10666. * @hidden
  10667. */
  10668. protected _serialize(serializedAction: any, parent?: any): any;
  10669. /**
  10670. * Internal only
  10671. * @hidden
  10672. */
  10673. static _SerializeValueAsString: (value: any) => string;
  10674. /**
  10675. * Internal only
  10676. * @hidden
  10677. */
  10678. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10679. name: string;
  10680. targetType: string;
  10681. value: string;
  10682. };
  10683. }
  10684. }
  10685. declare module "babylonjs/Actions/condition" {
  10686. import { ActionManager } from "babylonjs/Actions/actionManager";
  10687. /**
  10688. * A Condition applied to an Action
  10689. */
  10690. export class Condition {
  10691. /**
  10692. * Internal only - manager for action
  10693. * @hidden
  10694. */
  10695. _actionManager: ActionManager;
  10696. /**
  10697. * Internal only
  10698. * @hidden
  10699. */
  10700. _evaluationId: number;
  10701. /**
  10702. * Internal only
  10703. * @hidden
  10704. */
  10705. _currentResult: boolean;
  10706. /**
  10707. * Creates a new Condition
  10708. * @param actionManager the manager of the action the condition is applied to
  10709. */
  10710. constructor(actionManager: ActionManager);
  10711. /**
  10712. * Check if the current condition is valid
  10713. * @returns a boolean
  10714. */
  10715. isValid(): boolean;
  10716. /**
  10717. * Internal only
  10718. * @hidden
  10719. */
  10720. _getProperty(propertyPath: string): string;
  10721. /**
  10722. * Internal only
  10723. * @hidden
  10724. */
  10725. _getEffectiveTarget(target: any, propertyPath: string): any;
  10726. /**
  10727. * Serialize placeholder for child classes
  10728. * @returns the serialized object
  10729. */
  10730. serialize(): any;
  10731. /**
  10732. * Internal only
  10733. * @hidden
  10734. */
  10735. protected _serialize(serializedCondition: any): any;
  10736. }
  10737. /**
  10738. * Defines specific conditional operators as extensions of Condition
  10739. */
  10740. export class ValueCondition extends Condition {
  10741. /** path to specify the property of the target the conditional operator uses */
  10742. propertyPath: string;
  10743. /** the value compared by the conditional operator against the current value of the property */
  10744. value: any;
  10745. /** the conditional operator, default ValueCondition.IsEqual */
  10746. operator: number;
  10747. /**
  10748. * Internal only
  10749. * @hidden
  10750. */
  10751. private static _IsEqual;
  10752. /**
  10753. * Internal only
  10754. * @hidden
  10755. */
  10756. private static _IsDifferent;
  10757. /**
  10758. * Internal only
  10759. * @hidden
  10760. */
  10761. private static _IsGreater;
  10762. /**
  10763. * Internal only
  10764. * @hidden
  10765. */
  10766. private static _IsLesser;
  10767. /**
  10768. * returns the number for IsEqual
  10769. */
  10770. static get IsEqual(): number;
  10771. /**
  10772. * Returns the number for IsDifferent
  10773. */
  10774. static get IsDifferent(): number;
  10775. /**
  10776. * Returns the number for IsGreater
  10777. */
  10778. static get IsGreater(): number;
  10779. /**
  10780. * Returns the number for IsLesser
  10781. */
  10782. static get IsLesser(): number;
  10783. /**
  10784. * Internal only The action manager for the condition
  10785. * @hidden
  10786. */
  10787. _actionManager: ActionManager;
  10788. /**
  10789. * Internal only
  10790. * @hidden
  10791. */
  10792. private _target;
  10793. /**
  10794. * Internal only
  10795. * @hidden
  10796. */
  10797. private _effectiveTarget;
  10798. /**
  10799. * Internal only
  10800. * @hidden
  10801. */
  10802. private _property;
  10803. /**
  10804. * Creates a new ValueCondition
  10805. * @param actionManager manager for the action the condition applies to
  10806. * @param target for the action
  10807. * @param propertyPath path to specify the property of the target the conditional operator uses
  10808. * @param value the value compared by the conditional operator against the current value of the property
  10809. * @param operator the conditional operator, default ValueCondition.IsEqual
  10810. */
  10811. constructor(actionManager: ActionManager, target: any,
  10812. /** path to specify the property of the target the conditional operator uses */
  10813. propertyPath: string,
  10814. /** the value compared by the conditional operator against the current value of the property */
  10815. value: any,
  10816. /** the conditional operator, default ValueCondition.IsEqual */
  10817. operator?: number);
  10818. /**
  10819. * Compares the given value with the property value for the specified conditional operator
  10820. * @returns the result of the comparison
  10821. */
  10822. isValid(): boolean;
  10823. /**
  10824. * Serialize the ValueCondition into a JSON compatible object
  10825. * @returns serialization object
  10826. */
  10827. serialize(): any;
  10828. /**
  10829. * Gets the name of the conditional operator for the ValueCondition
  10830. * @param operator the conditional operator
  10831. * @returns the name
  10832. */
  10833. static GetOperatorName(operator: number): string;
  10834. }
  10835. /**
  10836. * Defines a predicate condition as an extension of Condition
  10837. */
  10838. export class PredicateCondition extends Condition {
  10839. /** defines the predicate function used to validate the condition */
  10840. predicate: () => boolean;
  10841. /**
  10842. * Internal only - manager for action
  10843. * @hidden
  10844. */
  10845. _actionManager: ActionManager;
  10846. /**
  10847. * Creates a new PredicateCondition
  10848. * @param actionManager manager for the action the condition applies to
  10849. * @param predicate defines the predicate function used to validate the condition
  10850. */
  10851. constructor(actionManager: ActionManager,
  10852. /** defines the predicate function used to validate the condition */
  10853. predicate: () => boolean);
  10854. /**
  10855. * @returns the validity of the predicate condition
  10856. */
  10857. isValid(): boolean;
  10858. }
  10859. /**
  10860. * Defines a state condition as an extension of Condition
  10861. */
  10862. export class StateCondition extends Condition {
  10863. /** Value to compare with target state */
  10864. value: string;
  10865. /**
  10866. * Internal only - manager for action
  10867. * @hidden
  10868. */
  10869. _actionManager: ActionManager;
  10870. /**
  10871. * Internal only
  10872. * @hidden
  10873. */
  10874. private _target;
  10875. /**
  10876. * Creates a new StateCondition
  10877. * @param actionManager manager for the action the condition applies to
  10878. * @param target of the condition
  10879. * @param value to compare with target state
  10880. */
  10881. constructor(actionManager: ActionManager, target: any,
  10882. /** Value to compare with target state */
  10883. value: string);
  10884. /**
  10885. * Gets a boolean indicating if the current condition is met
  10886. * @returns the validity of the state
  10887. */
  10888. isValid(): boolean;
  10889. /**
  10890. * Serialize the StateCondition into a JSON compatible object
  10891. * @returns serialization object
  10892. */
  10893. serialize(): any;
  10894. }
  10895. }
  10896. declare module "babylonjs/Actions/directActions" {
  10897. import { Action } from "babylonjs/Actions/action";
  10898. import { Condition } from "babylonjs/Actions/condition";
  10899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10900. /**
  10901. * This defines an action responsible to toggle a boolean once triggered.
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10903. */
  10904. export class SwitchBooleanAction extends Action {
  10905. /**
  10906. * The path to the boolean property in the target object
  10907. */
  10908. propertyPath: string;
  10909. private _target;
  10910. private _effectiveTarget;
  10911. private _property;
  10912. /**
  10913. * Instantiate the action
  10914. * @param triggerOptions defines the trigger options
  10915. * @param target defines the object containing the boolean
  10916. * @param propertyPath defines the path to the boolean property in the target object
  10917. * @param condition defines the trigger related conditions
  10918. */
  10919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10920. /** @hidden */
  10921. _prepare(): void;
  10922. /**
  10923. * Execute the action toggle the boolean value.
  10924. */
  10925. execute(): void;
  10926. /**
  10927. * Serializes the actions and its related information.
  10928. * @param parent defines the object to serialize in
  10929. * @returns the serialized object
  10930. */
  10931. serialize(parent: any): any;
  10932. }
  10933. /**
  10934. * This defines an action responsible to set a the state field of the target
  10935. * to a desired value once triggered.
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10937. */
  10938. export class SetStateAction extends Action {
  10939. /**
  10940. * The value to store in the state field.
  10941. */
  10942. value: string;
  10943. private _target;
  10944. /**
  10945. * Instantiate the action
  10946. * @param triggerOptions defines the trigger options
  10947. * @param target defines the object containing the state property
  10948. * @param value defines the value to store in the state field
  10949. * @param condition defines the trigger related conditions
  10950. */
  10951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10952. /**
  10953. * Execute the action and store the value on the target state property.
  10954. */
  10955. execute(): void;
  10956. /**
  10957. * Serializes the actions and its related information.
  10958. * @param parent defines the object to serialize in
  10959. * @returns the serialized object
  10960. */
  10961. serialize(parent: any): any;
  10962. }
  10963. /**
  10964. * This defines an action responsible to set a property of the target
  10965. * to a desired value once triggered.
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10967. */
  10968. export class SetValueAction extends Action {
  10969. /**
  10970. * The path of the property to set in the target.
  10971. */
  10972. propertyPath: string;
  10973. /**
  10974. * The value to set in the property
  10975. */
  10976. value: any;
  10977. private _target;
  10978. private _effectiveTarget;
  10979. private _property;
  10980. /**
  10981. * Instantiate the action
  10982. * @param triggerOptions defines the trigger options
  10983. * @param target defines the object containing the property
  10984. * @param propertyPath defines the path of the property to set in the target
  10985. * @param value defines the value to set in the property
  10986. * @param condition defines the trigger related conditions
  10987. */
  10988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10989. /** @hidden */
  10990. _prepare(): void;
  10991. /**
  10992. * Execute the action and set the targetted property to the desired value.
  10993. */
  10994. execute(): void;
  10995. /**
  10996. * Serializes the actions and its related information.
  10997. * @param parent defines the object to serialize in
  10998. * @returns the serialized object
  10999. */
  11000. serialize(parent: any): any;
  11001. }
  11002. /**
  11003. * This defines an action responsible to increment the target value
  11004. * to a desired value once triggered.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11006. */
  11007. export class IncrementValueAction extends Action {
  11008. /**
  11009. * The path of the property to increment in the target.
  11010. */
  11011. propertyPath: string;
  11012. /**
  11013. * The value we should increment the property by.
  11014. */
  11015. value: any;
  11016. private _target;
  11017. private _effectiveTarget;
  11018. private _property;
  11019. /**
  11020. * Instantiate the action
  11021. * @param triggerOptions defines the trigger options
  11022. * @param target defines the object containing the property
  11023. * @param propertyPath defines the path of the property to increment in the target
  11024. * @param value defines the value value we should increment the property by
  11025. * @param condition defines the trigger related conditions
  11026. */
  11027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11028. /** @hidden */
  11029. _prepare(): void;
  11030. /**
  11031. * Execute the action and increment the target of the value amount.
  11032. */
  11033. execute(): void;
  11034. /**
  11035. * Serializes the actions and its related information.
  11036. * @param parent defines the object to serialize in
  11037. * @returns the serialized object
  11038. */
  11039. serialize(parent: any): any;
  11040. }
  11041. /**
  11042. * This defines an action responsible to start an animation once triggered.
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11044. */
  11045. export class PlayAnimationAction extends Action {
  11046. /**
  11047. * Where the animation should start (animation frame)
  11048. */
  11049. from: number;
  11050. /**
  11051. * Where the animation should stop (animation frame)
  11052. */
  11053. to: number;
  11054. /**
  11055. * Define if the animation should loop or stop after the first play.
  11056. */
  11057. loop?: boolean;
  11058. private _target;
  11059. /**
  11060. * Instantiate the action
  11061. * @param triggerOptions defines the trigger options
  11062. * @param target defines the target animation or animation name
  11063. * @param from defines from where the animation should start (animation frame)
  11064. * @param end defines where the animation should stop (animation frame)
  11065. * @param loop defines if the animation should loop or stop after the first play
  11066. * @param condition defines the trigger related conditions
  11067. */
  11068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11069. /** @hidden */
  11070. _prepare(): void;
  11071. /**
  11072. * Execute the action and play the animation.
  11073. */
  11074. execute(): void;
  11075. /**
  11076. * Serializes the actions and its related information.
  11077. * @param parent defines the object to serialize in
  11078. * @returns the serialized object
  11079. */
  11080. serialize(parent: any): any;
  11081. }
  11082. /**
  11083. * This defines an action responsible to stop an animation once triggered.
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11085. */
  11086. export class StopAnimationAction extends Action {
  11087. private _target;
  11088. /**
  11089. * Instantiate the action
  11090. * @param triggerOptions defines the trigger options
  11091. * @param target defines the target animation or animation name
  11092. * @param condition defines the trigger related conditions
  11093. */
  11094. constructor(triggerOptions: any, target: any, condition?: Condition);
  11095. /** @hidden */
  11096. _prepare(): void;
  11097. /**
  11098. * Execute the action and stop the animation.
  11099. */
  11100. execute(): void;
  11101. /**
  11102. * Serializes the actions and its related information.
  11103. * @param parent defines the object to serialize in
  11104. * @returns the serialized object
  11105. */
  11106. serialize(parent: any): any;
  11107. }
  11108. /**
  11109. * This defines an action responsible that does nothing once triggered.
  11110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11111. */
  11112. export class DoNothingAction extends Action {
  11113. /**
  11114. * Instantiate the action
  11115. * @param triggerOptions defines the trigger options
  11116. * @param condition defines the trigger related conditions
  11117. */
  11118. constructor(triggerOptions?: any, condition?: Condition);
  11119. /**
  11120. * Execute the action and do nothing.
  11121. */
  11122. execute(): void;
  11123. /**
  11124. * Serializes the actions and its related information.
  11125. * @param parent defines the object to serialize in
  11126. * @returns the serialized object
  11127. */
  11128. serialize(parent: any): any;
  11129. }
  11130. /**
  11131. * This defines an action responsible to trigger several actions once triggered.
  11132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11133. */
  11134. export class CombineAction extends Action {
  11135. /**
  11136. * The list of aggregated animations to run.
  11137. */
  11138. children: Action[];
  11139. /**
  11140. * Instantiate the action
  11141. * @param triggerOptions defines the trigger options
  11142. * @param children defines the list of aggregated animations to run
  11143. * @param condition defines the trigger related conditions
  11144. */
  11145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11146. /** @hidden */
  11147. _prepare(): void;
  11148. /**
  11149. * Execute the action and executes all the aggregated actions.
  11150. */
  11151. execute(evt: ActionEvent): void;
  11152. /**
  11153. * Serializes the actions and its related information.
  11154. * @param parent defines the object to serialize in
  11155. * @returns the serialized object
  11156. */
  11157. serialize(parent: any): any;
  11158. }
  11159. /**
  11160. * This defines an action responsible to run code (external event) once triggered.
  11161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11162. */
  11163. export class ExecuteCodeAction extends Action {
  11164. /**
  11165. * The callback function to run.
  11166. */
  11167. func: (evt: ActionEvent) => void;
  11168. /**
  11169. * Instantiate the action
  11170. * @param triggerOptions defines the trigger options
  11171. * @param func defines the callback function to run
  11172. * @param condition defines the trigger related conditions
  11173. */
  11174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11175. /**
  11176. * Execute the action and run the attached code.
  11177. */
  11178. execute(evt: ActionEvent): void;
  11179. }
  11180. /**
  11181. * This defines an action responsible to set the parent property of the target once triggered.
  11182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11183. */
  11184. export class SetParentAction extends Action {
  11185. private _parent;
  11186. private _target;
  11187. /**
  11188. * Instantiate the action
  11189. * @param triggerOptions defines the trigger options
  11190. * @param target defines the target containing the parent property
  11191. * @param parent defines from where the animation should start (animation frame)
  11192. * @param condition defines the trigger related conditions
  11193. */
  11194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11195. /** @hidden */
  11196. _prepare(): void;
  11197. /**
  11198. * Execute the action and set the parent property.
  11199. */
  11200. execute(): void;
  11201. /**
  11202. * Serializes the actions and its related information.
  11203. * @param parent defines the object to serialize in
  11204. * @returns the serialized object
  11205. */
  11206. serialize(parent: any): any;
  11207. }
  11208. }
  11209. declare module "babylonjs/Actions/actionManager" {
  11210. import { Nullable } from "babylonjs/types";
  11211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11212. import { Scene } from "babylonjs/scene";
  11213. import { IAction } from "babylonjs/Actions/action";
  11214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11216. /**
  11217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11220. */
  11221. export class ActionManager extends AbstractActionManager {
  11222. /**
  11223. * Nothing
  11224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11225. */
  11226. static readonly NothingTrigger: number;
  11227. /**
  11228. * On pick
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11230. */
  11231. static readonly OnPickTrigger: number;
  11232. /**
  11233. * On left pick
  11234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11235. */
  11236. static readonly OnLeftPickTrigger: number;
  11237. /**
  11238. * On right pick
  11239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11240. */
  11241. static readonly OnRightPickTrigger: number;
  11242. /**
  11243. * On center pick
  11244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11245. */
  11246. static readonly OnCenterPickTrigger: number;
  11247. /**
  11248. * On pick down
  11249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11250. */
  11251. static readonly OnPickDownTrigger: number;
  11252. /**
  11253. * On double pick
  11254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11255. */
  11256. static readonly OnDoublePickTrigger: number;
  11257. /**
  11258. * On pick up
  11259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11260. */
  11261. static readonly OnPickUpTrigger: number;
  11262. /**
  11263. * On pick out.
  11264. * This trigger will only be raised if you also declared a OnPickDown
  11265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11266. */
  11267. static readonly OnPickOutTrigger: number;
  11268. /**
  11269. * On long press
  11270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11271. */
  11272. static readonly OnLongPressTrigger: number;
  11273. /**
  11274. * On pointer over
  11275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11276. */
  11277. static readonly OnPointerOverTrigger: number;
  11278. /**
  11279. * On pointer out
  11280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11281. */
  11282. static readonly OnPointerOutTrigger: number;
  11283. /**
  11284. * On every frame
  11285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11286. */
  11287. static readonly OnEveryFrameTrigger: number;
  11288. /**
  11289. * On intersection enter
  11290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11291. */
  11292. static readonly OnIntersectionEnterTrigger: number;
  11293. /**
  11294. * On intersection exit
  11295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11296. */
  11297. static readonly OnIntersectionExitTrigger: number;
  11298. /**
  11299. * On key down
  11300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11301. */
  11302. static readonly OnKeyDownTrigger: number;
  11303. /**
  11304. * On key up
  11305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11306. */
  11307. static readonly OnKeyUpTrigger: number;
  11308. private _scene;
  11309. /**
  11310. * Creates a new action manager
  11311. * @param scene defines the hosting scene
  11312. */
  11313. constructor(scene: Scene);
  11314. /**
  11315. * Releases all associated resources
  11316. */
  11317. dispose(): void;
  11318. /**
  11319. * Gets hosting scene
  11320. * @returns the hosting scene
  11321. */
  11322. getScene(): Scene;
  11323. /**
  11324. * Does this action manager handles actions of any of the given triggers
  11325. * @param triggers defines the triggers to be tested
  11326. * @return a boolean indicating whether one (or more) of the triggers is handled
  11327. */
  11328. hasSpecificTriggers(triggers: number[]): boolean;
  11329. /**
  11330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11331. * speed.
  11332. * @param triggerA defines the trigger to be tested
  11333. * @param triggerB defines the trigger to be tested
  11334. * @return a boolean indicating whether one (or more) of the triggers is handled
  11335. */
  11336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11337. /**
  11338. * Does this action manager handles actions of a given trigger
  11339. * @param trigger defines the trigger to be tested
  11340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11341. * @return whether the trigger is handled
  11342. */
  11343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11344. /**
  11345. * Does this action manager has pointer triggers
  11346. */
  11347. get hasPointerTriggers(): boolean;
  11348. /**
  11349. * Does this action manager has pick triggers
  11350. */
  11351. get hasPickTriggers(): boolean;
  11352. /**
  11353. * Registers an action to this action manager
  11354. * @param action defines the action to be registered
  11355. * @return the action amended (prepared) after registration
  11356. */
  11357. registerAction(action: IAction): Nullable<IAction>;
  11358. /**
  11359. * Unregisters an action to this action manager
  11360. * @param action defines the action to be unregistered
  11361. * @return a boolean indicating whether the action has been unregistered
  11362. */
  11363. unregisterAction(action: IAction): Boolean;
  11364. /**
  11365. * Process a specific trigger
  11366. * @param trigger defines the trigger to process
  11367. * @param evt defines the event details to be processed
  11368. */
  11369. processTrigger(trigger: number, evt?: IActionEvent): void;
  11370. /** @hidden */
  11371. _getEffectiveTarget(target: any, propertyPath: string): any;
  11372. /** @hidden */
  11373. _getProperty(propertyPath: string): string;
  11374. /**
  11375. * Serialize this manager to a JSON object
  11376. * @param name defines the property name to store this manager
  11377. * @returns a JSON representation of this manager
  11378. */
  11379. serialize(name: string): any;
  11380. /**
  11381. * Creates a new ActionManager from a JSON data
  11382. * @param parsedActions defines the JSON data to read from
  11383. * @param object defines the hosting mesh
  11384. * @param scene defines the hosting scene
  11385. */
  11386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11387. /**
  11388. * Get a trigger name by index
  11389. * @param trigger defines the trigger index
  11390. * @returns a trigger name
  11391. */
  11392. static GetTriggerName(trigger: number): string;
  11393. }
  11394. }
  11395. declare module "babylonjs/Culling/ray" {
  11396. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11397. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11399. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11400. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11401. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11402. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11403. import { Plane } from "babylonjs/Maths/math.plane";
  11404. /**
  11405. * Class representing a ray with position and direction
  11406. */
  11407. export class Ray {
  11408. /** origin point */
  11409. origin: Vector3;
  11410. /** direction */
  11411. direction: Vector3;
  11412. /** length of the ray */
  11413. length: number;
  11414. private static readonly TmpVector3;
  11415. private _tmpRay;
  11416. /**
  11417. * Creates a new ray
  11418. * @param origin origin point
  11419. * @param direction direction
  11420. * @param length length of the ray
  11421. */
  11422. constructor(
  11423. /** origin point */
  11424. origin: Vector3,
  11425. /** direction */
  11426. direction: Vector3,
  11427. /** length of the ray */
  11428. length?: number);
  11429. /**
  11430. * Checks if the ray intersects a box
  11431. * @param minimum bound of the box
  11432. * @param maximum bound of the box
  11433. * @param intersectionTreshold extra extend to be added to the box in all direction
  11434. * @returns if the box was hit
  11435. */
  11436. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11437. /**
  11438. * Checks if the ray intersects a box
  11439. * @param box the bounding box to check
  11440. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11441. * @returns if the box was hit
  11442. */
  11443. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11444. /**
  11445. * If the ray hits a sphere
  11446. * @param sphere the bounding sphere to check
  11447. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11448. * @returns true if it hits the sphere
  11449. */
  11450. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11451. /**
  11452. * If the ray hits a triange
  11453. * @param vertex0 triangle vertex
  11454. * @param vertex1 triangle vertex
  11455. * @param vertex2 triangle vertex
  11456. * @returns intersection information if hit
  11457. */
  11458. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11459. /**
  11460. * Checks if ray intersects a plane
  11461. * @param plane the plane to check
  11462. * @returns the distance away it was hit
  11463. */
  11464. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11465. /**
  11466. * Calculate the intercept of a ray on a given axis
  11467. * @param axis to check 'x' | 'y' | 'z'
  11468. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11469. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11470. */
  11471. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11472. /**
  11473. * Checks if ray intersects a mesh
  11474. * @param mesh the mesh to check
  11475. * @param fastCheck if only the bounding box should checked
  11476. * @returns picking info of the intersecton
  11477. */
  11478. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11479. /**
  11480. * Checks if ray intersects a mesh
  11481. * @param meshes the meshes to check
  11482. * @param fastCheck if only the bounding box should checked
  11483. * @param results array to store result in
  11484. * @returns Array of picking infos
  11485. */
  11486. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11487. private _comparePickingInfo;
  11488. private static smallnum;
  11489. private static rayl;
  11490. /**
  11491. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11492. * @param sega the first point of the segment to test the intersection against
  11493. * @param segb the second point of the segment to test the intersection against
  11494. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11495. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11496. */
  11497. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11498. /**
  11499. * Update the ray from viewport position
  11500. * @param x position
  11501. * @param y y position
  11502. * @param viewportWidth viewport width
  11503. * @param viewportHeight viewport height
  11504. * @param world world matrix
  11505. * @param view view matrix
  11506. * @param projection projection matrix
  11507. * @returns this ray updated
  11508. */
  11509. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11510. /**
  11511. * Creates a ray with origin and direction of 0,0,0
  11512. * @returns the new ray
  11513. */
  11514. static Zero(): Ray;
  11515. /**
  11516. * Creates a new ray from screen space and viewport
  11517. * @param x position
  11518. * @param y y position
  11519. * @param viewportWidth viewport width
  11520. * @param viewportHeight viewport height
  11521. * @param world world matrix
  11522. * @param view view matrix
  11523. * @param projection projection matrix
  11524. * @returns new ray
  11525. */
  11526. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11527. /**
  11528. * 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
  11529. * transformed to the given world matrix.
  11530. * @param origin The origin point
  11531. * @param end The end point
  11532. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11533. * @returns the new ray
  11534. */
  11535. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11536. /**
  11537. * Transforms a ray by a matrix
  11538. * @param ray ray to transform
  11539. * @param matrix matrix to apply
  11540. * @returns the resulting new ray
  11541. */
  11542. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11543. /**
  11544. * Transforms a ray by a matrix
  11545. * @param ray ray to transform
  11546. * @param matrix matrix to apply
  11547. * @param result ray to store result in
  11548. */
  11549. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11550. /**
  11551. * Unproject a ray from screen space to object space
  11552. * @param sourceX defines the screen space x coordinate to use
  11553. * @param sourceY defines the screen space y coordinate to use
  11554. * @param viewportWidth defines the current width of the viewport
  11555. * @param viewportHeight defines the current height of the viewport
  11556. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11557. * @param view defines the view matrix to use
  11558. * @param projection defines the projection matrix to use
  11559. */
  11560. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11561. }
  11562. /**
  11563. * Type used to define predicate used to select faces when a mesh intersection is detected
  11564. */
  11565. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11566. module "babylonjs/scene" {
  11567. interface Scene {
  11568. /** @hidden */
  11569. _tempPickingRay: Nullable<Ray>;
  11570. /** @hidden */
  11571. _cachedRayForTransform: Ray;
  11572. /** @hidden */
  11573. _pickWithRayInverseMatrix: Matrix;
  11574. /** @hidden */
  11575. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11576. /** @hidden */
  11577. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11578. }
  11579. }
  11580. }
  11581. declare module "babylonjs/sceneComponent" {
  11582. import { Scene } from "babylonjs/scene";
  11583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11584. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11585. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11586. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11587. import { Nullable } from "babylonjs/types";
  11588. import { Camera } from "babylonjs/Cameras/camera";
  11589. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11590. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11591. import { AbstractScene } from "babylonjs/abstractScene";
  11592. import { Mesh } from "babylonjs/Meshes/mesh";
  11593. /**
  11594. * Groups all the scene component constants in one place to ease maintenance.
  11595. * @hidden
  11596. */
  11597. export class SceneComponentConstants {
  11598. static readonly NAME_EFFECTLAYER: string;
  11599. static readonly NAME_LAYER: string;
  11600. static readonly NAME_LENSFLARESYSTEM: string;
  11601. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11602. static readonly NAME_PARTICLESYSTEM: string;
  11603. static readonly NAME_GAMEPAD: string;
  11604. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11605. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11606. static readonly NAME_DEPTHRENDERER: string;
  11607. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11608. static readonly NAME_SPRITE: string;
  11609. static readonly NAME_OUTLINERENDERER: string;
  11610. static readonly NAME_PROCEDURALTEXTURE: string;
  11611. static readonly NAME_SHADOWGENERATOR: string;
  11612. static readonly NAME_OCTREE: string;
  11613. static readonly NAME_PHYSICSENGINE: string;
  11614. static readonly NAME_AUDIO: string;
  11615. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11616. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11617. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11618. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11619. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11620. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11621. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11622. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11623. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11624. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11625. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11626. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11627. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11628. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11629. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11630. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11631. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11632. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11633. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11634. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11635. static readonly STEP_AFTERRENDER_AUDIO: number;
  11636. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11637. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11638. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11639. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11640. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11641. static readonly STEP_POINTERMOVE_SPRITE: number;
  11642. static readonly STEP_POINTERDOWN_SPRITE: number;
  11643. static readonly STEP_POINTERUP_SPRITE: number;
  11644. }
  11645. /**
  11646. * This represents a scene component.
  11647. *
  11648. * This is used to decouple the dependency the scene is having on the different workloads like
  11649. * layers, post processes...
  11650. */
  11651. export interface ISceneComponent {
  11652. /**
  11653. * The name of the component. Each component must have a unique name.
  11654. */
  11655. name: string;
  11656. /**
  11657. * The scene the component belongs to.
  11658. */
  11659. scene: Scene;
  11660. /**
  11661. * Register the component to one instance of a scene.
  11662. */
  11663. register(): void;
  11664. /**
  11665. * Rebuilds the elements related to this component in case of
  11666. * context lost for instance.
  11667. */
  11668. rebuild(): void;
  11669. /**
  11670. * Disposes the component and the associated ressources.
  11671. */
  11672. dispose(): void;
  11673. }
  11674. /**
  11675. * This represents a SERIALIZABLE scene component.
  11676. *
  11677. * This extends Scene Component to add Serialization methods on top.
  11678. */
  11679. export interface ISceneSerializableComponent extends ISceneComponent {
  11680. /**
  11681. * Adds all the elements from the container to the scene
  11682. * @param container the container holding the elements
  11683. */
  11684. addFromContainer(container: AbstractScene): void;
  11685. /**
  11686. * Removes all the elements in the container from the scene
  11687. * @param container contains the elements to remove
  11688. * @param dispose if the removed element should be disposed (default: false)
  11689. */
  11690. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11691. /**
  11692. * Serializes the component data to the specified json object
  11693. * @param serializationObject The object to serialize to
  11694. */
  11695. serialize(serializationObject: any): void;
  11696. }
  11697. /**
  11698. * Strong typing of a Mesh related stage step action
  11699. */
  11700. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11701. /**
  11702. * Strong typing of a Evaluate Sub Mesh related stage step action
  11703. */
  11704. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11705. /**
  11706. * Strong typing of a Active Mesh related stage step action
  11707. */
  11708. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11709. /**
  11710. * Strong typing of a Camera related stage step action
  11711. */
  11712. export type CameraStageAction = (camera: Camera) => void;
  11713. /**
  11714. * Strong typing of a Camera Frame buffer related stage step action
  11715. */
  11716. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11717. /**
  11718. * Strong typing of a Render Target related stage step action
  11719. */
  11720. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11721. /**
  11722. * Strong typing of a RenderingGroup related stage step action
  11723. */
  11724. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11725. /**
  11726. * Strong typing of a Mesh Render related stage step action
  11727. */
  11728. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11729. /**
  11730. * Strong typing of a simple stage step action
  11731. */
  11732. export type SimpleStageAction = () => void;
  11733. /**
  11734. * Strong typing of a render target action.
  11735. */
  11736. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11737. /**
  11738. * Strong typing of a pointer move action.
  11739. */
  11740. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11741. /**
  11742. * Strong typing of a pointer up/down action.
  11743. */
  11744. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11745. /**
  11746. * Representation of a stage in the scene (Basically a list of ordered steps)
  11747. * @hidden
  11748. */
  11749. export class Stage<T extends Function> extends Array<{
  11750. index: number;
  11751. component: ISceneComponent;
  11752. action: T;
  11753. }> {
  11754. /**
  11755. * Hide ctor from the rest of the world.
  11756. * @param items The items to add.
  11757. */
  11758. private constructor();
  11759. /**
  11760. * Creates a new Stage.
  11761. * @returns A new instance of a Stage
  11762. */
  11763. static Create<T extends Function>(): Stage<T>;
  11764. /**
  11765. * Registers a step in an ordered way in the targeted stage.
  11766. * @param index Defines the position to register the step in
  11767. * @param component Defines the component attached to the step
  11768. * @param action Defines the action to launch during the step
  11769. */
  11770. registerStep(index: number, component: ISceneComponent, action: T): void;
  11771. /**
  11772. * Clears all the steps from the stage.
  11773. */
  11774. clear(): void;
  11775. }
  11776. }
  11777. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11778. import { Nullable } from "babylonjs/types";
  11779. import { Observable } from "babylonjs/Misc/observable";
  11780. import { Scene } from "babylonjs/scene";
  11781. import { Sprite } from "babylonjs/Sprites/sprite";
  11782. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11783. import { Ray } from "babylonjs/Culling/ray";
  11784. import { Camera } from "babylonjs/Cameras/camera";
  11785. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11786. import { ISceneComponent } from "babylonjs/sceneComponent";
  11787. module "babylonjs/scene" {
  11788. interface Scene {
  11789. /** @hidden */
  11790. _pointerOverSprite: Nullable<Sprite>;
  11791. /** @hidden */
  11792. _pickedDownSprite: Nullable<Sprite>;
  11793. /** @hidden */
  11794. _tempSpritePickingRay: Nullable<Ray>;
  11795. /**
  11796. * All of the sprite managers added to this scene
  11797. * @see http://doc.babylonjs.com/babylon101/sprites
  11798. */
  11799. spriteManagers: Array<ISpriteManager>;
  11800. /**
  11801. * An event triggered when sprites rendering is about to start
  11802. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11803. */
  11804. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11805. /**
  11806. * An event triggered when sprites rendering is done
  11807. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11808. */
  11809. onAfterSpritesRenderingObservable: Observable<Scene>;
  11810. /** @hidden */
  11811. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11812. /** Launch a ray to try to pick a sprite in the scene
  11813. * @param x position on screen
  11814. * @param y position on screen
  11815. * @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
  11816. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11817. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11818. * @returns a PickingInfo
  11819. */
  11820. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11821. /** Use the given ray to pick a sprite in the scene
  11822. * @param ray The ray (in world space) to use to pick meshes
  11823. * @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
  11824. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11825. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11826. * @returns a PickingInfo
  11827. */
  11828. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11829. /** @hidden */
  11830. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11831. /** Launch a ray to try to pick sprites in the scene
  11832. * @param x position on screen
  11833. * @param y position on screen
  11834. * @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
  11835. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11836. * @returns a PickingInfo array
  11837. */
  11838. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11839. /** Use the given ray to pick sprites in the scene
  11840. * @param ray The ray (in world space) to use to pick meshes
  11841. * @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
  11842. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11843. * @returns a PickingInfo array
  11844. */
  11845. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11846. /**
  11847. * Force the sprite under the pointer
  11848. * @param sprite defines the sprite to use
  11849. */
  11850. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11851. /**
  11852. * Gets the sprite under the pointer
  11853. * @returns a Sprite or null if no sprite is under the pointer
  11854. */
  11855. getPointerOverSprite(): Nullable<Sprite>;
  11856. }
  11857. }
  11858. /**
  11859. * Defines the sprite scene component responsible to manage sprites
  11860. * in a given scene.
  11861. */
  11862. export class SpriteSceneComponent implements ISceneComponent {
  11863. /**
  11864. * The component name helpfull to identify the component in the list of scene components.
  11865. */
  11866. readonly name: string;
  11867. /**
  11868. * The scene the component belongs to.
  11869. */
  11870. scene: Scene;
  11871. /** @hidden */
  11872. private _spritePredicate;
  11873. /**
  11874. * Creates a new instance of the component for the given scene
  11875. * @param scene Defines the scene to register the component in
  11876. */
  11877. constructor(scene: Scene);
  11878. /**
  11879. * Registers the component in a given scene
  11880. */
  11881. register(): void;
  11882. /**
  11883. * Rebuilds the elements related to this component in case of
  11884. * context lost for instance.
  11885. */
  11886. rebuild(): void;
  11887. /**
  11888. * Disposes the component and the associated ressources.
  11889. */
  11890. dispose(): void;
  11891. private _pickSpriteButKeepRay;
  11892. private _pointerMove;
  11893. private _pointerDown;
  11894. private _pointerUp;
  11895. }
  11896. }
  11897. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11898. /** @hidden */
  11899. export var fogFragmentDeclaration: {
  11900. name: string;
  11901. shader: string;
  11902. };
  11903. }
  11904. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11905. /** @hidden */
  11906. export var fogFragment: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module "babylonjs/Shaders/sprites.fragment" {
  11912. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11913. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11914. /** @hidden */
  11915. export var spritesPixelShader: {
  11916. name: string;
  11917. shader: string;
  11918. };
  11919. }
  11920. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11921. /** @hidden */
  11922. export var fogVertexDeclaration: {
  11923. name: string;
  11924. shader: string;
  11925. };
  11926. }
  11927. declare module "babylonjs/Shaders/sprites.vertex" {
  11928. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11929. /** @hidden */
  11930. export var spritesVertexShader: {
  11931. name: string;
  11932. shader: string;
  11933. };
  11934. }
  11935. declare module "babylonjs/Sprites/spriteManager" {
  11936. import { IDisposable, Scene } from "babylonjs/scene";
  11937. import { Nullable } from "babylonjs/types";
  11938. import { Observable } from "babylonjs/Misc/observable";
  11939. import { Sprite } from "babylonjs/Sprites/sprite";
  11940. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11941. import { Camera } from "babylonjs/Cameras/camera";
  11942. import { Texture } from "babylonjs/Materials/Textures/texture";
  11943. import "babylonjs/Shaders/sprites.fragment";
  11944. import "babylonjs/Shaders/sprites.vertex";
  11945. import { Ray } from "babylonjs/Culling/ray";
  11946. /**
  11947. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11948. */
  11949. export interface ISpriteManager extends IDisposable {
  11950. /**
  11951. * Restricts the camera to viewing objects with the same layerMask.
  11952. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11953. */
  11954. layerMask: number;
  11955. /**
  11956. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11957. */
  11958. isPickable: boolean;
  11959. /**
  11960. * Specifies the rendering group id for this mesh (0 by default)
  11961. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11962. */
  11963. renderingGroupId: number;
  11964. /**
  11965. * Defines the list of sprites managed by the manager.
  11966. */
  11967. sprites: Array<Sprite>;
  11968. /**
  11969. * Tests the intersection of a sprite with a specific ray.
  11970. * @param ray The ray we are sending to test the collision
  11971. * @param camera The camera space we are sending rays in
  11972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11973. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11974. * @returns picking info or null.
  11975. */
  11976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11977. /**
  11978. * Intersects the sprites with a ray
  11979. * @param ray defines the ray to intersect with
  11980. * @param camera defines the current active camera
  11981. * @param predicate defines a predicate used to select candidate sprites
  11982. * @returns null if no hit or a PickingInfo array
  11983. */
  11984. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11985. /**
  11986. * Renders the list of sprites on screen.
  11987. */
  11988. render(): void;
  11989. }
  11990. /**
  11991. * Class used to manage multiple sprites on the same spritesheet
  11992. * @see http://doc.babylonjs.com/babylon101/sprites
  11993. */
  11994. export class SpriteManager implements ISpriteManager {
  11995. /** defines the manager's name */
  11996. name: string;
  11997. /** Gets the list of sprites */
  11998. sprites: Sprite[];
  11999. /** Gets or sets the rendering group id (0 by default) */
  12000. renderingGroupId: number;
  12001. /** Gets or sets camera layer mask */
  12002. layerMask: number;
  12003. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12004. fogEnabled: boolean;
  12005. /** Gets or sets a boolean indicating if the sprites are pickable */
  12006. isPickable: boolean;
  12007. /** Defines the default width of a cell in the spritesheet */
  12008. cellWidth: number;
  12009. /** Defines the default height of a cell in the spritesheet */
  12010. cellHeight: number;
  12011. /** Associative array from JSON sprite data file */
  12012. private _cellData;
  12013. /** Array of sprite names from JSON sprite data file */
  12014. private _spriteMap;
  12015. /** True when packed cell data from JSON file is ready*/
  12016. private _packedAndReady;
  12017. /**
  12018. * An event triggered when the manager is disposed.
  12019. */
  12020. onDisposeObservable: Observable<SpriteManager>;
  12021. private _onDisposeObserver;
  12022. /**
  12023. * Callback called when the manager is disposed
  12024. */
  12025. set onDispose(callback: () => void);
  12026. private _capacity;
  12027. private _fromPacked;
  12028. private _spriteTexture;
  12029. private _epsilon;
  12030. private _scene;
  12031. private _vertexData;
  12032. private _buffer;
  12033. private _vertexBuffers;
  12034. private _indexBuffer;
  12035. private _effectBase;
  12036. private _effectFog;
  12037. /**
  12038. * Gets or sets the spritesheet texture
  12039. */
  12040. get texture(): Texture;
  12041. set texture(value: Texture);
  12042. /**
  12043. * Creates a new sprite manager
  12044. * @param name defines the manager's name
  12045. * @param imgUrl defines the sprite sheet url
  12046. * @param capacity defines the maximum allowed number of sprites
  12047. * @param cellSize defines the size of a sprite cell
  12048. * @param scene defines the hosting scene
  12049. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12050. * @param samplingMode defines the smapling mode to use with spritesheet
  12051. * @param fromPacked set to false; do not alter
  12052. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  12053. */
  12054. constructor(
  12055. /** defines the manager's name */
  12056. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  12057. private _makePacked;
  12058. private _appendSpriteVertex;
  12059. /**
  12060. * Intersects the sprites with a ray
  12061. * @param ray defines the ray to intersect with
  12062. * @param camera defines the current active camera
  12063. * @param predicate defines a predicate used to select candidate sprites
  12064. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12065. * @returns null if no hit or a PickingInfo
  12066. */
  12067. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12068. /**
  12069. * Intersects the sprites with a ray
  12070. * @param ray defines the ray to intersect with
  12071. * @param camera defines the current active camera
  12072. * @param predicate defines a predicate used to select candidate sprites
  12073. * @returns null if no hit or a PickingInfo array
  12074. */
  12075. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12076. /**
  12077. * Render all child sprites
  12078. */
  12079. render(): void;
  12080. /**
  12081. * Release associated resources
  12082. */
  12083. dispose(): void;
  12084. }
  12085. }
  12086. declare module "babylonjs/Sprites/sprite" {
  12087. import { Vector3 } from "babylonjs/Maths/math.vector";
  12088. import { Nullable } from "babylonjs/types";
  12089. import { ActionManager } from "babylonjs/Actions/actionManager";
  12090. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12091. import { Color4 } from "babylonjs/Maths/math.color";
  12092. /**
  12093. * Class used to represent a sprite
  12094. * @see http://doc.babylonjs.com/babylon101/sprites
  12095. */
  12096. export class Sprite {
  12097. /** defines the name */
  12098. name: string;
  12099. /** Gets or sets the current world position */
  12100. position: Vector3;
  12101. /** Gets or sets the main color */
  12102. color: Color4;
  12103. /** Gets or sets the width */
  12104. width: number;
  12105. /** Gets or sets the height */
  12106. height: number;
  12107. /** Gets or sets rotation angle */
  12108. angle: number;
  12109. /** Gets or sets the cell index in the sprite sheet */
  12110. cellIndex: number;
  12111. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12112. cellRef: string;
  12113. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12114. invertU: number;
  12115. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12116. invertV: number;
  12117. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12118. disposeWhenFinishedAnimating: boolean;
  12119. /** Gets the list of attached animations */
  12120. animations: Animation[];
  12121. /** Gets or sets a boolean indicating if the sprite can be picked */
  12122. isPickable: boolean;
  12123. /**
  12124. * Gets or sets the associated action manager
  12125. */
  12126. actionManager: Nullable<ActionManager>;
  12127. private _animationStarted;
  12128. private _loopAnimation;
  12129. private _fromIndex;
  12130. private _toIndex;
  12131. private _delay;
  12132. private _direction;
  12133. private _manager;
  12134. private _time;
  12135. private _onAnimationEnd;
  12136. /**
  12137. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12138. */
  12139. isVisible: boolean;
  12140. /**
  12141. * Gets or sets the sprite size
  12142. */
  12143. get size(): number;
  12144. set size(value: number);
  12145. /**
  12146. * Creates a new Sprite
  12147. * @param name defines the name
  12148. * @param manager defines the manager
  12149. */
  12150. constructor(
  12151. /** defines the name */
  12152. name: string, manager: ISpriteManager);
  12153. /**
  12154. * Starts an animation
  12155. * @param from defines the initial key
  12156. * @param to defines the end key
  12157. * @param loop defines if the animation must loop
  12158. * @param delay defines the start delay (in ms)
  12159. * @param onAnimationEnd defines a callback to call when animation ends
  12160. */
  12161. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12162. /** Stops current animation (if any) */
  12163. stopAnimation(): void;
  12164. /** @hidden */
  12165. _animate(deltaTime: number): void;
  12166. /** Release associated resources */
  12167. dispose(): void;
  12168. }
  12169. }
  12170. declare module "babylonjs/Collisions/pickingInfo" {
  12171. import { Nullable } from "babylonjs/types";
  12172. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12174. import { Sprite } from "babylonjs/Sprites/sprite";
  12175. import { Ray } from "babylonjs/Culling/ray";
  12176. /**
  12177. * Information about the result of picking within a scene
  12178. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12179. */
  12180. export class PickingInfo {
  12181. /** @hidden */
  12182. _pickingUnavailable: boolean;
  12183. /**
  12184. * If the pick collided with an object
  12185. */
  12186. hit: boolean;
  12187. /**
  12188. * Distance away where the pick collided
  12189. */
  12190. distance: number;
  12191. /**
  12192. * The location of pick collision
  12193. */
  12194. pickedPoint: Nullable<Vector3>;
  12195. /**
  12196. * The mesh corresponding the the pick collision
  12197. */
  12198. pickedMesh: Nullable<AbstractMesh>;
  12199. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12200. bu: number;
  12201. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12202. bv: number;
  12203. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12204. faceId: number;
  12205. /** Id of the the submesh that was picked */
  12206. subMeshId: number;
  12207. /** If a sprite was picked, this will be the sprite the pick collided with */
  12208. pickedSprite: Nullable<Sprite>;
  12209. /**
  12210. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12211. */
  12212. originMesh: Nullable<AbstractMesh>;
  12213. /**
  12214. * The ray that was used to perform the picking.
  12215. */
  12216. ray: Nullable<Ray>;
  12217. /**
  12218. * Gets the normal correspodning to the face the pick collided with
  12219. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12220. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12221. * @returns The normal correspodning to the face the pick collided with
  12222. */
  12223. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12224. /**
  12225. * Gets the texture coordinates of where the pick occured
  12226. * @returns the vector containing the coordnates of the texture
  12227. */
  12228. getTextureCoordinates(): Nullable<Vector2>;
  12229. }
  12230. }
  12231. declare module "babylonjs/Events/pointerEvents" {
  12232. import { Nullable } from "babylonjs/types";
  12233. import { Vector2 } from "babylonjs/Maths/math.vector";
  12234. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12235. import { Ray } from "babylonjs/Culling/ray";
  12236. /**
  12237. * Gather the list of pointer event types as constants.
  12238. */
  12239. export class PointerEventTypes {
  12240. /**
  12241. * 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.
  12242. */
  12243. static readonly POINTERDOWN: number;
  12244. /**
  12245. * The pointerup event is fired when a pointer is no longer active.
  12246. */
  12247. static readonly POINTERUP: number;
  12248. /**
  12249. * The pointermove event is fired when a pointer changes coordinates.
  12250. */
  12251. static readonly POINTERMOVE: number;
  12252. /**
  12253. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12254. */
  12255. static readonly POINTERWHEEL: number;
  12256. /**
  12257. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12258. */
  12259. static readonly POINTERPICK: number;
  12260. /**
  12261. * The pointertap event is fired when a the object has been touched and released without drag.
  12262. */
  12263. static readonly POINTERTAP: number;
  12264. /**
  12265. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12266. */
  12267. static readonly POINTERDOUBLETAP: number;
  12268. }
  12269. /**
  12270. * Base class of pointer info types.
  12271. */
  12272. export class PointerInfoBase {
  12273. /**
  12274. * Defines the type of event (PointerEventTypes)
  12275. */
  12276. type: number;
  12277. /**
  12278. * Defines the related dom event
  12279. */
  12280. event: PointerEvent | MouseWheelEvent;
  12281. /**
  12282. * Instantiates the base class of pointers info.
  12283. * @param type Defines the type of event (PointerEventTypes)
  12284. * @param event Defines the related dom event
  12285. */
  12286. constructor(
  12287. /**
  12288. * Defines the type of event (PointerEventTypes)
  12289. */
  12290. type: number,
  12291. /**
  12292. * Defines the related dom event
  12293. */
  12294. event: PointerEvent | MouseWheelEvent);
  12295. }
  12296. /**
  12297. * This class is used to store pointer related info for the onPrePointerObservable event.
  12298. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12299. */
  12300. export class PointerInfoPre extends PointerInfoBase {
  12301. /**
  12302. * Ray from a pointer if availible (eg. 6dof controller)
  12303. */
  12304. ray: Nullable<Ray>;
  12305. /**
  12306. * Defines the local position of the pointer on the canvas.
  12307. */
  12308. localPosition: Vector2;
  12309. /**
  12310. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12311. */
  12312. skipOnPointerObservable: boolean;
  12313. /**
  12314. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12315. * @param type Defines the type of event (PointerEventTypes)
  12316. * @param event Defines the related dom event
  12317. * @param localX Defines the local x coordinates of the pointer when the event occured
  12318. * @param localY Defines the local y coordinates of the pointer when the event occured
  12319. */
  12320. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12321. }
  12322. /**
  12323. * This type contains all the data related to a pointer event in Babylon.js.
  12324. * 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.
  12325. */
  12326. export class PointerInfo extends PointerInfoBase {
  12327. /**
  12328. * Defines the picking info associated to the info (if any)\
  12329. */
  12330. pickInfo: Nullable<PickingInfo>;
  12331. /**
  12332. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12333. * @param type Defines the type of event (PointerEventTypes)
  12334. * @param event Defines the related dom event
  12335. * @param pickInfo Defines the picking info associated to the info (if any)\
  12336. */
  12337. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12338. /**
  12339. * Defines the picking info associated to the info (if any)\
  12340. */
  12341. pickInfo: Nullable<PickingInfo>);
  12342. }
  12343. /**
  12344. * Data relating to a touch event on the screen.
  12345. */
  12346. export interface PointerTouch {
  12347. /**
  12348. * X coordinate of touch.
  12349. */
  12350. x: number;
  12351. /**
  12352. * Y coordinate of touch.
  12353. */
  12354. y: number;
  12355. /**
  12356. * Id of touch. Unique for each finger.
  12357. */
  12358. pointerId: number;
  12359. /**
  12360. * Event type passed from DOM.
  12361. */
  12362. type: any;
  12363. }
  12364. }
  12365. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12366. import { Observable } from "babylonjs/Misc/observable";
  12367. import { Nullable } from "babylonjs/types";
  12368. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12369. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12370. /**
  12371. * Manage the mouse inputs to control the movement of a free camera.
  12372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12373. */
  12374. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12375. /**
  12376. * Define if touch is enabled in the mouse input
  12377. */
  12378. touchEnabled: boolean;
  12379. /**
  12380. * Defines the camera the input is attached to.
  12381. */
  12382. camera: FreeCamera;
  12383. /**
  12384. * Defines the buttons associated with the input to handle camera move.
  12385. */
  12386. buttons: number[];
  12387. /**
  12388. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12389. */
  12390. angularSensibility: number;
  12391. private _pointerInput;
  12392. private _onMouseMove;
  12393. private _observer;
  12394. private previousPosition;
  12395. /**
  12396. * Observable for when a pointer move event occurs containing the move offset
  12397. */
  12398. onPointerMovedObservable: Observable<{
  12399. offsetX: number;
  12400. offsetY: number;
  12401. }>;
  12402. /**
  12403. * @hidden
  12404. * If the camera should be rotated automatically based on pointer movement
  12405. */
  12406. _allowCameraRotation: boolean;
  12407. /**
  12408. * Manage the mouse inputs to control the movement of a free camera.
  12409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12410. * @param touchEnabled Defines if touch is enabled or not
  12411. */
  12412. constructor(
  12413. /**
  12414. * Define if touch is enabled in the mouse input
  12415. */
  12416. touchEnabled?: boolean);
  12417. /**
  12418. * Attach the input controls to a specific dom element to get the input from.
  12419. * @param element Defines the element the controls should be listened from
  12420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12421. */
  12422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12423. /**
  12424. * Called on JS contextmenu event.
  12425. * Override this method to provide functionality.
  12426. */
  12427. protected onContextMenu(evt: PointerEvent): void;
  12428. /**
  12429. * Detach the current controls from the specified dom element.
  12430. * @param element Defines the element to stop listening the inputs from
  12431. */
  12432. detachControl(element: Nullable<HTMLElement>): void;
  12433. /**
  12434. * Gets the class name of the current intput.
  12435. * @returns the class name
  12436. */
  12437. getClassName(): string;
  12438. /**
  12439. * Get the friendly name associated with the input class.
  12440. * @returns the input friendly name
  12441. */
  12442. getSimpleName(): string;
  12443. }
  12444. }
  12445. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12446. import { Nullable } from "babylonjs/types";
  12447. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12448. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12449. /**
  12450. * Manage the touch inputs to control the movement of a free camera.
  12451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12452. */
  12453. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12454. /**
  12455. * Defines the camera the input is attached to.
  12456. */
  12457. camera: FreeCamera;
  12458. /**
  12459. * Defines the touch sensibility for rotation.
  12460. * The higher the faster.
  12461. */
  12462. touchAngularSensibility: number;
  12463. /**
  12464. * Defines the touch sensibility for move.
  12465. * The higher the faster.
  12466. */
  12467. touchMoveSensibility: number;
  12468. private _offsetX;
  12469. private _offsetY;
  12470. private _pointerPressed;
  12471. private _pointerInput;
  12472. private _observer;
  12473. private _onLostFocus;
  12474. /**
  12475. * Attach the input controls to a specific dom element to get the input from.
  12476. * @param element Defines the element the controls should be listened from
  12477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12478. */
  12479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12480. /**
  12481. * Detach the current controls from the specified dom element.
  12482. * @param element Defines the element to stop listening the inputs from
  12483. */
  12484. detachControl(element: Nullable<HTMLElement>): void;
  12485. /**
  12486. * Update the current camera state depending on the inputs that have been used this frame.
  12487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12488. */
  12489. checkInputs(): void;
  12490. /**
  12491. * Gets the class name of the current intput.
  12492. * @returns the class name
  12493. */
  12494. getClassName(): string;
  12495. /**
  12496. * Get the friendly name associated with the input class.
  12497. * @returns the input friendly name
  12498. */
  12499. getSimpleName(): string;
  12500. }
  12501. }
  12502. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12504. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12505. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12506. import { Nullable } from "babylonjs/types";
  12507. /**
  12508. * Default Inputs manager for the FreeCamera.
  12509. * It groups all the default supported inputs for ease of use.
  12510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12511. */
  12512. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12513. /**
  12514. * @hidden
  12515. */
  12516. _mouseInput: Nullable<FreeCameraMouseInput>;
  12517. /**
  12518. * Instantiates a new FreeCameraInputsManager.
  12519. * @param camera Defines the camera the inputs belong to
  12520. */
  12521. constructor(camera: FreeCamera);
  12522. /**
  12523. * Add keyboard input support to the input manager.
  12524. * @returns the current input manager
  12525. */
  12526. addKeyboard(): FreeCameraInputsManager;
  12527. /**
  12528. * Add mouse input support to the input manager.
  12529. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12530. * @returns the current input manager
  12531. */
  12532. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12533. /**
  12534. * Removes the mouse input support from the manager
  12535. * @returns the current input manager
  12536. */
  12537. removeMouse(): FreeCameraInputsManager;
  12538. /**
  12539. * Add touch input support to the input manager.
  12540. * @returns the current input manager
  12541. */
  12542. addTouch(): FreeCameraInputsManager;
  12543. /**
  12544. * Remove all attached input methods from a camera
  12545. */
  12546. clear(): void;
  12547. }
  12548. }
  12549. declare module "babylonjs/Cameras/freeCamera" {
  12550. import { Vector3 } from "babylonjs/Maths/math.vector";
  12551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12552. import { Scene } from "babylonjs/scene";
  12553. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12554. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12555. /**
  12556. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12557. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12558. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12559. */
  12560. export class FreeCamera extends TargetCamera {
  12561. /**
  12562. * Define the collision ellipsoid of the camera.
  12563. * This is helpful to simulate a camera body like the player body around the camera
  12564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12565. */
  12566. ellipsoid: Vector3;
  12567. /**
  12568. * Define an offset for the position of the ellipsoid around the camera.
  12569. * This can be helpful to determine the center of the body near the gravity center of the body
  12570. * instead of its head.
  12571. */
  12572. ellipsoidOffset: Vector3;
  12573. /**
  12574. * Enable or disable collisions of the camera with the rest of the scene objects.
  12575. */
  12576. checkCollisions: boolean;
  12577. /**
  12578. * Enable or disable gravity on the camera.
  12579. */
  12580. applyGravity: boolean;
  12581. /**
  12582. * Define the input manager associated to the camera.
  12583. */
  12584. inputs: FreeCameraInputsManager;
  12585. /**
  12586. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12587. * Higher values reduce sensitivity.
  12588. */
  12589. get angularSensibility(): number;
  12590. /**
  12591. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12592. * Higher values reduce sensitivity.
  12593. */
  12594. set angularSensibility(value: number);
  12595. /**
  12596. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12597. */
  12598. get keysUp(): number[];
  12599. set keysUp(value: number[]);
  12600. /**
  12601. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12602. */
  12603. get keysDown(): number[];
  12604. set keysDown(value: number[]);
  12605. /**
  12606. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12607. */
  12608. get keysLeft(): number[];
  12609. set keysLeft(value: number[]);
  12610. /**
  12611. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12612. */
  12613. get keysRight(): number[];
  12614. set keysRight(value: number[]);
  12615. /**
  12616. * Event raised when the camera collide with a mesh in the scene.
  12617. */
  12618. onCollide: (collidedMesh: AbstractMesh) => void;
  12619. private _collider;
  12620. private _needMoveForGravity;
  12621. private _oldPosition;
  12622. private _diffPosition;
  12623. private _newPosition;
  12624. /** @hidden */
  12625. _localDirection: Vector3;
  12626. /** @hidden */
  12627. _transformedDirection: Vector3;
  12628. /**
  12629. * Instantiates a Free Camera.
  12630. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12631. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12632. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12633. * @param name Define the name of the camera in the scene
  12634. * @param position Define the start position of the camera in the scene
  12635. * @param scene Define the scene the camera belongs to
  12636. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12637. */
  12638. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12639. /**
  12640. * Attached controls to the current camera.
  12641. * @param element Defines the element the controls should be listened from
  12642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12643. */
  12644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12645. /**
  12646. * Detach the current controls from the camera.
  12647. * The camera will stop reacting to inputs.
  12648. * @param element Defines the element to stop listening the inputs from
  12649. */
  12650. detachControl(element: HTMLElement): void;
  12651. private _collisionMask;
  12652. /**
  12653. * Define a collision mask to limit the list of object the camera can collide with
  12654. */
  12655. get collisionMask(): number;
  12656. set collisionMask(mask: number);
  12657. /** @hidden */
  12658. _collideWithWorld(displacement: Vector3): void;
  12659. private _onCollisionPositionChange;
  12660. /** @hidden */
  12661. _checkInputs(): void;
  12662. /** @hidden */
  12663. _decideIfNeedsToMove(): boolean;
  12664. /** @hidden */
  12665. _updatePosition(): void;
  12666. /**
  12667. * Destroy the camera and release the current resources hold by it.
  12668. */
  12669. dispose(): void;
  12670. /**
  12671. * Gets the current object class name.
  12672. * @return the class name
  12673. */
  12674. getClassName(): string;
  12675. }
  12676. }
  12677. declare module "babylonjs/Gamepads/gamepad" {
  12678. import { Observable } from "babylonjs/Misc/observable";
  12679. /**
  12680. * Represents a gamepad control stick position
  12681. */
  12682. export class StickValues {
  12683. /**
  12684. * The x component of the control stick
  12685. */
  12686. x: number;
  12687. /**
  12688. * The y component of the control stick
  12689. */
  12690. y: number;
  12691. /**
  12692. * Initializes the gamepad x and y control stick values
  12693. * @param x The x component of the gamepad control stick value
  12694. * @param y The y component of the gamepad control stick value
  12695. */
  12696. constructor(
  12697. /**
  12698. * The x component of the control stick
  12699. */
  12700. x: number,
  12701. /**
  12702. * The y component of the control stick
  12703. */
  12704. y: number);
  12705. }
  12706. /**
  12707. * An interface which manages callbacks for gamepad button changes
  12708. */
  12709. export interface GamepadButtonChanges {
  12710. /**
  12711. * Called when a gamepad has been changed
  12712. */
  12713. changed: boolean;
  12714. /**
  12715. * Called when a gamepad press event has been triggered
  12716. */
  12717. pressChanged: boolean;
  12718. /**
  12719. * Called when a touch event has been triggered
  12720. */
  12721. touchChanged: boolean;
  12722. /**
  12723. * Called when a value has changed
  12724. */
  12725. valueChanged: boolean;
  12726. }
  12727. /**
  12728. * Represents a gamepad
  12729. */
  12730. export class Gamepad {
  12731. /**
  12732. * The id of the gamepad
  12733. */
  12734. id: string;
  12735. /**
  12736. * The index of the gamepad
  12737. */
  12738. index: number;
  12739. /**
  12740. * The browser gamepad
  12741. */
  12742. browserGamepad: any;
  12743. /**
  12744. * Specifies what type of gamepad this represents
  12745. */
  12746. type: number;
  12747. private _leftStick;
  12748. private _rightStick;
  12749. /** @hidden */
  12750. _isConnected: boolean;
  12751. private _leftStickAxisX;
  12752. private _leftStickAxisY;
  12753. private _rightStickAxisX;
  12754. private _rightStickAxisY;
  12755. /**
  12756. * Triggered when the left control stick has been changed
  12757. */
  12758. private _onleftstickchanged;
  12759. /**
  12760. * Triggered when the right control stick has been changed
  12761. */
  12762. private _onrightstickchanged;
  12763. /**
  12764. * Represents a gamepad controller
  12765. */
  12766. static GAMEPAD: number;
  12767. /**
  12768. * Represents a generic controller
  12769. */
  12770. static GENERIC: number;
  12771. /**
  12772. * Represents an XBox controller
  12773. */
  12774. static XBOX: number;
  12775. /**
  12776. * Represents a pose-enabled controller
  12777. */
  12778. static POSE_ENABLED: number;
  12779. /**
  12780. * Represents an Dual Shock controller
  12781. */
  12782. static DUALSHOCK: number;
  12783. /**
  12784. * Specifies whether the left control stick should be Y-inverted
  12785. */
  12786. protected _invertLeftStickY: boolean;
  12787. /**
  12788. * Specifies if the gamepad has been connected
  12789. */
  12790. get isConnected(): boolean;
  12791. /**
  12792. * Initializes the gamepad
  12793. * @param id The id of the gamepad
  12794. * @param index The index of the gamepad
  12795. * @param browserGamepad The browser gamepad
  12796. * @param leftStickX The x component of the left joystick
  12797. * @param leftStickY The y component of the left joystick
  12798. * @param rightStickX The x component of the right joystick
  12799. * @param rightStickY The y component of the right joystick
  12800. */
  12801. constructor(
  12802. /**
  12803. * The id of the gamepad
  12804. */
  12805. id: string,
  12806. /**
  12807. * The index of the gamepad
  12808. */
  12809. index: number,
  12810. /**
  12811. * The browser gamepad
  12812. */
  12813. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12814. /**
  12815. * Callback triggered when the left joystick has changed
  12816. * @param callback
  12817. */
  12818. onleftstickchanged(callback: (values: StickValues) => void): void;
  12819. /**
  12820. * Callback triggered when the right joystick has changed
  12821. * @param callback
  12822. */
  12823. onrightstickchanged(callback: (values: StickValues) => void): void;
  12824. /**
  12825. * Gets the left joystick
  12826. */
  12827. get leftStick(): StickValues;
  12828. /**
  12829. * Sets the left joystick values
  12830. */
  12831. set leftStick(newValues: StickValues);
  12832. /**
  12833. * Gets the right joystick
  12834. */
  12835. get rightStick(): StickValues;
  12836. /**
  12837. * Sets the right joystick value
  12838. */
  12839. set rightStick(newValues: StickValues);
  12840. /**
  12841. * Updates the gamepad joystick positions
  12842. */
  12843. update(): void;
  12844. /**
  12845. * Disposes the gamepad
  12846. */
  12847. dispose(): void;
  12848. }
  12849. /**
  12850. * Represents a generic gamepad
  12851. */
  12852. export class GenericPad extends Gamepad {
  12853. private _buttons;
  12854. private _onbuttondown;
  12855. private _onbuttonup;
  12856. /**
  12857. * Observable triggered when a button has been pressed
  12858. */
  12859. onButtonDownObservable: Observable<number>;
  12860. /**
  12861. * Observable triggered when a button has been released
  12862. */
  12863. onButtonUpObservable: Observable<number>;
  12864. /**
  12865. * Callback triggered when a button has been pressed
  12866. * @param callback Called when a button has been pressed
  12867. */
  12868. onbuttondown(callback: (buttonPressed: number) => void): void;
  12869. /**
  12870. * Callback triggered when a button has been released
  12871. * @param callback Called when a button has been released
  12872. */
  12873. onbuttonup(callback: (buttonReleased: number) => void): void;
  12874. /**
  12875. * Initializes the generic gamepad
  12876. * @param id The id of the generic gamepad
  12877. * @param index The index of the generic gamepad
  12878. * @param browserGamepad The browser gamepad
  12879. */
  12880. constructor(id: string, index: number, browserGamepad: any);
  12881. private _setButtonValue;
  12882. /**
  12883. * Updates the generic gamepad
  12884. */
  12885. update(): void;
  12886. /**
  12887. * Disposes the generic gamepad
  12888. */
  12889. dispose(): void;
  12890. }
  12891. }
  12892. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12893. import { Nullable } from "babylonjs/types";
  12894. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12895. import { Scene } from "babylonjs/scene";
  12896. module "babylonjs/Engines/engine" {
  12897. interface Engine {
  12898. /**
  12899. * Creates a raw texture
  12900. * @param data defines the data to store in the texture
  12901. * @param width defines the width of the texture
  12902. * @param height defines the height of the texture
  12903. * @param format defines the format of the data
  12904. * @param generateMipMaps defines if the engine should generate the mip levels
  12905. * @param invertY defines if data must be stored with Y axis inverted
  12906. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12907. * @param compression defines the compression used (null by default)
  12908. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12909. * @returns the raw texture inside an InternalTexture
  12910. */
  12911. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12912. /**
  12913. * Update a raw texture
  12914. * @param texture defines the texture to update
  12915. * @param data defines the data to store in the texture
  12916. * @param format defines the format of the data
  12917. * @param invertY defines if data must be stored with Y axis inverted
  12918. */
  12919. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12920. /**
  12921. * Update a raw texture
  12922. * @param texture defines the texture to update
  12923. * @param data defines the data to store in the texture
  12924. * @param format defines the format of the data
  12925. * @param invertY defines if data must be stored with Y axis inverted
  12926. * @param compression defines the compression used (null by default)
  12927. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12928. */
  12929. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12930. /**
  12931. * Creates a new raw cube texture
  12932. * @param data defines the array of data to use to create each face
  12933. * @param size defines the size of the textures
  12934. * @param format defines the format of the data
  12935. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12936. * @param generateMipMaps defines if the engine should generate the mip levels
  12937. * @param invertY defines if data must be stored with Y axis inverted
  12938. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12939. * @param compression defines the compression used (null by default)
  12940. * @returns the cube texture as an InternalTexture
  12941. */
  12942. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12943. /**
  12944. * Update a raw cube texture
  12945. * @param texture defines the texture to udpdate
  12946. * @param data defines the data to store
  12947. * @param format defines the data format
  12948. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12949. * @param invertY defines if data must be stored with Y axis inverted
  12950. */
  12951. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12952. /**
  12953. * Update a raw cube texture
  12954. * @param texture defines the texture to udpdate
  12955. * @param data defines the data to store
  12956. * @param format defines the data format
  12957. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12958. * @param invertY defines if data must be stored with Y axis inverted
  12959. * @param compression defines the compression used (null by default)
  12960. */
  12961. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12962. /**
  12963. * Update a raw cube texture
  12964. * @param texture defines the texture to udpdate
  12965. * @param data defines the data to store
  12966. * @param format defines the data format
  12967. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12968. * @param invertY defines if data must be stored with Y axis inverted
  12969. * @param compression defines the compression used (null by default)
  12970. * @param level defines which level of the texture to update
  12971. */
  12972. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12973. /**
  12974. * Creates a new raw cube texture from a specified url
  12975. * @param url defines the url where the data is located
  12976. * @param scene defines the current scene
  12977. * @param size defines the size of the textures
  12978. * @param format defines the format of the data
  12979. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12980. * @param noMipmap defines if the engine should avoid generating the mip levels
  12981. * @param callback defines a callback used to extract texture data from loaded data
  12982. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12983. * @param onLoad defines a callback called when texture is loaded
  12984. * @param onError defines a callback called if there is an error
  12985. * @returns the cube texture as an InternalTexture
  12986. */
  12987. 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;
  12988. /**
  12989. * Creates a new raw cube texture from a specified url
  12990. * @param url defines the url where the data is located
  12991. * @param scene defines the current scene
  12992. * @param size defines the size of the textures
  12993. * @param format defines the format of the data
  12994. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12995. * @param noMipmap defines if the engine should avoid generating the mip levels
  12996. * @param callback defines a callback used to extract texture data from loaded data
  12997. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12998. * @param onLoad defines a callback called when texture is loaded
  12999. * @param onError defines a callback called if there is an error
  13000. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13001. * @param invertY defines if data must be stored with Y axis inverted
  13002. * @returns the cube texture as an InternalTexture
  13003. */
  13004. 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;
  13005. /**
  13006. * Creates a new raw 3D texture
  13007. * @param data defines the data used to create the texture
  13008. * @param width defines the width of the texture
  13009. * @param height defines the height of the texture
  13010. * @param depth defines the depth of the texture
  13011. * @param format defines the format of the texture
  13012. * @param generateMipMaps defines if the engine must generate mip levels
  13013. * @param invertY defines if data must be stored with Y axis inverted
  13014. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13015. * @param compression defines the compressed used (can be null)
  13016. * @param textureType defines the compressed used (can be null)
  13017. * @returns a new raw 3D texture (stored in an InternalTexture)
  13018. */
  13019. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13020. /**
  13021. * Update a raw 3D texture
  13022. * @param texture defines the texture to update
  13023. * @param data defines the data to store
  13024. * @param format defines the data format
  13025. * @param invertY defines if data must be stored with Y axis inverted
  13026. */
  13027. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13028. /**
  13029. * Update a raw 3D texture
  13030. * @param texture defines the texture to update
  13031. * @param data defines the data to store
  13032. * @param format defines the data format
  13033. * @param invertY defines if data must be stored with Y axis inverted
  13034. * @param compression defines the used compression (can be null)
  13035. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13036. */
  13037. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13038. /**
  13039. * Creates a new raw 2D array texture
  13040. * @param data defines the data used to create the texture
  13041. * @param width defines the width of the texture
  13042. * @param height defines the height of the texture
  13043. * @param depth defines the number of layers of the texture
  13044. * @param format defines the format of the texture
  13045. * @param generateMipMaps defines if the engine must generate mip levels
  13046. * @param invertY defines if data must be stored with Y axis inverted
  13047. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13048. * @param compression defines the compressed used (can be null)
  13049. * @param textureType defines the compressed used (can be null)
  13050. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13051. */
  13052. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13053. /**
  13054. * Update a raw 2D array texture
  13055. * @param texture defines the texture to update
  13056. * @param data defines the data to store
  13057. * @param format defines the data format
  13058. * @param invertY defines if data must be stored with Y axis inverted
  13059. */
  13060. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13061. /**
  13062. * Update a raw 2D array texture
  13063. * @param texture defines the texture to update
  13064. * @param data defines the data to store
  13065. * @param format defines the data format
  13066. * @param invertY defines if data must be stored with Y axis inverted
  13067. * @param compression defines the used compression (can be null)
  13068. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13069. */
  13070. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13071. }
  13072. }
  13073. }
  13074. declare module "babylonjs/Materials/Textures/rawTexture" {
  13075. import { Scene } from "babylonjs/scene";
  13076. import { Texture } from "babylonjs/Materials/Textures/texture";
  13077. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13078. /**
  13079. * Raw texture can help creating a texture directly from an array of data.
  13080. * This can be super useful if you either get the data from an uncompressed source or
  13081. * if you wish to create your texture pixel by pixel.
  13082. */
  13083. export class RawTexture extends Texture {
  13084. /**
  13085. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13086. */
  13087. format: number;
  13088. private _engine;
  13089. /**
  13090. * Instantiates a new RawTexture.
  13091. * Raw texture can help creating a texture directly from an array of data.
  13092. * This can be super useful if you either get the data from an uncompressed source or
  13093. * if you wish to create your texture pixel by pixel.
  13094. * @param data define the array of data to use to create the texture
  13095. * @param width define the width of the texture
  13096. * @param height define the height of the texture
  13097. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13098. * @param scene define the scene the texture belongs to
  13099. * @param generateMipMaps define whether mip maps should be generated or not
  13100. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13101. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13102. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13103. */
  13104. constructor(data: ArrayBufferView, width: number, height: number,
  13105. /**
  13106. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13107. */
  13108. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13109. /**
  13110. * Updates the texture underlying data.
  13111. * @param data Define the new data of the texture
  13112. */
  13113. update(data: ArrayBufferView): void;
  13114. /**
  13115. * Creates a luminance texture from some data.
  13116. * @param data Define the texture data
  13117. * @param width Define the width of the texture
  13118. * @param height Define the height of the texture
  13119. * @param scene Define the scene the texture belongs to
  13120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13123. * @returns the luminance texture
  13124. */
  13125. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13126. /**
  13127. * Creates a luminance alpha texture from some data.
  13128. * @param data Define the texture data
  13129. * @param width Define the width of the texture
  13130. * @param height Define the height of the texture
  13131. * @param scene Define the scene the texture belongs to
  13132. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13133. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13134. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13135. * @returns the luminance alpha texture
  13136. */
  13137. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13138. /**
  13139. * Creates an alpha texture from some data.
  13140. * @param data Define the texture data
  13141. * @param width Define the width of the texture
  13142. * @param height Define the height of the texture
  13143. * @param scene Define the scene the texture belongs to
  13144. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13147. * @returns the alpha texture
  13148. */
  13149. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13150. /**
  13151. * Creates a RGB texture from some data.
  13152. * @param data Define the texture data
  13153. * @param width Define the width of the texture
  13154. * @param height Define the height of the texture
  13155. * @param scene Define the scene the texture belongs to
  13156. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13157. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13158. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13159. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13160. * @returns the RGB alpha texture
  13161. */
  13162. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13163. /**
  13164. * Creates a RGBA texture from some data.
  13165. * @param data Define the texture data
  13166. * @param width Define the width of the texture
  13167. * @param height Define the height of the texture
  13168. * @param scene Define the scene the texture belongs to
  13169. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13170. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13171. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13172. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13173. * @returns the RGBA texture
  13174. */
  13175. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13176. /**
  13177. * Creates a R texture from some data.
  13178. * @param data Define the texture data
  13179. * @param width Define the width of the texture
  13180. * @param height Define the height of the texture
  13181. * @param scene Define the scene the texture belongs to
  13182. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13183. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13184. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13185. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13186. * @returns the R texture
  13187. */
  13188. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13189. }
  13190. }
  13191. declare module "babylonjs/Maths/math.size" {
  13192. /**
  13193. * Interface for the size containing width and height
  13194. */
  13195. export interface ISize {
  13196. /**
  13197. * Width
  13198. */
  13199. width: number;
  13200. /**
  13201. * Heighht
  13202. */
  13203. height: number;
  13204. }
  13205. /**
  13206. * Size containing widht and height
  13207. */
  13208. export class Size implements ISize {
  13209. /**
  13210. * Width
  13211. */
  13212. width: number;
  13213. /**
  13214. * Height
  13215. */
  13216. height: number;
  13217. /**
  13218. * Creates a Size object from the given width and height (floats).
  13219. * @param width width of the new size
  13220. * @param height height of the new size
  13221. */
  13222. constructor(width: number, height: number);
  13223. /**
  13224. * Returns a string with the Size width and height
  13225. * @returns a string with the Size width and height
  13226. */
  13227. toString(): string;
  13228. /**
  13229. * "Size"
  13230. * @returns the string "Size"
  13231. */
  13232. getClassName(): string;
  13233. /**
  13234. * Returns the Size hash code.
  13235. * @returns a hash code for a unique width and height
  13236. */
  13237. getHashCode(): number;
  13238. /**
  13239. * Updates the current size from the given one.
  13240. * @param src the given size
  13241. */
  13242. copyFrom(src: Size): void;
  13243. /**
  13244. * Updates in place the current Size from the given floats.
  13245. * @param width width of the new size
  13246. * @param height height of the new size
  13247. * @returns the updated Size.
  13248. */
  13249. copyFromFloats(width: number, height: number): Size;
  13250. /**
  13251. * Updates in place the current Size from the given floats.
  13252. * @param width width to set
  13253. * @param height height to set
  13254. * @returns the updated Size.
  13255. */
  13256. set(width: number, height: number): Size;
  13257. /**
  13258. * Multiplies the width and height by numbers
  13259. * @param w factor to multiple the width by
  13260. * @param h factor to multiple the height by
  13261. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13262. */
  13263. multiplyByFloats(w: number, h: number): Size;
  13264. /**
  13265. * Clones the size
  13266. * @returns a new Size copied from the given one.
  13267. */
  13268. clone(): Size;
  13269. /**
  13270. * True if the current Size and the given one width and height are strictly equal.
  13271. * @param other the other size to compare against
  13272. * @returns True if the current Size and the given one width and height are strictly equal.
  13273. */
  13274. equals(other: Size): boolean;
  13275. /**
  13276. * The surface of the Size : width * height (float).
  13277. */
  13278. get surface(): number;
  13279. /**
  13280. * Create a new size of zero
  13281. * @returns a new Size set to (0.0, 0.0)
  13282. */
  13283. static Zero(): Size;
  13284. /**
  13285. * Sums the width and height of two sizes
  13286. * @param otherSize size to add to this size
  13287. * @returns a new Size set as the addition result of the current Size and the given one.
  13288. */
  13289. add(otherSize: Size): Size;
  13290. /**
  13291. * Subtracts the width and height of two
  13292. * @param otherSize size to subtract to this size
  13293. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13294. */
  13295. subtract(otherSize: Size): Size;
  13296. /**
  13297. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13298. * @param start starting size to lerp between
  13299. * @param end end size to lerp between
  13300. * @param amount amount to lerp between the start and end values
  13301. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13302. */
  13303. static Lerp(start: Size, end: Size, amount: number): Size;
  13304. }
  13305. }
  13306. declare module "babylonjs/Animations/runtimeAnimation" {
  13307. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13308. import { Animatable } from "babylonjs/Animations/animatable";
  13309. import { Scene } from "babylonjs/scene";
  13310. /**
  13311. * Defines a runtime animation
  13312. */
  13313. export class RuntimeAnimation {
  13314. private _events;
  13315. /**
  13316. * The current frame of the runtime animation
  13317. */
  13318. private _currentFrame;
  13319. /**
  13320. * The animation used by the runtime animation
  13321. */
  13322. private _animation;
  13323. /**
  13324. * The target of the runtime animation
  13325. */
  13326. private _target;
  13327. /**
  13328. * The initiating animatable
  13329. */
  13330. private _host;
  13331. /**
  13332. * The original value of the runtime animation
  13333. */
  13334. private _originalValue;
  13335. /**
  13336. * The original blend value of the runtime animation
  13337. */
  13338. private _originalBlendValue;
  13339. /**
  13340. * The offsets cache of the runtime animation
  13341. */
  13342. private _offsetsCache;
  13343. /**
  13344. * The high limits cache of the runtime animation
  13345. */
  13346. private _highLimitsCache;
  13347. /**
  13348. * Specifies if the runtime animation has been stopped
  13349. */
  13350. private _stopped;
  13351. /**
  13352. * The blending factor of the runtime animation
  13353. */
  13354. private _blendingFactor;
  13355. /**
  13356. * The BabylonJS scene
  13357. */
  13358. private _scene;
  13359. /**
  13360. * The current value of the runtime animation
  13361. */
  13362. private _currentValue;
  13363. /** @hidden */
  13364. _animationState: _IAnimationState;
  13365. /**
  13366. * The active target of the runtime animation
  13367. */
  13368. private _activeTargets;
  13369. private _currentActiveTarget;
  13370. private _directTarget;
  13371. /**
  13372. * The target path of the runtime animation
  13373. */
  13374. private _targetPath;
  13375. /**
  13376. * The weight of the runtime animation
  13377. */
  13378. private _weight;
  13379. /**
  13380. * The ratio offset of the runtime animation
  13381. */
  13382. private _ratioOffset;
  13383. /**
  13384. * The previous delay of the runtime animation
  13385. */
  13386. private _previousDelay;
  13387. /**
  13388. * The previous ratio of the runtime animation
  13389. */
  13390. private _previousRatio;
  13391. private _enableBlending;
  13392. private _keys;
  13393. private _minFrame;
  13394. private _maxFrame;
  13395. private _minValue;
  13396. private _maxValue;
  13397. private _targetIsArray;
  13398. /**
  13399. * Gets the current frame of the runtime animation
  13400. */
  13401. get currentFrame(): number;
  13402. /**
  13403. * Gets the weight of the runtime animation
  13404. */
  13405. get weight(): number;
  13406. /**
  13407. * Gets the current value of the runtime animation
  13408. */
  13409. get currentValue(): any;
  13410. /**
  13411. * Gets the target path of the runtime animation
  13412. */
  13413. get targetPath(): string;
  13414. /**
  13415. * Gets the actual target of the runtime animation
  13416. */
  13417. get target(): any;
  13418. /** @hidden */
  13419. _onLoop: () => void;
  13420. /**
  13421. * Create a new RuntimeAnimation object
  13422. * @param target defines the target of the animation
  13423. * @param animation defines the source animation object
  13424. * @param scene defines the hosting scene
  13425. * @param host defines the initiating Animatable
  13426. */
  13427. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13428. private _preparePath;
  13429. /**
  13430. * Gets the animation from the runtime animation
  13431. */
  13432. get animation(): Animation;
  13433. /**
  13434. * Resets the runtime animation to the beginning
  13435. * @param restoreOriginal defines whether to restore the target property to the original value
  13436. */
  13437. reset(restoreOriginal?: boolean): void;
  13438. /**
  13439. * Specifies if the runtime animation is stopped
  13440. * @returns Boolean specifying if the runtime animation is stopped
  13441. */
  13442. isStopped(): boolean;
  13443. /**
  13444. * Disposes of the runtime animation
  13445. */
  13446. dispose(): void;
  13447. /**
  13448. * Apply the interpolated value to the target
  13449. * @param currentValue defines the value computed by the animation
  13450. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13451. */
  13452. setValue(currentValue: any, weight: number): void;
  13453. private _getOriginalValues;
  13454. private _setValue;
  13455. /**
  13456. * Gets the loop pmode of the runtime animation
  13457. * @returns Loop Mode
  13458. */
  13459. private _getCorrectLoopMode;
  13460. /**
  13461. * Move the current animation to a given frame
  13462. * @param frame defines the frame to move to
  13463. */
  13464. goToFrame(frame: number): void;
  13465. /**
  13466. * @hidden Internal use only
  13467. */
  13468. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13469. /**
  13470. * Execute the current animation
  13471. * @param delay defines the delay to add to the current frame
  13472. * @param from defines the lower bound of the animation range
  13473. * @param to defines the upper bound of the animation range
  13474. * @param loop defines if the current animation must loop
  13475. * @param speedRatio defines the current speed ratio
  13476. * @param weight defines the weight of the animation (default is -1 so no weight)
  13477. * @param onLoop optional callback called when animation loops
  13478. * @returns a boolean indicating if the animation is running
  13479. */
  13480. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13481. }
  13482. }
  13483. declare module "babylonjs/Animations/animatable" {
  13484. import { Animation } from "babylonjs/Animations/animation";
  13485. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13486. import { Nullable } from "babylonjs/types";
  13487. import { Observable } from "babylonjs/Misc/observable";
  13488. import { Scene } from "babylonjs/scene";
  13489. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13490. import { Node } from "babylonjs/node";
  13491. /**
  13492. * Class used to store an actual running animation
  13493. */
  13494. export class Animatable {
  13495. /** defines the target object */
  13496. target: any;
  13497. /** defines the starting frame number (default is 0) */
  13498. fromFrame: number;
  13499. /** defines the ending frame number (default is 100) */
  13500. toFrame: number;
  13501. /** defines if the animation must loop (default is false) */
  13502. loopAnimation: boolean;
  13503. /** defines a callback to call when animation ends if it is not looping */
  13504. onAnimationEnd?: (() => void) | null | undefined;
  13505. /** defines a callback to call when animation loops */
  13506. onAnimationLoop?: (() => void) | null | undefined;
  13507. private _localDelayOffset;
  13508. private _pausedDelay;
  13509. private _runtimeAnimations;
  13510. private _paused;
  13511. private _scene;
  13512. private _speedRatio;
  13513. private _weight;
  13514. private _syncRoot;
  13515. /**
  13516. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13517. * This will only apply for non looping animation (default is true)
  13518. */
  13519. disposeOnEnd: boolean;
  13520. /**
  13521. * Gets a boolean indicating if the animation has started
  13522. */
  13523. animationStarted: boolean;
  13524. /**
  13525. * Observer raised when the animation ends
  13526. */
  13527. onAnimationEndObservable: Observable<Animatable>;
  13528. /**
  13529. * Observer raised when the animation loops
  13530. */
  13531. onAnimationLoopObservable: Observable<Animatable>;
  13532. /**
  13533. * Gets the root Animatable used to synchronize and normalize animations
  13534. */
  13535. get syncRoot(): Nullable<Animatable>;
  13536. /**
  13537. * Gets the current frame of the first RuntimeAnimation
  13538. * Used to synchronize Animatables
  13539. */
  13540. get masterFrame(): number;
  13541. /**
  13542. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13543. */
  13544. get weight(): number;
  13545. set weight(value: number);
  13546. /**
  13547. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13548. */
  13549. get speedRatio(): number;
  13550. set speedRatio(value: number);
  13551. /**
  13552. * Creates a new Animatable
  13553. * @param scene defines the hosting scene
  13554. * @param target defines the target object
  13555. * @param fromFrame defines the starting frame number (default is 0)
  13556. * @param toFrame defines the ending frame number (default is 100)
  13557. * @param loopAnimation defines if the animation must loop (default is false)
  13558. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13559. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13560. * @param animations defines a group of animation to add to the new Animatable
  13561. * @param onAnimationLoop defines a callback to call when animation loops
  13562. */
  13563. constructor(scene: Scene,
  13564. /** defines the target object */
  13565. target: any,
  13566. /** defines the starting frame number (default is 0) */
  13567. fromFrame?: number,
  13568. /** defines the ending frame number (default is 100) */
  13569. toFrame?: number,
  13570. /** defines if the animation must loop (default is false) */
  13571. loopAnimation?: boolean, speedRatio?: number,
  13572. /** defines a callback to call when animation ends if it is not looping */
  13573. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13574. /** defines a callback to call when animation loops */
  13575. onAnimationLoop?: (() => void) | null | undefined);
  13576. /**
  13577. * Synchronize and normalize current Animatable with a source Animatable
  13578. * This is useful when using animation weights and when animations are not of the same length
  13579. * @param root defines the root Animatable to synchronize with
  13580. * @returns the current Animatable
  13581. */
  13582. syncWith(root: Animatable): Animatable;
  13583. /**
  13584. * Gets the list of runtime animations
  13585. * @returns an array of RuntimeAnimation
  13586. */
  13587. getAnimations(): RuntimeAnimation[];
  13588. /**
  13589. * Adds more animations to the current animatable
  13590. * @param target defines the target of the animations
  13591. * @param animations defines the new animations to add
  13592. */
  13593. appendAnimations(target: any, animations: Animation[]): void;
  13594. /**
  13595. * Gets the source animation for a specific property
  13596. * @param property defines the propertyu to look for
  13597. * @returns null or the source animation for the given property
  13598. */
  13599. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13600. /**
  13601. * Gets the runtime animation for a specific property
  13602. * @param property defines the propertyu to look for
  13603. * @returns null or the runtime animation for the given property
  13604. */
  13605. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13606. /**
  13607. * Resets the animatable to its original state
  13608. */
  13609. reset(): void;
  13610. /**
  13611. * Allows the animatable to blend with current running animations
  13612. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13613. * @param blendingSpeed defines the blending speed to use
  13614. */
  13615. enableBlending(blendingSpeed: number): void;
  13616. /**
  13617. * Disable animation blending
  13618. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13619. */
  13620. disableBlending(): void;
  13621. /**
  13622. * Jump directly to a given frame
  13623. * @param frame defines the frame to jump to
  13624. */
  13625. goToFrame(frame: number): void;
  13626. /**
  13627. * Pause the animation
  13628. */
  13629. pause(): void;
  13630. /**
  13631. * Restart the animation
  13632. */
  13633. restart(): void;
  13634. private _raiseOnAnimationEnd;
  13635. /**
  13636. * Stop and delete the current animation
  13637. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13638. * @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)
  13639. */
  13640. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13641. /**
  13642. * Wait asynchronously for the animation to end
  13643. * @returns a promise which will be fullfilled when the animation ends
  13644. */
  13645. waitAsync(): Promise<Animatable>;
  13646. /** @hidden */
  13647. _animate(delay: number): boolean;
  13648. }
  13649. module "babylonjs/scene" {
  13650. interface Scene {
  13651. /** @hidden */
  13652. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13653. /** @hidden */
  13654. _processLateAnimationBindingsForMatrices(holder: {
  13655. totalWeight: number;
  13656. animations: RuntimeAnimation[];
  13657. originalValue: Matrix;
  13658. }): any;
  13659. /** @hidden */
  13660. _processLateAnimationBindingsForQuaternions(holder: {
  13661. totalWeight: number;
  13662. animations: RuntimeAnimation[];
  13663. originalValue: Quaternion;
  13664. }, refQuaternion: Quaternion): Quaternion;
  13665. /** @hidden */
  13666. _processLateAnimationBindings(): void;
  13667. /**
  13668. * Will start the animation sequence of a given target
  13669. * @param target defines the target
  13670. * @param from defines from which frame should animation start
  13671. * @param to defines until which frame should animation run.
  13672. * @param weight defines the weight to apply to the animation (1.0 by default)
  13673. * @param loop defines if the animation loops
  13674. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13675. * @param onAnimationEnd defines the function to be executed when the animation ends
  13676. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13677. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13678. * @param onAnimationLoop defines the callback to call when an animation loops
  13679. * @returns the animatable object created for this animation
  13680. */
  13681. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13682. /**
  13683. * Will start the animation sequence of a given target
  13684. * @param target defines the target
  13685. * @param from defines from which frame should animation start
  13686. * @param to defines until which frame should animation run.
  13687. * @param loop defines if the animation loops
  13688. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13689. * @param onAnimationEnd defines the function to be executed when the animation ends
  13690. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13691. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13692. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13693. * @param onAnimationLoop defines the callback to call when an animation loops
  13694. * @returns the animatable object created for this animation
  13695. */
  13696. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13697. /**
  13698. * Will start the animation sequence of a given target and its hierarchy
  13699. * @param target defines the target
  13700. * @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.
  13701. * @param from defines from which frame should animation start
  13702. * @param to defines until which frame should animation run.
  13703. * @param loop defines if the animation loops
  13704. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13705. * @param onAnimationEnd defines the function to be executed when the animation ends
  13706. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13707. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13708. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13709. * @param onAnimationLoop defines the callback to call when an animation loops
  13710. * @returns the list of created animatables
  13711. */
  13712. 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[];
  13713. /**
  13714. * Begin a new animation on a given node
  13715. * @param target defines the target where the animation will take place
  13716. * @param animations defines the list of animations to start
  13717. * @param from defines the initial value
  13718. * @param to defines the final value
  13719. * @param loop defines if you want animation to loop (off by default)
  13720. * @param speedRatio defines the speed ratio to apply to all animations
  13721. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13722. * @param onAnimationLoop defines the callback to call when an animation loops
  13723. * @returns the list of created animatables
  13724. */
  13725. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13726. /**
  13727. * Begin a new animation on a given node and its hierarchy
  13728. * @param target defines the root node where the animation will take place
  13729. * @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.
  13730. * @param animations defines the list of animations to start
  13731. * @param from defines the initial value
  13732. * @param to defines the final value
  13733. * @param loop defines if you want animation to loop (off by default)
  13734. * @param speedRatio defines the speed ratio to apply to all animations
  13735. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13736. * @param onAnimationLoop defines the callback to call when an animation loops
  13737. * @returns the list of animatables created for all nodes
  13738. */
  13739. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13740. /**
  13741. * Gets the animatable associated with a specific target
  13742. * @param target defines the target of the animatable
  13743. * @returns the required animatable if found
  13744. */
  13745. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13746. /**
  13747. * Gets all animatables associated with a given target
  13748. * @param target defines the target to look animatables for
  13749. * @returns an array of Animatables
  13750. */
  13751. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13752. /**
  13753. * Stops and removes all animations that have been applied to the scene
  13754. */
  13755. stopAllAnimations(): void;
  13756. /**
  13757. * Gets the current delta time used by animation engine
  13758. */
  13759. deltaTime: number;
  13760. }
  13761. }
  13762. module "babylonjs/Bones/bone" {
  13763. interface Bone {
  13764. /**
  13765. * Copy an animation range from another bone
  13766. * @param source defines the source bone
  13767. * @param rangeName defines the range name to copy
  13768. * @param frameOffset defines the frame offset
  13769. * @param rescaleAsRequired defines if rescaling must be applied if required
  13770. * @param skelDimensionsRatio defines the scaling ratio
  13771. * @returns true if operation was successful
  13772. */
  13773. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13774. }
  13775. }
  13776. }
  13777. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13778. /**
  13779. * Class used to override all child animations of a given target
  13780. */
  13781. export class AnimationPropertiesOverride {
  13782. /**
  13783. * Gets or sets a value indicating if animation blending must be used
  13784. */
  13785. enableBlending: boolean;
  13786. /**
  13787. * Gets or sets the blending speed to use when enableBlending is true
  13788. */
  13789. blendingSpeed: number;
  13790. /**
  13791. * Gets or sets the default loop mode to use
  13792. */
  13793. loopMode: number;
  13794. }
  13795. }
  13796. declare module "babylonjs/Bones/skeleton" {
  13797. import { Bone } from "babylonjs/Bones/bone";
  13798. import { Observable } from "babylonjs/Misc/observable";
  13799. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13800. import { Scene } from "babylonjs/scene";
  13801. import { Nullable } from "babylonjs/types";
  13802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13803. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13804. import { Animatable } from "babylonjs/Animations/animatable";
  13805. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13806. import { Animation } from "babylonjs/Animations/animation";
  13807. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13808. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13809. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13810. /**
  13811. * Class used to handle skinning animations
  13812. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13813. */
  13814. export class Skeleton implements IAnimatable {
  13815. /** defines the skeleton name */
  13816. name: string;
  13817. /** defines the skeleton Id */
  13818. id: string;
  13819. /**
  13820. * Defines the list of child bones
  13821. */
  13822. bones: Bone[];
  13823. /**
  13824. * Defines an estimate of the dimension of the skeleton at rest
  13825. */
  13826. dimensionsAtRest: Vector3;
  13827. /**
  13828. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13829. */
  13830. needInitialSkinMatrix: boolean;
  13831. /**
  13832. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13833. */
  13834. overrideMesh: Nullable<AbstractMesh>;
  13835. /**
  13836. * Gets the list of animations attached to this skeleton
  13837. */
  13838. animations: Array<Animation>;
  13839. private _scene;
  13840. private _isDirty;
  13841. private _transformMatrices;
  13842. private _transformMatrixTexture;
  13843. private _meshesWithPoseMatrix;
  13844. private _animatables;
  13845. private _identity;
  13846. private _synchronizedWithMesh;
  13847. private _ranges;
  13848. private _lastAbsoluteTransformsUpdateId;
  13849. private _canUseTextureForBones;
  13850. private _uniqueId;
  13851. /** @hidden */
  13852. _numBonesWithLinkedTransformNode: number;
  13853. /** @hidden */
  13854. _hasWaitingData: Nullable<boolean>;
  13855. /**
  13856. * Specifies if the skeleton should be serialized
  13857. */
  13858. doNotSerialize: boolean;
  13859. private _useTextureToStoreBoneMatrices;
  13860. /**
  13861. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13862. * Please note that this option is not available if the hardware does not support it
  13863. */
  13864. get useTextureToStoreBoneMatrices(): boolean;
  13865. set useTextureToStoreBoneMatrices(value: boolean);
  13866. private _animationPropertiesOverride;
  13867. /**
  13868. * Gets or sets the animation properties override
  13869. */
  13870. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13871. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13872. /**
  13873. * List of inspectable custom properties (used by the Inspector)
  13874. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13875. */
  13876. inspectableCustomProperties: IInspectable[];
  13877. /**
  13878. * An observable triggered before computing the skeleton's matrices
  13879. */
  13880. onBeforeComputeObservable: Observable<Skeleton>;
  13881. /**
  13882. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13883. */
  13884. get isUsingTextureForMatrices(): boolean;
  13885. /**
  13886. * Gets the unique ID of this skeleton
  13887. */
  13888. get uniqueId(): number;
  13889. /**
  13890. * Creates a new skeleton
  13891. * @param name defines the skeleton name
  13892. * @param id defines the skeleton Id
  13893. * @param scene defines the hosting scene
  13894. */
  13895. constructor(
  13896. /** defines the skeleton name */
  13897. name: string,
  13898. /** defines the skeleton Id */
  13899. id: string, scene: Scene);
  13900. /**
  13901. * Gets the current object class name.
  13902. * @return the class name
  13903. */
  13904. getClassName(): string;
  13905. /**
  13906. * Returns an array containing the root bones
  13907. * @returns an array containing the root bones
  13908. */
  13909. getChildren(): Array<Bone>;
  13910. /**
  13911. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13912. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13913. * @returns a Float32Array containing matrices data
  13914. */
  13915. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13916. /**
  13917. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13918. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13919. * @returns a raw texture containing the data
  13920. */
  13921. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13922. /**
  13923. * Gets the current hosting scene
  13924. * @returns a scene object
  13925. */
  13926. getScene(): Scene;
  13927. /**
  13928. * Gets a string representing the current skeleton data
  13929. * @param fullDetails defines a boolean indicating if we want a verbose version
  13930. * @returns a string representing the current skeleton data
  13931. */
  13932. toString(fullDetails?: boolean): string;
  13933. /**
  13934. * Get bone's index searching by name
  13935. * @param name defines bone's name to search for
  13936. * @return the indice of the bone. Returns -1 if not found
  13937. */
  13938. getBoneIndexByName(name: string): number;
  13939. /**
  13940. * Creater a new animation range
  13941. * @param name defines the name of the range
  13942. * @param from defines the start key
  13943. * @param to defines the end key
  13944. */
  13945. createAnimationRange(name: string, from: number, to: number): void;
  13946. /**
  13947. * Delete a specific animation range
  13948. * @param name defines the name of the range
  13949. * @param deleteFrames defines if frames must be removed as well
  13950. */
  13951. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13952. /**
  13953. * Gets a specific animation range
  13954. * @param name defines the name of the range to look for
  13955. * @returns the requested animation range or null if not found
  13956. */
  13957. getAnimationRange(name: string): Nullable<AnimationRange>;
  13958. /**
  13959. * Gets the list of all animation ranges defined on this skeleton
  13960. * @returns an array
  13961. */
  13962. getAnimationRanges(): Nullable<AnimationRange>[];
  13963. /**
  13964. * Copy animation range from a source skeleton.
  13965. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13966. * @param source defines the source skeleton
  13967. * @param name defines the name of the range to copy
  13968. * @param rescaleAsRequired defines if rescaling must be applied if required
  13969. * @returns true if operation was successful
  13970. */
  13971. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13972. /**
  13973. * Forces the skeleton to go to rest pose
  13974. */
  13975. returnToRest(): void;
  13976. private _getHighestAnimationFrame;
  13977. /**
  13978. * Begin a specific animation range
  13979. * @param name defines the name of the range to start
  13980. * @param loop defines if looping must be turned on (false by default)
  13981. * @param speedRatio defines the speed ratio to apply (1 by default)
  13982. * @param onAnimationEnd defines a callback which will be called when animation will end
  13983. * @returns a new animatable
  13984. */
  13985. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13986. /** @hidden */
  13987. _markAsDirty(): void;
  13988. /** @hidden */
  13989. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13990. /** @hidden */
  13991. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13992. private _computeTransformMatrices;
  13993. /**
  13994. * Build all resources required to render a skeleton
  13995. */
  13996. prepare(): void;
  13997. /**
  13998. * Gets the list of animatables currently running for this skeleton
  13999. * @returns an array of animatables
  14000. */
  14001. getAnimatables(): IAnimatable[];
  14002. /**
  14003. * Clone the current skeleton
  14004. * @param name defines the name of the new skeleton
  14005. * @param id defines the id of the new skeleton
  14006. * @returns the new skeleton
  14007. */
  14008. clone(name: string, id?: string): Skeleton;
  14009. /**
  14010. * Enable animation blending for this skeleton
  14011. * @param blendingSpeed defines the blending speed to apply
  14012. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14013. */
  14014. enableBlending(blendingSpeed?: number): void;
  14015. /**
  14016. * Releases all resources associated with the current skeleton
  14017. */
  14018. dispose(): void;
  14019. /**
  14020. * Serialize the skeleton in a JSON object
  14021. * @returns a JSON object
  14022. */
  14023. serialize(): any;
  14024. /**
  14025. * Creates a new skeleton from serialized data
  14026. * @param parsedSkeleton defines the serialized data
  14027. * @param scene defines the hosting scene
  14028. * @returns a new skeleton
  14029. */
  14030. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  14031. /**
  14032. * Compute all node absolute transforms
  14033. * @param forceUpdate defines if computation must be done even if cache is up to date
  14034. */
  14035. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  14036. /**
  14037. * Gets the root pose matrix
  14038. * @returns a matrix
  14039. */
  14040. getPoseMatrix(): Nullable<Matrix>;
  14041. /**
  14042. * Sorts bones per internal index
  14043. */
  14044. sortBones(): void;
  14045. private _sortBones;
  14046. }
  14047. }
  14048. declare module "babylonjs/Bones/bone" {
  14049. import { Skeleton } from "babylonjs/Bones/skeleton";
  14050. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14051. import { Nullable } from "babylonjs/types";
  14052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14053. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14054. import { Node } from "babylonjs/node";
  14055. import { Space } from "babylonjs/Maths/math.axis";
  14056. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14057. /**
  14058. * Class used to store bone information
  14059. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14060. */
  14061. export class Bone extends Node {
  14062. /**
  14063. * defines the bone name
  14064. */
  14065. name: string;
  14066. private static _tmpVecs;
  14067. private static _tmpQuat;
  14068. private static _tmpMats;
  14069. /**
  14070. * Gets the list of child bones
  14071. */
  14072. children: Bone[];
  14073. /** Gets the animations associated with this bone */
  14074. animations: import("babylonjs/Animations/animation").Animation[];
  14075. /**
  14076. * Gets or sets bone length
  14077. */
  14078. length: number;
  14079. /**
  14080. * @hidden Internal only
  14081. * Set this value to map this bone to a different index in the transform matrices
  14082. * Set this value to -1 to exclude the bone from the transform matrices
  14083. */
  14084. _index: Nullable<number>;
  14085. private _skeleton;
  14086. private _localMatrix;
  14087. private _restPose;
  14088. private _baseMatrix;
  14089. private _absoluteTransform;
  14090. private _invertedAbsoluteTransform;
  14091. private _parent;
  14092. private _scalingDeterminant;
  14093. private _worldTransform;
  14094. private _localScaling;
  14095. private _localRotation;
  14096. private _localPosition;
  14097. private _needToDecompose;
  14098. private _needToCompose;
  14099. /** @hidden */
  14100. _linkedTransformNode: Nullable<TransformNode>;
  14101. /** @hidden */
  14102. _waitingTransformNodeId: Nullable<string>;
  14103. /** @hidden */
  14104. get _matrix(): Matrix;
  14105. /** @hidden */
  14106. set _matrix(value: Matrix);
  14107. /**
  14108. * Create a new bone
  14109. * @param name defines the bone name
  14110. * @param skeleton defines the parent skeleton
  14111. * @param parentBone defines the parent (can be null if the bone is the root)
  14112. * @param localMatrix defines the local matrix
  14113. * @param restPose defines the rest pose matrix
  14114. * @param baseMatrix defines the base matrix
  14115. * @param index defines index of the bone in the hiearchy
  14116. */
  14117. constructor(
  14118. /**
  14119. * defines the bone name
  14120. */
  14121. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14122. /**
  14123. * Gets the current object class name.
  14124. * @return the class name
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Gets the parent skeleton
  14129. * @returns a skeleton
  14130. */
  14131. getSkeleton(): Skeleton;
  14132. /**
  14133. * Gets parent bone
  14134. * @returns a bone or null if the bone is the root of the bone hierarchy
  14135. */
  14136. getParent(): Nullable<Bone>;
  14137. /**
  14138. * Returns an array containing the root bones
  14139. * @returns an array containing the root bones
  14140. */
  14141. getChildren(): Array<Bone>;
  14142. /**
  14143. * Gets the node index in matrix array generated for rendering
  14144. * @returns the node index
  14145. */
  14146. getIndex(): number;
  14147. /**
  14148. * Sets the parent bone
  14149. * @param parent defines the parent (can be null if the bone is the root)
  14150. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14151. */
  14152. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14153. /**
  14154. * Gets the local matrix
  14155. * @returns a matrix
  14156. */
  14157. getLocalMatrix(): Matrix;
  14158. /**
  14159. * Gets the base matrix (initial matrix which remains unchanged)
  14160. * @returns a matrix
  14161. */
  14162. getBaseMatrix(): Matrix;
  14163. /**
  14164. * Gets the rest pose matrix
  14165. * @returns a matrix
  14166. */
  14167. getRestPose(): Matrix;
  14168. /**
  14169. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14170. */
  14171. getWorldMatrix(): Matrix;
  14172. /**
  14173. * Sets the local matrix to rest pose matrix
  14174. */
  14175. returnToRest(): void;
  14176. /**
  14177. * Gets the inverse of the absolute transform matrix.
  14178. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14179. * @returns a matrix
  14180. */
  14181. getInvertedAbsoluteTransform(): Matrix;
  14182. /**
  14183. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14184. * @returns a matrix
  14185. */
  14186. getAbsoluteTransform(): Matrix;
  14187. /**
  14188. * Links with the given transform node.
  14189. * The local matrix of this bone is copied from the transform node every frame.
  14190. * @param transformNode defines the transform node to link to
  14191. */
  14192. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14193. /**
  14194. * Gets the node used to drive the bone's transformation
  14195. * @returns a transform node or null
  14196. */
  14197. getTransformNode(): Nullable<TransformNode>;
  14198. /** Gets or sets current position (in local space) */
  14199. get position(): Vector3;
  14200. set position(newPosition: Vector3);
  14201. /** Gets or sets current rotation (in local space) */
  14202. get rotation(): Vector3;
  14203. set rotation(newRotation: Vector3);
  14204. /** Gets or sets current rotation quaternion (in local space) */
  14205. get rotationQuaternion(): Quaternion;
  14206. set rotationQuaternion(newRotation: Quaternion);
  14207. /** Gets or sets current scaling (in local space) */
  14208. get scaling(): Vector3;
  14209. set scaling(newScaling: Vector3);
  14210. /**
  14211. * Gets the animation properties override
  14212. */
  14213. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14214. private _decompose;
  14215. private _compose;
  14216. /**
  14217. * Update the base and local matrices
  14218. * @param matrix defines the new base or local matrix
  14219. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14220. * @param updateLocalMatrix defines if the local matrix should be updated
  14221. */
  14222. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14223. /** @hidden */
  14224. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14225. /**
  14226. * Flag the bone as dirty (Forcing it to update everything)
  14227. */
  14228. markAsDirty(): void;
  14229. /** @hidden */
  14230. _markAsDirtyAndCompose(): void;
  14231. private _markAsDirtyAndDecompose;
  14232. /**
  14233. * Translate the bone in local or world space
  14234. * @param vec The amount to translate the bone
  14235. * @param space The space that the translation is in
  14236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14237. */
  14238. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14239. /**
  14240. * Set the postion of the bone in local or world space
  14241. * @param position The position to set the bone
  14242. * @param space The space that the position is in
  14243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14244. */
  14245. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14246. /**
  14247. * Set the absolute position of the bone (world space)
  14248. * @param position The position to set the bone
  14249. * @param mesh The mesh that this bone is attached to
  14250. */
  14251. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14252. /**
  14253. * Scale the bone on the x, y and z axes (in local space)
  14254. * @param x The amount to scale the bone on the x axis
  14255. * @param y The amount to scale the bone on the y axis
  14256. * @param z The amount to scale the bone on the z axis
  14257. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14258. */
  14259. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14260. /**
  14261. * Set the bone scaling in local space
  14262. * @param scale defines the scaling vector
  14263. */
  14264. setScale(scale: Vector3): void;
  14265. /**
  14266. * Gets the current scaling in local space
  14267. * @returns the current scaling vector
  14268. */
  14269. getScale(): Vector3;
  14270. /**
  14271. * Gets the current scaling in local space and stores it in a target vector
  14272. * @param result defines the target vector
  14273. */
  14274. getScaleToRef(result: Vector3): void;
  14275. /**
  14276. * Set the yaw, pitch, and roll of the bone in local or world space
  14277. * @param yaw The rotation of the bone on the y axis
  14278. * @param pitch The rotation of the bone on the x axis
  14279. * @param roll The rotation of the bone on the z axis
  14280. * @param space The space that the axes of rotation are in
  14281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14282. */
  14283. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14284. /**
  14285. * Add a rotation to the bone on an axis in local or world space
  14286. * @param axis The axis to rotate the bone on
  14287. * @param amount The amount to rotate the bone
  14288. * @param space The space that the axis is in
  14289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14290. */
  14291. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14292. /**
  14293. * Set the rotation of the bone to a particular axis angle in local or world space
  14294. * @param axis The axis to rotate the bone on
  14295. * @param angle The angle that the bone should be rotated to
  14296. * @param space The space that the axis is in
  14297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14298. */
  14299. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14300. /**
  14301. * Set the euler rotation of the bone in local of world space
  14302. * @param rotation The euler rotation that the bone should be set to
  14303. * @param space The space that the rotation is in
  14304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14305. */
  14306. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14307. /**
  14308. * Set the quaternion rotation of the bone in local of world space
  14309. * @param quat The quaternion rotation that the bone should be set to
  14310. * @param space The space that the rotation is in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. */
  14313. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14314. /**
  14315. * Set the rotation matrix of the bone in local of world space
  14316. * @param rotMat The rotation matrix that the bone should be set to
  14317. * @param space The space that the rotation is in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. */
  14320. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14321. private _rotateWithMatrix;
  14322. private _getNegativeRotationToRef;
  14323. /**
  14324. * Get the position of the bone in local or world space
  14325. * @param space The space that the returned position is in
  14326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14327. * @returns The position of the bone
  14328. */
  14329. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14330. /**
  14331. * Copy the position of the bone to a vector3 in local or world space
  14332. * @param space The space that the returned position is in
  14333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14334. * @param result The vector3 to copy the position to
  14335. */
  14336. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14337. /**
  14338. * Get the absolute position of the bone (world space)
  14339. * @param mesh The mesh that this bone is attached to
  14340. * @returns The absolute position of the bone
  14341. */
  14342. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14343. /**
  14344. * Copy the absolute position of the bone (world space) to the result param
  14345. * @param mesh The mesh that this bone is attached to
  14346. * @param result The vector3 to copy the absolute position to
  14347. */
  14348. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14349. /**
  14350. * Compute the absolute transforms of this bone and its children
  14351. */
  14352. computeAbsoluteTransforms(): void;
  14353. /**
  14354. * Get the world direction from an axis that is in the local space of the bone
  14355. * @param localAxis The local direction that is used to compute the world direction
  14356. * @param mesh The mesh that this bone is attached to
  14357. * @returns The world direction
  14358. */
  14359. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14360. /**
  14361. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14362. * @param localAxis The local direction that is used to compute the world direction
  14363. * @param mesh The mesh that this bone is attached to
  14364. * @param result The vector3 that the world direction will be copied to
  14365. */
  14366. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14367. /**
  14368. * Get the euler rotation of the bone in local or world space
  14369. * @param space The space that the rotation should be in
  14370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14371. * @returns The euler rotation
  14372. */
  14373. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14374. /**
  14375. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14376. * @param space The space that the rotation should be in
  14377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14378. * @param result The vector3 that the rotation should be copied to
  14379. */
  14380. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14381. /**
  14382. * Get the quaternion rotation of the bone in either local or world space
  14383. * @param space The space that the rotation should be in
  14384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14385. * @returns The quaternion rotation
  14386. */
  14387. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14388. /**
  14389. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14390. * @param space The space that the rotation should be in
  14391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14392. * @param result The quaternion that the rotation should be copied to
  14393. */
  14394. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14395. /**
  14396. * Get the rotation matrix of the bone in local or world space
  14397. * @param space The space that the rotation should be in
  14398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14399. * @returns The rotation matrix
  14400. */
  14401. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14402. /**
  14403. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14404. * @param space The space that the rotation should be in
  14405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14406. * @param result The quaternion that the rotation should be copied to
  14407. */
  14408. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14409. /**
  14410. * Get the world position of a point that is in the local space of the bone
  14411. * @param position The local position
  14412. * @param mesh The mesh that this bone is attached to
  14413. * @returns The world position
  14414. */
  14415. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14416. /**
  14417. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14418. * @param position The local position
  14419. * @param mesh The mesh that this bone is attached to
  14420. * @param result The vector3 that the world position should be copied to
  14421. */
  14422. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14423. /**
  14424. * Get the local position of a point that is in world space
  14425. * @param position The world position
  14426. * @param mesh The mesh that this bone is attached to
  14427. * @returns The local position
  14428. */
  14429. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14430. /**
  14431. * Get the local position of a point that is in world space and copy it to the result param
  14432. * @param position The world position
  14433. * @param mesh The mesh that this bone is attached to
  14434. * @param result The vector3 that the local position should be copied to
  14435. */
  14436. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14437. }
  14438. }
  14439. declare module "babylonjs/Meshes/transformNode" {
  14440. import { DeepImmutable } from "babylonjs/types";
  14441. import { Observable } from "babylonjs/Misc/observable";
  14442. import { Nullable } from "babylonjs/types";
  14443. import { Camera } from "babylonjs/Cameras/camera";
  14444. import { Scene } from "babylonjs/scene";
  14445. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14446. import { Node } from "babylonjs/node";
  14447. import { Bone } from "babylonjs/Bones/bone";
  14448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14449. import { Space } from "babylonjs/Maths/math.axis";
  14450. /**
  14451. * 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.
  14452. * @see https://doc.babylonjs.com/how_to/transformnode
  14453. */
  14454. export class TransformNode extends Node {
  14455. /**
  14456. * Object will not rotate to face the camera
  14457. */
  14458. static BILLBOARDMODE_NONE: number;
  14459. /**
  14460. * Object will rotate to face the camera but only on the x axis
  14461. */
  14462. static BILLBOARDMODE_X: number;
  14463. /**
  14464. * Object will rotate to face the camera but only on the y axis
  14465. */
  14466. static BILLBOARDMODE_Y: number;
  14467. /**
  14468. * Object will rotate to face the camera but only on the z axis
  14469. */
  14470. static BILLBOARDMODE_Z: number;
  14471. /**
  14472. * Object will rotate to face the camera
  14473. */
  14474. static BILLBOARDMODE_ALL: number;
  14475. /**
  14476. * Object will rotate to face the camera's position instead of orientation
  14477. */
  14478. static BILLBOARDMODE_USE_POSITION: number;
  14479. private _forward;
  14480. private _forwardInverted;
  14481. private _up;
  14482. private _right;
  14483. private _rightInverted;
  14484. private _position;
  14485. private _rotation;
  14486. private _rotationQuaternion;
  14487. protected _scaling: Vector3;
  14488. protected _isDirty: boolean;
  14489. private _transformToBoneReferal;
  14490. private _isAbsoluteSynced;
  14491. private _billboardMode;
  14492. /**
  14493. * Gets or sets the billboard mode. Default is 0.
  14494. *
  14495. * | Value | Type | Description |
  14496. * | --- | --- | --- |
  14497. * | 0 | BILLBOARDMODE_NONE | |
  14498. * | 1 | BILLBOARDMODE_X | |
  14499. * | 2 | BILLBOARDMODE_Y | |
  14500. * | 4 | BILLBOARDMODE_Z | |
  14501. * | 7 | BILLBOARDMODE_ALL | |
  14502. *
  14503. */
  14504. get billboardMode(): number;
  14505. set billboardMode(value: number);
  14506. private _preserveParentRotationForBillboard;
  14507. /**
  14508. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14509. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14510. */
  14511. get preserveParentRotationForBillboard(): boolean;
  14512. set preserveParentRotationForBillboard(value: boolean);
  14513. /**
  14514. * 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
  14515. */
  14516. scalingDeterminant: number;
  14517. private _infiniteDistance;
  14518. /**
  14519. * Gets or sets the distance of the object to max, often used by skybox
  14520. */
  14521. get infiniteDistance(): boolean;
  14522. set infiniteDistance(value: boolean);
  14523. /**
  14524. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14525. * By default the system will update normals to compensate
  14526. */
  14527. ignoreNonUniformScaling: boolean;
  14528. /**
  14529. * 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
  14530. */
  14531. reIntegrateRotationIntoRotationQuaternion: boolean;
  14532. /** @hidden */
  14533. _poseMatrix: Nullable<Matrix>;
  14534. /** @hidden */
  14535. _localMatrix: Matrix;
  14536. private _usePivotMatrix;
  14537. private _absolutePosition;
  14538. private _absoluteScaling;
  14539. private _absoluteRotationQuaternion;
  14540. private _pivotMatrix;
  14541. private _pivotMatrixInverse;
  14542. protected _postMultiplyPivotMatrix: boolean;
  14543. protected _isWorldMatrixFrozen: boolean;
  14544. /** @hidden */
  14545. _indexInSceneTransformNodesArray: number;
  14546. /**
  14547. * An event triggered after the world matrix is updated
  14548. */
  14549. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14550. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14551. /**
  14552. * Gets a string identifying the name of the class
  14553. * @returns "TransformNode" string
  14554. */
  14555. getClassName(): string;
  14556. /**
  14557. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14558. */
  14559. get position(): Vector3;
  14560. set position(newPosition: Vector3);
  14561. /**
  14562. * 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)).
  14563. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14564. */
  14565. get rotation(): Vector3;
  14566. set rotation(newRotation: Vector3);
  14567. /**
  14568. * 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)).
  14569. */
  14570. get scaling(): Vector3;
  14571. set scaling(newScaling: Vector3);
  14572. /**
  14573. * 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).
  14574. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14575. */
  14576. get rotationQuaternion(): Nullable<Quaternion>;
  14577. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14578. /**
  14579. * The forward direction of that transform in world space.
  14580. */
  14581. get forward(): Vector3;
  14582. /**
  14583. * The up direction of that transform in world space.
  14584. */
  14585. get up(): Vector3;
  14586. /**
  14587. * The right direction of that transform in world space.
  14588. */
  14589. get right(): Vector3;
  14590. /**
  14591. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14592. * @param matrix the matrix to copy the pose from
  14593. * @returns this TransformNode.
  14594. */
  14595. updatePoseMatrix(matrix: Matrix): TransformNode;
  14596. /**
  14597. * Returns the mesh Pose matrix.
  14598. * @returns the pose matrix
  14599. */
  14600. getPoseMatrix(): Matrix;
  14601. /** @hidden */
  14602. _isSynchronized(): boolean;
  14603. /** @hidden */
  14604. _initCache(): void;
  14605. /**
  14606. * Flag the transform node as dirty (Forcing it to update everything)
  14607. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14608. * @returns this transform node
  14609. */
  14610. markAsDirty(property: string): TransformNode;
  14611. /**
  14612. * Returns the current mesh absolute position.
  14613. * Returns a Vector3.
  14614. */
  14615. get absolutePosition(): Vector3;
  14616. /**
  14617. * Returns the current mesh absolute scaling.
  14618. * Returns a Vector3.
  14619. */
  14620. get absoluteScaling(): Vector3;
  14621. /**
  14622. * Returns the current mesh absolute rotation.
  14623. * Returns a Quaternion.
  14624. */
  14625. get absoluteRotationQuaternion(): Quaternion;
  14626. /**
  14627. * Sets a new matrix to apply before all other transformation
  14628. * @param matrix defines the transform matrix
  14629. * @returns the current TransformNode
  14630. */
  14631. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14632. /**
  14633. * Sets a new pivot matrix to the current node
  14634. * @param matrix defines the new pivot matrix to use
  14635. * @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
  14636. * @returns the current TransformNode
  14637. */
  14638. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14639. /**
  14640. * Returns the mesh pivot matrix.
  14641. * Default : Identity.
  14642. * @returns the matrix
  14643. */
  14644. getPivotMatrix(): Matrix;
  14645. /**
  14646. * Instantiate (when possible) or clone that node with its hierarchy
  14647. * @param newParent defines the new parent to use for the instance (or clone)
  14648. * @param options defines options to configure how copy is done
  14649. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14650. * @returns an instance (or a clone) of the current node with its hiearchy
  14651. */
  14652. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14653. doNotInstantiate: boolean;
  14654. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14655. /**
  14656. * Prevents the World matrix to be computed any longer
  14657. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14658. * @returns the TransformNode.
  14659. */
  14660. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14661. /**
  14662. * Allows back the World matrix computation.
  14663. * @returns the TransformNode.
  14664. */
  14665. unfreezeWorldMatrix(): this;
  14666. /**
  14667. * True if the World matrix has been frozen.
  14668. */
  14669. get isWorldMatrixFrozen(): boolean;
  14670. /**
  14671. * Retuns the mesh absolute position in the World.
  14672. * @returns a Vector3.
  14673. */
  14674. getAbsolutePosition(): Vector3;
  14675. /**
  14676. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14677. * @param absolutePosition the absolute position to set
  14678. * @returns the TransformNode.
  14679. */
  14680. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14681. /**
  14682. * Sets the mesh position in its local space.
  14683. * @param vector3 the position to set in localspace
  14684. * @returns the TransformNode.
  14685. */
  14686. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14687. /**
  14688. * Returns the mesh position in the local space from the current World matrix values.
  14689. * @returns a new Vector3.
  14690. */
  14691. getPositionExpressedInLocalSpace(): Vector3;
  14692. /**
  14693. * Translates the mesh along the passed Vector3 in its local space.
  14694. * @param vector3 the distance to translate in localspace
  14695. * @returns the TransformNode.
  14696. */
  14697. locallyTranslate(vector3: Vector3): TransformNode;
  14698. private static _lookAtVectorCache;
  14699. /**
  14700. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14701. * @param targetPoint the position (must be in same space as current mesh) to look at
  14702. * @param yawCor optional yaw (y-axis) correction in radians
  14703. * @param pitchCor optional pitch (x-axis) correction in radians
  14704. * @param rollCor optional roll (z-axis) correction in radians
  14705. * @param space the choosen space of the target
  14706. * @returns the TransformNode.
  14707. */
  14708. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14709. /**
  14710. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14711. * This Vector3 is expressed in the World space.
  14712. * @param localAxis axis to rotate
  14713. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14714. */
  14715. getDirection(localAxis: Vector3): Vector3;
  14716. /**
  14717. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14718. * localAxis is expressed in the mesh local space.
  14719. * result is computed in the Wordl space from the mesh World matrix.
  14720. * @param localAxis axis to rotate
  14721. * @param result the resulting transformnode
  14722. * @returns this TransformNode.
  14723. */
  14724. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14725. /**
  14726. * Sets this transform node rotation to the given local axis.
  14727. * @param localAxis the axis in local space
  14728. * @param yawCor optional yaw (y-axis) correction in radians
  14729. * @param pitchCor optional pitch (x-axis) correction in radians
  14730. * @param rollCor optional roll (z-axis) correction in radians
  14731. * @returns this TransformNode
  14732. */
  14733. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14734. /**
  14735. * Sets a new pivot point to the current node
  14736. * @param point defines the new pivot point to use
  14737. * @param space defines if the point is in world or local space (local by default)
  14738. * @returns the current TransformNode
  14739. */
  14740. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14741. /**
  14742. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14743. * @returns the pivot point
  14744. */
  14745. getPivotPoint(): Vector3;
  14746. /**
  14747. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14748. * @param result the vector3 to store the result
  14749. * @returns this TransformNode.
  14750. */
  14751. getPivotPointToRef(result: Vector3): TransformNode;
  14752. /**
  14753. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14754. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14755. */
  14756. getAbsolutePivotPoint(): Vector3;
  14757. /**
  14758. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14759. * @param result vector3 to store the result
  14760. * @returns this TransformNode.
  14761. */
  14762. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14763. /**
  14764. * Defines the passed node as the parent of the current node.
  14765. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14766. * @see https://doc.babylonjs.com/how_to/parenting
  14767. * @param node the node ot set as the parent
  14768. * @returns this TransformNode.
  14769. */
  14770. setParent(node: Nullable<Node>): TransformNode;
  14771. private _nonUniformScaling;
  14772. /**
  14773. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14774. */
  14775. get nonUniformScaling(): boolean;
  14776. /** @hidden */
  14777. _updateNonUniformScalingState(value: boolean): boolean;
  14778. /**
  14779. * Attach the current TransformNode to another TransformNode associated with a bone
  14780. * @param bone Bone affecting the TransformNode
  14781. * @param affectedTransformNode TransformNode associated with the bone
  14782. * @returns this object
  14783. */
  14784. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14785. /**
  14786. * Detach the transform node if its associated with a bone
  14787. * @returns this object
  14788. */
  14789. detachFromBone(): TransformNode;
  14790. private static _rotationAxisCache;
  14791. /**
  14792. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14793. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14794. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14795. * The passed axis is also normalized.
  14796. * @param axis the axis to rotate around
  14797. * @param amount the amount to rotate in radians
  14798. * @param space Space to rotate in (Default: local)
  14799. * @returns the TransformNode.
  14800. */
  14801. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14802. /**
  14803. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14804. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14805. * The passed axis is also normalized. .
  14806. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14807. * @param point the point to rotate around
  14808. * @param axis the axis to rotate around
  14809. * @param amount the amount to rotate in radians
  14810. * @returns the TransformNode
  14811. */
  14812. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14813. /**
  14814. * Translates the mesh along the axis vector for the passed distance in the given space.
  14815. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14816. * @param axis the axis to translate in
  14817. * @param distance the distance to translate
  14818. * @param space Space to rotate in (Default: local)
  14819. * @returns the TransformNode.
  14820. */
  14821. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14822. /**
  14823. * Adds a rotation step to the mesh current rotation.
  14824. * x, y, z are Euler angles expressed in radians.
  14825. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14826. * This means this rotation is made in the mesh local space only.
  14827. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14828. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14829. * ```javascript
  14830. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14831. * ```
  14832. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14833. * 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.
  14834. * @param x Rotation to add
  14835. * @param y Rotation to add
  14836. * @param z Rotation to add
  14837. * @returns the TransformNode.
  14838. */
  14839. addRotation(x: number, y: number, z: number): TransformNode;
  14840. /**
  14841. * @hidden
  14842. */
  14843. protected _getEffectiveParent(): Nullable<Node>;
  14844. /**
  14845. * Computes the world matrix of the node
  14846. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14847. * @returns the world matrix
  14848. */
  14849. computeWorldMatrix(force?: boolean): Matrix;
  14850. /**
  14851. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14852. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14853. */
  14854. resetLocalMatrix(independentOfChildren?: boolean): void;
  14855. protected _afterComputeWorldMatrix(): void;
  14856. /**
  14857. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14858. * @param func callback function to add
  14859. *
  14860. * @returns the TransformNode.
  14861. */
  14862. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14863. /**
  14864. * Removes a registered callback function.
  14865. * @param func callback function to remove
  14866. * @returns the TransformNode.
  14867. */
  14868. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14869. /**
  14870. * Gets the position of the current mesh in camera space
  14871. * @param camera defines the camera to use
  14872. * @returns a position
  14873. */
  14874. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14875. /**
  14876. * Returns the distance from the mesh to the active camera
  14877. * @param camera defines the camera to use
  14878. * @returns the distance
  14879. */
  14880. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14881. /**
  14882. * Clone the current transform node
  14883. * @param name Name of the new clone
  14884. * @param newParent New parent for the clone
  14885. * @param doNotCloneChildren Do not clone children hierarchy
  14886. * @returns the new transform node
  14887. */
  14888. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14889. /**
  14890. * Serializes the objects information.
  14891. * @param currentSerializationObject defines the object to serialize in
  14892. * @returns the serialized object
  14893. */
  14894. serialize(currentSerializationObject?: any): any;
  14895. /**
  14896. * Returns a new TransformNode object parsed from the source provided.
  14897. * @param parsedTransformNode is the source.
  14898. * @param scene the scne the object belongs to
  14899. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14900. * @returns a new TransformNode object parsed from the source provided.
  14901. */
  14902. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14903. /**
  14904. * Get all child-transformNodes of this node
  14905. * @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
  14906. * @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
  14907. * @returns an array of TransformNode
  14908. */
  14909. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14910. /**
  14911. * Releases resources associated with this transform node.
  14912. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14913. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14914. */
  14915. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14916. /**
  14917. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14918. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14919. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14920. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14921. * @returns the current mesh
  14922. */
  14923. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14924. private _syncAbsoluteScalingAndRotation;
  14925. }
  14926. }
  14927. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14928. import { Observable } from "babylonjs/Misc/observable";
  14929. import { Nullable } from "babylonjs/types";
  14930. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14931. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14933. import { Ray } from "babylonjs/Culling/ray";
  14934. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14935. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14936. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14937. /**
  14938. * Defines the types of pose enabled controllers that are supported
  14939. */
  14940. export enum PoseEnabledControllerType {
  14941. /**
  14942. * HTC Vive
  14943. */
  14944. VIVE = 0,
  14945. /**
  14946. * Oculus Rift
  14947. */
  14948. OCULUS = 1,
  14949. /**
  14950. * Windows mixed reality
  14951. */
  14952. WINDOWS = 2,
  14953. /**
  14954. * Samsung gear VR
  14955. */
  14956. GEAR_VR = 3,
  14957. /**
  14958. * Google Daydream
  14959. */
  14960. DAYDREAM = 4,
  14961. /**
  14962. * Generic
  14963. */
  14964. GENERIC = 5
  14965. }
  14966. /**
  14967. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14968. */
  14969. export interface MutableGamepadButton {
  14970. /**
  14971. * Value of the button/trigger
  14972. */
  14973. value: number;
  14974. /**
  14975. * If the button/trigger is currently touched
  14976. */
  14977. touched: boolean;
  14978. /**
  14979. * If the button/trigger is currently pressed
  14980. */
  14981. pressed: boolean;
  14982. }
  14983. /**
  14984. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14985. * @hidden
  14986. */
  14987. export interface ExtendedGamepadButton extends GamepadButton {
  14988. /**
  14989. * If the button/trigger is currently pressed
  14990. */
  14991. readonly pressed: boolean;
  14992. /**
  14993. * If the button/trigger is currently touched
  14994. */
  14995. readonly touched: boolean;
  14996. /**
  14997. * Value of the button/trigger
  14998. */
  14999. readonly value: number;
  15000. }
  15001. /** @hidden */
  15002. export interface _GamePadFactory {
  15003. /**
  15004. * Returns whether or not the current gamepad can be created for this type of controller.
  15005. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  15006. * @returns true if it can be created, otherwise false
  15007. */
  15008. canCreate(gamepadInfo: any): boolean;
  15009. /**
  15010. * Creates a new instance of the Gamepad.
  15011. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  15012. * @returns the new gamepad instance
  15013. */
  15014. create(gamepadInfo: any): Gamepad;
  15015. }
  15016. /**
  15017. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  15018. */
  15019. export class PoseEnabledControllerHelper {
  15020. /** @hidden */
  15021. static _ControllerFactories: _GamePadFactory[];
  15022. /** @hidden */
  15023. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  15024. /**
  15025. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  15026. * @param vrGamepad the gamepad to initialized
  15027. * @returns a vr controller of the type the gamepad identified as
  15028. */
  15029. static InitiateController(vrGamepad: any): Gamepad;
  15030. }
  15031. /**
  15032. * Defines the PoseEnabledController object that contains state of a vr capable controller
  15033. */
  15034. export class PoseEnabledController extends Gamepad implements PoseControlled {
  15035. /**
  15036. * If the controller is used in a webXR session
  15037. */
  15038. isXR: boolean;
  15039. private _deviceRoomPosition;
  15040. private _deviceRoomRotationQuaternion;
  15041. /**
  15042. * The device position in babylon space
  15043. */
  15044. devicePosition: Vector3;
  15045. /**
  15046. * The device rotation in babylon space
  15047. */
  15048. deviceRotationQuaternion: Quaternion;
  15049. /**
  15050. * The scale factor of the device in babylon space
  15051. */
  15052. deviceScaleFactor: number;
  15053. /**
  15054. * (Likely devicePosition should be used instead) The device position in its room space
  15055. */
  15056. position: Vector3;
  15057. /**
  15058. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  15059. */
  15060. rotationQuaternion: Quaternion;
  15061. /**
  15062. * The type of controller (Eg. Windows mixed reality)
  15063. */
  15064. controllerType: PoseEnabledControllerType;
  15065. protected _calculatedPosition: Vector3;
  15066. private _calculatedRotation;
  15067. /**
  15068. * The raw pose from the device
  15069. */
  15070. rawPose: DevicePose;
  15071. private _trackPosition;
  15072. private _maxRotationDistFromHeadset;
  15073. private _draggedRoomRotation;
  15074. /**
  15075. * @hidden
  15076. */
  15077. _disableTrackPosition(fixedPosition: Vector3): void;
  15078. /**
  15079. * Internal, the mesh attached to the controller
  15080. * @hidden
  15081. */
  15082. _mesh: Nullable<AbstractMesh>;
  15083. private _poseControlledCamera;
  15084. private _leftHandSystemQuaternion;
  15085. /**
  15086. * Internal, matrix used to convert room space to babylon space
  15087. * @hidden
  15088. */
  15089. _deviceToWorld: Matrix;
  15090. /**
  15091. * Node to be used when casting a ray from the controller
  15092. * @hidden
  15093. */
  15094. _pointingPoseNode: Nullable<TransformNode>;
  15095. /**
  15096. * Name of the child mesh that can be used to cast a ray from the controller
  15097. */
  15098. static readonly POINTING_POSE: string;
  15099. /**
  15100. * Creates a new PoseEnabledController from a gamepad
  15101. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15102. */
  15103. constructor(browserGamepad: any);
  15104. private _workingMatrix;
  15105. /**
  15106. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15107. */
  15108. update(): void;
  15109. /**
  15110. * Updates only the pose device and mesh without doing any button event checking
  15111. */
  15112. protected _updatePoseAndMesh(): void;
  15113. /**
  15114. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15115. * @param poseData raw pose fromthe device
  15116. */
  15117. updateFromDevice(poseData: DevicePose): void;
  15118. /**
  15119. * @hidden
  15120. */
  15121. _meshAttachedObservable: Observable<AbstractMesh>;
  15122. /**
  15123. * Attaches a mesh to the controller
  15124. * @param mesh the mesh to be attached
  15125. */
  15126. attachToMesh(mesh: AbstractMesh): void;
  15127. /**
  15128. * Attaches the controllers mesh to a camera
  15129. * @param camera the camera the mesh should be attached to
  15130. */
  15131. attachToPoseControlledCamera(camera: TargetCamera): void;
  15132. /**
  15133. * Disposes of the controller
  15134. */
  15135. dispose(): void;
  15136. /**
  15137. * The mesh that is attached to the controller
  15138. */
  15139. get mesh(): Nullable<AbstractMesh>;
  15140. /**
  15141. * Gets the ray of the controller in the direction the controller is pointing
  15142. * @param length the length the resulting ray should be
  15143. * @returns a ray in the direction the controller is pointing
  15144. */
  15145. getForwardRay(length?: number): Ray;
  15146. }
  15147. }
  15148. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15149. import { Observable } from "babylonjs/Misc/observable";
  15150. import { Scene } from "babylonjs/scene";
  15151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15152. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15153. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15154. import { Nullable } from "babylonjs/types";
  15155. /**
  15156. * Defines the WebVRController object that represents controllers tracked in 3D space
  15157. */
  15158. export abstract class WebVRController extends PoseEnabledController {
  15159. /**
  15160. * Internal, the default controller model for the controller
  15161. */
  15162. protected _defaultModel: Nullable<AbstractMesh>;
  15163. /**
  15164. * Fired when the trigger state has changed
  15165. */
  15166. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15167. /**
  15168. * Fired when the main button state has changed
  15169. */
  15170. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15171. /**
  15172. * Fired when the secondary button state has changed
  15173. */
  15174. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15175. /**
  15176. * Fired when the pad state has changed
  15177. */
  15178. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15179. /**
  15180. * Fired when controllers stick values have changed
  15181. */
  15182. onPadValuesChangedObservable: Observable<StickValues>;
  15183. /**
  15184. * Array of button availible on the controller
  15185. */
  15186. protected _buttons: Array<MutableGamepadButton>;
  15187. private _onButtonStateChange;
  15188. /**
  15189. * Fired when a controller button's state has changed
  15190. * @param callback the callback containing the button that was modified
  15191. */
  15192. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15193. /**
  15194. * X and Y axis corresponding to the controllers joystick
  15195. */
  15196. pad: StickValues;
  15197. /**
  15198. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15199. */
  15200. hand: string;
  15201. /**
  15202. * The default controller model for the controller
  15203. */
  15204. get defaultModel(): Nullable<AbstractMesh>;
  15205. /**
  15206. * Creates a new WebVRController from a gamepad
  15207. * @param vrGamepad the gamepad that the WebVRController should be created from
  15208. */
  15209. constructor(vrGamepad: any);
  15210. /**
  15211. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15212. */
  15213. update(): void;
  15214. /**
  15215. * Function to be called when a button is modified
  15216. */
  15217. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15218. /**
  15219. * Loads a mesh and attaches it to the controller
  15220. * @param scene the scene the mesh should be added to
  15221. * @param meshLoaded callback for when the mesh has been loaded
  15222. */
  15223. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15224. private _setButtonValue;
  15225. private _changes;
  15226. private _checkChanges;
  15227. /**
  15228. * Disposes of th webVRCOntroller
  15229. */
  15230. dispose(): void;
  15231. }
  15232. }
  15233. declare module "babylonjs/Lights/hemisphericLight" {
  15234. import { Nullable } from "babylonjs/types";
  15235. import { Scene } from "babylonjs/scene";
  15236. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15237. import { Color3 } from "babylonjs/Maths/math.color";
  15238. import { Effect } from "babylonjs/Materials/effect";
  15239. import { Light } from "babylonjs/Lights/light";
  15240. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15241. /**
  15242. * The HemisphericLight simulates the ambient environment light,
  15243. * so the passed direction is the light reflection direction, not the incoming direction.
  15244. */
  15245. export class HemisphericLight extends Light {
  15246. /**
  15247. * The groundColor is the light in the opposite direction to the one specified during creation.
  15248. * 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.
  15249. */
  15250. groundColor: Color3;
  15251. /**
  15252. * The light reflection direction, not the incoming direction.
  15253. */
  15254. direction: Vector3;
  15255. /**
  15256. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15257. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15258. * The HemisphericLight can't cast shadows.
  15259. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15260. * @param name The friendly name of the light
  15261. * @param direction The direction of the light reflection
  15262. * @param scene The scene the light belongs to
  15263. */
  15264. constructor(name: string, direction: Vector3, scene: Scene);
  15265. protected _buildUniformLayout(): void;
  15266. /**
  15267. * Returns the string "HemisphericLight".
  15268. * @return The class name
  15269. */
  15270. getClassName(): string;
  15271. /**
  15272. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15273. * Returns the updated direction.
  15274. * @param target The target the direction should point to
  15275. * @return The computed direction
  15276. */
  15277. setDirectionToTarget(target: Vector3): Vector3;
  15278. /**
  15279. * Returns the shadow generator associated to the light.
  15280. * @returns Always null for hemispheric lights because it does not support shadows.
  15281. */
  15282. getShadowGenerator(): Nullable<IShadowGenerator>;
  15283. /**
  15284. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15285. * @param effect The effect to update
  15286. * @param lightIndex The index of the light in the effect to update
  15287. * @returns The hemispheric light
  15288. */
  15289. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15290. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15291. /**
  15292. * Computes the world matrix of the node
  15293. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15294. * @param useWasUpdatedFlag defines a reserved property
  15295. * @returns the world matrix
  15296. */
  15297. computeWorldMatrix(): Matrix;
  15298. /**
  15299. * Returns the integer 3.
  15300. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15301. */
  15302. getTypeID(): number;
  15303. /**
  15304. * Prepares the list of defines specific to the light type.
  15305. * @param defines the list of defines
  15306. * @param lightIndex defines the index of the light for the effect
  15307. */
  15308. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15309. }
  15310. }
  15311. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15312. /** @hidden */
  15313. export var vrMultiviewToSingleviewPixelShader: {
  15314. name: string;
  15315. shader: string;
  15316. };
  15317. }
  15318. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15319. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15320. import { Scene } from "babylonjs/scene";
  15321. /**
  15322. * Renders to multiple views with a single draw call
  15323. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15324. */
  15325. export class MultiviewRenderTarget extends RenderTargetTexture {
  15326. /**
  15327. * Creates a multiview render target
  15328. * @param scene scene used with the render target
  15329. * @param size the size of the render target (used for each view)
  15330. */
  15331. constructor(scene: Scene, size?: number | {
  15332. width: number;
  15333. height: number;
  15334. } | {
  15335. ratio: number;
  15336. });
  15337. /**
  15338. * @hidden
  15339. * @param faceIndex the face index, if its a cube texture
  15340. */
  15341. _bindFrameBuffer(faceIndex?: number): void;
  15342. /**
  15343. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15344. * @returns the view count
  15345. */
  15346. getViewCount(): number;
  15347. }
  15348. }
  15349. declare module "babylonjs/Maths/math.frustum" {
  15350. import { Matrix } from "babylonjs/Maths/math.vector";
  15351. import { DeepImmutable } from "babylonjs/types";
  15352. import { Plane } from "babylonjs/Maths/math.plane";
  15353. /**
  15354. * Represents a camera frustum
  15355. */
  15356. export class Frustum {
  15357. /**
  15358. * Gets the planes representing the frustum
  15359. * @param transform matrix to be applied to the returned planes
  15360. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15361. */
  15362. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15363. /**
  15364. * Gets the near frustum plane transformed by the transform matrix
  15365. * @param transform transformation matrix to be applied to the resulting frustum plane
  15366. * @param frustumPlane the resuling frustum plane
  15367. */
  15368. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15369. /**
  15370. * Gets the far frustum plane transformed by the transform matrix
  15371. * @param transform transformation matrix to be applied to the resulting frustum plane
  15372. * @param frustumPlane the resuling frustum plane
  15373. */
  15374. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15375. /**
  15376. * Gets the left frustum plane transformed by the transform matrix
  15377. * @param transform transformation matrix to be applied to the resulting frustum plane
  15378. * @param frustumPlane the resuling frustum plane
  15379. */
  15380. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15381. /**
  15382. * Gets the right frustum plane transformed by the transform matrix
  15383. * @param transform transformation matrix to be applied to the resulting frustum plane
  15384. * @param frustumPlane the resuling frustum plane
  15385. */
  15386. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15387. /**
  15388. * Gets the top frustum plane transformed by the transform matrix
  15389. * @param transform transformation matrix to be applied to the resulting frustum plane
  15390. * @param frustumPlane the resuling frustum plane
  15391. */
  15392. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15393. /**
  15394. * Gets the bottom frustum plane transformed by the transform matrix
  15395. * @param transform transformation matrix to be applied to the resulting frustum plane
  15396. * @param frustumPlane the resuling frustum plane
  15397. */
  15398. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15399. /**
  15400. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15401. * @param transform transformation matrix to be applied to the resulting frustum planes
  15402. * @param frustumPlanes the resuling frustum planes
  15403. */
  15404. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15405. }
  15406. }
  15407. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15408. import { Camera } from "babylonjs/Cameras/camera";
  15409. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15410. import { Nullable } from "babylonjs/types";
  15411. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15412. import { Matrix } from "babylonjs/Maths/math.vector";
  15413. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15414. module "babylonjs/Engines/engine" {
  15415. interface Engine {
  15416. /**
  15417. * Creates a new multiview render target
  15418. * @param width defines the width of the texture
  15419. * @param height defines the height of the texture
  15420. * @returns the created multiview texture
  15421. */
  15422. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15423. /**
  15424. * Binds a multiview framebuffer to be drawn to
  15425. * @param multiviewTexture texture to bind
  15426. */
  15427. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15428. }
  15429. }
  15430. module "babylonjs/Cameras/camera" {
  15431. interface Camera {
  15432. /**
  15433. * @hidden
  15434. * 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)
  15435. */
  15436. _useMultiviewToSingleView: boolean;
  15437. /**
  15438. * @hidden
  15439. * 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)
  15440. */
  15441. _multiviewTexture: Nullable<RenderTargetTexture>;
  15442. /**
  15443. * @hidden
  15444. * ensures the multiview texture of the camera exists and has the specified width/height
  15445. * @param width height to set on the multiview texture
  15446. * @param height width to set on the multiview texture
  15447. */
  15448. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15449. }
  15450. }
  15451. module "babylonjs/scene" {
  15452. interface Scene {
  15453. /** @hidden */
  15454. _transformMatrixR: Matrix;
  15455. /** @hidden */
  15456. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15457. /** @hidden */
  15458. _createMultiviewUbo(): void;
  15459. /** @hidden */
  15460. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15461. /** @hidden */
  15462. _renderMultiviewToSingleView(camera: Camera): void;
  15463. }
  15464. }
  15465. }
  15466. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15467. import { Camera } from "babylonjs/Cameras/camera";
  15468. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15469. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15470. import "babylonjs/Engines/Extensions/engine.multiview";
  15471. /**
  15472. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15473. * This will not be used for webXR as it supports displaying texture arrays directly
  15474. */
  15475. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15476. /**
  15477. * Initializes a VRMultiviewToSingleview
  15478. * @param name name of the post process
  15479. * @param camera camera to be applied to
  15480. * @param scaleFactor scaling factor to the size of the output texture
  15481. */
  15482. constructor(name: string, camera: Camera, scaleFactor: number);
  15483. }
  15484. }
  15485. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15486. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15487. import { Nullable } from "babylonjs/types";
  15488. import { Size } from "babylonjs/Maths/math.size";
  15489. import { Observable } from "babylonjs/Misc/observable";
  15490. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15491. /**
  15492. * Interface used to define additional presentation attributes
  15493. */
  15494. export interface IVRPresentationAttributes {
  15495. /**
  15496. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15497. */
  15498. highRefreshRate: boolean;
  15499. /**
  15500. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15501. */
  15502. foveationLevel: number;
  15503. }
  15504. module "babylonjs/Engines/engine" {
  15505. interface Engine {
  15506. /** @hidden */
  15507. _vrDisplay: any;
  15508. /** @hidden */
  15509. _vrSupported: boolean;
  15510. /** @hidden */
  15511. _oldSize: Size;
  15512. /** @hidden */
  15513. _oldHardwareScaleFactor: number;
  15514. /** @hidden */
  15515. _vrExclusivePointerMode: boolean;
  15516. /** @hidden */
  15517. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15518. /** @hidden */
  15519. _onVRDisplayPointerRestricted: () => void;
  15520. /** @hidden */
  15521. _onVRDisplayPointerUnrestricted: () => void;
  15522. /** @hidden */
  15523. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15524. /** @hidden */
  15525. _onVrDisplayDisconnect: Nullable<() => void>;
  15526. /** @hidden */
  15527. _onVrDisplayPresentChange: Nullable<() => void>;
  15528. /**
  15529. * Observable signaled when VR display mode changes
  15530. */
  15531. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15532. /**
  15533. * Observable signaled when VR request present is complete
  15534. */
  15535. onVRRequestPresentComplete: Observable<boolean>;
  15536. /**
  15537. * Observable signaled when VR request present starts
  15538. */
  15539. onVRRequestPresentStart: Observable<Engine>;
  15540. /**
  15541. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15542. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15543. */
  15544. isInVRExclusivePointerMode: boolean;
  15545. /**
  15546. * Gets a boolean indicating if a webVR device was detected
  15547. * @returns true if a webVR device was detected
  15548. */
  15549. isVRDevicePresent(): boolean;
  15550. /**
  15551. * Gets the current webVR device
  15552. * @returns the current webVR device (or null)
  15553. */
  15554. getVRDevice(): any;
  15555. /**
  15556. * Initializes a webVR display and starts listening to display change events
  15557. * The onVRDisplayChangedObservable will be notified upon these changes
  15558. * @returns A promise containing a VRDisplay and if vr is supported
  15559. */
  15560. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15561. /** @hidden */
  15562. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15563. /**
  15564. * Gets or sets the presentation attributes used to configure VR rendering
  15565. */
  15566. vrPresentationAttributes?: IVRPresentationAttributes;
  15567. /**
  15568. * Call this function to switch to webVR mode
  15569. * Will do nothing if webVR is not supported or if there is no webVR device
  15570. * @param options the webvr options provided to the camera. mainly used for multiview
  15571. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15572. */
  15573. enableVR(options: WebVROptions): void;
  15574. /** @hidden */
  15575. _onVRFullScreenTriggered(): void;
  15576. }
  15577. }
  15578. }
  15579. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15580. import { Nullable } from "babylonjs/types";
  15581. import { Observable } from "babylonjs/Misc/observable";
  15582. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15583. import { Scene } from "babylonjs/scene";
  15584. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15585. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15586. import { Node } from "babylonjs/node";
  15587. import { Ray } from "babylonjs/Culling/ray";
  15588. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15589. import "babylonjs/Engines/Extensions/engine.webVR";
  15590. /**
  15591. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15592. * IMPORTANT!! The data is right-hand data.
  15593. * @export
  15594. * @interface DevicePose
  15595. */
  15596. export interface DevicePose {
  15597. /**
  15598. * The position of the device, values in array are [x,y,z].
  15599. */
  15600. readonly position: Nullable<Float32Array>;
  15601. /**
  15602. * The linearVelocity of the device, values in array are [x,y,z].
  15603. */
  15604. readonly linearVelocity: Nullable<Float32Array>;
  15605. /**
  15606. * The linearAcceleration of the device, values in array are [x,y,z].
  15607. */
  15608. readonly linearAcceleration: Nullable<Float32Array>;
  15609. /**
  15610. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15611. */
  15612. readonly orientation: Nullable<Float32Array>;
  15613. /**
  15614. * The angularVelocity of the device, values in array are [x,y,z].
  15615. */
  15616. readonly angularVelocity: Nullable<Float32Array>;
  15617. /**
  15618. * The angularAcceleration of the device, values in array are [x,y,z].
  15619. */
  15620. readonly angularAcceleration: Nullable<Float32Array>;
  15621. }
  15622. /**
  15623. * Interface representing a pose controlled object in Babylon.
  15624. * A pose controlled object has both regular pose values as well as pose values
  15625. * from an external device such as a VR head mounted display
  15626. */
  15627. export interface PoseControlled {
  15628. /**
  15629. * The position of the object in babylon space.
  15630. */
  15631. position: Vector3;
  15632. /**
  15633. * The rotation quaternion of the object in babylon space.
  15634. */
  15635. rotationQuaternion: Quaternion;
  15636. /**
  15637. * The position of the device in babylon space.
  15638. */
  15639. devicePosition?: Vector3;
  15640. /**
  15641. * The rotation quaternion of the device in babylon space.
  15642. */
  15643. deviceRotationQuaternion: Quaternion;
  15644. /**
  15645. * The raw pose coming from the device.
  15646. */
  15647. rawPose: Nullable<DevicePose>;
  15648. /**
  15649. * The scale of the device to be used when translating from device space to babylon space.
  15650. */
  15651. deviceScaleFactor: number;
  15652. /**
  15653. * Updates the poseControlled values based on the input device pose.
  15654. * @param poseData the pose data to update the object with
  15655. */
  15656. updateFromDevice(poseData: DevicePose): void;
  15657. }
  15658. /**
  15659. * Set of options to customize the webVRCamera
  15660. */
  15661. export interface WebVROptions {
  15662. /**
  15663. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15664. */
  15665. trackPosition?: boolean;
  15666. /**
  15667. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15668. */
  15669. positionScale?: number;
  15670. /**
  15671. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15672. */
  15673. displayName?: string;
  15674. /**
  15675. * Should the native controller meshes be initialized. (default: true)
  15676. */
  15677. controllerMeshes?: boolean;
  15678. /**
  15679. * Creating a default HemiLight only on controllers. (default: true)
  15680. */
  15681. defaultLightingOnControllers?: boolean;
  15682. /**
  15683. * If you don't want to use the default VR button of the helper. (default: false)
  15684. */
  15685. useCustomVRButton?: boolean;
  15686. /**
  15687. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15688. */
  15689. customVRButton?: HTMLButtonElement;
  15690. /**
  15691. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15692. */
  15693. rayLength?: number;
  15694. /**
  15695. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15696. */
  15697. defaultHeight?: number;
  15698. /**
  15699. * If multiview should be used if availible (default: false)
  15700. */
  15701. useMultiview?: boolean;
  15702. }
  15703. /**
  15704. * This represents a WebVR camera.
  15705. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15706. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15707. */
  15708. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15709. private webVROptions;
  15710. /**
  15711. * @hidden
  15712. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15713. */
  15714. _vrDevice: any;
  15715. /**
  15716. * The rawPose of the vrDevice.
  15717. */
  15718. rawPose: Nullable<DevicePose>;
  15719. private _onVREnabled;
  15720. private _specsVersion;
  15721. private _attached;
  15722. private _frameData;
  15723. protected _descendants: Array<Node>;
  15724. private _deviceRoomPosition;
  15725. /** @hidden */
  15726. _deviceRoomRotationQuaternion: Quaternion;
  15727. private _standingMatrix;
  15728. /**
  15729. * Represents device position in babylon space.
  15730. */
  15731. devicePosition: Vector3;
  15732. /**
  15733. * Represents device rotation in babylon space.
  15734. */
  15735. deviceRotationQuaternion: Quaternion;
  15736. /**
  15737. * The scale of the device to be used when translating from device space to babylon space.
  15738. */
  15739. deviceScaleFactor: number;
  15740. private _deviceToWorld;
  15741. private _worldToDevice;
  15742. /**
  15743. * References to the webVR controllers for the vrDevice.
  15744. */
  15745. controllers: Array<WebVRController>;
  15746. /**
  15747. * Emits an event when a controller is attached.
  15748. */
  15749. onControllersAttachedObservable: Observable<WebVRController[]>;
  15750. /**
  15751. * Emits an event when a controller's mesh has been loaded;
  15752. */
  15753. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15754. /**
  15755. * Emits an event when the HMD's pose has been updated.
  15756. */
  15757. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15758. private _poseSet;
  15759. /**
  15760. * If the rig cameras be used as parent instead of this camera.
  15761. */
  15762. rigParenting: boolean;
  15763. private _lightOnControllers;
  15764. private _defaultHeight?;
  15765. /**
  15766. * Instantiates a WebVRFreeCamera.
  15767. * @param name The name of the WebVRFreeCamera
  15768. * @param position The starting anchor position for the camera
  15769. * @param scene The scene the camera belongs to
  15770. * @param webVROptions a set of customizable options for the webVRCamera
  15771. */
  15772. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15773. /**
  15774. * Gets the device distance from the ground in meters.
  15775. * @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.
  15776. */
  15777. deviceDistanceToRoomGround(): number;
  15778. /**
  15779. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15780. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15781. */
  15782. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15783. /**
  15784. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15785. * @returns A promise with a boolean set to if the standing matrix is supported.
  15786. */
  15787. useStandingMatrixAsync(): Promise<boolean>;
  15788. /**
  15789. * Disposes the camera
  15790. */
  15791. dispose(): void;
  15792. /**
  15793. * Gets a vrController by name.
  15794. * @param name The name of the controller to retreive
  15795. * @returns the controller matching the name specified or null if not found
  15796. */
  15797. getControllerByName(name: string): Nullable<WebVRController>;
  15798. private _leftController;
  15799. /**
  15800. * The controller corresponding to the users left hand.
  15801. */
  15802. get leftController(): Nullable<WebVRController>;
  15803. private _rightController;
  15804. /**
  15805. * The controller corresponding to the users right hand.
  15806. */
  15807. get rightController(): Nullable<WebVRController>;
  15808. /**
  15809. * Casts a ray forward from the vrCamera's gaze.
  15810. * @param length Length of the ray (default: 100)
  15811. * @returns the ray corresponding to the gaze
  15812. */
  15813. getForwardRay(length?: number): Ray;
  15814. /**
  15815. * @hidden
  15816. * Updates the camera based on device's frame data
  15817. */
  15818. _checkInputs(): void;
  15819. /**
  15820. * Updates the poseControlled values based on the input device pose.
  15821. * @param poseData Pose coming from the device
  15822. */
  15823. updateFromDevice(poseData: DevicePose): void;
  15824. private _htmlElementAttached;
  15825. private _detachIfAttached;
  15826. /**
  15827. * WebVR's attach control will start broadcasting frames to the device.
  15828. * Note that in certain browsers (chrome for example) this function must be called
  15829. * within a user-interaction callback. Example:
  15830. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15831. *
  15832. * @param element html element to attach the vrDevice to
  15833. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15834. */
  15835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15836. /**
  15837. * Detaches the camera from the html element and disables VR
  15838. *
  15839. * @param element html element to detach from
  15840. */
  15841. detachControl(element: HTMLElement): void;
  15842. /**
  15843. * @returns the name of this class
  15844. */
  15845. getClassName(): string;
  15846. /**
  15847. * Calls resetPose on the vrDisplay
  15848. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15849. */
  15850. resetToCurrentRotation(): void;
  15851. /**
  15852. * @hidden
  15853. * Updates the rig cameras (left and right eye)
  15854. */
  15855. _updateRigCameras(): void;
  15856. private _workingVector;
  15857. private _oneVector;
  15858. private _workingMatrix;
  15859. private updateCacheCalled;
  15860. private _correctPositionIfNotTrackPosition;
  15861. /**
  15862. * @hidden
  15863. * Updates the cached values of the camera
  15864. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15865. */
  15866. _updateCache(ignoreParentClass?: boolean): void;
  15867. /**
  15868. * @hidden
  15869. * Get current device position in babylon world
  15870. */
  15871. _computeDevicePosition(): void;
  15872. /**
  15873. * Updates the current device position and rotation in the babylon world
  15874. */
  15875. update(): void;
  15876. /**
  15877. * @hidden
  15878. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15879. * @returns an identity matrix
  15880. */
  15881. _getViewMatrix(): Matrix;
  15882. private _tmpMatrix;
  15883. /**
  15884. * This function is called by the two RIG cameras.
  15885. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15886. * @hidden
  15887. */
  15888. _getWebVRViewMatrix(): Matrix;
  15889. /** @hidden */
  15890. _getWebVRProjectionMatrix(): Matrix;
  15891. private _onGamepadConnectedObserver;
  15892. private _onGamepadDisconnectedObserver;
  15893. private _updateCacheWhenTrackingDisabledObserver;
  15894. /**
  15895. * Initializes the controllers and their meshes
  15896. */
  15897. initControllers(): void;
  15898. }
  15899. }
  15900. declare module "babylonjs/PostProcesses/postProcess" {
  15901. import { Nullable } from "babylonjs/types";
  15902. import { SmartArray } from "babylonjs/Misc/smartArray";
  15903. import { Observable } from "babylonjs/Misc/observable";
  15904. import { Vector2 } from "babylonjs/Maths/math.vector";
  15905. import { Camera } from "babylonjs/Cameras/camera";
  15906. import { Effect } from "babylonjs/Materials/effect";
  15907. import "babylonjs/Shaders/postprocess.vertex";
  15908. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15909. import { Engine } from "babylonjs/Engines/engine";
  15910. import { Color4 } from "babylonjs/Maths/math.color";
  15911. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15913. /**
  15914. * Size options for a post process
  15915. */
  15916. export type PostProcessOptions = {
  15917. width: number;
  15918. height: number;
  15919. };
  15920. /**
  15921. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15922. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15923. */
  15924. export class PostProcess {
  15925. /** Name of the PostProcess. */
  15926. name: string;
  15927. /**
  15928. * Gets or sets the unique id of the post process
  15929. */
  15930. uniqueId: number;
  15931. /**
  15932. * Width of the texture to apply the post process on
  15933. */
  15934. width: number;
  15935. /**
  15936. * Height of the texture to apply the post process on
  15937. */
  15938. height: number;
  15939. /**
  15940. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15941. * @hidden
  15942. */
  15943. _outputTexture: Nullable<InternalTexture>;
  15944. /**
  15945. * Sampling mode used by the shader
  15946. * See https://doc.babylonjs.com/classes/3.1/texture
  15947. */
  15948. renderTargetSamplingMode: number;
  15949. /**
  15950. * Clear color to use when screen clearing
  15951. */
  15952. clearColor: Color4;
  15953. /**
  15954. * If the buffer needs to be cleared before applying the post process. (default: true)
  15955. * Should be set to false if shader will overwrite all previous pixels.
  15956. */
  15957. autoClear: boolean;
  15958. /**
  15959. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15960. */
  15961. alphaMode: number;
  15962. /**
  15963. * Sets the setAlphaBlendConstants of the babylon engine
  15964. */
  15965. alphaConstants: Color4;
  15966. /**
  15967. * Animations to be used for the post processing
  15968. */
  15969. animations: import("babylonjs/Animations/animation").Animation[];
  15970. /**
  15971. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15972. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15973. */
  15974. enablePixelPerfectMode: boolean;
  15975. /**
  15976. * Force the postprocess to be applied without taking in account viewport
  15977. */
  15978. forceFullscreenViewport: boolean;
  15979. /**
  15980. * List of inspectable custom properties (used by the Inspector)
  15981. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15982. */
  15983. inspectableCustomProperties: IInspectable[];
  15984. /**
  15985. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15986. *
  15987. * | Value | Type | Description |
  15988. * | ----- | ----------------------------------- | ----------- |
  15989. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15990. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15991. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15992. *
  15993. */
  15994. scaleMode: number;
  15995. /**
  15996. * Force textures to be a power of two (default: false)
  15997. */
  15998. alwaysForcePOT: boolean;
  15999. private _samples;
  16000. /**
  16001. * Number of sample textures (default: 1)
  16002. */
  16003. get samples(): number;
  16004. set samples(n: number);
  16005. /**
  16006. * Modify the scale of the post process to be the same as the viewport (default: false)
  16007. */
  16008. adaptScaleToCurrentViewport: boolean;
  16009. private _camera;
  16010. private _scene;
  16011. private _engine;
  16012. private _options;
  16013. private _reusable;
  16014. private _textureType;
  16015. private _textureFormat;
  16016. /**
  16017. * Smart array of input and output textures for the post process.
  16018. * @hidden
  16019. */
  16020. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  16021. /**
  16022. * The index in _textures that corresponds to the output texture.
  16023. * @hidden
  16024. */
  16025. _currentRenderTextureInd: number;
  16026. private _effect;
  16027. private _samplers;
  16028. private _fragmentUrl;
  16029. private _vertexUrl;
  16030. private _parameters;
  16031. private _scaleRatio;
  16032. protected _indexParameters: any;
  16033. private _shareOutputWithPostProcess;
  16034. private _texelSize;
  16035. private _forcedOutputTexture;
  16036. /**
  16037. * Returns the fragment url or shader name used in the post process.
  16038. * @returns the fragment url or name in the shader store.
  16039. */
  16040. getEffectName(): string;
  16041. /**
  16042. * An event triggered when the postprocess is activated.
  16043. */
  16044. onActivateObservable: Observable<Camera>;
  16045. private _onActivateObserver;
  16046. /**
  16047. * A function that is added to the onActivateObservable
  16048. */
  16049. set onActivate(callback: Nullable<(camera: Camera) => void>);
  16050. /**
  16051. * An event triggered when the postprocess changes its size.
  16052. */
  16053. onSizeChangedObservable: Observable<PostProcess>;
  16054. private _onSizeChangedObserver;
  16055. /**
  16056. * A function that is added to the onSizeChangedObservable
  16057. */
  16058. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  16059. /**
  16060. * An event triggered when the postprocess applies its effect.
  16061. */
  16062. onApplyObservable: Observable<Effect>;
  16063. private _onApplyObserver;
  16064. /**
  16065. * A function that is added to the onApplyObservable
  16066. */
  16067. set onApply(callback: (effect: Effect) => void);
  16068. /**
  16069. * An event triggered before rendering the postprocess
  16070. */
  16071. onBeforeRenderObservable: Observable<Effect>;
  16072. private _onBeforeRenderObserver;
  16073. /**
  16074. * A function that is added to the onBeforeRenderObservable
  16075. */
  16076. set onBeforeRender(callback: (effect: Effect) => void);
  16077. /**
  16078. * An event triggered after rendering the postprocess
  16079. */
  16080. onAfterRenderObservable: Observable<Effect>;
  16081. private _onAfterRenderObserver;
  16082. /**
  16083. * A function that is added to the onAfterRenderObservable
  16084. */
  16085. set onAfterRender(callback: (efect: Effect) => void);
  16086. /**
  16087. * 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
  16088. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16089. */
  16090. get inputTexture(): InternalTexture;
  16091. set inputTexture(value: InternalTexture);
  16092. /**
  16093. * Gets the camera which post process is applied to.
  16094. * @returns The camera the post process is applied to.
  16095. */
  16096. getCamera(): Camera;
  16097. /**
  16098. * Gets the texel size of the postprocess.
  16099. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16100. */
  16101. get texelSize(): Vector2;
  16102. /**
  16103. * Creates a new instance PostProcess
  16104. * @param name The name of the PostProcess.
  16105. * @param fragmentUrl The url of the fragment shader to be used.
  16106. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16107. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16108. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16109. * @param camera The camera to apply the render pass to.
  16110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16111. * @param engine The engine which the post process will be applied. (default: current engine)
  16112. * @param reusable If the post process can be reused on the same frame. (default: false)
  16113. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16114. * @param textureType Type of textures used when performing the post process. (default: 0)
  16115. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16116. * @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
  16117. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16118. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  16119. */
  16120. constructor(
  16121. /** Name of the PostProcess. */
  16122. 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);
  16123. /**
  16124. * Gets a string idenfifying the name of the class
  16125. * @returns "PostProcess" string
  16126. */
  16127. getClassName(): string;
  16128. /**
  16129. * Gets the engine which this post process belongs to.
  16130. * @returns The engine the post process was enabled with.
  16131. */
  16132. getEngine(): Engine;
  16133. /**
  16134. * The effect that is created when initializing the post process.
  16135. * @returns The created effect corresponding the the postprocess.
  16136. */
  16137. getEffect(): Effect;
  16138. /**
  16139. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16140. * @param postProcess The post process to share the output with.
  16141. * @returns This post process.
  16142. */
  16143. shareOutputWith(postProcess: PostProcess): PostProcess;
  16144. /**
  16145. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16146. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16147. */
  16148. useOwnOutput(): void;
  16149. /**
  16150. * Updates the effect with the current post process compile time values and recompiles the shader.
  16151. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16152. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16153. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16154. * @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
  16155. * @param onCompiled Called when the shader has been compiled.
  16156. * @param onError Called if there is an error when compiling a shader.
  16157. */
  16158. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16159. /**
  16160. * The post process is reusable if it can be used multiple times within one frame.
  16161. * @returns If the post process is reusable
  16162. */
  16163. isReusable(): boolean;
  16164. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16165. markTextureDirty(): void;
  16166. /**
  16167. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16168. * 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.
  16169. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16170. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16171. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16172. * @returns The target texture that was bound to be written to.
  16173. */
  16174. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16175. /**
  16176. * If the post process is supported.
  16177. */
  16178. get isSupported(): boolean;
  16179. /**
  16180. * The aspect ratio of the output texture.
  16181. */
  16182. get aspectRatio(): number;
  16183. /**
  16184. * Get a value indicating if the post-process is ready to be used
  16185. * @returns true if the post-process is ready (shader is compiled)
  16186. */
  16187. isReady(): boolean;
  16188. /**
  16189. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16190. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16191. */
  16192. apply(): Nullable<Effect>;
  16193. private _disposeTextures;
  16194. /**
  16195. * Disposes the post process.
  16196. * @param camera The camera to dispose the post process on.
  16197. */
  16198. dispose(camera?: Camera): void;
  16199. }
  16200. }
  16201. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16202. /** @hidden */
  16203. export var kernelBlurVaryingDeclaration: {
  16204. name: string;
  16205. shader: string;
  16206. };
  16207. }
  16208. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16209. /** @hidden */
  16210. export var kernelBlurFragment: {
  16211. name: string;
  16212. shader: string;
  16213. };
  16214. }
  16215. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16216. /** @hidden */
  16217. export var kernelBlurFragment2: {
  16218. name: string;
  16219. shader: string;
  16220. };
  16221. }
  16222. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16223. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16224. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16225. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16226. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16227. /** @hidden */
  16228. export var kernelBlurPixelShader: {
  16229. name: string;
  16230. shader: string;
  16231. };
  16232. }
  16233. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16234. /** @hidden */
  16235. export var kernelBlurVertex: {
  16236. name: string;
  16237. shader: string;
  16238. };
  16239. }
  16240. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16241. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16242. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16243. /** @hidden */
  16244. export var kernelBlurVertexShader: {
  16245. name: string;
  16246. shader: string;
  16247. };
  16248. }
  16249. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16250. import { Vector2 } from "babylonjs/Maths/math.vector";
  16251. import { Nullable } from "babylonjs/types";
  16252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16253. import { Camera } from "babylonjs/Cameras/camera";
  16254. import { Effect } from "babylonjs/Materials/effect";
  16255. import { Engine } from "babylonjs/Engines/engine";
  16256. import "babylonjs/Shaders/kernelBlur.fragment";
  16257. import "babylonjs/Shaders/kernelBlur.vertex";
  16258. /**
  16259. * The Blur Post Process which blurs an image based on a kernel and direction.
  16260. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16261. */
  16262. export class BlurPostProcess extends PostProcess {
  16263. /** The direction in which to blur the image. */
  16264. direction: Vector2;
  16265. private blockCompilation;
  16266. protected _kernel: number;
  16267. protected _idealKernel: number;
  16268. protected _packedFloat: boolean;
  16269. private _staticDefines;
  16270. /**
  16271. * Sets the length in pixels of the blur sample region
  16272. */
  16273. set kernel(v: number);
  16274. /**
  16275. * Gets the length in pixels of the blur sample region
  16276. */
  16277. get kernel(): number;
  16278. /**
  16279. * Sets wether or not the blur needs to unpack/repack floats
  16280. */
  16281. set packedFloat(v: boolean);
  16282. /**
  16283. * Gets wether or not the blur is unpacking/repacking floats
  16284. */
  16285. get packedFloat(): boolean;
  16286. /**
  16287. * Creates a new instance BlurPostProcess
  16288. * @param name The name of the effect.
  16289. * @param direction The direction in which to blur the image.
  16290. * @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.
  16291. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16292. * @param camera The camera to apply the render pass to.
  16293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16294. * @param engine The engine which the post process will be applied. (default: current engine)
  16295. * @param reusable If the post process can be reused on the same frame. (default: false)
  16296. * @param textureType Type of textures used when performing the post process. (default: 0)
  16297. * @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)
  16298. */
  16299. constructor(name: string,
  16300. /** The direction in which to blur the image. */
  16301. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16302. /**
  16303. * Updates the effect with the current post process compile time values and recompiles the shader.
  16304. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16305. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16306. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16307. * @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
  16308. * @param onCompiled Called when the shader has been compiled.
  16309. * @param onError Called if there is an error when compiling a shader.
  16310. */
  16311. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16312. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16313. /**
  16314. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16315. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16316. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16317. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16318. * The gaps between physical kernels are compensated for in the weighting of the samples
  16319. * @param idealKernel Ideal blur kernel.
  16320. * @return Nearest best kernel.
  16321. */
  16322. protected _nearestBestKernel(idealKernel: number): number;
  16323. /**
  16324. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16325. * @param x The point on the Gaussian distribution to sample.
  16326. * @return the value of the Gaussian function at x.
  16327. */
  16328. protected _gaussianWeight(x: number): number;
  16329. /**
  16330. * Generates a string that can be used as a floating point number in GLSL.
  16331. * @param x Value to print.
  16332. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16333. * @return GLSL float string.
  16334. */
  16335. protected _glslFloat(x: number, decimalFigures?: number): string;
  16336. }
  16337. }
  16338. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16339. import { Scene } from "babylonjs/scene";
  16340. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16341. import { Plane } from "babylonjs/Maths/math.plane";
  16342. /**
  16343. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16344. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16345. * You can then easily use it as a reflectionTexture on a flat surface.
  16346. * In case the surface is not a plane, please consider relying on reflection probes.
  16347. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16348. */
  16349. export class MirrorTexture extends RenderTargetTexture {
  16350. private scene;
  16351. /**
  16352. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16353. * 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.
  16354. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16355. */
  16356. mirrorPlane: Plane;
  16357. /**
  16358. * Define the blur ratio used to blur the reflection if needed.
  16359. */
  16360. set blurRatio(value: number);
  16361. get blurRatio(): number;
  16362. /**
  16363. * Define the adaptive blur kernel used to blur the reflection if needed.
  16364. * This will autocompute the closest best match for the `blurKernel`
  16365. */
  16366. set adaptiveBlurKernel(value: number);
  16367. /**
  16368. * Define the blur kernel used to blur the reflection if needed.
  16369. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16370. */
  16371. set blurKernel(value: number);
  16372. /**
  16373. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16374. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16375. */
  16376. set blurKernelX(value: number);
  16377. get blurKernelX(): number;
  16378. /**
  16379. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16380. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16381. */
  16382. set blurKernelY(value: number);
  16383. get blurKernelY(): number;
  16384. private _autoComputeBlurKernel;
  16385. protected _onRatioRescale(): void;
  16386. private _updateGammaSpace;
  16387. private _imageProcessingConfigChangeObserver;
  16388. private _transformMatrix;
  16389. private _mirrorMatrix;
  16390. private _savedViewMatrix;
  16391. private _blurX;
  16392. private _blurY;
  16393. private _adaptiveBlurKernel;
  16394. private _blurKernelX;
  16395. private _blurKernelY;
  16396. private _blurRatio;
  16397. /**
  16398. * Instantiates a Mirror Texture.
  16399. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16400. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16401. * You can then easily use it as a reflectionTexture on a flat surface.
  16402. * In case the surface is not a plane, please consider relying on reflection probes.
  16403. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16404. * @param name
  16405. * @param size
  16406. * @param scene
  16407. * @param generateMipMaps
  16408. * @param type
  16409. * @param samplingMode
  16410. * @param generateDepthBuffer
  16411. */
  16412. constructor(name: string, size: number | {
  16413. width: number;
  16414. height: number;
  16415. } | {
  16416. ratio: number;
  16417. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16418. private _preparePostProcesses;
  16419. /**
  16420. * Clone the mirror texture.
  16421. * @returns the cloned texture
  16422. */
  16423. clone(): MirrorTexture;
  16424. /**
  16425. * Serialize the texture to a JSON representation you could use in Parse later on
  16426. * @returns the serialized JSON representation
  16427. */
  16428. serialize(): any;
  16429. /**
  16430. * Dispose the texture and release its associated resources.
  16431. */
  16432. dispose(): void;
  16433. }
  16434. }
  16435. declare module "babylonjs/Materials/Textures/texture" {
  16436. import { Observable } from "babylonjs/Misc/observable";
  16437. import { Nullable } from "babylonjs/types";
  16438. import { Matrix } from "babylonjs/Maths/math.vector";
  16439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16440. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16441. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16442. import { Scene } from "babylonjs/scene";
  16443. /**
  16444. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16445. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16446. */
  16447. export class Texture extends BaseTexture {
  16448. /**
  16449. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16450. */
  16451. static SerializeBuffers: boolean;
  16452. /** @hidden */
  16453. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16454. /** @hidden */
  16455. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16456. /** @hidden */
  16457. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16458. /** nearest is mag = nearest and min = nearest and mip = linear */
  16459. static readonly NEAREST_SAMPLINGMODE: number;
  16460. /** nearest is mag = nearest and min = nearest and mip = linear */
  16461. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16462. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16463. static readonly BILINEAR_SAMPLINGMODE: number;
  16464. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16465. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16466. /** Trilinear is mag = linear and min = linear and mip = linear */
  16467. static readonly TRILINEAR_SAMPLINGMODE: number;
  16468. /** Trilinear is mag = linear and min = linear and mip = linear */
  16469. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16470. /** mag = nearest and min = nearest and mip = nearest */
  16471. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16472. /** mag = nearest and min = linear and mip = nearest */
  16473. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16474. /** mag = nearest and min = linear and mip = linear */
  16475. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16476. /** mag = nearest and min = linear and mip = none */
  16477. static readonly NEAREST_LINEAR: number;
  16478. /** mag = nearest and min = nearest and mip = none */
  16479. static readonly NEAREST_NEAREST: number;
  16480. /** mag = linear and min = nearest and mip = nearest */
  16481. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16482. /** mag = linear and min = nearest and mip = linear */
  16483. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16484. /** mag = linear and min = linear and mip = none */
  16485. static readonly LINEAR_LINEAR: number;
  16486. /** mag = linear and min = nearest and mip = none */
  16487. static readonly LINEAR_NEAREST: number;
  16488. /** Explicit coordinates mode */
  16489. static readonly EXPLICIT_MODE: number;
  16490. /** Spherical coordinates mode */
  16491. static readonly SPHERICAL_MODE: number;
  16492. /** Planar coordinates mode */
  16493. static readonly PLANAR_MODE: number;
  16494. /** Cubic coordinates mode */
  16495. static readonly CUBIC_MODE: number;
  16496. /** Projection coordinates mode */
  16497. static readonly PROJECTION_MODE: number;
  16498. /** Inverse Cubic coordinates mode */
  16499. static readonly SKYBOX_MODE: number;
  16500. /** Inverse Cubic coordinates mode */
  16501. static readonly INVCUBIC_MODE: number;
  16502. /** Equirectangular coordinates mode */
  16503. static readonly EQUIRECTANGULAR_MODE: number;
  16504. /** Equirectangular Fixed coordinates mode */
  16505. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16506. /** Equirectangular Fixed Mirrored coordinates mode */
  16507. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16508. /** Texture is not repeating outside of 0..1 UVs */
  16509. static readonly CLAMP_ADDRESSMODE: number;
  16510. /** Texture is repeating outside of 0..1 UVs */
  16511. static readonly WRAP_ADDRESSMODE: number;
  16512. /** Texture is repeating and mirrored */
  16513. static readonly MIRROR_ADDRESSMODE: number;
  16514. /**
  16515. * 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
  16516. */
  16517. static UseSerializedUrlIfAny: boolean;
  16518. /**
  16519. * Define the url of the texture.
  16520. */
  16521. url: Nullable<string>;
  16522. /**
  16523. * Define an offset on the texture to offset the u coordinates of the UVs
  16524. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16525. */
  16526. uOffset: number;
  16527. /**
  16528. * Define an offset on the texture to offset the v coordinates of the UVs
  16529. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16530. */
  16531. vOffset: number;
  16532. /**
  16533. * Define an offset on the texture to scale the u coordinates of the UVs
  16534. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16535. */
  16536. uScale: number;
  16537. /**
  16538. * Define an offset on the texture to scale the v coordinates of the UVs
  16539. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16540. */
  16541. vScale: number;
  16542. /**
  16543. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16544. * @see http://doc.babylonjs.com/how_to/more_materials
  16545. */
  16546. uAng: number;
  16547. /**
  16548. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16549. * @see http://doc.babylonjs.com/how_to/more_materials
  16550. */
  16551. vAng: number;
  16552. /**
  16553. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16554. * @see http://doc.babylonjs.com/how_to/more_materials
  16555. */
  16556. wAng: number;
  16557. /**
  16558. * Defines the center of rotation (U)
  16559. */
  16560. uRotationCenter: number;
  16561. /**
  16562. * Defines the center of rotation (V)
  16563. */
  16564. vRotationCenter: number;
  16565. /**
  16566. * Defines the center of rotation (W)
  16567. */
  16568. wRotationCenter: number;
  16569. /**
  16570. * Are mip maps generated for this texture or not.
  16571. */
  16572. get noMipmap(): boolean;
  16573. /**
  16574. * List of inspectable custom properties (used by the Inspector)
  16575. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16576. */
  16577. inspectableCustomProperties: Nullable<IInspectable[]>;
  16578. private _noMipmap;
  16579. /** @hidden */
  16580. _invertY: boolean;
  16581. private _rowGenerationMatrix;
  16582. private _cachedTextureMatrix;
  16583. private _projectionModeMatrix;
  16584. private _t0;
  16585. private _t1;
  16586. private _t2;
  16587. private _cachedUOffset;
  16588. private _cachedVOffset;
  16589. private _cachedUScale;
  16590. private _cachedVScale;
  16591. private _cachedUAng;
  16592. private _cachedVAng;
  16593. private _cachedWAng;
  16594. private _cachedProjectionMatrixId;
  16595. private _cachedCoordinatesMode;
  16596. /** @hidden */
  16597. protected _initialSamplingMode: number;
  16598. /** @hidden */
  16599. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16600. private _deleteBuffer;
  16601. protected _format: Nullable<number>;
  16602. private _delayedOnLoad;
  16603. private _delayedOnError;
  16604. private _mimeType?;
  16605. /**
  16606. * Observable triggered once the texture has been loaded.
  16607. */
  16608. onLoadObservable: Observable<Texture>;
  16609. protected _isBlocking: boolean;
  16610. /**
  16611. * Is the texture preventing material to render while loading.
  16612. * If false, a default texture will be used instead of the loading one during the preparation step.
  16613. */
  16614. set isBlocking(value: boolean);
  16615. get isBlocking(): boolean;
  16616. /**
  16617. * Get the current sampling mode associated with the texture.
  16618. */
  16619. get samplingMode(): number;
  16620. /**
  16621. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16622. */
  16623. get invertY(): boolean;
  16624. /**
  16625. * Instantiates a new texture.
  16626. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16627. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16628. * @param url defines the url of the picture to load as a texture
  16629. * @param scene defines the scene or engine the texture will belong to
  16630. * @param noMipmap defines if the texture will require mip maps or not
  16631. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16632. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16633. * @param onLoad defines a callback triggered when the texture has been loaded
  16634. * @param onError defines a callback triggered when an error occurred during the loading session
  16635. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16636. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16637. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16638. * @param mimeType defines an optional mime type information
  16639. */
  16640. 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);
  16641. /**
  16642. * Update the url (and optional buffer) of this texture if url was null during construction.
  16643. * @param url the url of the texture
  16644. * @param buffer the buffer of the texture (defaults to null)
  16645. * @param onLoad callback called when the texture is loaded (defaults to null)
  16646. */
  16647. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16648. /**
  16649. * Finish the loading sequence of a texture flagged as delayed load.
  16650. * @hidden
  16651. */
  16652. delayLoad(): void;
  16653. private _prepareRowForTextureGeneration;
  16654. /**
  16655. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16656. * @returns the transform matrix of the texture.
  16657. */
  16658. getTextureMatrix(uBase?: number): Matrix;
  16659. /**
  16660. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16661. * @returns The reflection texture transform
  16662. */
  16663. getReflectionTextureMatrix(): Matrix;
  16664. /**
  16665. * Clones the texture.
  16666. * @returns the cloned texture
  16667. */
  16668. clone(): Texture;
  16669. /**
  16670. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16671. * @returns The JSON representation of the texture
  16672. */
  16673. serialize(): any;
  16674. /**
  16675. * Get the current class name of the texture useful for serialization or dynamic coding.
  16676. * @returns "Texture"
  16677. */
  16678. getClassName(): string;
  16679. /**
  16680. * Dispose the texture and release its associated resources.
  16681. */
  16682. dispose(): void;
  16683. /**
  16684. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16685. * @param parsedTexture Define the JSON representation of the texture
  16686. * @param scene Define the scene the parsed texture should be instantiated in
  16687. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16688. * @returns The parsed texture if successful
  16689. */
  16690. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16691. /**
  16692. * Creates a texture from its base 64 representation.
  16693. * @param data Define the base64 payload without the data: prefix
  16694. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16695. * @param scene Define the scene the texture should belong to
  16696. * @param noMipmap Forces the texture to not create mip map information if true
  16697. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16698. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16699. * @param onLoad define a callback triggered when the texture has been loaded
  16700. * @param onError define a callback triggered when an error occurred during the loading session
  16701. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16702. * @returns the created texture
  16703. */
  16704. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16705. /**
  16706. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16707. * @param data Define the base64 payload without the data: prefix
  16708. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16709. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16710. * @param scene Define the scene the texture should belong to
  16711. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16712. * @param noMipmap Forces the texture to not create mip map information if true
  16713. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16714. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16715. * @param onLoad define a callback triggered when the texture has been loaded
  16716. * @param onError define a callback triggered when an error occurred during the loading session
  16717. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16718. * @returns the created texture
  16719. */
  16720. 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;
  16721. }
  16722. }
  16723. declare module "babylonjs/PostProcesses/postProcessManager" {
  16724. import { Nullable } from "babylonjs/types";
  16725. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16726. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16727. import { Scene } from "babylonjs/scene";
  16728. /**
  16729. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16730. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16731. */
  16732. export class PostProcessManager {
  16733. private _scene;
  16734. private _indexBuffer;
  16735. private _vertexBuffers;
  16736. /**
  16737. * Creates a new instance PostProcess
  16738. * @param scene The scene that the post process is associated with.
  16739. */
  16740. constructor(scene: Scene);
  16741. private _prepareBuffers;
  16742. private _buildIndexBuffer;
  16743. /**
  16744. * Rebuilds the vertex buffers of the manager.
  16745. * @hidden
  16746. */
  16747. _rebuild(): void;
  16748. /**
  16749. * Prepares a frame to be run through a post process.
  16750. * @param sourceTexture The input texture to the post procesess. (default: null)
  16751. * @param postProcesses An array of post processes to be run. (default: null)
  16752. * @returns True if the post processes were able to be run.
  16753. * @hidden
  16754. */
  16755. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16756. /**
  16757. * Manually render a set of post processes to a texture.
  16758. * @param postProcesses An array of post processes to be run.
  16759. * @param targetTexture The target texture to render to.
  16760. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16761. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16762. * @param lodLevel defines which lod of the texture to render to
  16763. */
  16764. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16765. /**
  16766. * Finalize the result of the output of the postprocesses.
  16767. * @param doNotPresent If true the result will not be displayed to the screen.
  16768. * @param targetTexture The target texture to render to.
  16769. * @param faceIndex The index of the face to bind the target texture to.
  16770. * @param postProcesses The array of post processes to render.
  16771. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16772. * @hidden
  16773. */
  16774. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16775. /**
  16776. * Disposes of the post process manager.
  16777. */
  16778. dispose(): void;
  16779. }
  16780. }
  16781. declare module "babylonjs/Misc/gradients" {
  16782. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16783. /** Interface used by value gradients (color, factor, ...) */
  16784. export interface IValueGradient {
  16785. /**
  16786. * Gets or sets the gradient value (between 0 and 1)
  16787. */
  16788. gradient: number;
  16789. }
  16790. /** Class used to store color4 gradient */
  16791. export class ColorGradient implements IValueGradient {
  16792. /**
  16793. * Gets or sets the gradient value (between 0 and 1)
  16794. */
  16795. gradient: number;
  16796. /**
  16797. * Gets or sets first associated color
  16798. */
  16799. color1: Color4;
  16800. /**
  16801. * Gets or sets second associated color
  16802. */
  16803. color2?: Color4;
  16804. /**
  16805. * Will get a color picked randomly between color1 and color2.
  16806. * If color2 is undefined then color1 will be used
  16807. * @param result defines the target Color4 to store the result in
  16808. */
  16809. getColorToRef(result: Color4): void;
  16810. }
  16811. /** Class used to store color 3 gradient */
  16812. export class Color3Gradient implements IValueGradient {
  16813. /**
  16814. * Gets or sets the gradient value (between 0 and 1)
  16815. */
  16816. gradient: number;
  16817. /**
  16818. * Gets or sets the associated color
  16819. */
  16820. color: Color3;
  16821. }
  16822. /** Class used to store factor gradient */
  16823. export class FactorGradient implements IValueGradient {
  16824. /**
  16825. * Gets or sets the gradient value (between 0 and 1)
  16826. */
  16827. gradient: number;
  16828. /**
  16829. * Gets or sets first associated factor
  16830. */
  16831. factor1: number;
  16832. /**
  16833. * Gets or sets second associated factor
  16834. */
  16835. factor2?: number;
  16836. /**
  16837. * Will get a number picked randomly between factor1 and factor2.
  16838. * If factor2 is undefined then factor1 will be used
  16839. * @returns the picked number
  16840. */
  16841. getFactor(): number;
  16842. }
  16843. /**
  16844. * Helper used to simplify some generic gradient tasks
  16845. */
  16846. export class GradientHelper {
  16847. /**
  16848. * Gets the current gradient from an array of IValueGradient
  16849. * @param ratio defines the current ratio to get
  16850. * @param gradients defines the array of IValueGradient
  16851. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16852. */
  16853. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16854. }
  16855. }
  16856. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16858. import { Nullable } from "babylonjs/types";
  16859. module "babylonjs/Engines/thinEngine" {
  16860. interface ThinEngine {
  16861. /**
  16862. * Creates a dynamic texture
  16863. * @param width defines the width of the texture
  16864. * @param height defines the height of the texture
  16865. * @param generateMipMaps defines if the engine should generate the mip levels
  16866. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16867. * @returns the dynamic texture inside an InternalTexture
  16868. */
  16869. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16870. /**
  16871. * Update the content of a dynamic texture
  16872. * @param texture defines the texture to update
  16873. * @param canvas defines the canvas containing the source
  16874. * @param invertY defines if data must be stored with Y axis inverted
  16875. * @param premulAlpha defines if alpha is stored as premultiplied
  16876. * @param format defines the format of the data
  16877. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16878. */
  16879. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16880. }
  16881. }
  16882. }
  16883. declare module "babylonjs/Misc/canvasGenerator" {
  16884. /**
  16885. * Helper class used to generate a canvas to manipulate images
  16886. */
  16887. export class CanvasGenerator {
  16888. /**
  16889. * Create a new canvas (or offscreen canvas depending on the context)
  16890. * @param width defines the expected width
  16891. * @param height defines the expected height
  16892. * @return a new canvas or offscreen canvas
  16893. */
  16894. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16895. }
  16896. }
  16897. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16898. import { Scene } from "babylonjs/scene";
  16899. import { Texture } from "babylonjs/Materials/Textures/texture";
  16900. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16901. /**
  16902. * A class extending Texture allowing drawing on a texture
  16903. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16904. */
  16905. export class DynamicTexture extends Texture {
  16906. private _generateMipMaps;
  16907. private _canvas;
  16908. private _context;
  16909. private _engine;
  16910. /**
  16911. * Creates a DynamicTexture
  16912. * @param name defines the name of the texture
  16913. * @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
  16914. * @param scene defines the scene where you want the texture
  16915. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16916. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16917. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16918. */
  16919. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16920. /**
  16921. * Get the current class name of the texture useful for serialization or dynamic coding.
  16922. * @returns "DynamicTexture"
  16923. */
  16924. getClassName(): string;
  16925. /**
  16926. * Gets the current state of canRescale
  16927. */
  16928. get canRescale(): boolean;
  16929. private _recreate;
  16930. /**
  16931. * Scales the texture
  16932. * @param ratio the scale factor to apply to both width and height
  16933. */
  16934. scale(ratio: number): void;
  16935. /**
  16936. * Resizes the texture
  16937. * @param width the new width
  16938. * @param height the new height
  16939. */
  16940. scaleTo(width: number, height: number): void;
  16941. /**
  16942. * Gets the context of the canvas used by the texture
  16943. * @returns the canvas context of the dynamic texture
  16944. */
  16945. getContext(): CanvasRenderingContext2D;
  16946. /**
  16947. * Clears the texture
  16948. */
  16949. clear(): void;
  16950. /**
  16951. * Updates the texture
  16952. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16953. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16954. */
  16955. update(invertY?: boolean, premulAlpha?: boolean): void;
  16956. /**
  16957. * Draws text onto the texture
  16958. * @param text defines the text to be drawn
  16959. * @param x defines the placement of the text from the left
  16960. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16961. * @param font defines the font to be used with font-style, font-size, font-name
  16962. * @param color defines the color used for the text
  16963. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16964. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16965. * @param update defines whether texture is immediately update (default is true)
  16966. */
  16967. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16968. /**
  16969. * Clones the texture
  16970. * @returns the clone of the texture.
  16971. */
  16972. clone(): DynamicTexture;
  16973. /**
  16974. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16975. * @returns a serialized dynamic texture object
  16976. */
  16977. serialize(): any;
  16978. /** @hidden */
  16979. _rebuild(): void;
  16980. }
  16981. }
  16982. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16983. import { Scene } from "babylonjs/scene";
  16984. import { ISceneComponent } from "babylonjs/sceneComponent";
  16985. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16986. module "babylonjs/abstractScene" {
  16987. interface AbstractScene {
  16988. /**
  16989. * The list of procedural textures added to the scene
  16990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16991. */
  16992. proceduralTextures: Array<ProceduralTexture>;
  16993. }
  16994. }
  16995. /**
  16996. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16997. * in a given scene.
  16998. */
  16999. export class ProceduralTextureSceneComponent implements ISceneComponent {
  17000. /**
  17001. * The component name helpfull to identify the component in the list of scene components.
  17002. */
  17003. readonly name: string;
  17004. /**
  17005. * The scene the component belongs to.
  17006. */
  17007. scene: Scene;
  17008. /**
  17009. * Creates a new instance of the component for the given scene
  17010. * @param scene Defines the scene to register the component in
  17011. */
  17012. constructor(scene: Scene);
  17013. /**
  17014. * Registers the component in a given scene
  17015. */
  17016. register(): void;
  17017. /**
  17018. * Rebuilds the elements related to this component in case of
  17019. * context lost for instance.
  17020. */
  17021. rebuild(): void;
  17022. /**
  17023. * Disposes the component and the associated ressources.
  17024. */
  17025. dispose(): void;
  17026. private _beforeClear;
  17027. }
  17028. }
  17029. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  17030. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17031. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17032. module "babylonjs/Engines/thinEngine" {
  17033. interface ThinEngine {
  17034. /**
  17035. * Creates a new render target cube texture
  17036. * @param size defines the size of the texture
  17037. * @param options defines the options used to create the texture
  17038. * @returns a new render target cube texture stored in an InternalTexture
  17039. */
  17040. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  17041. }
  17042. }
  17043. }
  17044. declare module "babylonjs/Shaders/procedural.vertex" {
  17045. /** @hidden */
  17046. export var proceduralVertexShader: {
  17047. name: string;
  17048. shader: string;
  17049. };
  17050. }
  17051. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  17052. import { Observable } from "babylonjs/Misc/observable";
  17053. import { Nullable } from "babylonjs/types";
  17054. import { Scene } from "babylonjs/scene";
  17055. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  17056. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17057. import { Effect } from "babylonjs/Materials/effect";
  17058. import { Texture } from "babylonjs/Materials/Textures/texture";
  17059. import "babylonjs/Engines/Extensions/engine.renderTarget";
  17060. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  17061. import "babylonjs/Shaders/procedural.vertex";
  17062. /**
  17063. * 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.
  17064. * This is the base class of any Procedural texture and contains most of the shareable code.
  17065. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17066. */
  17067. export class ProceduralTexture extends Texture {
  17068. isCube: boolean;
  17069. /**
  17070. * Define if the texture is enabled or not (disabled texture will not render)
  17071. */
  17072. isEnabled: boolean;
  17073. /**
  17074. * Define if the texture must be cleared before rendering (default is true)
  17075. */
  17076. autoClear: boolean;
  17077. /**
  17078. * Callback called when the texture is generated
  17079. */
  17080. onGenerated: () => void;
  17081. /**
  17082. * Event raised when the texture is generated
  17083. */
  17084. onGeneratedObservable: Observable<ProceduralTexture>;
  17085. /** @hidden */
  17086. _generateMipMaps: boolean;
  17087. /** @hidden **/
  17088. _effect: Effect;
  17089. /** @hidden */
  17090. _textures: {
  17091. [key: string]: Texture;
  17092. };
  17093. private _size;
  17094. private _currentRefreshId;
  17095. private _frameId;
  17096. private _refreshRate;
  17097. private _vertexBuffers;
  17098. private _indexBuffer;
  17099. private _uniforms;
  17100. private _samplers;
  17101. private _fragment;
  17102. private _floats;
  17103. private _ints;
  17104. private _floatsArrays;
  17105. private _colors3;
  17106. private _colors4;
  17107. private _vectors2;
  17108. private _vectors3;
  17109. private _matrices;
  17110. private _fallbackTexture;
  17111. private _fallbackTextureUsed;
  17112. private _engine;
  17113. private _cachedDefines;
  17114. private _contentUpdateId;
  17115. private _contentData;
  17116. /**
  17117. * Instantiates a new procedural texture.
  17118. * 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.
  17119. * This is the base class of any Procedural texture and contains most of the shareable code.
  17120. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17121. * @param name Define the name of the texture
  17122. * @param size Define the size of the texture to create
  17123. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17124. * @param scene Define the scene the texture belongs to
  17125. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17126. * @param generateMipMaps Define if the texture should creates mip maps or not
  17127. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17128. */
  17129. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17130. /**
  17131. * The effect that is created when initializing the post process.
  17132. * @returns The created effect corresponding the the postprocess.
  17133. */
  17134. getEffect(): Effect;
  17135. /**
  17136. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17137. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17138. */
  17139. getContent(): Nullable<ArrayBufferView>;
  17140. private _createIndexBuffer;
  17141. /** @hidden */
  17142. _rebuild(): void;
  17143. /**
  17144. * Resets the texture in order to recreate its associated resources.
  17145. * This can be called in case of context loss
  17146. */
  17147. reset(): void;
  17148. protected _getDefines(): string;
  17149. /**
  17150. * Is the texture ready to be used ? (rendered at least once)
  17151. * @returns true if ready, otherwise, false.
  17152. */
  17153. isReady(): boolean;
  17154. /**
  17155. * Resets the refresh counter of the texture and start bak from scratch.
  17156. * Could be useful to regenerate the texture if it is setup to render only once.
  17157. */
  17158. resetRefreshCounter(): void;
  17159. /**
  17160. * Set the fragment shader to use in order to render the texture.
  17161. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17162. */
  17163. setFragment(fragment: any): void;
  17164. /**
  17165. * Define the refresh rate of the texture or the rendering frequency.
  17166. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17167. */
  17168. get refreshRate(): number;
  17169. set refreshRate(value: number);
  17170. /** @hidden */
  17171. _shouldRender(): boolean;
  17172. /**
  17173. * Get the size the texture is rendering at.
  17174. * @returns the size (texture is always squared)
  17175. */
  17176. getRenderSize(): number;
  17177. /**
  17178. * Resize the texture to new value.
  17179. * @param size Define the new size the texture should have
  17180. * @param generateMipMaps Define whether the new texture should create mip maps
  17181. */
  17182. resize(size: number, generateMipMaps: boolean): void;
  17183. private _checkUniform;
  17184. /**
  17185. * Set a texture in the shader program used to render.
  17186. * @param name Define the name of the uniform samplers as defined in the shader
  17187. * @param texture Define the texture to bind to this sampler
  17188. * @return the texture itself allowing "fluent" like uniform updates
  17189. */
  17190. setTexture(name: string, texture: Texture): ProceduralTexture;
  17191. /**
  17192. * Set a float in the shader.
  17193. * @param name Define the name of the uniform as defined in the shader
  17194. * @param value Define the value to give to the uniform
  17195. * @return the texture itself allowing "fluent" like uniform updates
  17196. */
  17197. setFloat(name: string, value: number): ProceduralTexture;
  17198. /**
  17199. * Set a int in the shader.
  17200. * @param name Define the name of the uniform as defined in the shader
  17201. * @param value Define the value to give to the uniform
  17202. * @return the texture itself allowing "fluent" like uniform updates
  17203. */
  17204. setInt(name: string, value: number): ProceduralTexture;
  17205. /**
  17206. * Set an array of floats in the shader.
  17207. * @param name Define the name of the uniform as defined in the shader
  17208. * @param value Define the value to give to the uniform
  17209. * @return the texture itself allowing "fluent" like uniform updates
  17210. */
  17211. setFloats(name: string, value: number[]): ProceduralTexture;
  17212. /**
  17213. * Set a vec3 in the shader from a Color3.
  17214. * @param name Define the name of the uniform as defined in the shader
  17215. * @param value Define the value to give to the uniform
  17216. * @return the texture itself allowing "fluent" like uniform updates
  17217. */
  17218. setColor3(name: string, value: Color3): ProceduralTexture;
  17219. /**
  17220. * Set a vec4 in the shader from a Color4.
  17221. * @param name Define the name of the uniform as defined in the shader
  17222. * @param value Define the value to give to the uniform
  17223. * @return the texture itself allowing "fluent" like uniform updates
  17224. */
  17225. setColor4(name: string, value: Color4): ProceduralTexture;
  17226. /**
  17227. * Set a vec2 in the shader from a Vector2.
  17228. * @param name Define the name of the uniform as defined in the shader
  17229. * @param value Define the value to give to the uniform
  17230. * @return the texture itself allowing "fluent" like uniform updates
  17231. */
  17232. setVector2(name: string, value: Vector2): ProceduralTexture;
  17233. /**
  17234. * Set a vec3 in the shader from a Vector3.
  17235. * @param name Define the name of the uniform as defined in the shader
  17236. * @param value Define the value to give to the uniform
  17237. * @return the texture itself allowing "fluent" like uniform updates
  17238. */
  17239. setVector3(name: string, value: Vector3): ProceduralTexture;
  17240. /**
  17241. * Set a mat4 in the shader from a MAtrix.
  17242. * @param name Define the name of the uniform as defined in the shader
  17243. * @param value Define the value to give to the uniform
  17244. * @return the texture itself allowing "fluent" like uniform updates
  17245. */
  17246. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17247. /**
  17248. * Render the texture to its associated render target.
  17249. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17250. */
  17251. render(useCameraPostProcess?: boolean): void;
  17252. /**
  17253. * Clone the texture.
  17254. * @returns the cloned texture
  17255. */
  17256. clone(): ProceduralTexture;
  17257. /**
  17258. * Dispose the texture and release its asoociated resources.
  17259. */
  17260. dispose(): void;
  17261. }
  17262. }
  17263. declare module "babylonjs/Particles/baseParticleSystem" {
  17264. import { Nullable } from "babylonjs/types";
  17265. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17267. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17268. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17269. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17270. import { Scene } from "babylonjs/scene";
  17271. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17272. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17273. import { Texture } from "babylonjs/Materials/Textures/texture";
  17274. import { Color4 } from "babylonjs/Maths/math.color";
  17275. import { Animation } from "babylonjs/Animations/animation";
  17276. /**
  17277. * This represents the base class for particle system in Babylon.
  17278. * 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.
  17279. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17280. * @example https://doc.babylonjs.com/babylon101/particles
  17281. */
  17282. export class BaseParticleSystem {
  17283. /**
  17284. * Source color is added to the destination color without alpha affecting the result
  17285. */
  17286. static BLENDMODE_ONEONE: number;
  17287. /**
  17288. * Blend current color and particle color using particle’s alpha
  17289. */
  17290. static BLENDMODE_STANDARD: number;
  17291. /**
  17292. * Add current color and particle color multiplied by particle’s alpha
  17293. */
  17294. static BLENDMODE_ADD: number;
  17295. /**
  17296. * Multiply current color with particle color
  17297. */
  17298. static BLENDMODE_MULTIPLY: number;
  17299. /**
  17300. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17301. */
  17302. static BLENDMODE_MULTIPLYADD: number;
  17303. /**
  17304. * List of animations used by the particle system.
  17305. */
  17306. animations: Animation[];
  17307. /**
  17308. * The id of the Particle system.
  17309. */
  17310. id: string;
  17311. /**
  17312. * The friendly name of the Particle system.
  17313. */
  17314. name: string;
  17315. /**
  17316. * The rendering group used by the Particle system to chose when to render.
  17317. */
  17318. renderingGroupId: number;
  17319. /**
  17320. * The emitter represents the Mesh or position we are attaching the particle system to.
  17321. */
  17322. emitter: Nullable<AbstractMesh | Vector3>;
  17323. /**
  17324. * The maximum number of particles to emit per frame
  17325. */
  17326. emitRate: number;
  17327. /**
  17328. * If you want to launch only a few particles at once, that can be done, as well.
  17329. */
  17330. manualEmitCount: number;
  17331. /**
  17332. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17333. */
  17334. updateSpeed: number;
  17335. /**
  17336. * The amount of time the particle system is running (depends of the overall update speed).
  17337. */
  17338. targetStopDuration: number;
  17339. /**
  17340. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17341. */
  17342. disposeOnStop: boolean;
  17343. /**
  17344. * Minimum power of emitting particles.
  17345. */
  17346. minEmitPower: number;
  17347. /**
  17348. * Maximum power of emitting particles.
  17349. */
  17350. maxEmitPower: number;
  17351. /**
  17352. * Minimum life time of emitting particles.
  17353. */
  17354. minLifeTime: number;
  17355. /**
  17356. * Maximum life time of emitting particles.
  17357. */
  17358. maxLifeTime: number;
  17359. /**
  17360. * Minimum Size of emitting particles.
  17361. */
  17362. minSize: number;
  17363. /**
  17364. * Maximum Size of emitting particles.
  17365. */
  17366. maxSize: number;
  17367. /**
  17368. * Minimum scale of emitting particles on X axis.
  17369. */
  17370. minScaleX: number;
  17371. /**
  17372. * Maximum scale of emitting particles on X axis.
  17373. */
  17374. maxScaleX: number;
  17375. /**
  17376. * Minimum scale of emitting particles on Y axis.
  17377. */
  17378. minScaleY: number;
  17379. /**
  17380. * Maximum scale of emitting particles on Y axis.
  17381. */
  17382. maxScaleY: number;
  17383. /**
  17384. * Gets or sets the minimal initial rotation in radians.
  17385. */
  17386. minInitialRotation: number;
  17387. /**
  17388. * Gets or sets the maximal initial rotation in radians.
  17389. */
  17390. maxInitialRotation: number;
  17391. /**
  17392. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17393. */
  17394. minAngularSpeed: number;
  17395. /**
  17396. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17397. */
  17398. maxAngularSpeed: number;
  17399. /**
  17400. * The texture used to render each particle. (this can be a spritesheet)
  17401. */
  17402. particleTexture: Nullable<Texture>;
  17403. /**
  17404. * The layer mask we are rendering the particles through.
  17405. */
  17406. layerMask: number;
  17407. /**
  17408. * This can help using your own shader to render the particle system.
  17409. * The according effect will be created
  17410. */
  17411. customShader: any;
  17412. /**
  17413. * By default particle system starts as soon as they are created. This prevents the
  17414. * automatic start to happen and let you decide when to start emitting particles.
  17415. */
  17416. preventAutoStart: boolean;
  17417. private _noiseTexture;
  17418. /**
  17419. * Gets or sets a texture used to add random noise to particle positions
  17420. */
  17421. get noiseTexture(): Nullable<ProceduralTexture>;
  17422. set noiseTexture(value: Nullable<ProceduralTexture>);
  17423. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17424. noiseStrength: Vector3;
  17425. /**
  17426. * Callback triggered when the particle animation is ending.
  17427. */
  17428. onAnimationEnd: Nullable<() => void>;
  17429. /**
  17430. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17431. */
  17432. blendMode: number;
  17433. /**
  17434. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17435. * to override the particles.
  17436. */
  17437. forceDepthWrite: boolean;
  17438. /** 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 */
  17439. preWarmCycles: number;
  17440. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17441. preWarmStepOffset: number;
  17442. /**
  17443. * 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)
  17444. */
  17445. spriteCellChangeSpeed: number;
  17446. /**
  17447. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17448. */
  17449. startSpriteCellID: number;
  17450. /**
  17451. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17452. */
  17453. endSpriteCellID: number;
  17454. /**
  17455. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17456. */
  17457. spriteCellWidth: number;
  17458. /**
  17459. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17460. */
  17461. spriteCellHeight: number;
  17462. /**
  17463. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17464. */
  17465. spriteRandomStartCell: boolean;
  17466. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17467. translationPivot: Vector2;
  17468. /** @hidden */
  17469. protected _isAnimationSheetEnabled: boolean;
  17470. /**
  17471. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17472. */
  17473. beginAnimationOnStart: boolean;
  17474. /**
  17475. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17476. */
  17477. beginAnimationFrom: number;
  17478. /**
  17479. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17480. */
  17481. beginAnimationTo: number;
  17482. /**
  17483. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17484. */
  17485. beginAnimationLoop: boolean;
  17486. /**
  17487. * Gets or sets a world offset applied to all particles
  17488. */
  17489. worldOffset: Vector3;
  17490. /**
  17491. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17492. */
  17493. get isAnimationSheetEnabled(): boolean;
  17494. set isAnimationSheetEnabled(value: boolean);
  17495. /**
  17496. * Get hosting scene
  17497. * @returns the scene
  17498. */
  17499. getScene(): Scene;
  17500. /**
  17501. * You can use gravity if you want to give an orientation to your particles.
  17502. */
  17503. gravity: Vector3;
  17504. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17505. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17506. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17507. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17508. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17509. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17510. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17511. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17512. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17513. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17514. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17515. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17516. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17517. /**
  17518. * Defines the delay in milliseconds before starting the system (0 by default)
  17519. */
  17520. startDelay: number;
  17521. /**
  17522. * Gets the current list of drag gradients.
  17523. * You must use addDragGradient and removeDragGradient to udpate this list
  17524. * @returns the list of drag gradients
  17525. */
  17526. getDragGradients(): Nullable<Array<FactorGradient>>;
  17527. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17528. limitVelocityDamping: number;
  17529. /**
  17530. * Gets the current list of limit velocity gradients.
  17531. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17532. * @returns the list of limit velocity gradients
  17533. */
  17534. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17535. /**
  17536. * Gets the current list of color gradients.
  17537. * You must use addColorGradient and removeColorGradient to udpate this list
  17538. * @returns the list of color gradients
  17539. */
  17540. getColorGradients(): Nullable<Array<ColorGradient>>;
  17541. /**
  17542. * Gets the current list of size gradients.
  17543. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17544. * @returns the list of size gradients
  17545. */
  17546. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17547. /**
  17548. * Gets the current list of color remap gradients.
  17549. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17550. * @returns the list of color remap gradients
  17551. */
  17552. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17553. /**
  17554. * Gets the current list of alpha remap gradients.
  17555. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17556. * @returns the list of alpha remap gradients
  17557. */
  17558. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17559. /**
  17560. * Gets the current list of life time gradients.
  17561. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17562. * @returns the list of life time gradients
  17563. */
  17564. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17565. /**
  17566. * Gets the current list of angular speed gradients.
  17567. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17568. * @returns the list of angular speed gradients
  17569. */
  17570. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17571. /**
  17572. * Gets the current list of velocity gradients.
  17573. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17574. * @returns the list of velocity gradients
  17575. */
  17576. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17577. /**
  17578. * Gets the current list of start size gradients.
  17579. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17580. * @returns the list of start size gradients
  17581. */
  17582. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17583. /**
  17584. * Gets the current list of emit rate gradients.
  17585. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17586. * @returns the list of emit rate gradients
  17587. */
  17588. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17589. /**
  17590. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17591. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17592. */
  17593. get direction1(): Vector3;
  17594. set direction1(value: Vector3);
  17595. /**
  17596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17597. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17598. */
  17599. get direction2(): Vector3;
  17600. set direction2(value: Vector3);
  17601. /**
  17602. * 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.
  17603. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17604. */
  17605. get minEmitBox(): Vector3;
  17606. set minEmitBox(value: Vector3);
  17607. /**
  17608. * 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.
  17609. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17610. */
  17611. get maxEmitBox(): Vector3;
  17612. set maxEmitBox(value: Vector3);
  17613. /**
  17614. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17615. */
  17616. color1: Color4;
  17617. /**
  17618. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17619. */
  17620. color2: Color4;
  17621. /**
  17622. * Color the particle will have at the end of its lifetime
  17623. */
  17624. colorDead: Color4;
  17625. /**
  17626. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17627. */
  17628. textureMask: Color4;
  17629. /**
  17630. * The particle emitter type defines the emitter used by the particle system.
  17631. * It can be for example box, sphere, or cone...
  17632. */
  17633. particleEmitterType: IParticleEmitterType;
  17634. /** @hidden */
  17635. _isSubEmitter: boolean;
  17636. /**
  17637. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17638. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17639. */
  17640. billboardMode: number;
  17641. protected _isBillboardBased: boolean;
  17642. /**
  17643. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17644. */
  17645. get isBillboardBased(): boolean;
  17646. set isBillboardBased(value: boolean);
  17647. /**
  17648. * The scene the particle system belongs to.
  17649. */
  17650. protected _scene: Scene;
  17651. /**
  17652. * Local cache of defines for image processing.
  17653. */
  17654. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17655. /**
  17656. * Default configuration related to image processing available in the standard Material.
  17657. */
  17658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17659. /**
  17660. * Gets the image processing configuration used either in this material.
  17661. */
  17662. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17663. /**
  17664. * Sets the Default image processing configuration used either in the this material.
  17665. *
  17666. * If sets to null, the scene one is in use.
  17667. */
  17668. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17669. /**
  17670. * Attaches a new image processing configuration to the Standard Material.
  17671. * @param configuration
  17672. */
  17673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17674. /** @hidden */
  17675. protected _reset(): void;
  17676. /** @hidden */
  17677. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17678. /**
  17679. * Instantiates a particle system.
  17680. * 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.
  17681. * @param name The name of the particle system
  17682. */
  17683. constructor(name: string);
  17684. /**
  17685. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17686. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17687. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17688. * @returns the emitter
  17689. */
  17690. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17691. /**
  17692. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17693. * @param radius The radius of the hemisphere to emit from
  17694. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17695. * @returns the emitter
  17696. */
  17697. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17698. /**
  17699. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17700. * @param radius The radius of the sphere to emit from
  17701. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17702. * @returns the emitter
  17703. */
  17704. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17705. /**
  17706. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17707. * @param radius The radius of the sphere to emit from
  17708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17710. * @returns the emitter
  17711. */
  17712. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17713. /**
  17714. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17715. * @param radius The radius of the emission cylinder
  17716. * @param height The height of the emission cylinder
  17717. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17718. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17719. * @returns the emitter
  17720. */
  17721. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17722. /**
  17723. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17724. * @param radius The radius of the cylinder to emit from
  17725. * @param height The height of the emission cylinder
  17726. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17727. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17728. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17729. * @returns the emitter
  17730. */
  17731. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17732. /**
  17733. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17734. * @param radius The radius of the cone to emit from
  17735. * @param angle The base angle of the cone
  17736. * @returns the emitter
  17737. */
  17738. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17739. /**
  17740. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17741. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17742. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17743. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17744. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17745. * @returns the emitter
  17746. */
  17747. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17748. }
  17749. }
  17750. declare module "babylonjs/Particles/subEmitter" {
  17751. import { Scene } from "babylonjs/scene";
  17752. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17753. /**
  17754. * Type of sub emitter
  17755. */
  17756. export enum SubEmitterType {
  17757. /**
  17758. * Attached to the particle over it's lifetime
  17759. */
  17760. ATTACHED = 0,
  17761. /**
  17762. * Created when the particle dies
  17763. */
  17764. END = 1
  17765. }
  17766. /**
  17767. * Sub emitter class used to emit particles from an existing particle
  17768. */
  17769. export class SubEmitter {
  17770. /**
  17771. * the particle system to be used by the sub emitter
  17772. */
  17773. particleSystem: ParticleSystem;
  17774. /**
  17775. * Type of the submitter (Default: END)
  17776. */
  17777. type: SubEmitterType;
  17778. /**
  17779. * 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)
  17780. * Note: This only is supported when using an emitter of type Mesh
  17781. */
  17782. inheritDirection: boolean;
  17783. /**
  17784. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17785. */
  17786. inheritedVelocityAmount: number;
  17787. /**
  17788. * Creates a sub emitter
  17789. * @param particleSystem the particle system to be used by the sub emitter
  17790. */
  17791. constructor(
  17792. /**
  17793. * the particle system to be used by the sub emitter
  17794. */
  17795. particleSystem: ParticleSystem);
  17796. /**
  17797. * Clones the sub emitter
  17798. * @returns the cloned sub emitter
  17799. */
  17800. clone(): SubEmitter;
  17801. /**
  17802. * Serialize current object to a JSON object
  17803. * @returns the serialized object
  17804. */
  17805. serialize(): any;
  17806. /** @hidden */
  17807. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17808. /**
  17809. * Creates a new SubEmitter from a serialized JSON version
  17810. * @param serializationObject defines the JSON object to read from
  17811. * @param scene defines the hosting scene
  17812. * @param rootUrl defines the rootUrl for data loading
  17813. * @returns a new SubEmitter
  17814. */
  17815. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17816. /** Release associated resources */
  17817. dispose(): void;
  17818. }
  17819. }
  17820. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17821. /** @hidden */
  17822. export var imageProcessingDeclaration: {
  17823. name: string;
  17824. shader: string;
  17825. };
  17826. }
  17827. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17828. /** @hidden */
  17829. export var imageProcessingFunctions: {
  17830. name: string;
  17831. shader: string;
  17832. };
  17833. }
  17834. declare module "babylonjs/Shaders/particles.fragment" {
  17835. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17836. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17837. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17838. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17839. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17840. /** @hidden */
  17841. export var particlesPixelShader: {
  17842. name: string;
  17843. shader: string;
  17844. };
  17845. }
  17846. declare module "babylonjs/Shaders/particles.vertex" {
  17847. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17848. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17849. /** @hidden */
  17850. export var particlesVertexShader: {
  17851. name: string;
  17852. shader: string;
  17853. };
  17854. }
  17855. declare module "babylonjs/Particles/particleSystem" {
  17856. import { Nullable } from "babylonjs/types";
  17857. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17858. import { Observable } from "babylonjs/Misc/observable";
  17859. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17860. import { Effect } from "babylonjs/Materials/effect";
  17861. import { Scene, IDisposable } from "babylonjs/scene";
  17862. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17863. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17864. import { Particle } from "babylonjs/Particles/particle";
  17865. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17866. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17867. import "babylonjs/Shaders/particles.fragment";
  17868. import "babylonjs/Shaders/particles.vertex";
  17869. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17870. /**
  17871. * This represents a particle system in Babylon.
  17872. * 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.
  17873. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17874. * @example https://doc.babylonjs.com/babylon101/particles
  17875. */
  17876. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17877. /**
  17878. * Billboard mode will only apply to Y axis
  17879. */
  17880. static readonly BILLBOARDMODE_Y: number;
  17881. /**
  17882. * Billboard mode will apply to all axes
  17883. */
  17884. static readonly BILLBOARDMODE_ALL: number;
  17885. /**
  17886. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17887. */
  17888. static readonly BILLBOARDMODE_STRETCHED: number;
  17889. /**
  17890. * This function can be defined to provide custom update for active particles.
  17891. * This function will be called instead of regular update (age, position, color, etc.).
  17892. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17893. */
  17894. updateFunction: (particles: Particle[]) => void;
  17895. private _emitterWorldMatrix;
  17896. /**
  17897. * This function can be defined to specify initial direction for every new particle.
  17898. * It by default use the emitterType defined function
  17899. */
  17900. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17901. /**
  17902. * This function can be defined to specify initial position for every new particle.
  17903. * It by default use the emitterType defined function
  17904. */
  17905. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17906. /**
  17907. * @hidden
  17908. */
  17909. _inheritedVelocityOffset: Vector3;
  17910. /**
  17911. * An event triggered when the system is disposed
  17912. */
  17913. onDisposeObservable: Observable<ParticleSystem>;
  17914. private _onDisposeObserver;
  17915. /**
  17916. * Sets a callback that will be triggered when the system is disposed
  17917. */
  17918. set onDispose(callback: () => void);
  17919. private _particles;
  17920. private _epsilon;
  17921. private _capacity;
  17922. private _stockParticles;
  17923. private _newPartsExcess;
  17924. private _vertexData;
  17925. private _vertexBuffer;
  17926. private _vertexBuffers;
  17927. private _spriteBuffer;
  17928. private _indexBuffer;
  17929. private _effect;
  17930. private _customEffect;
  17931. private _cachedDefines;
  17932. private _scaledColorStep;
  17933. private _colorDiff;
  17934. private _scaledDirection;
  17935. private _scaledGravity;
  17936. private _currentRenderId;
  17937. private _alive;
  17938. private _useInstancing;
  17939. private _started;
  17940. private _stopped;
  17941. private _actualFrame;
  17942. private _scaledUpdateSpeed;
  17943. private _vertexBufferSize;
  17944. /** @hidden */
  17945. _currentEmitRateGradient: Nullable<FactorGradient>;
  17946. /** @hidden */
  17947. _currentEmitRate1: number;
  17948. /** @hidden */
  17949. _currentEmitRate2: number;
  17950. /** @hidden */
  17951. _currentStartSizeGradient: Nullable<FactorGradient>;
  17952. /** @hidden */
  17953. _currentStartSize1: number;
  17954. /** @hidden */
  17955. _currentStartSize2: number;
  17956. private readonly _rawTextureWidth;
  17957. private _rampGradientsTexture;
  17958. private _useRampGradients;
  17959. /** Gets or sets a boolean indicating that ramp gradients must be used
  17960. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17961. */
  17962. get useRampGradients(): boolean;
  17963. set useRampGradients(value: boolean);
  17964. /**
  17965. * 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.
  17966. * 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: [])
  17967. */
  17968. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17969. private _subEmitters;
  17970. /**
  17971. * @hidden
  17972. * If the particle systems emitter should be disposed when the particle system is disposed
  17973. */
  17974. _disposeEmitterOnDispose: boolean;
  17975. /**
  17976. * The current active Sub-systems, this property is used by the root particle system only.
  17977. */
  17978. activeSubSystems: Array<ParticleSystem>;
  17979. private _rootParticleSystem;
  17980. /**
  17981. * Gets the current list of active particles
  17982. */
  17983. get particles(): Particle[];
  17984. /**
  17985. * Returns the string "ParticleSystem"
  17986. * @returns a string containing the class name
  17987. */
  17988. getClassName(): string;
  17989. /**
  17990. * Instantiates a particle system.
  17991. * 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.
  17992. * @param name The name of the particle system
  17993. * @param capacity The max number of particles alive at the same time
  17994. * @param scene The scene the particle system belongs to
  17995. * @param customEffect a custom effect used to change the way particles are rendered by default
  17996. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17997. * @param epsilon Offset used to render the particles
  17998. */
  17999. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18000. private _addFactorGradient;
  18001. private _removeFactorGradient;
  18002. /**
  18003. * Adds a new life time gradient
  18004. * @param gradient defines the gradient to use (between 0 and 1)
  18005. * @param factor defines the life time factor to affect to the specified gradient
  18006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18007. * @returns the current particle system
  18008. */
  18009. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18010. /**
  18011. * Remove a specific life time gradient
  18012. * @param gradient defines the gradient to remove
  18013. * @returns the current particle system
  18014. */
  18015. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18016. /**
  18017. * Adds a new size gradient
  18018. * @param gradient defines the gradient to use (between 0 and 1)
  18019. * @param factor defines the size factor to affect to the specified gradient
  18020. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18021. * @returns the current particle system
  18022. */
  18023. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18024. /**
  18025. * Remove a specific size gradient
  18026. * @param gradient defines the gradient to remove
  18027. * @returns the current particle system
  18028. */
  18029. removeSizeGradient(gradient: number): IParticleSystem;
  18030. /**
  18031. * Adds a new color remap gradient
  18032. * @param gradient defines the gradient to use (between 0 and 1)
  18033. * @param min defines the color remap minimal range
  18034. * @param max defines the color remap maximal range
  18035. * @returns the current particle system
  18036. */
  18037. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18038. /**
  18039. * Remove a specific color remap gradient
  18040. * @param gradient defines the gradient to remove
  18041. * @returns the current particle system
  18042. */
  18043. removeColorRemapGradient(gradient: number): IParticleSystem;
  18044. /**
  18045. * Adds a new alpha remap gradient
  18046. * @param gradient defines the gradient to use (between 0 and 1)
  18047. * @param min defines the alpha remap minimal range
  18048. * @param max defines the alpha remap maximal range
  18049. * @returns the current particle system
  18050. */
  18051. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18052. /**
  18053. * Remove a specific alpha remap gradient
  18054. * @param gradient defines the gradient to remove
  18055. * @returns the current particle system
  18056. */
  18057. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18058. /**
  18059. * Adds a new angular speed gradient
  18060. * @param gradient defines the gradient to use (between 0 and 1)
  18061. * @param factor defines the angular speed to affect to the specified gradient
  18062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18063. * @returns the current particle system
  18064. */
  18065. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18066. /**
  18067. * Remove a specific angular speed gradient
  18068. * @param gradient defines the gradient to remove
  18069. * @returns the current particle system
  18070. */
  18071. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18072. /**
  18073. * Adds a new velocity gradient
  18074. * @param gradient defines the gradient to use (between 0 and 1)
  18075. * @param factor defines the velocity to affect to the specified gradient
  18076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18077. * @returns the current particle system
  18078. */
  18079. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18080. /**
  18081. * Remove a specific velocity gradient
  18082. * @param gradient defines the gradient to remove
  18083. * @returns the current particle system
  18084. */
  18085. removeVelocityGradient(gradient: number): IParticleSystem;
  18086. /**
  18087. * Adds a new limit velocity gradient
  18088. * @param gradient defines the gradient to use (between 0 and 1)
  18089. * @param factor defines the limit velocity value to affect to the specified gradient
  18090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18091. * @returns the current particle system
  18092. */
  18093. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18094. /**
  18095. * Remove a specific limit velocity gradient
  18096. * @param gradient defines the gradient to remove
  18097. * @returns the current particle system
  18098. */
  18099. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18100. /**
  18101. * Adds a new drag gradient
  18102. * @param gradient defines the gradient to use (between 0 and 1)
  18103. * @param factor defines the drag value to affect to the specified gradient
  18104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18105. * @returns the current particle system
  18106. */
  18107. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18108. /**
  18109. * Remove a specific drag gradient
  18110. * @param gradient defines the gradient to remove
  18111. * @returns the current particle system
  18112. */
  18113. removeDragGradient(gradient: number): IParticleSystem;
  18114. /**
  18115. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18116. * @param gradient defines the gradient to use (between 0 and 1)
  18117. * @param factor defines the emit rate value to affect to the specified gradient
  18118. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18119. * @returns the current particle system
  18120. */
  18121. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18122. /**
  18123. * Remove a specific emit rate gradient
  18124. * @param gradient defines the gradient to remove
  18125. * @returns the current particle system
  18126. */
  18127. removeEmitRateGradient(gradient: number): IParticleSystem;
  18128. /**
  18129. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18130. * @param gradient defines the gradient to use (between 0 and 1)
  18131. * @param factor defines the start size value to affect to the specified gradient
  18132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18133. * @returns the current particle system
  18134. */
  18135. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18136. /**
  18137. * Remove a specific start size gradient
  18138. * @param gradient defines the gradient to remove
  18139. * @returns the current particle system
  18140. */
  18141. removeStartSizeGradient(gradient: number): IParticleSystem;
  18142. private _createRampGradientTexture;
  18143. /**
  18144. * Gets the current list of ramp gradients.
  18145. * You must use addRampGradient and removeRampGradient to udpate this list
  18146. * @returns the list of ramp gradients
  18147. */
  18148. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18149. /**
  18150. * Adds a new ramp gradient used to remap particle colors
  18151. * @param gradient defines the gradient to use (between 0 and 1)
  18152. * @param color defines the color to affect to the specified gradient
  18153. * @returns the current particle system
  18154. */
  18155. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18156. /**
  18157. * Remove a specific ramp gradient
  18158. * @param gradient defines the gradient to remove
  18159. * @returns the current particle system
  18160. */
  18161. removeRampGradient(gradient: number): ParticleSystem;
  18162. /**
  18163. * Adds a new color gradient
  18164. * @param gradient defines the gradient to use (between 0 and 1)
  18165. * @param color1 defines the color to affect to the specified gradient
  18166. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18167. * @returns this particle system
  18168. */
  18169. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18170. /**
  18171. * Remove a specific color gradient
  18172. * @param gradient defines the gradient to remove
  18173. * @returns this particle system
  18174. */
  18175. removeColorGradient(gradient: number): IParticleSystem;
  18176. private _fetchR;
  18177. protected _reset(): void;
  18178. private _resetEffect;
  18179. private _createVertexBuffers;
  18180. private _createIndexBuffer;
  18181. /**
  18182. * Gets the maximum number of particles active at the same time.
  18183. * @returns The max number of active particles.
  18184. */
  18185. getCapacity(): number;
  18186. /**
  18187. * Gets whether there are still active particles in the system.
  18188. * @returns True if it is alive, otherwise false.
  18189. */
  18190. isAlive(): boolean;
  18191. /**
  18192. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18193. * @returns True if it has been started, otherwise false.
  18194. */
  18195. isStarted(): boolean;
  18196. private _prepareSubEmitterInternalArray;
  18197. /**
  18198. * Starts the particle system and begins to emit
  18199. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18200. */
  18201. start(delay?: number): void;
  18202. /**
  18203. * Stops the particle system.
  18204. * @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.
  18205. */
  18206. stop(stopSubEmitters?: boolean): void;
  18207. /**
  18208. * Remove all active particles
  18209. */
  18210. reset(): void;
  18211. /**
  18212. * @hidden (for internal use only)
  18213. */
  18214. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18215. /**
  18216. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18217. * Its lifetime will start back at 0.
  18218. */
  18219. recycleParticle: (particle: Particle) => void;
  18220. private _stopSubEmitters;
  18221. private _createParticle;
  18222. private _removeFromRoot;
  18223. private _emitFromParticle;
  18224. private _update;
  18225. /** @hidden */
  18226. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18227. /** @hidden */
  18228. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18229. /** @hidden */
  18230. private _getEffect;
  18231. /**
  18232. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18233. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18234. */
  18235. animate(preWarmOnly?: boolean): void;
  18236. private _appendParticleVertices;
  18237. /**
  18238. * Rebuilds the particle system.
  18239. */
  18240. rebuild(): void;
  18241. /**
  18242. * Is this system ready to be used/rendered
  18243. * @return true if the system is ready
  18244. */
  18245. isReady(): boolean;
  18246. private _render;
  18247. /**
  18248. * Renders the particle system in its current state.
  18249. * @returns the current number of particles
  18250. */
  18251. render(): number;
  18252. /**
  18253. * Disposes the particle system and free the associated resources
  18254. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18255. */
  18256. dispose(disposeTexture?: boolean): void;
  18257. /**
  18258. * Clones the particle system.
  18259. * @param name The name of the cloned object
  18260. * @param newEmitter The new emitter to use
  18261. * @returns the cloned particle system
  18262. */
  18263. clone(name: string, newEmitter: any): ParticleSystem;
  18264. /**
  18265. * Serializes the particle system to a JSON object.
  18266. * @returns the JSON object
  18267. */
  18268. serialize(): any;
  18269. /** @hidden */
  18270. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18271. /** @hidden */
  18272. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18273. /**
  18274. * Parses a JSON object to create a particle system.
  18275. * @param parsedParticleSystem The JSON object to parse
  18276. * @param scene The scene to create the particle system in
  18277. * @param rootUrl The root url to use to load external dependencies like texture
  18278. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18279. * @returns the Parsed particle system
  18280. */
  18281. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18282. }
  18283. }
  18284. declare module "babylonjs/Particles/particle" {
  18285. import { Nullable } from "babylonjs/types";
  18286. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18287. import { Color4 } from "babylonjs/Maths/math.color";
  18288. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18289. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18290. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18291. /**
  18292. * A particle represents one of the element emitted by a particle system.
  18293. * This is mainly define by its coordinates, direction, velocity and age.
  18294. */
  18295. export class Particle {
  18296. /**
  18297. * The particle system the particle belongs to.
  18298. */
  18299. particleSystem: ParticleSystem;
  18300. private static _Count;
  18301. /**
  18302. * Unique ID of the particle
  18303. */
  18304. id: number;
  18305. /**
  18306. * The world position of the particle in the scene.
  18307. */
  18308. position: Vector3;
  18309. /**
  18310. * The world direction of the particle in the scene.
  18311. */
  18312. direction: Vector3;
  18313. /**
  18314. * The color of the particle.
  18315. */
  18316. color: Color4;
  18317. /**
  18318. * The color change of the particle per step.
  18319. */
  18320. colorStep: Color4;
  18321. /**
  18322. * Defines how long will the life of the particle be.
  18323. */
  18324. lifeTime: number;
  18325. /**
  18326. * The current age of the particle.
  18327. */
  18328. age: number;
  18329. /**
  18330. * The current size of the particle.
  18331. */
  18332. size: number;
  18333. /**
  18334. * The current scale of the particle.
  18335. */
  18336. scale: Vector2;
  18337. /**
  18338. * The current angle of the particle.
  18339. */
  18340. angle: number;
  18341. /**
  18342. * Defines how fast is the angle changing.
  18343. */
  18344. angularSpeed: number;
  18345. /**
  18346. * Defines the cell index used by the particle to be rendered from a sprite.
  18347. */
  18348. cellIndex: number;
  18349. /**
  18350. * The information required to support color remapping
  18351. */
  18352. remapData: Vector4;
  18353. /** @hidden */
  18354. _randomCellOffset?: number;
  18355. /** @hidden */
  18356. _initialDirection: Nullable<Vector3>;
  18357. /** @hidden */
  18358. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18359. /** @hidden */
  18360. _initialStartSpriteCellID: number;
  18361. /** @hidden */
  18362. _initialEndSpriteCellID: number;
  18363. /** @hidden */
  18364. _currentColorGradient: Nullable<ColorGradient>;
  18365. /** @hidden */
  18366. _currentColor1: Color4;
  18367. /** @hidden */
  18368. _currentColor2: Color4;
  18369. /** @hidden */
  18370. _currentSizeGradient: Nullable<FactorGradient>;
  18371. /** @hidden */
  18372. _currentSize1: number;
  18373. /** @hidden */
  18374. _currentSize2: number;
  18375. /** @hidden */
  18376. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18377. /** @hidden */
  18378. _currentAngularSpeed1: number;
  18379. /** @hidden */
  18380. _currentAngularSpeed2: number;
  18381. /** @hidden */
  18382. _currentVelocityGradient: Nullable<FactorGradient>;
  18383. /** @hidden */
  18384. _currentVelocity1: number;
  18385. /** @hidden */
  18386. _currentVelocity2: number;
  18387. /** @hidden */
  18388. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18389. /** @hidden */
  18390. _currentLimitVelocity1: number;
  18391. /** @hidden */
  18392. _currentLimitVelocity2: number;
  18393. /** @hidden */
  18394. _currentDragGradient: Nullable<FactorGradient>;
  18395. /** @hidden */
  18396. _currentDrag1: number;
  18397. /** @hidden */
  18398. _currentDrag2: number;
  18399. /** @hidden */
  18400. _randomNoiseCoordinates1: Vector3;
  18401. /** @hidden */
  18402. _randomNoiseCoordinates2: Vector3;
  18403. /**
  18404. * Creates a new instance Particle
  18405. * @param particleSystem the particle system the particle belongs to
  18406. */
  18407. constructor(
  18408. /**
  18409. * The particle system the particle belongs to.
  18410. */
  18411. particleSystem: ParticleSystem);
  18412. private updateCellInfoFromSystem;
  18413. /**
  18414. * Defines how the sprite cell index is updated for the particle
  18415. */
  18416. updateCellIndex(): void;
  18417. /** @hidden */
  18418. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18419. /** @hidden */
  18420. _inheritParticleInfoToSubEmitters(): void;
  18421. /** @hidden */
  18422. _reset(): void;
  18423. /**
  18424. * Copy the properties of particle to another one.
  18425. * @param other the particle to copy the information to.
  18426. */
  18427. copyTo(other: Particle): void;
  18428. }
  18429. }
  18430. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18431. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18432. import { Effect } from "babylonjs/Materials/effect";
  18433. import { Particle } from "babylonjs/Particles/particle";
  18434. /**
  18435. * Particle emitter represents a volume emitting particles.
  18436. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18437. */
  18438. export interface IParticleEmitterType {
  18439. /**
  18440. * Called by the particle System when the direction is computed for the created particle.
  18441. * @param worldMatrix is the world matrix of the particle system
  18442. * @param directionToUpdate is the direction vector to update with the result
  18443. * @param particle is the particle we are computed the direction for
  18444. */
  18445. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18446. /**
  18447. * Called by the particle System when the position is computed for the created particle.
  18448. * @param worldMatrix is the world matrix of the particle system
  18449. * @param positionToUpdate is the position vector to update with the result
  18450. * @param particle is the particle we are computed the position for
  18451. */
  18452. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18453. /**
  18454. * Clones the current emitter and returns a copy of it
  18455. * @returns the new emitter
  18456. */
  18457. clone(): IParticleEmitterType;
  18458. /**
  18459. * Called by the GPUParticleSystem to setup the update shader
  18460. * @param effect defines the update shader
  18461. */
  18462. applyToShader(effect: Effect): void;
  18463. /**
  18464. * Returns a string to use to update the GPU particles update shader
  18465. * @returns the effect defines string
  18466. */
  18467. getEffectDefines(): string;
  18468. /**
  18469. * Returns a string representing the class name
  18470. * @returns a string containing the class name
  18471. */
  18472. getClassName(): string;
  18473. /**
  18474. * Serializes the particle system to a JSON object.
  18475. * @returns the JSON object
  18476. */
  18477. serialize(): any;
  18478. /**
  18479. * Parse properties from a JSON object
  18480. * @param serializationObject defines the JSON object
  18481. */
  18482. parse(serializationObject: any): void;
  18483. }
  18484. }
  18485. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18486. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18487. import { Effect } from "babylonjs/Materials/effect";
  18488. import { Particle } from "babylonjs/Particles/particle";
  18489. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18490. /**
  18491. * Particle emitter emitting particles from the inside of a box.
  18492. * It emits the particles randomly between 2 given directions.
  18493. */
  18494. export class BoxParticleEmitter implements IParticleEmitterType {
  18495. /**
  18496. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18497. */
  18498. direction1: Vector3;
  18499. /**
  18500. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18501. */
  18502. direction2: Vector3;
  18503. /**
  18504. * 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.
  18505. */
  18506. minEmitBox: Vector3;
  18507. /**
  18508. * 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.
  18509. */
  18510. maxEmitBox: Vector3;
  18511. /**
  18512. * Creates a new instance BoxParticleEmitter
  18513. */
  18514. constructor();
  18515. /**
  18516. * Called by the particle System when the direction is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param directionToUpdate is the direction vector to update with the result
  18519. * @param particle is the particle we are computed the direction for
  18520. */
  18521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Called by the particle System when the position is computed for the created particle.
  18524. * @param worldMatrix is the world matrix of the particle system
  18525. * @param positionToUpdate is the position vector to update with the result
  18526. * @param particle is the particle we are computed the position for
  18527. */
  18528. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18529. /**
  18530. * Clones the current emitter and returns a copy of it
  18531. * @returns the new emitter
  18532. */
  18533. clone(): BoxParticleEmitter;
  18534. /**
  18535. * Called by the GPUParticleSystem to setup the update shader
  18536. * @param effect defines the update shader
  18537. */
  18538. applyToShader(effect: Effect): void;
  18539. /**
  18540. * Returns a string to use to update the GPU particles update shader
  18541. * @returns a string containng the defines string
  18542. */
  18543. getEffectDefines(): string;
  18544. /**
  18545. * Returns the string "BoxParticleEmitter"
  18546. * @returns a string containing the class name
  18547. */
  18548. getClassName(): string;
  18549. /**
  18550. * Serializes the particle system to a JSON object.
  18551. * @returns the JSON object
  18552. */
  18553. serialize(): any;
  18554. /**
  18555. * Parse properties from a JSON object
  18556. * @param serializationObject defines the JSON object
  18557. */
  18558. parse(serializationObject: any): void;
  18559. }
  18560. }
  18561. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18562. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18563. import { Effect } from "babylonjs/Materials/effect";
  18564. import { Particle } from "babylonjs/Particles/particle";
  18565. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18566. /**
  18567. * Particle emitter emitting particles from the inside of a cone.
  18568. * It emits the particles alongside the cone volume from the base to the particle.
  18569. * The emission direction might be randomized.
  18570. */
  18571. export class ConeParticleEmitter implements IParticleEmitterType {
  18572. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18573. directionRandomizer: number;
  18574. private _radius;
  18575. private _angle;
  18576. private _height;
  18577. /**
  18578. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18579. */
  18580. radiusRange: number;
  18581. /**
  18582. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18583. */
  18584. heightRange: number;
  18585. /**
  18586. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18587. */
  18588. emitFromSpawnPointOnly: boolean;
  18589. /**
  18590. * Gets or sets the radius of the emission cone
  18591. */
  18592. get radius(): number;
  18593. set radius(value: number);
  18594. /**
  18595. * Gets or sets the angle of the emission cone
  18596. */
  18597. get angle(): number;
  18598. set angle(value: number);
  18599. private _buildHeight;
  18600. /**
  18601. * Creates a new instance ConeParticleEmitter
  18602. * @param radius the radius of the emission cone (1 by default)
  18603. * @param angle the cone base angle (PI by default)
  18604. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18605. */
  18606. constructor(radius?: number, angle?: number,
  18607. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18608. directionRandomizer?: number);
  18609. /**
  18610. * Called by the particle System when the direction is computed for the created particle.
  18611. * @param worldMatrix is the world matrix of the particle system
  18612. * @param directionToUpdate is the direction vector to update with the result
  18613. * @param particle is the particle we are computed the direction for
  18614. */
  18615. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18616. /**
  18617. * Called by the particle System when the position is computed for the created particle.
  18618. * @param worldMatrix is the world matrix of the particle system
  18619. * @param positionToUpdate is the position vector to update with the result
  18620. * @param particle is the particle we are computed the position for
  18621. */
  18622. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18623. /**
  18624. * Clones the current emitter and returns a copy of it
  18625. * @returns the new emitter
  18626. */
  18627. clone(): ConeParticleEmitter;
  18628. /**
  18629. * Called by the GPUParticleSystem to setup the update shader
  18630. * @param effect defines the update shader
  18631. */
  18632. applyToShader(effect: Effect): void;
  18633. /**
  18634. * Returns a string to use to update the GPU particles update shader
  18635. * @returns a string containng the defines string
  18636. */
  18637. getEffectDefines(): string;
  18638. /**
  18639. * Returns the string "ConeParticleEmitter"
  18640. * @returns a string containing the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Serializes the particle system to a JSON object.
  18645. * @returns the JSON object
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Parse properties from a JSON object
  18650. * @param serializationObject defines the JSON object
  18651. */
  18652. parse(serializationObject: any): void;
  18653. }
  18654. }
  18655. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18656. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18657. import { Effect } from "babylonjs/Materials/effect";
  18658. import { Particle } from "babylonjs/Particles/particle";
  18659. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18660. /**
  18661. * Particle emitter emitting particles from the inside of a cylinder.
  18662. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18663. */
  18664. export class CylinderParticleEmitter implements IParticleEmitterType {
  18665. /**
  18666. * The radius of the emission cylinder.
  18667. */
  18668. radius: number;
  18669. /**
  18670. * The height of the emission cylinder.
  18671. */
  18672. height: number;
  18673. /**
  18674. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18675. */
  18676. radiusRange: number;
  18677. /**
  18678. * How much to randomize the particle direction [0-1].
  18679. */
  18680. directionRandomizer: number;
  18681. /**
  18682. * Creates a new instance CylinderParticleEmitter
  18683. * @param radius the radius of the emission cylinder (1 by default)
  18684. * @param height the height of the emission cylinder (1 by default)
  18685. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18686. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18687. */
  18688. constructor(
  18689. /**
  18690. * The radius of the emission cylinder.
  18691. */
  18692. radius?: number,
  18693. /**
  18694. * The height of the emission cylinder.
  18695. */
  18696. height?: number,
  18697. /**
  18698. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18699. */
  18700. radiusRange?: number,
  18701. /**
  18702. * How much to randomize the particle direction [0-1].
  18703. */
  18704. directionRandomizer?: number);
  18705. /**
  18706. * Called by the particle System when the direction is computed for the created particle.
  18707. * @param worldMatrix is the world matrix of the particle system
  18708. * @param directionToUpdate is the direction vector to update with the result
  18709. * @param particle is the particle we are computed the direction for
  18710. */
  18711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18712. /**
  18713. * Called by the particle System when the position is computed for the created particle.
  18714. * @param worldMatrix is the world matrix of the particle system
  18715. * @param positionToUpdate is the position vector to update with the result
  18716. * @param particle is the particle we are computed the position for
  18717. */
  18718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18719. /**
  18720. * Clones the current emitter and returns a copy of it
  18721. * @returns the new emitter
  18722. */
  18723. clone(): CylinderParticleEmitter;
  18724. /**
  18725. * Called by the GPUParticleSystem to setup the update shader
  18726. * @param effect defines the update shader
  18727. */
  18728. applyToShader(effect: Effect): void;
  18729. /**
  18730. * Returns a string to use to update the GPU particles update shader
  18731. * @returns a string containng the defines string
  18732. */
  18733. getEffectDefines(): string;
  18734. /**
  18735. * Returns the string "CylinderParticleEmitter"
  18736. * @returns a string containing the class name
  18737. */
  18738. getClassName(): string;
  18739. /**
  18740. * Serializes the particle system to a JSON object.
  18741. * @returns the JSON object
  18742. */
  18743. serialize(): any;
  18744. /**
  18745. * Parse properties from a JSON object
  18746. * @param serializationObject defines the JSON object
  18747. */
  18748. parse(serializationObject: any): void;
  18749. }
  18750. /**
  18751. * Particle emitter emitting particles from the inside of a cylinder.
  18752. * It emits the particles randomly between two vectors.
  18753. */
  18754. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18755. /**
  18756. * The min limit of the emission direction.
  18757. */
  18758. direction1: Vector3;
  18759. /**
  18760. * The max limit of the emission direction.
  18761. */
  18762. direction2: Vector3;
  18763. /**
  18764. * Creates a new instance CylinderDirectedParticleEmitter
  18765. * @param radius the radius of the emission cylinder (1 by default)
  18766. * @param height the height of the emission cylinder (1 by default)
  18767. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18768. * @param direction1 the min limit of the emission direction (up vector by default)
  18769. * @param direction2 the max limit of the emission direction (up vector by default)
  18770. */
  18771. constructor(radius?: number, height?: number, radiusRange?: number,
  18772. /**
  18773. * The min limit of the emission direction.
  18774. */
  18775. direction1?: Vector3,
  18776. /**
  18777. * The max limit of the emission direction.
  18778. */
  18779. direction2?: Vector3);
  18780. /**
  18781. * Called by the particle System when the direction is computed for the created particle.
  18782. * @param worldMatrix is the world matrix of the particle system
  18783. * @param directionToUpdate is the direction vector to update with the result
  18784. * @param particle is the particle we are computed the direction for
  18785. */
  18786. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18787. /**
  18788. * Clones the current emitter and returns a copy of it
  18789. * @returns the new emitter
  18790. */
  18791. clone(): CylinderDirectedParticleEmitter;
  18792. /**
  18793. * Called by the GPUParticleSystem to setup the update shader
  18794. * @param effect defines the update shader
  18795. */
  18796. applyToShader(effect: Effect): void;
  18797. /**
  18798. * Returns a string to use to update the GPU particles update shader
  18799. * @returns a string containng the defines string
  18800. */
  18801. getEffectDefines(): string;
  18802. /**
  18803. * Returns the string "CylinderDirectedParticleEmitter"
  18804. * @returns a string containing the class name
  18805. */
  18806. getClassName(): string;
  18807. /**
  18808. * Serializes the particle system to a JSON object.
  18809. * @returns the JSON object
  18810. */
  18811. serialize(): any;
  18812. /**
  18813. * Parse properties from a JSON object
  18814. * @param serializationObject defines the JSON object
  18815. */
  18816. parse(serializationObject: any): void;
  18817. }
  18818. }
  18819. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18820. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18821. import { Effect } from "babylonjs/Materials/effect";
  18822. import { Particle } from "babylonjs/Particles/particle";
  18823. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18824. /**
  18825. * Particle emitter emitting particles from the inside of a hemisphere.
  18826. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18827. */
  18828. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18829. /**
  18830. * The radius of the emission hemisphere.
  18831. */
  18832. radius: number;
  18833. /**
  18834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18835. */
  18836. radiusRange: number;
  18837. /**
  18838. * How much to randomize the particle direction [0-1].
  18839. */
  18840. directionRandomizer: number;
  18841. /**
  18842. * Creates a new instance HemisphericParticleEmitter
  18843. * @param radius the radius of the emission hemisphere (1 by default)
  18844. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18845. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18846. */
  18847. constructor(
  18848. /**
  18849. * The radius of the emission hemisphere.
  18850. */
  18851. radius?: number,
  18852. /**
  18853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18854. */
  18855. radiusRange?: number,
  18856. /**
  18857. * How much to randomize the particle direction [0-1].
  18858. */
  18859. directionRandomizer?: number);
  18860. /**
  18861. * Called by the particle System when the direction is computed for the created particle.
  18862. * @param worldMatrix is the world matrix of the particle system
  18863. * @param directionToUpdate is the direction vector to update with the result
  18864. * @param particle is the particle we are computed the direction for
  18865. */
  18866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18867. /**
  18868. * Called by the particle System when the position is computed for the created particle.
  18869. * @param worldMatrix is the world matrix of the particle system
  18870. * @param positionToUpdate is the position vector to update with the result
  18871. * @param particle is the particle we are computed the position for
  18872. */
  18873. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18874. /**
  18875. * Clones the current emitter and returns a copy of it
  18876. * @returns the new emitter
  18877. */
  18878. clone(): HemisphericParticleEmitter;
  18879. /**
  18880. * Called by the GPUParticleSystem to setup the update shader
  18881. * @param effect defines the update shader
  18882. */
  18883. applyToShader(effect: Effect): void;
  18884. /**
  18885. * Returns a string to use to update the GPU particles update shader
  18886. * @returns a string containng the defines string
  18887. */
  18888. getEffectDefines(): string;
  18889. /**
  18890. * Returns the string "HemisphericParticleEmitter"
  18891. * @returns a string containing the class name
  18892. */
  18893. getClassName(): string;
  18894. /**
  18895. * Serializes the particle system to a JSON object.
  18896. * @returns the JSON object
  18897. */
  18898. serialize(): any;
  18899. /**
  18900. * Parse properties from a JSON object
  18901. * @param serializationObject defines the JSON object
  18902. */
  18903. parse(serializationObject: any): void;
  18904. }
  18905. }
  18906. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18907. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18908. import { Effect } from "babylonjs/Materials/effect";
  18909. import { Particle } from "babylonjs/Particles/particle";
  18910. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18911. /**
  18912. * Particle emitter emitting particles from a point.
  18913. * It emits the particles randomly between 2 given directions.
  18914. */
  18915. export class PointParticleEmitter implements IParticleEmitterType {
  18916. /**
  18917. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18918. */
  18919. direction1: Vector3;
  18920. /**
  18921. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18922. */
  18923. direction2: Vector3;
  18924. /**
  18925. * Creates a new instance PointParticleEmitter
  18926. */
  18927. constructor();
  18928. /**
  18929. * Called by the particle System when the direction is computed for the created particle.
  18930. * @param worldMatrix is the world matrix of the particle system
  18931. * @param directionToUpdate is the direction vector to update with the result
  18932. * @param particle is the particle we are computed the direction for
  18933. */
  18934. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18935. /**
  18936. * Called by the particle System when the position is computed for the created particle.
  18937. * @param worldMatrix is the world matrix of the particle system
  18938. * @param positionToUpdate is the position vector to update with the result
  18939. * @param particle is the particle we are computed the position for
  18940. */
  18941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18942. /**
  18943. * Clones the current emitter and returns a copy of it
  18944. * @returns the new emitter
  18945. */
  18946. clone(): PointParticleEmitter;
  18947. /**
  18948. * Called by the GPUParticleSystem to setup the update shader
  18949. * @param effect defines the update shader
  18950. */
  18951. applyToShader(effect: Effect): void;
  18952. /**
  18953. * Returns a string to use to update the GPU particles update shader
  18954. * @returns a string containng the defines string
  18955. */
  18956. getEffectDefines(): string;
  18957. /**
  18958. * Returns the string "PointParticleEmitter"
  18959. * @returns a string containing the class name
  18960. */
  18961. getClassName(): string;
  18962. /**
  18963. * Serializes the particle system to a JSON object.
  18964. * @returns the JSON object
  18965. */
  18966. serialize(): any;
  18967. /**
  18968. * Parse properties from a JSON object
  18969. * @param serializationObject defines the JSON object
  18970. */
  18971. parse(serializationObject: any): void;
  18972. }
  18973. }
  18974. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18975. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18976. import { Effect } from "babylonjs/Materials/effect";
  18977. import { Particle } from "babylonjs/Particles/particle";
  18978. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18979. /**
  18980. * Particle emitter emitting particles from the inside of a sphere.
  18981. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18982. */
  18983. export class SphereParticleEmitter implements IParticleEmitterType {
  18984. /**
  18985. * The radius of the emission sphere.
  18986. */
  18987. radius: number;
  18988. /**
  18989. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18990. */
  18991. radiusRange: number;
  18992. /**
  18993. * How much to randomize the particle direction [0-1].
  18994. */
  18995. directionRandomizer: number;
  18996. /**
  18997. * Creates a new instance SphereParticleEmitter
  18998. * @param radius the radius of the emission sphere (1 by default)
  18999. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19000. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  19001. */
  19002. constructor(
  19003. /**
  19004. * The radius of the emission sphere.
  19005. */
  19006. radius?: number,
  19007. /**
  19008. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  19009. */
  19010. radiusRange?: number,
  19011. /**
  19012. * How much to randomize the particle direction [0-1].
  19013. */
  19014. directionRandomizer?: number);
  19015. /**
  19016. * Called by the particle System when the direction is computed for the created particle.
  19017. * @param worldMatrix is the world matrix of the particle system
  19018. * @param directionToUpdate is the direction vector to update with the result
  19019. * @param particle is the particle we are computed the direction for
  19020. */
  19021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19022. /**
  19023. * Called by the particle System when the position is computed for the created particle.
  19024. * @param worldMatrix is the world matrix of the particle system
  19025. * @param positionToUpdate is the position vector to update with the result
  19026. * @param particle is the particle we are computed the position for
  19027. */
  19028. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19029. /**
  19030. * Clones the current emitter and returns a copy of it
  19031. * @returns the new emitter
  19032. */
  19033. clone(): SphereParticleEmitter;
  19034. /**
  19035. * Called by the GPUParticleSystem to setup the update shader
  19036. * @param effect defines the update shader
  19037. */
  19038. applyToShader(effect: Effect): void;
  19039. /**
  19040. * Returns a string to use to update the GPU particles update shader
  19041. * @returns a string containng the defines string
  19042. */
  19043. getEffectDefines(): string;
  19044. /**
  19045. * Returns the string "SphereParticleEmitter"
  19046. * @returns a string containing the class name
  19047. */
  19048. getClassName(): string;
  19049. /**
  19050. * Serializes the particle system to a JSON object.
  19051. * @returns the JSON object
  19052. */
  19053. serialize(): any;
  19054. /**
  19055. * Parse properties from a JSON object
  19056. * @param serializationObject defines the JSON object
  19057. */
  19058. parse(serializationObject: any): void;
  19059. }
  19060. /**
  19061. * Particle emitter emitting particles from the inside of a sphere.
  19062. * It emits the particles randomly between two vectors.
  19063. */
  19064. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19065. /**
  19066. * The min limit of the emission direction.
  19067. */
  19068. direction1: Vector3;
  19069. /**
  19070. * The max limit of the emission direction.
  19071. */
  19072. direction2: Vector3;
  19073. /**
  19074. * Creates a new instance SphereDirectedParticleEmitter
  19075. * @param radius the radius of the emission sphere (1 by default)
  19076. * @param direction1 the min limit of the emission direction (up vector by default)
  19077. * @param direction2 the max limit of the emission direction (up vector by default)
  19078. */
  19079. constructor(radius?: number,
  19080. /**
  19081. * The min limit of the emission direction.
  19082. */
  19083. direction1?: Vector3,
  19084. /**
  19085. * The max limit of the emission direction.
  19086. */
  19087. direction2?: Vector3);
  19088. /**
  19089. * Called by the particle System when the direction is computed for the created particle.
  19090. * @param worldMatrix is the world matrix of the particle system
  19091. * @param directionToUpdate is the direction vector to update with the result
  19092. * @param particle is the particle we are computed the direction for
  19093. */
  19094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19095. /**
  19096. * Clones the current emitter and returns a copy of it
  19097. * @returns the new emitter
  19098. */
  19099. clone(): SphereDirectedParticleEmitter;
  19100. /**
  19101. * Called by the GPUParticleSystem to setup the update shader
  19102. * @param effect defines the update shader
  19103. */
  19104. applyToShader(effect: Effect): void;
  19105. /**
  19106. * Returns a string to use to update the GPU particles update shader
  19107. * @returns a string containng the defines string
  19108. */
  19109. getEffectDefines(): string;
  19110. /**
  19111. * Returns the string "SphereDirectedParticleEmitter"
  19112. * @returns a string containing the class name
  19113. */
  19114. getClassName(): string;
  19115. /**
  19116. * Serializes the particle system to a JSON object.
  19117. * @returns the JSON object
  19118. */
  19119. serialize(): any;
  19120. /**
  19121. * Parse properties from a JSON object
  19122. * @param serializationObject defines the JSON object
  19123. */
  19124. parse(serializationObject: any): void;
  19125. }
  19126. }
  19127. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  19128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19129. import { Effect } from "babylonjs/Materials/effect";
  19130. import { Particle } from "babylonjs/Particles/particle";
  19131. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19132. import { Nullable } from "babylonjs/types";
  19133. /**
  19134. * Particle emitter emitting particles from a custom list of positions.
  19135. */
  19136. export class CustomParticleEmitter implements IParticleEmitterType {
  19137. /**
  19138. * Gets or sets the position generator that will create the inital position of each particle.
  19139. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19140. */
  19141. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  19142. /**
  19143. * Gets or sets the destination generator that will create the final destination of each particle.
  19144. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19145. */
  19146. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  19147. /**
  19148. * Creates a new instance CustomParticleEmitter
  19149. */
  19150. constructor();
  19151. /**
  19152. * Called by the particle System when the direction is computed for the created particle.
  19153. * @param worldMatrix is the world matrix of the particle system
  19154. * @param directionToUpdate is the direction vector to update with the result
  19155. * @param particle is the particle we are computed the direction for
  19156. */
  19157. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19158. /**
  19159. * Called by the particle System when the position is computed for the created particle.
  19160. * @param worldMatrix is the world matrix of the particle system
  19161. * @param positionToUpdate is the position vector to update with the result
  19162. * @param particle is the particle we are computed the position for
  19163. */
  19164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19165. /**
  19166. * Clones the current emitter and returns a copy of it
  19167. * @returns the new emitter
  19168. */
  19169. clone(): CustomParticleEmitter;
  19170. /**
  19171. * Called by the GPUParticleSystem to setup the update shader
  19172. * @param effect defines the update shader
  19173. */
  19174. applyToShader(effect: Effect): void;
  19175. /**
  19176. * Returns a string to use to update the GPU particles update shader
  19177. * @returns a string containng the defines string
  19178. */
  19179. getEffectDefines(): string;
  19180. /**
  19181. * Returns the string "PointParticleEmitter"
  19182. * @returns a string containing the class name
  19183. */
  19184. getClassName(): string;
  19185. /**
  19186. * Serializes the particle system to a JSON object.
  19187. * @returns the JSON object
  19188. */
  19189. serialize(): any;
  19190. /**
  19191. * Parse properties from a JSON object
  19192. * @param serializationObject defines the JSON object
  19193. */
  19194. parse(serializationObject: any): void;
  19195. }
  19196. }
  19197. declare module "babylonjs/Particles/EmitterTypes/index" {
  19198. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19199. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19200. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19201. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19202. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19203. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19204. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19205. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  19206. }
  19207. declare module "babylonjs/Particles/IParticleSystem" {
  19208. import { Nullable } from "babylonjs/types";
  19209. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19210. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19213. import { Texture } from "babylonjs/Materials/Textures/texture";
  19214. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19215. import { Scene } from "babylonjs/scene";
  19216. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19217. import { Animation } from "babylonjs/Animations/animation";
  19218. /**
  19219. * Interface representing a particle system in Babylon.js.
  19220. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19221. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19222. */
  19223. export interface IParticleSystem {
  19224. /**
  19225. * List of animations used by the particle system.
  19226. */
  19227. animations: Animation[];
  19228. /**
  19229. * The id of the Particle system.
  19230. */
  19231. id: string;
  19232. /**
  19233. * The name of the Particle system.
  19234. */
  19235. name: string;
  19236. /**
  19237. * The emitter represents the Mesh or position we are attaching the particle system to.
  19238. */
  19239. emitter: Nullable<AbstractMesh | Vector3>;
  19240. /**
  19241. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19242. */
  19243. isBillboardBased: boolean;
  19244. /**
  19245. * The rendering group used by the Particle system to chose when to render.
  19246. */
  19247. renderingGroupId: number;
  19248. /**
  19249. * The layer mask we are rendering the particles through.
  19250. */
  19251. layerMask: number;
  19252. /**
  19253. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19254. */
  19255. updateSpeed: number;
  19256. /**
  19257. * The amount of time the particle system is running (depends of the overall update speed).
  19258. */
  19259. targetStopDuration: number;
  19260. /**
  19261. * The texture used to render each particle. (this can be a spritesheet)
  19262. */
  19263. particleTexture: Nullable<Texture>;
  19264. /**
  19265. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19266. */
  19267. blendMode: number;
  19268. /**
  19269. * Minimum life time of emitting particles.
  19270. */
  19271. minLifeTime: number;
  19272. /**
  19273. * Maximum life time of emitting particles.
  19274. */
  19275. maxLifeTime: number;
  19276. /**
  19277. * Minimum Size of emitting particles.
  19278. */
  19279. minSize: number;
  19280. /**
  19281. * Maximum Size of emitting particles.
  19282. */
  19283. maxSize: number;
  19284. /**
  19285. * Minimum scale of emitting particles on X axis.
  19286. */
  19287. minScaleX: number;
  19288. /**
  19289. * Maximum scale of emitting particles on X axis.
  19290. */
  19291. maxScaleX: number;
  19292. /**
  19293. * Minimum scale of emitting particles on Y axis.
  19294. */
  19295. minScaleY: number;
  19296. /**
  19297. * Maximum scale of emitting particles on Y axis.
  19298. */
  19299. maxScaleY: number;
  19300. /**
  19301. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19302. */
  19303. color1: Color4;
  19304. /**
  19305. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19306. */
  19307. color2: Color4;
  19308. /**
  19309. * Color the particle will have at the end of its lifetime.
  19310. */
  19311. colorDead: Color4;
  19312. /**
  19313. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19314. */
  19315. emitRate: number;
  19316. /**
  19317. * You can use gravity if you want to give an orientation to your particles.
  19318. */
  19319. gravity: Vector3;
  19320. /**
  19321. * Minimum power of emitting particles.
  19322. */
  19323. minEmitPower: number;
  19324. /**
  19325. * Maximum power of emitting particles.
  19326. */
  19327. maxEmitPower: number;
  19328. /**
  19329. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19330. */
  19331. minAngularSpeed: number;
  19332. /**
  19333. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19334. */
  19335. maxAngularSpeed: number;
  19336. /**
  19337. * Gets or sets the minimal initial rotation in radians.
  19338. */
  19339. minInitialRotation: number;
  19340. /**
  19341. * Gets or sets the maximal initial rotation in radians.
  19342. */
  19343. maxInitialRotation: number;
  19344. /**
  19345. * The particle emitter type defines the emitter used by the particle system.
  19346. * It can be for example box, sphere, or cone...
  19347. */
  19348. particleEmitterType: Nullable<IParticleEmitterType>;
  19349. /**
  19350. * Defines the delay in milliseconds before starting the system (0 by default)
  19351. */
  19352. startDelay: number;
  19353. /**
  19354. * 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
  19355. */
  19356. preWarmCycles: number;
  19357. /**
  19358. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19359. */
  19360. preWarmStepOffset: number;
  19361. /**
  19362. * 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)
  19363. */
  19364. spriteCellChangeSpeed: number;
  19365. /**
  19366. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19367. */
  19368. startSpriteCellID: number;
  19369. /**
  19370. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19371. */
  19372. endSpriteCellID: number;
  19373. /**
  19374. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19375. */
  19376. spriteCellWidth: number;
  19377. /**
  19378. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19379. */
  19380. spriteCellHeight: number;
  19381. /**
  19382. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19383. */
  19384. spriteRandomStartCell: boolean;
  19385. /**
  19386. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19387. */
  19388. isAnimationSheetEnabled: boolean;
  19389. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19390. translationPivot: Vector2;
  19391. /**
  19392. * Gets or sets a texture used to add random noise to particle positions
  19393. */
  19394. noiseTexture: Nullable<BaseTexture>;
  19395. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19396. noiseStrength: Vector3;
  19397. /**
  19398. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19399. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19400. */
  19401. billboardMode: number;
  19402. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19403. limitVelocityDamping: number;
  19404. /**
  19405. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19406. */
  19407. beginAnimationOnStart: boolean;
  19408. /**
  19409. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19410. */
  19411. beginAnimationFrom: number;
  19412. /**
  19413. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19414. */
  19415. beginAnimationTo: number;
  19416. /**
  19417. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19418. */
  19419. beginAnimationLoop: boolean;
  19420. /**
  19421. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19422. */
  19423. disposeOnStop: boolean;
  19424. /**
  19425. * Gets the maximum number of particles active at the same time.
  19426. * @returns The max number of active particles.
  19427. */
  19428. getCapacity(): number;
  19429. /**
  19430. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19431. * @returns True if it has been started, otherwise false.
  19432. */
  19433. isStarted(): boolean;
  19434. /**
  19435. * Animates the particle system for this frame.
  19436. */
  19437. animate(): void;
  19438. /**
  19439. * Renders the particle system in its current state.
  19440. * @returns the current number of particles
  19441. */
  19442. render(): number;
  19443. /**
  19444. * Dispose the particle system and frees its associated resources.
  19445. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19446. */
  19447. dispose(disposeTexture?: boolean): void;
  19448. /**
  19449. * Clones the particle system.
  19450. * @param name The name of the cloned object
  19451. * @param newEmitter The new emitter to use
  19452. * @returns the cloned particle system
  19453. */
  19454. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19455. /**
  19456. * Serializes the particle system to a JSON object.
  19457. * @returns the JSON object
  19458. */
  19459. serialize(): any;
  19460. /**
  19461. * Rebuild the particle system
  19462. */
  19463. rebuild(): void;
  19464. /**
  19465. * Starts the particle system and begins to emit
  19466. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19467. */
  19468. start(delay?: number): void;
  19469. /**
  19470. * Stops the particle system.
  19471. */
  19472. stop(): void;
  19473. /**
  19474. * Remove all active particles
  19475. */
  19476. reset(): void;
  19477. /**
  19478. * Is this system ready to be used/rendered
  19479. * @return true if the system is ready
  19480. */
  19481. isReady(): boolean;
  19482. /**
  19483. * Adds a new color gradient
  19484. * @param gradient defines the gradient to use (between 0 and 1)
  19485. * @param color1 defines the color to affect to the specified gradient
  19486. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19487. * @returns the current particle system
  19488. */
  19489. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19490. /**
  19491. * Remove a specific color gradient
  19492. * @param gradient defines the gradient to remove
  19493. * @returns the current particle system
  19494. */
  19495. removeColorGradient(gradient: number): IParticleSystem;
  19496. /**
  19497. * Adds a new size gradient
  19498. * @param gradient defines the gradient to use (between 0 and 1)
  19499. * @param factor defines the size factor to affect to the specified gradient
  19500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19501. * @returns the current particle system
  19502. */
  19503. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19504. /**
  19505. * Remove a specific size gradient
  19506. * @param gradient defines the gradient to remove
  19507. * @returns the current particle system
  19508. */
  19509. removeSizeGradient(gradient: number): IParticleSystem;
  19510. /**
  19511. * Gets the current list of color gradients.
  19512. * You must use addColorGradient and removeColorGradient to udpate this list
  19513. * @returns the list of color gradients
  19514. */
  19515. getColorGradients(): Nullable<Array<ColorGradient>>;
  19516. /**
  19517. * Gets the current list of size gradients.
  19518. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19519. * @returns the list of size gradients
  19520. */
  19521. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19522. /**
  19523. * Gets the current list of angular speed gradients.
  19524. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19525. * @returns the list of angular speed gradients
  19526. */
  19527. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19528. /**
  19529. * Adds a new angular speed gradient
  19530. * @param gradient defines the gradient to use (between 0 and 1)
  19531. * @param factor defines the angular speed to affect to the specified gradient
  19532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19533. * @returns the current particle system
  19534. */
  19535. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19536. /**
  19537. * Remove a specific angular speed gradient
  19538. * @param gradient defines the gradient to remove
  19539. * @returns the current particle system
  19540. */
  19541. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19542. /**
  19543. * Gets the current list of velocity gradients.
  19544. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19545. * @returns the list of velocity gradients
  19546. */
  19547. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19548. /**
  19549. * Adds a new velocity gradient
  19550. * @param gradient defines the gradient to use (between 0 and 1)
  19551. * @param factor defines the velocity to affect to the specified gradient
  19552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19553. * @returns the current particle system
  19554. */
  19555. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19556. /**
  19557. * Remove a specific velocity gradient
  19558. * @param gradient defines the gradient to remove
  19559. * @returns the current particle system
  19560. */
  19561. removeVelocityGradient(gradient: number): IParticleSystem;
  19562. /**
  19563. * Gets the current list of limit velocity gradients.
  19564. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19565. * @returns the list of limit velocity gradients
  19566. */
  19567. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19568. /**
  19569. * Adds a new limit velocity gradient
  19570. * @param gradient defines the gradient to use (between 0 and 1)
  19571. * @param factor defines the limit velocity to affect to the specified gradient
  19572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19573. * @returns the current particle system
  19574. */
  19575. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19576. /**
  19577. * Remove a specific limit velocity gradient
  19578. * @param gradient defines the gradient to remove
  19579. * @returns the current particle system
  19580. */
  19581. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19582. /**
  19583. * Adds a new drag gradient
  19584. * @param gradient defines the gradient to use (between 0 and 1)
  19585. * @param factor defines the drag to affect to the specified gradient
  19586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19587. * @returns the current particle system
  19588. */
  19589. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19590. /**
  19591. * Remove a specific drag gradient
  19592. * @param gradient defines the gradient to remove
  19593. * @returns the current particle system
  19594. */
  19595. removeDragGradient(gradient: number): IParticleSystem;
  19596. /**
  19597. * Gets the current list of drag gradients.
  19598. * You must use addDragGradient and removeDragGradient to udpate this list
  19599. * @returns the list of drag gradients
  19600. */
  19601. getDragGradients(): Nullable<Array<FactorGradient>>;
  19602. /**
  19603. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19604. * @param gradient defines the gradient to use (between 0 and 1)
  19605. * @param factor defines the emit rate to affect to the specified gradient
  19606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19607. * @returns the current particle system
  19608. */
  19609. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19610. /**
  19611. * Remove a specific emit rate gradient
  19612. * @param gradient defines the gradient to remove
  19613. * @returns the current particle system
  19614. */
  19615. removeEmitRateGradient(gradient: number): IParticleSystem;
  19616. /**
  19617. * Gets the current list of emit rate gradients.
  19618. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19619. * @returns the list of emit rate gradients
  19620. */
  19621. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19622. /**
  19623. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19624. * @param gradient defines the gradient to use (between 0 and 1)
  19625. * @param factor defines the start size to affect to the specified gradient
  19626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19627. * @returns the current particle system
  19628. */
  19629. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19630. /**
  19631. * Remove a specific start size gradient
  19632. * @param gradient defines the gradient to remove
  19633. * @returns the current particle system
  19634. */
  19635. removeStartSizeGradient(gradient: number): IParticleSystem;
  19636. /**
  19637. * Gets the current list of start size gradients.
  19638. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19639. * @returns the list of start size gradients
  19640. */
  19641. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19642. /**
  19643. * Adds a new life time gradient
  19644. * @param gradient defines the gradient to use (between 0 and 1)
  19645. * @param factor defines the life time factor to affect to the specified gradient
  19646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19647. * @returns the current particle system
  19648. */
  19649. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19650. /**
  19651. * Remove a specific life time gradient
  19652. * @param gradient defines the gradient to remove
  19653. * @returns the current particle system
  19654. */
  19655. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19656. /**
  19657. * Gets the current list of life time gradients.
  19658. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19659. * @returns the list of life time gradients
  19660. */
  19661. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19662. /**
  19663. * Gets the current list of color gradients.
  19664. * You must use addColorGradient and removeColorGradient to udpate this list
  19665. * @returns the list of color gradients
  19666. */
  19667. getColorGradients(): Nullable<Array<ColorGradient>>;
  19668. /**
  19669. * Adds a new ramp gradient used to remap particle colors
  19670. * @param gradient defines the gradient to use (between 0 and 1)
  19671. * @param color defines the color to affect to the specified gradient
  19672. * @returns the current particle system
  19673. */
  19674. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19675. /**
  19676. * Gets the current list of ramp gradients.
  19677. * You must use addRampGradient and removeRampGradient to udpate this list
  19678. * @returns the list of ramp gradients
  19679. */
  19680. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19681. /** Gets or sets a boolean indicating that ramp gradients must be used
  19682. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19683. */
  19684. useRampGradients: boolean;
  19685. /**
  19686. * Adds a new color remap gradient
  19687. * @param gradient defines the gradient to use (between 0 and 1)
  19688. * @param min defines the color remap minimal range
  19689. * @param max defines the color remap maximal range
  19690. * @returns the current particle system
  19691. */
  19692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19693. /**
  19694. * Gets the current list of color remap gradients.
  19695. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19696. * @returns the list of color remap gradients
  19697. */
  19698. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19699. /**
  19700. * Adds a new alpha remap gradient
  19701. * @param gradient defines the gradient to use (between 0 and 1)
  19702. * @param min defines the alpha remap minimal range
  19703. * @param max defines the alpha remap maximal range
  19704. * @returns the current particle system
  19705. */
  19706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19707. /**
  19708. * Gets the current list of alpha remap gradients.
  19709. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19710. * @returns the list of alpha remap gradients
  19711. */
  19712. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19713. /**
  19714. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19717. * @returns the emitter
  19718. */
  19719. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19720. /**
  19721. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19722. * @param radius The radius of the hemisphere to emit from
  19723. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19724. * @returns the emitter
  19725. */
  19726. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19727. /**
  19728. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19729. * @param radius The radius of the sphere to emit from
  19730. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19731. * @returns the emitter
  19732. */
  19733. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19734. /**
  19735. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19736. * @param radius The radius of the sphere to emit from
  19737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19739. * @returns the emitter
  19740. */
  19741. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19742. /**
  19743. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19744. * @param radius The radius of the emission cylinder
  19745. * @param height The height of the emission cylinder
  19746. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19747. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19748. * @returns the emitter
  19749. */
  19750. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19751. /**
  19752. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19753. * @param radius The radius of the cylinder to emit from
  19754. * @param height The height of the emission cylinder
  19755. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19756. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19757. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19758. * @returns the emitter
  19759. */
  19760. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19761. /**
  19762. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19763. * @param radius The radius of the cone to emit from
  19764. * @param angle The base angle of the cone
  19765. * @returns the emitter
  19766. */
  19767. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19768. /**
  19769. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19770. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19771. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19772. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19773. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19774. * @returns the emitter
  19775. */
  19776. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19777. /**
  19778. * Get hosting scene
  19779. * @returns the scene
  19780. */
  19781. getScene(): Scene;
  19782. }
  19783. }
  19784. declare module "babylonjs/Meshes/instancedMesh" {
  19785. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19786. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19787. import { Camera } from "babylonjs/Cameras/camera";
  19788. import { Node } from "babylonjs/node";
  19789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19790. import { Mesh } from "babylonjs/Meshes/mesh";
  19791. import { Material } from "babylonjs/Materials/material";
  19792. import { Skeleton } from "babylonjs/Bones/skeleton";
  19793. import { Light } from "babylonjs/Lights/light";
  19794. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19795. /**
  19796. * Creates an instance based on a source mesh.
  19797. */
  19798. export class InstancedMesh extends AbstractMesh {
  19799. private _sourceMesh;
  19800. private _currentLOD;
  19801. /** @hidden */
  19802. _indexInSourceMeshInstanceArray: number;
  19803. constructor(name: string, source: Mesh);
  19804. /**
  19805. * Returns the string "InstancedMesh".
  19806. */
  19807. getClassName(): string;
  19808. /** Gets the list of lights affecting that mesh */
  19809. get lightSources(): Light[];
  19810. _resyncLightSources(): void;
  19811. _resyncLightSource(light: Light): void;
  19812. _removeLightSource(light: Light, dispose: boolean): void;
  19813. /**
  19814. * If the source mesh receives shadows
  19815. */
  19816. get receiveShadows(): boolean;
  19817. /**
  19818. * The material of the source mesh
  19819. */
  19820. get material(): Nullable<Material>;
  19821. /**
  19822. * Visibility of the source mesh
  19823. */
  19824. get visibility(): number;
  19825. /**
  19826. * Skeleton of the source mesh
  19827. */
  19828. get skeleton(): Nullable<Skeleton>;
  19829. /**
  19830. * Rendering ground id of the source mesh
  19831. */
  19832. get renderingGroupId(): number;
  19833. set renderingGroupId(value: number);
  19834. /**
  19835. * Returns the total number of vertices (integer).
  19836. */
  19837. getTotalVertices(): number;
  19838. /**
  19839. * Returns a positive integer : the total number of indices in this mesh geometry.
  19840. * @returns the numner of indices or zero if the mesh has no geometry.
  19841. */
  19842. getTotalIndices(): number;
  19843. /**
  19844. * The source mesh of the instance
  19845. */
  19846. get sourceMesh(): Mesh;
  19847. /**
  19848. * Is this node ready to be used/rendered
  19849. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19850. * @return {boolean} is it ready
  19851. */
  19852. isReady(completeCheck?: boolean): boolean;
  19853. /**
  19854. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19855. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19856. * @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.
  19857. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19858. */
  19859. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19860. /**
  19861. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19862. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19863. * The `data` are either a numeric array either a Float32Array.
  19864. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19865. * 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).
  19866. * Note that a new underlying VertexBuffer object is created each call.
  19867. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19868. *
  19869. * Possible `kind` values :
  19870. * - VertexBuffer.PositionKind
  19871. * - VertexBuffer.UVKind
  19872. * - VertexBuffer.UV2Kind
  19873. * - VertexBuffer.UV3Kind
  19874. * - VertexBuffer.UV4Kind
  19875. * - VertexBuffer.UV5Kind
  19876. * - VertexBuffer.UV6Kind
  19877. * - VertexBuffer.ColorKind
  19878. * - VertexBuffer.MatricesIndicesKind
  19879. * - VertexBuffer.MatricesIndicesExtraKind
  19880. * - VertexBuffer.MatricesWeightsKind
  19881. * - VertexBuffer.MatricesWeightsExtraKind
  19882. *
  19883. * Returns the Mesh.
  19884. */
  19885. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19886. /**
  19887. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19888. * If the mesh has no geometry, it is simply returned as it is.
  19889. * The `data` are either a numeric array either a Float32Array.
  19890. * No new underlying VertexBuffer object is created.
  19891. * 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.
  19892. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19893. *
  19894. * Possible `kind` values :
  19895. * - VertexBuffer.PositionKind
  19896. * - VertexBuffer.UVKind
  19897. * - VertexBuffer.UV2Kind
  19898. * - VertexBuffer.UV3Kind
  19899. * - VertexBuffer.UV4Kind
  19900. * - VertexBuffer.UV5Kind
  19901. * - VertexBuffer.UV6Kind
  19902. * - VertexBuffer.ColorKind
  19903. * - VertexBuffer.MatricesIndicesKind
  19904. * - VertexBuffer.MatricesIndicesExtraKind
  19905. * - VertexBuffer.MatricesWeightsKind
  19906. * - VertexBuffer.MatricesWeightsExtraKind
  19907. *
  19908. * Returns the Mesh.
  19909. */
  19910. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19911. /**
  19912. * Sets the mesh indices.
  19913. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19914. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19915. * This method creates a new index buffer each call.
  19916. * Returns the Mesh.
  19917. */
  19918. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19919. /**
  19920. * Boolean : True if the mesh owns the requested kind of data.
  19921. */
  19922. isVerticesDataPresent(kind: string): boolean;
  19923. /**
  19924. * Returns an array of indices (IndicesArray).
  19925. */
  19926. getIndices(): Nullable<IndicesArray>;
  19927. get _positions(): Nullable<Vector3[]>;
  19928. /**
  19929. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19930. * This means the mesh underlying bounding box and sphere are recomputed.
  19931. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19932. * @returns the current mesh
  19933. */
  19934. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19935. /** @hidden */
  19936. _preActivate(): InstancedMesh;
  19937. /** @hidden */
  19938. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19939. /** @hidden */
  19940. _postActivate(): void;
  19941. getWorldMatrix(): Matrix;
  19942. get isAnInstance(): boolean;
  19943. /**
  19944. * Returns the current associated LOD AbstractMesh.
  19945. */
  19946. getLOD(camera: Camera): AbstractMesh;
  19947. /** @hidden */
  19948. _syncSubMeshes(): InstancedMesh;
  19949. /** @hidden */
  19950. _generatePointsArray(): boolean;
  19951. /**
  19952. * Creates a new InstancedMesh from the current mesh.
  19953. * - name (string) : the cloned mesh name
  19954. * - newParent (optional Node) : the optional Node to parent the clone to.
  19955. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19956. *
  19957. * Returns the clone.
  19958. */
  19959. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19960. /**
  19961. * Disposes the InstancedMesh.
  19962. * Returns nothing.
  19963. */
  19964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19965. }
  19966. module "babylonjs/Meshes/mesh" {
  19967. interface Mesh {
  19968. /**
  19969. * Register a custom buffer that will be instanced
  19970. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19971. * @param kind defines the buffer kind
  19972. * @param stride defines the stride in floats
  19973. */
  19974. registerInstancedBuffer(kind: string, stride: number): void;
  19975. /** @hidden */
  19976. _userInstancedBuffersStorage: {
  19977. data: {
  19978. [key: string]: Float32Array;
  19979. };
  19980. sizes: {
  19981. [key: string]: number;
  19982. };
  19983. vertexBuffers: {
  19984. [key: string]: Nullable<VertexBuffer>;
  19985. };
  19986. strides: {
  19987. [key: string]: number;
  19988. };
  19989. };
  19990. }
  19991. }
  19992. module "babylonjs/Meshes/abstractMesh" {
  19993. interface AbstractMesh {
  19994. /**
  19995. * Object used to store instanced buffers defined by user
  19996. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19997. */
  19998. instancedBuffers: {
  19999. [key: string]: any;
  20000. };
  20001. }
  20002. }
  20003. }
  20004. declare module "babylonjs/Materials/shaderMaterial" {
  20005. import { Scene } from "babylonjs/scene";
  20006. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  20007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20008. import { Mesh } from "babylonjs/Meshes/mesh";
  20009. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  20010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20011. import { Texture } from "babylonjs/Materials/Textures/texture";
  20012. import { Material } from "babylonjs/Materials/material";
  20013. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  20014. /**
  20015. * Defines the options associated with the creation of a shader material.
  20016. */
  20017. export interface IShaderMaterialOptions {
  20018. /**
  20019. * Does the material work in alpha blend mode
  20020. */
  20021. needAlphaBlending: boolean;
  20022. /**
  20023. * Does the material work in alpha test mode
  20024. */
  20025. needAlphaTesting: boolean;
  20026. /**
  20027. * The list of attribute names used in the shader
  20028. */
  20029. attributes: string[];
  20030. /**
  20031. * The list of unifrom names used in the shader
  20032. */
  20033. uniforms: string[];
  20034. /**
  20035. * The list of UBO names used in the shader
  20036. */
  20037. uniformBuffers: string[];
  20038. /**
  20039. * The list of sampler names used in the shader
  20040. */
  20041. samplers: string[];
  20042. /**
  20043. * The list of defines used in the shader
  20044. */
  20045. defines: string[];
  20046. }
  20047. /**
  20048. * 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.
  20049. *
  20050. * This returned material effects how the mesh will look based on the code in the shaders.
  20051. *
  20052. * @see http://doc.babylonjs.com/how_to/shader_material
  20053. */
  20054. export class ShaderMaterial extends Material {
  20055. private _shaderPath;
  20056. private _options;
  20057. private _textures;
  20058. private _textureArrays;
  20059. private _floats;
  20060. private _ints;
  20061. private _floatsArrays;
  20062. private _colors3;
  20063. private _colors3Arrays;
  20064. private _colors4;
  20065. private _colors4Arrays;
  20066. private _vectors2;
  20067. private _vectors3;
  20068. private _vectors4;
  20069. private _matrices;
  20070. private _matrixArrays;
  20071. private _matrices3x3;
  20072. private _matrices2x2;
  20073. private _vectors2Arrays;
  20074. private _vectors3Arrays;
  20075. private _vectors4Arrays;
  20076. private _cachedWorldViewMatrix;
  20077. private _cachedWorldViewProjectionMatrix;
  20078. private _renderId;
  20079. private _multiview;
  20080. /**
  20081. * Instantiate a new shader material.
  20082. * 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.
  20083. * This returned material effects how the mesh will look based on the code in the shaders.
  20084. * @see http://doc.babylonjs.com/how_to/shader_material
  20085. * @param name Define the name of the material in the scene
  20086. * @param scene Define the scene the material belongs to
  20087. * @param shaderPath Defines the route to the shader code in one of three ways:
  20088. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  20089. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  20090. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  20091. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  20092. * @param options Define the options used to create the shader
  20093. */
  20094. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  20095. /**
  20096. * Gets the shader path used to define the shader code
  20097. * It can be modified to trigger a new compilation
  20098. */
  20099. get shaderPath(): any;
  20100. /**
  20101. * Sets the shader path used to define the shader code
  20102. * It can be modified to trigger a new compilation
  20103. */
  20104. set shaderPath(shaderPath: any);
  20105. /**
  20106. * Gets the options used to compile the shader.
  20107. * They can be modified to trigger a new compilation
  20108. */
  20109. get options(): IShaderMaterialOptions;
  20110. /**
  20111. * Gets the current class name of the material e.g. "ShaderMaterial"
  20112. * Mainly use in serialization.
  20113. * @returns the class name
  20114. */
  20115. getClassName(): string;
  20116. /**
  20117. * Specifies if the material will require alpha blending
  20118. * @returns a boolean specifying if alpha blending is needed
  20119. */
  20120. needAlphaBlending(): boolean;
  20121. /**
  20122. * Specifies if this material should be rendered in alpha test mode
  20123. * @returns a boolean specifying if an alpha test is needed.
  20124. */
  20125. needAlphaTesting(): boolean;
  20126. private _checkUniform;
  20127. /**
  20128. * Set a texture in the shader.
  20129. * @param name Define the name of the uniform samplers as defined in the shader
  20130. * @param texture Define the texture to bind to this sampler
  20131. * @return the material itself allowing "fluent" like uniform updates
  20132. */
  20133. setTexture(name: string, texture: Texture): ShaderMaterial;
  20134. /**
  20135. * Set a texture array in the shader.
  20136. * @param name Define the name of the uniform sampler array as defined in the shader
  20137. * @param textures Define the list of textures to bind to this sampler
  20138. * @return the material itself allowing "fluent" like uniform updates
  20139. */
  20140. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20141. /**
  20142. * Set a float in the shader.
  20143. * @param name Define the name of the uniform as defined in the shader
  20144. * @param value Define the value to give to the uniform
  20145. * @return the material itself allowing "fluent" like uniform updates
  20146. */
  20147. setFloat(name: string, value: number): ShaderMaterial;
  20148. /**
  20149. * Set a int in the shader.
  20150. * @param name Define the name of the uniform as defined in the shader
  20151. * @param value Define the value to give to the uniform
  20152. * @return the material itself allowing "fluent" like uniform updates
  20153. */
  20154. setInt(name: string, value: number): ShaderMaterial;
  20155. /**
  20156. * Set an array of floats in the shader.
  20157. * @param name Define the name of the uniform as defined in the shader
  20158. * @param value Define the value to give to the uniform
  20159. * @return the material itself allowing "fluent" like uniform updates
  20160. */
  20161. setFloats(name: string, value: number[]): ShaderMaterial;
  20162. /**
  20163. * Set a vec3 in the shader from a Color3.
  20164. * @param name Define the name of the uniform as defined in the shader
  20165. * @param value Define the value to give to the uniform
  20166. * @return the material itself allowing "fluent" like uniform updates
  20167. */
  20168. setColor3(name: string, value: Color3): ShaderMaterial;
  20169. /**
  20170. * Set a vec3 array in the shader from a Color3 array.
  20171. * @param name Define the name of the uniform as defined in the shader
  20172. * @param value Define the value to give to the uniform
  20173. * @return the material itself allowing "fluent" like uniform updates
  20174. */
  20175. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20176. /**
  20177. * Set a vec4 in the shader from a Color4.
  20178. * @param name Define the name of the uniform as defined in the shader
  20179. * @param value Define the value to give to the uniform
  20180. * @return the material itself allowing "fluent" like uniform updates
  20181. */
  20182. setColor4(name: string, value: Color4): ShaderMaterial;
  20183. /**
  20184. * Set a vec4 array in the shader from a Color4 array.
  20185. * @param name Define the name of the uniform as defined in the shader
  20186. * @param value Define the value to give to the uniform
  20187. * @return the material itself allowing "fluent" like uniform updates
  20188. */
  20189. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20190. /**
  20191. * Set a vec2 in the shader from a Vector2.
  20192. * @param name Define the name of the uniform as defined in the shader
  20193. * @param value Define the value to give to the uniform
  20194. * @return the material itself allowing "fluent" like uniform updates
  20195. */
  20196. setVector2(name: string, value: Vector2): ShaderMaterial;
  20197. /**
  20198. * Set a vec3 in the shader from a Vector3.
  20199. * @param name Define the name of the uniform as defined in the shader
  20200. * @param value Define the value to give to the uniform
  20201. * @return the material itself allowing "fluent" like uniform updates
  20202. */
  20203. setVector3(name: string, value: Vector3): ShaderMaterial;
  20204. /**
  20205. * Set a vec4 in the shader from a Vector4.
  20206. * @param name Define the name of the uniform as defined in the shader
  20207. * @param value Define the value to give to the uniform
  20208. * @return the material itself allowing "fluent" like uniform updates
  20209. */
  20210. setVector4(name: string, value: Vector4): ShaderMaterial;
  20211. /**
  20212. * Set a mat4 in the shader from a Matrix.
  20213. * @param name Define the name of the uniform as defined in the shader
  20214. * @param value Define the value to give to the uniform
  20215. * @return the material itself allowing "fluent" like uniform updates
  20216. */
  20217. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20218. /**
  20219. * Set a float32Array in the shader from a matrix array.
  20220. * @param name Define the name of the uniform as defined in the shader
  20221. * @param value Define the value to give to the uniform
  20222. * @return the material itself allowing "fluent" like uniform updates
  20223. */
  20224. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20225. /**
  20226. * Set a mat3 in the shader from a Float32Array.
  20227. * @param name Define the name of the uniform as defined in the shader
  20228. * @param value Define the value to give to the uniform
  20229. * @return the material itself allowing "fluent" like uniform updates
  20230. */
  20231. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20232. /**
  20233. * Set a mat2 in the shader from a Float32Array.
  20234. * @param name Define the name of the uniform as defined in the shader
  20235. * @param value Define the value to give to the uniform
  20236. * @return the material itself allowing "fluent" like uniform updates
  20237. */
  20238. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20239. /**
  20240. * Set a vec2 array in the shader from a number array.
  20241. * @param name Define the name of the uniform as defined in the shader
  20242. * @param value Define the value to give to the uniform
  20243. * @return the material itself allowing "fluent" like uniform updates
  20244. */
  20245. setArray2(name: string, value: number[]): ShaderMaterial;
  20246. /**
  20247. * Set a vec3 array in the shader from a number array.
  20248. * @param name Define the name of the uniform as defined in the shader
  20249. * @param value Define the value to give to the uniform
  20250. * @return the material itself allowing "fluent" like uniform updates
  20251. */
  20252. setArray3(name: string, value: number[]): ShaderMaterial;
  20253. /**
  20254. * Set a vec4 array in the shader from a number array.
  20255. * @param name Define the name of the uniform as defined in the shader
  20256. * @param value Define the value to give to the uniform
  20257. * @return the material itself allowing "fluent" like uniform updates
  20258. */
  20259. setArray4(name: string, value: number[]): ShaderMaterial;
  20260. private _checkCache;
  20261. /**
  20262. * Specifies that the submesh is ready to be used
  20263. * @param mesh defines the mesh to check
  20264. * @param subMesh defines which submesh to check
  20265. * @param useInstances specifies that instances should be used
  20266. * @returns a boolean indicating that the submesh is ready or not
  20267. */
  20268. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20269. /**
  20270. * Checks if the material is ready to render the requested mesh
  20271. * @param mesh Define the mesh to render
  20272. * @param useInstances Define whether or not the material is used with instances
  20273. * @returns true if ready, otherwise false
  20274. */
  20275. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20276. /**
  20277. * Binds the world matrix to the material
  20278. * @param world defines the world transformation matrix
  20279. */
  20280. bindOnlyWorldMatrix(world: Matrix): void;
  20281. /**
  20282. * Binds the material to the mesh
  20283. * @param world defines the world transformation matrix
  20284. * @param mesh defines the mesh to bind the material to
  20285. */
  20286. bind(world: Matrix, mesh?: Mesh): void;
  20287. /**
  20288. * Gets the active textures from the material
  20289. * @returns an array of textures
  20290. */
  20291. getActiveTextures(): BaseTexture[];
  20292. /**
  20293. * Specifies if the material uses a texture
  20294. * @param texture defines the texture to check against the material
  20295. * @returns a boolean specifying if the material uses the texture
  20296. */
  20297. hasTexture(texture: BaseTexture): boolean;
  20298. /**
  20299. * Makes a duplicate of the material, and gives it a new name
  20300. * @param name defines the new name for the duplicated material
  20301. * @returns the cloned material
  20302. */
  20303. clone(name: string): ShaderMaterial;
  20304. /**
  20305. * Disposes the material
  20306. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20307. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20308. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20309. */
  20310. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20311. /**
  20312. * Serializes this material in a JSON representation
  20313. * @returns the serialized material object
  20314. */
  20315. serialize(): any;
  20316. /**
  20317. * Creates a shader material from parsed shader material data
  20318. * @param source defines the JSON represnetation of the material
  20319. * @param scene defines the hosting scene
  20320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20321. * @returns a new material
  20322. */
  20323. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20324. }
  20325. }
  20326. declare module "babylonjs/Shaders/color.fragment" {
  20327. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20328. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20329. /** @hidden */
  20330. export var colorPixelShader: {
  20331. name: string;
  20332. shader: string;
  20333. };
  20334. }
  20335. declare module "babylonjs/Shaders/color.vertex" {
  20336. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20337. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20339. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20340. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20341. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20342. /** @hidden */
  20343. export var colorVertexShader: {
  20344. name: string;
  20345. shader: string;
  20346. };
  20347. }
  20348. declare module "babylonjs/Meshes/linesMesh" {
  20349. import { Nullable } from "babylonjs/types";
  20350. import { Scene } from "babylonjs/scene";
  20351. import { Color3 } from "babylonjs/Maths/math.color";
  20352. import { Node } from "babylonjs/node";
  20353. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20354. import { Mesh } from "babylonjs/Meshes/mesh";
  20355. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20356. import { Effect } from "babylonjs/Materials/effect";
  20357. import { Material } from "babylonjs/Materials/material";
  20358. import "babylonjs/Shaders/color.fragment";
  20359. import "babylonjs/Shaders/color.vertex";
  20360. /**
  20361. * Line mesh
  20362. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20363. */
  20364. export class LinesMesh extends Mesh {
  20365. /**
  20366. * If vertex color should be applied to the mesh
  20367. */
  20368. readonly useVertexColor?: boolean | undefined;
  20369. /**
  20370. * If vertex alpha should be applied to the mesh
  20371. */
  20372. readonly useVertexAlpha?: boolean | undefined;
  20373. /**
  20374. * Color of the line (Default: White)
  20375. */
  20376. color: Color3;
  20377. /**
  20378. * Alpha of the line (Default: 1)
  20379. */
  20380. alpha: number;
  20381. /**
  20382. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20383. * This margin is expressed in world space coordinates, so its value may vary.
  20384. * Default value is 0.1
  20385. */
  20386. intersectionThreshold: number;
  20387. private _colorShader;
  20388. private color4;
  20389. /**
  20390. * Creates a new LinesMesh
  20391. * @param name defines the name
  20392. * @param scene defines the hosting scene
  20393. * @param parent defines the parent mesh if any
  20394. * @param source defines the optional source LinesMesh used to clone data from
  20395. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20396. * When false, achieved by calling a clone(), also passing False.
  20397. * This will make creation of children, recursive.
  20398. * @param useVertexColor defines if this LinesMesh supports vertex color
  20399. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20400. */
  20401. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20402. /**
  20403. * If vertex color should be applied to the mesh
  20404. */
  20405. useVertexColor?: boolean | undefined,
  20406. /**
  20407. * If vertex alpha should be applied to the mesh
  20408. */
  20409. useVertexAlpha?: boolean | undefined);
  20410. private _addClipPlaneDefine;
  20411. private _removeClipPlaneDefine;
  20412. isReady(): boolean;
  20413. /**
  20414. * Returns the string "LineMesh"
  20415. */
  20416. getClassName(): string;
  20417. /**
  20418. * @hidden
  20419. */
  20420. get material(): Material;
  20421. /**
  20422. * @hidden
  20423. */
  20424. set material(value: Material);
  20425. /**
  20426. * @hidden
  20427. */
  20428. get checkCollisions(): boolean;
  20429. /** @hidden */
  20430. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20431. /** @hidden */
  20432. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20433. /**
  20434. * Disposes of the line mesh
  20435. * @param doNotRecurse If children should be disposed
  20436. */
  20437. dispose(doNotRecurse?: boolean): void;
  20438. /**
  20439. * Returns a new LineMesh object cloned from the current one.
  20440. */
  20441. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  20442. /**
  20443. * Creates a new InstancedLinesMesh object from the mesh model.
  20444. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20445. * @param name defines the name of the new instance
  20446. * @returns a new InstancedLinesMesh
  20447. */
  20448. createInstance(name: string): InstancedLinesMesh;
  20449. }
  20450. /**
  20451. * Creates an instance based on a source LinesMesh
  20452. */
  20453. export class InstancedLinesMesh extends InstancedMesh {
  20454. /**
  20455. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20456. * This margin is expressed in world space coordinates, so its value may vary.
  20457. * Initilized with the intersectionThreshold value of the source LinesMesh
  20458. */
  20459. intersectionThreshold: number;
  20460. constructor(name: string, source: LinesMesh);
  20461. /**
  20462. * Returns the string "InstancedLinesMesh".
  20463. */
  20464. getClassName(): string;
  20465. }
  20466. }
  20467. declare module "babylonjs/Shaders/line.fragment" {
  20468. /** @hidden */
  20469. export var linePixelShader: {
  20470. name: string;
  20471. shader: string;
  20472. };
  20473. }
  20474. declare module "babylonjs/Shaders/line.vertex" {
  20475. /** @hidden */
  20476. export var lineVertexShader: {
  20477. name: string;
  20478. shader: string;
  20479. };
  20480. }
  20481. declare module "babylonjs/Rendering/edgesRenderer" {
  20482. import { Nullable } from "babylonjs/types";
  20483. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20485. import { Vector3 } from "babylonjs/Maths/math.vector";
  20486. import { IDisposable } from "babylonjs/scene";
  20487. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20488. import "babylonjs/Shaders/line.fragment";
  20489. import "babylonjs/Shaders/line.vertex";
  20490. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20491. module "babylonjs/Meshes/abstractMesh" {
  20492. interface AbstractMesh {
  20493. /**
  20494. * Gets the edgesRenderer associated with the mesh
  20495. */
  20496. edgesRenderer: Nullable<EdgesRenderer>;
  20497. }
  20498. }
  20499. module "babylonjs/Meshes/linesMesh" {
  20500. interface LinesMesh {
  20501. /**
  20502. * Enables the edge rendering mode on the mesh.
  20503. * This mode makes the mesh edges visible
  20504. * @param epsilon defines the maximal distance between two angles to detect a face
  20505. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20506. * @returns the currentAbstractMesh
  20507. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20508. */
  20509. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20510. }
  20511. }
  20512. module "babylonjs/Meshes/linesMesh" {
  20513. interface InstancedLinesMesh {
  20514. /**
  20515. * Enables the edge rendering mode on the mesh.
  20516. * This mode makes the mesh edges visible
  20517. * @param epsilon defines the maximal distance between two angles to detect a face
  20518. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20519. * @returns the current InstancedLinesMesh
  20520. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20521. */
  20522. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20523. }
  20524. }
  20525. /**
  20526. * Defines the minimum contract an Edges renderer should follow.
  20527. */
  20528. export interface IEdgesRenderer extends IDisposable {
  20529. /**
  20530. * Gets or sets a boolean indicating if the edgesRenderer is active
  20531. */
  20532. isEnabled: boolean;
  20533. /**
  20534. * Renders the edges of the attached mesh,
  20535. */
  20536. render(): void;
  20537. /**
  20538. * Checks wether or not the edges renderer is ready to render.
  20539. * @return true if ready, otherwise false.
  20540. */
  20541. isReady(): boolean;
  20542. }
  20543. /**
  20544. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20545. */
  20546. export class EdgesRenderer implements IEdgesRenderer {
  20547. /**
  20548. * Define the size of the edges with an orthographic camera
  20549. */
  20550. edgesWidthScalerForOrthographic: number;
  20551. /**
  20552. * Define the size of the edges with a perspective camera
  20553. */
  20554. edgesWidthScalerForPerspective: number;
  20555. protected _source: AbstractMesh;
  20556. protected _linesPositions: number[];
  20557. protected _linesNormals: number[];
  20558. protected _linesIndices: number[];
  20559. protected _epsilon: number;
  20560. protected _indicesCount: number;
  20561. protected _lineShader: ShaderMaterial;
  20562. protected _ib: DataBuffer;
  20563. protected _buffers: {
  20564. [key: string]: Nullable<VertexBuffer>;
  20565. };
  20566. protected _checkVerticesInsteadOfIndices: boolean;
  20567. private _meshRebuildObserver;
  20568. private _meshDisposeObserver;
  20569. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20570. isEnabled: boolean;
  20571. /**
  20572. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20573. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20574. * @param source Mesh used to create edges
  20575. * @param epsilon sum of angles in adjacency to check for edge
  20576. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20577. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20578. */
  20579. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20580. protected _prepareRessources(): void;
  20581. /** @hidden */
  20582. _rebuild(): void;
  20583. /**
  20584. * Releases the required resources for the edges renderer
  20585. */
  20586. dispose(): void;
  20587. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20588. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20589. /**
  20590. * Checks if the pair of p0 and p1 is en edge
  20591. * @param faceIndex
  20592. * @param edge
  20593. * @param faceNormals
  20594. * @param p0
  20595. * @param p1
  20596. * @private
  20597. */
  20598. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20599. /**
  20600. * push line into the position, normal and index buffer
  20601. * @protected
  20602. */
  20603. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20604. /**
  20605. * Generates lines edges from adjacencjes
  20606. * @private
  20607. */
  20608. _generateEdgesLines(): void;
  20609. /**
  20610. * Checks wether or not the edges renderer is ready to render.
  20611. * @return true if ready, otherwise false.
  20612. */
  20613. isReady(): boolean;
  20614. /**
  20615. * Renders the edges of the attached mesh,
  20616. */
  20617. render(): void;
  20618. }
  20619. /**
  20620. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20621. */
  20622. export class LineEdgesRenderer extends EdgesRenderer {
  20623. /**
  20624. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20625. * @param source LineMesh used to generate edges
  20626. * @param epsilon not important (specified angle for edge detection)
  20627. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20628. */
  20629. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20630. /**
  20631. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20632. */
  20633. _generateEdgesLines(): void;
  20634. }
  20635. }
  20636. declare module "babylonjs/Rendering/renderingGroup" {
  20637. import { SmartArray } from "babylonjs/Misc/smartArray";
  20638. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20640. import { Nullable } from "babylonjs/types";
  20641. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20642. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20643. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20644. import { Material } from "babylonjs/Materials/material";
  20645. import { Scene } from "babylonjs/scene";
  20646. /**
  20647. * This represents the object necessary to create a rendering group.
  20648. * This is exclusively used and created by the rendering manager.
  20649. * To modify the behavior, you use the available helpers in your scene or meshes.
  20650. * @hidden
  20651. */
  20652. export class RenderingGroup {
  20653. index: number;
  20654. private static _zeroVector;
  20655. private _scene;
  20656. private _opaqueSubMeshes;
  20657. private _transparentSubMeshes;
  20658. private _alphaTestSubMeshes;
  20659. private _depthOnlySubMeshes;
  20660. private _particleSystems;
  20661. private _spriteManagers;
  20662. private _opaqueSortCompareFn;
  20663. private _alphaTestSortCompareFn;
  20664. private _transparentSortCompareFn;
  20665. private _renderOpaque;
  20666. private _renderAlphaTest;
  20667. private _renderTransparent;
  20668. /** @hidden */
  20669. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20670. onBeforeTransparentRendering: () => void;
  20671. /**
  20672. * Set the opaque sort comparison function.
  20673. * If null the sub meshes will be render in the order they were created
  20674. */
  20675. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20676. /**
  20677. * Set the alpha test sort comparison function.
  20678. * If null the sub meshes will be render in the order they were created
  20679. */
  20680. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20681. /**
  20682. * Set the transparent sort comparison function.
  20683. * If null the sub meshes will be render in the order they were created
  20684. */
  20685. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20686. /**
  20687. * Creates a new rendering group.
  20688. * @param index The rendering group index
  20689. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20690. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20691. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20692. */
  20693. 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>);
  20694. /**
  20695. * Render all the sub meshes contained in the group.
  20696. * @param customRenderFunction Used to override the default render behaviour of the group.
  20697. * @returns true if rendered some submeshes.
  20698. */
  20699. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20700. /**
  20701. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20702. * @param subMeshes The submeshes to render
  20703. */
  20704. private renderOpaqueSorted;
  20705. /**
  20706. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20707. * @param subMeshes The submeshes to render
  20708. */
  20709. private renderAlphaTestSorted;
  20710. /**
  20711. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20712. * @param subMeshes The submeshes to render
  20713. */
  20714. private renderTransparentSorted;
  20715. /**
  20716. * Renders the submeshes in a specified order.
  20717. * @param subMeshes The submeshes to sort before render
  20718. * @param sortCompareFn The comparison function use to sort
  20719. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20720. * @param transparent Specifies to activate blending if true
  20721. */
  20722. private static renderSorted;
  20723. /**
  20724. * Renders the submeshes in the order they were dispatched (no sort applied).
  20725. * @param subMeshes The submeshes to render
  20726. */
  20727. private static renderUnsorted;
  20728. /**
  20729. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20730. * are rendered back to front if in the same alpha index.
  20731. *
  20732. * @param a The first submesh
  20733. * @param b The second submesh
  20734. * @returns The result of the comparison
  20735. */
  20736. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20737. /**
  20738. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20739. * are rendered back to front.
  20740. *
  20741. * @param a The first submesh
  20742. * @param b The second submesh
  20743. * @returns The result of the comparison
  20744. */
  20745. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20746. /**
  20747. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20748. * are rendered front to back (prevent overdraw).
  20749. *
  20750. * @param a The first submesh
  20751. * @param b The second submesh
  20752. * @returns The result of the comparison
  20753. */
  20754. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20755. /**
  20756. * Resets the different lists of submeshes to prepare a new frame.
  20757. */
  20758. prepare(): void;
  20759. dispose(): void;
  20760. /**
  20761. * Inserts the submesh in its correct queue depending on its material.
  20762. * @param subMesh The submesh to dispatch
  20763. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20764. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20765. */
  20766. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20767. dispatchSprites(spriteManager: ISpriteManager): void;
  20768. dispatchParticles(particleSystem: IParticleSystem): void;
  20769. private _renderParticles;
  20770. private _renderSprites;
  20771. }
  20772. }
  20773. declare module "babylonjs/Rendering/renderingManager" {
  20774. import { Nullable } from "babylonjs/types";
  20775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20776. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20777. import { SmartArray } from "babylonjs/Misc/smartArray";
  20778. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20779. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20780. import { Material } from "babylonjs/Materials/material";
  20781. import { Scene } from "babylonjs/scene";
  20782. import { Camera } from "babylonjs/Cameras/camera";
  20783. /**
  20784. * Interface describing the different options available in the rendering manager
  20785. * regarding Auto Clear between groups.
  20786. */
  20787. export interface IRenderingManagerAutoClearSetup {
  20788. /**
  20789. * Defines whether or not autoclear is enable.
  20790. */
  20791. autoClear: boolean;
  20792. /**
  20793. * Defines whether or not to autoclear the depth buffer.
  20794. */
  20795. depth: boolean;
  20796. /**
  20797. * Defines whether or not to autoclear the stencil buffer.
  20798. */
  20799. stencil: boolean;
  20800. }
  20801. /**
  20802. * This class is used by the onRenderingGroupObservable
  20803. */
  20804. export class RenderingGroupInfo {
  20805. /**
  20806. * The Scene that being rendered
  20807. */
  20808. scene: Scene;
  20809. /**
  20810. * The camera currently used for the rendering pass
  20811. */
  20812. camera: Nullable<Camera>;
  20813. /**
  20814. * The ID of the renderingGroup being processed
  20815. */
  20816. renderingGroupId: number;
  20817. }
  20818. /**
  20819. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20820. * It is enable to manage the different groups as well as the different necessary sort functions.
  20821. * This should not be used directly aside of the few static configurations
  20822. */
  20823. export class RenderingManager {
  20824. /**
  20825. * The max id used for rendering groups (not included)
  20826. */
  20827. static MAX_RENDERINGGROUPS: number;
  20828. /**
  20829. * The min id used for rendering groups (included)
  20830. */
  20831. static MIN_RENDERINGGROUPS: number;
  20832. /**
  20833. * Used to globally prevent autoclearing scenes.
  20834. */
  20835. static AUTOCLEAR: boolean;
  20836. /**
  20837. * @hidden
  20838. */
  20839. _useSceneAutoClearSetup: boolean;
  20840. private _scene;
  20841. private _renderingGroups;
  20842. private _depthStencilBufferAlreadyCleaned;
  20843. private _autoClearDepthStencil;
  20844. private _customOpaqueSortCompareFn;
  20845. private _customAlphaTestSortCompareFn;
  20846. private _customTransparentSortCompareFn;
  20847. private _renderingGroupInfo;
  20848. /**
  20849. * Instantiates a new rendering group for a particular scene
  20850. * @param scene Defines the scene the groups belongs to
  20851. */
  20852. constructor(scene: Scene);
  20853. private _clearDepthStencilBuffer;
  20854. /**
  20855. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20856. * @hidden
  20857. */
  20858. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20859. /**
  20860. * Resets the different information of the group to prepare a new frame
  20861. * @hidden
  20862. */
  20863. reset(): void;
  20864. /**
  20865. * Dispose and release the group and its associated resources.
  20866. * @hidden
  20867. */
  20868. dispose(): void;
  20869. /**
  20870. * Clear the info related to rendering groups preventing retention points during dispose.
  20871. */
  20872. freeRenderingGroups(): void;
  20873. private _prepareRenderingGroup;
  20874. /**
  20875. * Add a sprite manager to the rendering manager in order to render it this frame.
  20876. * @param spriteManager Define the sprite manager to render
  20877. */
  20878. dispatchSprites(spriteManager: ISpriteManager): void;
  20879. /**
  20880. * Add a particle system to the rendering manager in order to render it this frame.
  20881. * @param particleSystem Define the particle system to render
  20882. */
  20883. dispatchParticles(particleSystem: IParticleSystem): void;
  20884. /**
  20885. * Add a submesh to the manager in order to render it this frame
  20886. * @param subMesh The submesh to dispatch
  20887. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20888. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20889. */
  20890. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20891. /**
  20892. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20893. * This allowed control for front to back rendering or reversly depending of the special needs.
  20894. *
  20895. * @param renderingGroupId The rendering group id corresponding to its index
  20896. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20897. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20898. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20899. */
  20900. 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;
  20901. /**
  20902. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20903. *
  20904. * @param renderingGroupId The rendering group id corresponding to its index
  20905. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20906. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20907. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20908. */
  20909. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20910. /**
  20911. * Gets the current auto clear configuration for one rendering group of the rendering
  20912. * manager.
  20913. * @param index the rendering group index to get the information for
  20914. * @returns The auto clear setup for the requested rendering group
  20915. */
  20916. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20917. }
  20918. }
  20919. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20920. import { Observable } from "babylonjs/Misc/observable";
  20921. import { SmartArray } from "babylonjs/Misc/smartArray";
  20922. import { Nullable, Immutable } from "babylonjs/types";
  20923. import { Camera } from "babylonjs/Cameras/camera";
  20924. import { Scene } from "babylonjs/scene";
  20925. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20926. import { Color4 } from "babylonjs/Maths/math.color";
  20927. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20931. import { Texture } from "babylonjs/Materials/Textures/texture";
  20932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20933. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20934. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20935. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20936. import { Engine } from "babylonjs/Engines/engine";
  20937. /**
  20938. * This Helps creating a texture that will be created from a camera in your scene.
  20939. * It is basically a dynamic texture that could be used to create special effects for instance.
  20940. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20941. */
  20942. export class RenderTargetTexture extends Texture {
  20943. isCube: boolean;
  20944. /**
  20945. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20946. */
  20947. static readonly REFRESHRATE_RENDER_ONCE: number;
  20948. /**
  20949. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20950. */
  20951. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20952. /**
  20953. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20954. * the central point of your effect and can save a lot of performances.
  20955. */
  20956. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20957. /**
  20958. * Use this predicate to dynamically define the list of mesh you want to render.
  20959. * If set, the renderList property will be overwritten.
  20960. */
  20961. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20962. private _renderList;
  20963. /**
  20964. * Use this list to define the list of mesh you want to render.
  20965. */
  20966. get renderList(): Nullable<Array<AbstractMesh>>;
  20967. set renderList(value: Nullable<Array<AbstractMesh>>);
  20968. /**
  20969. * Use this function to overload the renderList array at rendering time.
  20970. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20971. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20972. * the cube (if the RTT is a cube, else layerOrFace=0).
  20973. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20974. */
  20975. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20976. private _hookArray;
  20977. /**
  20978. * Define if particles should be rendered in your texture.
  20979. */
  20980. renderParticles: boolean;
  20981. /**
  20982. * Define if sprites should be rendered in your texture.
  20983. */
  20984. renderSprites: boolean;
  20985. /**
  20986. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20987. */
  20988. coordinatesMode: number;
  20989. /**
  20990. * Define the camera used to render the texture.
  20991. */
  20992. activeCamera: Nullable<Camera>;
  20993. /**
  20994. * Override the render function of the texture with your own one.
  20995. */
  20996. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20997. /**
  20998. * Define if camera post processes should be use while rendering the texture.
  20999. */
  21000. useCameraPostProcesses: boolean;
  21001. /**
  21002. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21003. */
  21004. ignoreCameraViewport: boolean;
  21005. private _postProcessManager;
  21006. private _postProcesses;
  21007. private _resizeObserver;
  21008. /**
  21009. * An event triggered when the texture is unbind.
  21010. */
  21011. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21012. /**
  21013. * An event triggered when the texture is unbind.
  21014. */
  21015. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21016. private _onAfterUnbindObserver;
  21017. /**
  21018. * Set a after unbind callback in the texture.
  21019. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21020. */
  21021. set onAfterUnbind(callback: () => void);
  21022. /**
  21023. * An event triggered before rendering the texture
  21024. */
  21025. onBeforeRenderObservable: Observable<number>;
  21026. private _onBeforeRenderObserver;
  21027. /**
  21028. * Set a before render callback in the texture.
  21029. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21030. */
  21031. set onBeforeRender(callback: (faceIndex: number) => void);
  21032. /**
  21033. * An event triggered after rendering the texture
  21034. */
  21035. onAfterRenderObservable: Observable<number>;
  21036. private _onAfterRenderObserver;
  21037. /**
  21038. * Set a after render callback in the texture.
  21039. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21040. */
  21041. set onAfterRender(callback: (faceIndex: number) => void);
  21042. /**
  21043. * An event triggered after the texture clear
  21044. */
  21045. onClearObservable: Observable<Engine>;
  21046. private _onClearObserver;
  21047. /**
  21048. * Set a clear callback in the texture.
  21049. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21050. */
  21051. set onClear(callback: (Engine: Engine) => void);
  21052. /**
  21053. * An event triggered when the texture is resized.
  21054. */
  21055. onResizeObservable: Observable<RenderTargetTexture>;
  21056. /**
  21057. * Define the clear color of the Render Target if it should be different from the scene.
  21058. */
  21059. clearColor: Color4;
  21060. protected _size: number | {
  21061. width: number;
  21062. height: number;
  21063. layers?: number;
  21064. };
  21065. protected _initialSizeParameter: number | {
  21066. width: number;
  21067. height: number;
  21068. } | {
  21069. ratio: number;
  21070. };
  21071. protected _sizeRatio: Nullable<number>;
  21072. /** @hidden */
  21073. _generateMipMaps: boolean;
  21074. protected _renderingManager: RenderingManager;
  21075. /** @hidden */
  21076. _waitingRenderList: string[];
  21077. protected _doNotChangeAspectRatio: boolean;
  21078. protected _currentRefreshId: number;
  21079. protected _refreshRate: number;
  21080. protected _textureMatrix: Matrix;
  21081. protected _samples: number;
  21082. protected _renderTargetOptions: RenderTargetCreationOptions;
  21083. /**
  21084. * Gets render target creation options that were used.
  21085. */
  21086. get renderTargetOptions(): RenderTargetCreationOptions;
  21087. protected _engine: Engine;
  21088. protected _onRatioRescale(): void;
  21089. /**
  21090. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21091. * It must define where the camera used to render the texture is set
  21092. */
  21093. boundingBoxPosition: Vector3;
  21094. private _boundingBoxSize;
  21095. /**
  21096. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21097. * When defined, the cubemap will switch to local mode
  21098. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21099. * @example https://www.babylonjs-playground.com/#RNASML
  21100. */
  21101. set boundingBoxSize(value: Vector3);
  21102. get boundingBoxSize(): Vector3;
  21103. /**
  21104. * In case the RTT has been created with a depth texture, get the associated
  21105. * depth texture.
  21106. * Otherwise, return null.
  21107. */
  21108. get depthStencilTexture(): Nullable<InternalTexture>;
  21109. /**
  21110. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21111. * or used a shadow, depth texture...
  21112. * @param name The friendly name of the texture
  21113. * @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)
  21114. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21115. * @param generateMipMaps True if mip maps need to be generated after render.
  21116. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21117. * @param type The type of the buffer in the RTT (int, half float, float...)
  21118. * @param isCube True if a cube texture needs to be created
  21119. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21120. * @param generateDepthBuffer True to generate a depth buffer
  21121. * @param generateStencilBuffer True to generate a stencil buffer
  21122. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21123. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21124. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21125. */
  21126. constructor(name: string, size: number | {
  21127. width: number;
  21128. height: number;
  21129. layers?: number;
  21130. } | {
  21131. ratio: number;
  21132. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21133. /**
  21134. * Creates a depth stencil texture.
  21135. * This is only available in WebGL 2 or with the depth texture extension available.
  21136. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21137. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21138. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21139. */
  21140. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21141. private _processSizeParameter;
  21142. /**
  21143. * Define the number of samples to use in case of MSAA.
  21144. * It defaults to one meaning no MSAA has been enabled.
  21145. */
  21146. get samples(): number;
  21147. set samples(value: number);
  21148. /**
  21149. * Resets the refresh counter of the texture and start bak from scratch.
  21150. * Could be useful to regenerate the texture if it is setup to render only once.
  21151. */
  21152. resetRefreshCounter(): void;
  21153. /**
  21154. * Define the refresh rate of the texture or the rendering frequency.
  21155. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21156. */
  21157. get refreshRate(): number;
  21158. set refreshRate(value: number);
  21159. /**
  21160. * Adds a post process to the render target rendering passes.
  21161. * @param postProcess define the post process to add
  21162. */
  21163. addPostProcess(postProcess: PostProcess): void;
  21164. /**
  21165. * Clear all the post processes attached to the render target
  21166. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21167. */
  21168. clearPostProcesses(dispose?: boolean): void;
  21169. /**
  21170. * Remove one of the post process from the list of attached post processes to the texture
  21171. * @param postProcess define the post process to remove from the list
  21172. */
  21173. removePostProcess(postProcess: PostProcess): void;
  21174. /** @hidden */
  21175. _shouldRender(): boolean;
  21176. /**
  21177. * Gets the actual render size of the texture.
  21178. * @returns the width of the render size
  21179. */
  21180. getRenderSize(): number;
  21181. /**
  21182. * Gets the actual render width of the texture.
  21183. * @returns the width of the render size
  21184. */
  21185. getRenderWidth(): number;
  21186. /**
  21187. * Gets the actual render height of the texture.
  21188. * @returns the height of the render size
  21189. */
  21190. getRenderHeight(): number;
  21191. /**
  21192. * Gets the actual number of layers of the texture.
  21193. * @returns the number of layers
  21194. */
  21195. getRenderLayers(): number;
  21196. /**
  21197. * Get if the texture can be rescaled or not.
  21198. */
  21199. get canRescale(): boolean;
  21200. /**
  21201. * Resize the texture using a ratio.
  21202. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21203. */
  21204. scale(ratio: number): void;
  21205. /**
  21206. * Get the texture reflection matrix used to rotate/transform the reflection.
  21207. * @returns the reflection matrix
  21208. */
  21209. getReflectionTextureMatrix(): Matrix;
  21210. /**
  21211. * Resize the texture to a new desired size.
  21212. * Be carrefull as it will recreate all the data in the new texture.
  21213. * @param size Define the new size. It can be:
  21214. * - a number for squared texture,
  21215. * - an object containing { width: number, height: number }
  21216. * - or an object containing a ratio { ratio: number }
  21217. */
  21218. resize(size: number | {
  21219. width: number;
  21220. height: number;
  21221. } | {
  21222. ratio: number;
  21223. }): void;
  21224. private _defaultRenderListPrepared;
  21225. /**
  21226. * Renders all the objects from the render list into the texture.
  21227. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21228. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21229. */
  21230. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21231. private _bestReflectionRenderTargetDimension;
  21232. private _prepareRenderingManager;
  21233. /**
  21234. * @hidden
  21235. * @param faceIndex face index to bind to if this is a cubetexture
  21236. * @param layer defines the index of the texture to bind in the array
  21237. */
  21238. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21239. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21240. private renderToTarget;
  21241. /**
  21242. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21243. * This allowed control for front to back rendering or reversly depending of the special needs.
  21244. *
  21245. * @param renderingGroupId The rendering group id corresponding to its index
  21246. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21247. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21248. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21249. */
  21250. 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;
  21251. /**
  21252. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21253. *
  21254. * @param renderingGroupId The rendering group id corresponding to its index
  21255. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21256. */
  21257. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21258. /**
  21259. * Clones the texture.
  21260. * @returns the cloned texture
  21261. */
  21262. clone(): RenderTargetTexture;
  21263. /**
  21264. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21265. * @returns The JSON representation of the texture
  21266. */
  21267. serialize(): any;
  21268. /**
  21269. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21270. */
  21271. disposeFramebufferObjects(): void;
  21272. /**
  21273. * Dispose the texture and release its associated resources.
  21274. */
  21275. dispose(): void;
  21276. /** @hidden */
  21277. _rebuild(): void;
  21278. /**
  21279. * Clear the info related to rendering groups preventing retention point in material dispose.
  21280. */
  21281. freeRenderingGroups(): void;
  21282. /**
  21283. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21284. * @returns the view count
  21285. */
  21286. getViewCount(): number;
  21287. }
  21288. }
  21289. declare module "babylonjs/Materials/material" {
  21290. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21291. import { SmartArray } from "babylonjs/Misc/smartArray";
  21292. import { Observable } from "babylonjs/Misc/observable";
  21293. import { Nullable } from "babylonjs/types";
  21294. import { Scene } from "babylonjs/scene";
  21295. import { Matrix } from "babylonjs/Maths/math.vector";
  21296. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21298. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21299. import { Effect } from "babylonjs/Materials/effect";
  21300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21301. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21302. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21303. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21304. import { Mesh } from "babylonjs/Meshes/mesh";
  21305. import { Animation } from "babylonjs/Animations/animation";
  21306. /**
  21307. * Options for compiling materials.
  21308. */
  21309. export interface IMaterialCompilationOptions {
  21310. /**
  21311. * Defines whether clip planes are enabled.
  21312. */
  21313. clipPlane: boolean;
  21314. /**
  21315. * Defines whether instances are enabled.
  21316. */
  21317. useInstances: boolean;
  21318. }
  21319. /**
  21320. * Base class for the main features of a material in Babylon.js
  21321. */
  21322. export class Material implements IAnimatable {
  21323. /**
  21324. * Returns the triangle fill mode
  21325. */
  21326. static readonly TriangleFillMode: number;
  21327. /**
  21328. * Returns the wireframe mode
  21329. */
  21330. static readonly WireFrameFillMode: number;
  21331. /**
  21332. * Returns the point fill mode
  21333. */
  21334. static readonly PointFillMode: number;
  21335. /**
  21336. * Returns the point list draw mode
  21337. */
  21338. static readonly PointListDrawMode: number;
  21339. /**
  21340. * Returns the line list draw mode
  21341. */
  21342. static readonly LineListDrawMode: number;
  21343. /**
  21344. * Returns the line loop draw mode
  21345. */
  21346. static readonly LineLoopDrawMode: number;
  21347. /**
  21348. * Returns the line strip draw mode
  21349. */
  21350. static readonly LineStripDrawMode: number;
  21351. /**
  21352. * Returns the triangle strip draw mode
  21353. */
  21354. static readonly TriangleStripDrawMode: number;
  21355. /**
  21356. * Returns the triangle fan draw mode
  21357. */
  21358. static readonly TriangleFanDrawMode: number;
  21359. /**
  21360. * Stores the clock-wise side orientation
  21361. */
  21362. static readonly ClockWiseSideOrientation: number;
  21363. /**
  21364. * Stores the counter clock-wise side orientation
  21365. */
  21366. static readonly CounterClockWiseSideOrientation: number;
  21367. /**
  21368. * The dirty texture flag value
  21369. */
  21370. static readonly TextureDirtyFlag: number;
  21371. /**
  21372. * The dirty light flag value
  21373. */
  21374. static readonly LightDirtyFlag: number;
  21375. /**
  21376. * The dirty fresnel flag value
  21377. */
  21378. static readonly FresnelDirtyFlag: number;
  21379. /**
  21380. * The dirty attribute flag value
  21381. */
  21382. static readonly AttributesDirtyFlag: number;
  21383. /**
  21384. * The dirty misc flag value
  21385. */
  21386. static readonly MiscDirtyFlag: number;
  21387. /**
  21388. * The all dirty flag value
  21389. */
  21390. static readonly AllDirtyFlag: number;
  21391. /**
  21392. * The ID of the material
  21393. */
  21394. id: string;
  21395. /**
  21396. * Gets or sets the unique id of the material
  21397. */
  21398. uniqueId: number;
  21399. /**
  21400. * The name of the material
  21401. */
  21402. name: string;
  21403. /**
  21404. * Gets or sets user defined metadata
  21405. */
  21406. metadata: any;
  21407. /**
  21408. * For internal use only. Please do not use.
  21409. */
  21410. reservedDataStore: any;
  21411. /**
  21412. * Specifies if the ready state should be checked on each call
  21413. */
  21414. checkReadyOnEveryCall: boolean;
  21415. /**
  21416. * Specifies if the ready state should be checked once
  21417. */
  21418. checkReadyOnlyOnce: boolean;
  21419. /**
  21420. * The state of the material
  21421. */
  21422. state: string;
  21423. /**
  21424. * The alpha value of the material
  21425. */
  21426. protected _alpha: number;
  21427. /**
  21428. * List of inspectable custom properties (used by the Inspector)
  21429. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21430. */
  21431. inspectableCustomProperties: IInspectable[];
  21432. /**
  21433. * Sets the alpha value of the material
  21434. */
  21435. set alpha(value: number);
  21436. /**
  21437. * Gets the alpha value of the material
  21438. */
  21439. get alpha(): number;
  21440. /**
  21441. * Specifies if back face culling is enabled
  21442. */
  21443. protected _backFaceCulling: boolean;
  21444. /**
  21445. * Sets the back-face culling state
  21446. */
  21447. set backFaceCulling(value: boolean);
  21448. /**
  21449. * Gets the back-face culling state
  21450. */
  21451. get backFaceCulling(): boolean;
  21452. /**
  21453. * Stores the value for side orientation
  21454. */
  21455. sideOrientation: number;
  21456. /**
  21457. * Callback triggered when the material is compiled
  21458. */
  21459. onCompiled: Nullable<(effect: Effect) => void>;
  21460. /**
  21461. * Callback triggered when an error occurs
  21462. */
  21463. onError: Nullable<(effect: Effect, errors: string) => void>;
  21464. /**
  21465. * Callback triggered to get the render target textures
  21466. */
  21467. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21468. /**
  21469. * Gets a boolean indicating that current material needs to register RTT
  21470. */
  21471. get hasRenderTargetTextures(): boolean;
  21472. /**
  21473. * Specifies if the material should be serialized
  21474. */
  21475. doNotSerialize: boolean;
  21476. /**
  21477. * @hidden
  21478. */
  21479. _storeEffectOnSubMeshes: boolean;
  21480. /**
  21481. * Stores the animations for the material
  21482. */
  21483. animations: Nullable<Array<Animation>>;
  21484. /**
  21485. * An event triggered when the material is disposed
  21486. */
  21487. onDisposeObservable: Observable<Material>;
  21488. /**
  21489. * An observer which watches for dispose events
  21490. */
  21491. private _onDisposeObserver;
  21492. private _onUnBindObservable;
  21493. /**
  21494. * Called during a dispose event
  21495. */
  21496. set onDispose(callback: () => void);
  21497. private _onBindObservable;
  21498. /**
  21499. * An event triggered when the material is bound
  21500. */
  21501. get onBindObservable(): Observable<AbstractMesh>;
  21502. /**
  21503. * An observer which watches for bind events
  21504. */
  21505. private _onBindObserver;
  21506. /**
  21507. * Called during a bind event
  21508. */
  21509. set onBind(callback: (Mesh: AbstractMesh) => void);
  21510. /**
  21511. * An event triggered when the material is unbound
  21512. */
  21513. get onUnBindObservable(): Observable<Material>;
  21514. /**
  21515. * Stores the value of the alpha mode
  21516. */
  21517. private _alphaMode;
  21518. /**
  21519. * Sets the value of the alpha mode.
  21520. *
  21521. * | Value | Type | Description |
  21522. * | --- | --- | --- |
  21523. * | 0 | ALPHA_DISABLE | |
  21524. * | 1 | ALPHA_ADD | |
  21525. * | 2 | ALPHA_COMBINE | |
  21526. * | 3 | ALPHA_SUBTRACT | |
  21527. * | 4 | ALPHA_MULTIPLY | |
  21528. * | 5 | ALPHA_MAXIMIZED | |
  21529. * | 6 | ALPHA_ONEONE | |
  21530. * | 7 | ALPHA_PREMULTIPLIED | |
  21531. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21532. * | 9 | ALPHA_INTERPOLATE | |
  21533. * | 10 | ALPHA_SCREENMODE | |
  21534. *
  21535. */
  21536. set alphaMode(value: number);
  21537. /**
  21538. * Gets the value of the alpha mode
  21539. */
  21540. get alphaMode(): number;
  21541. /**
  21542. * Stores the state of the need depth pre-pass value
  21543. */
  21544. private _needDepthPrePass;
  21545. /**
  21546. * Sets the need depth pre-pass value
  21547. */
  21548. set needDepthPrePass(value: boolean);
  21549. /**
  21550. * Gets the depth pre-pass value
  21551. */
  21552. get needDepthPrePass(): boolean;
  21553. /**
  21554. * Specifies if depth writing should be disabled
  21555. */
  21556. disableDepthWrite: boolean;
  21557. /**
  21558. * Specifies if depth writing should be forced
  21559. */
  21560. forceDepthWrite: boolean;
  21561. /**
  21562. * Specifies the depth function that should be used. 0 means the default engine function
  21563. */
  21564. depthFunction: number;
  21565. /**
  21566. * Specifies if there should be a separate pass for culling
  21567. */
  21568. separateCullingPass: boolean;
  21569. /**
  21570. * Stores the state specifing if fog should be enabled
  21571. */
  21572. private _fogEnabled;
  21573. /**
  21574. * Sets the state for enabling fog
  21575. */
  21576. set fogEnabled(value: boolean);
  21577. /**
  21578. * Gets the value of the fog enabled state
  21579. */
  21580. get fogEnabled(): boolean;
  21581. /**
  21582. * Stores the size of points
  21583. */
  21584. pointSize: number;
  21585. /**
  21586. * Stores the z offset value
  21587. */
  21588. zOffset: number;
  21589. /**
  21590. * Gets a value specifying if wireframe mode is enabled
  21591. */
  21592. get wireframe(): boolean;
  21593. /**
  21594. * Sets the state of wireframe mode
  21595. */
  21596. set wireframe(value: boolean);
  21597. /**
  21598. * Gets the value specifying if point clouds are enabled
  21599. */
  21600. get pointsCloud(): boolean;
  21601. /**
  21602. * Sets the state of point cloud mode
  21603. */
  21604. set pointsCloud(value: boolean);
  21605. /**
  21606. * Gets the material fill mode
  21607. */
  21608. get fillMode(): number;
  21609. /**
  21610. * Sets the material fill mode
  21611. */
  21612. set fillMode(value: number);
  21613. /**
  21614. * @hidden
  21615. * Stores the effects for the material
  21616. */
  21617. _effect: Nullable<Effect>;
  21618. /**
  21619. * Specifies if uniform buffers should be used
  21620. */
  21621. private _useUBO;
  21622. /**
  21623. * Stores a reference to the scene
  21624. */
  21625. private _scene;
  21626. /**
  21627. * Stores the fill mode state
  21628. */
  21629. private _fillMode;
  21630. /**
  21631. * Specifies if the depth write state should be cached
  21632. */
  21633. private _cachedDepthWriteState;
  21634. /**
  21635. * Specifies if the depth function state should be cached
  21636. */
  21637. private _cachedDepthFunctionState;
  21638. /**
  21639. * Stores the uniform buffer
  21640. */
  21641. protected _uniformBuffer: UniformBuffer;
  21642. /** @hidden */
  21643. _indexInSceneMaterialArray: number;
  21644. /** @hidden */
  21645. meshMap: Nullable<{
  21646. [id: string]: AbstractMesh | undefined;
  21647. }>;
  21648. /**
  21649. * Creates a material instance
  21650. * @param name defines the name of the material
  21651. * @param scene defines the scene to reference
  21652. * @param doNotAdd specifies if the material should be added to the scene
  21653. */
  21654. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21655. /**
  21656. * Returns a string representation of the current material
  21657. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21658. * @returns a string with material information
  21659. */
  21660. toString(fullDetails?: boolean): string;
  21661. /**
  21662. * Gets the class name of the material
  21663. * @returns a string with the class name of the material
  21664. */
  21665. getClassName(): string;
  21666. /**
  21667. * Specifies if updates for the material been locked
  21668. */
  21669. get isFrozen(): boolean;
  21670. /**
  21671. * Locks updates for the material
  21672. */
  21673. freeze(): void;
  21674. /**
  21675. * Unlocks updates for the material
  21676. */
  21677. unfreeze(): void;
  21678. /**
  21679. * Specifies if the material is ready to be used
  21680. * @param mesh defines the mesh to check
  21681. * @param useInstances specifies if instances should be used
  21682. * @returns a boolean indicating if the material is ready to be used
  21683. */
  21684. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21685. /**
  21686. * Specifies that the submesh is ready to be used
  21687. * @param mesh defines the mesh to check
  21688. * @param subMesh defines which submesh to check
  21689. * @param useInstances specifies that instances should be used
  21690. * @returns a boolean indicating that the submesh is ready or not
  21691. */
  21692. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21693. /**
  21694. * Returns the material effect
  21695. * @returns the effect associated with the material
  21696. */
  21697. getEffect(): Nullable<Effect>;
  21698. /**
  21699. * Returns the current scene
  21700. * @returns a Scene
  21701. */
  21702. getScene(): Scene;
  21703. /**
  21704. * Specifies if the material will require alpha blending
  21705. * @returns a boolean specifying if alpha blending is needed
  21706. */
  21707. needAlphaBlending(): boolean;
  21708. /**
  21709. * Specifies if the mesh will require alpha blending
  21710. * @param mesh defines the mesh to check
  21711. * @returns a boolean specifying if alpha blending is needed for the mesh
  21712. */
  21713. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21714. /**
  21715. * Specifies if this material should be rendered in alpha test mode
  21716. * @returns a boolean specifying if an alpha test is needed.
  21717. */
  21718. needAlphaTesting(): boolean;
  21719. /**
  21720. * Gets the texture used for the alpha test
  21721. * @returns the texture to use for alpha testing
  21722. */
  21723. getAlphaTestTexture(): Nullable<BaseTexture>;
  21724. /**
  21725. * Marks the material to indicate that it needs to be re-calculated
  21726. */
  21727. markDirty(): void;
  21728. /** @hidden */
  21729. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21730. /**
  21731. * Binds the material to the mesh
  21732. * @param world defines the world transformation matrix
  21733. * @param mesh defines the mesh to bind the material to
  21734. */
  21735. bind(world: Matrix, mesh?: Mesh): void;
  21736. /**
  21737. * Binds the submesh to the material
  21738. * @param world defines the world transformation matrix
  21739. * @param mesh defines the mesh containing the submesh
  21740. * @param subMesh defines the submesh to bind the material to
  21741. */
  21742. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21743. /**
  21744. * Binds the world matrix to the material
  21745. * @param world defines the world transformation matrix
  21746. */
  21747. bindOnlyWorldMatrix(world: Matrix): void;
  21748. /**
  21749. * Binds the scene's uniform buffer to the effect.
  21750. * @param effect defines the effect to bind to the scene uniform buffer
  21751. * @param sceneUbo defines the uniform buffer storing scene data
  21752. */
  21753. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21754. /**
  21755. * Binds the view matrix to the effect
  21756. * @param effect defines the effect to bind the view matrix to
  21757. */
  21758. bindView(effect: Effect): void;
  21759. /**
  21760. * Binds the view projection matrix to the effect
  21761. * @param effect defines the effect to bind the view projection matrix to
  21762. */
  21763. bindViewProjection(effect: Effect): void;
  21764. /**
  21765. * Specifies if material alpha testing should be turned on for the mesh
  21766. * @param mesh defines the mesh to check
  21767. */
  21768. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21769. /**
  21770. * Processes to execute after binding the material to a mesh
  21771. * @param mesh defines the rendered mesh
  21772. */
  21773. protected _afterBind(mesh?: Mesh): void;
  21774. /**
  21775. * Unbinds the material from the mesh
  21776. */
  21777. unbind(): void;
  21778. /**
  21779. * Gets the active textures from the material
  21780. * @returns an array of textures
  21781. */
  21782. getActiveTextures(): BaseTexture[];
  21783. /**
  21784. * Specifies if the material uses a texture
  21785. * @param texture defines the texture to check against the material
  21786. * @returns a boolean specifying if the material uses the texture
  21787. */
  21788. hasTexture(texture: BaseTexture): boolean;
  21789. /**
  21790. * Makes a duplicate of the material, and gives it a new name
  21791. * @param name defines the new name for the duplicated material
  21792. * @returns the cloned material
  21793. */
  21794. clone(name: string): Nullable<Material>;
  21795. /**
  21796. * Gets the meshes bound to the material
  21797. * @returns an array of meshes bound to the material
  21798. */
  21799. getBindedMeshes(): AbstractMesh[];
  21800. /**
  21801. * Force shader compilation
  21802. * @param mesh defines the mesh associated with this material
  21803. * @param onCompiled defines a function to execute once the material is compiled
  21804. * @param options defines the options to configure the compilation
  21805. * @param onError defines a function to execute if the material fails compiling
  21806. */
  21807. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21808. /**
  21809. * Force shader compilation
  21810. * @param mesh defines the mesh that will use this material
  21811. * @param options defines additional options for compiling the shaders
  21812. * @returns a promise that resolves when the compilation completes
  21813. */
  21814. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21815. private static readonly _AllDirtyCallBack;
  21816. private static readonly _ImageProcessingDirtyCallBack;
  21817. private static readonly _TextureDirtyCallBack;
  21818. private static readonly _FresnelDirtyCallBack;
  21819. private static readonly _MiscDirtyCallBack;
  21820. private static readonly _LightsDirtyCallBack;
  21821. private static readonly _AttributeDirtyCallBack;
  21822. private static _FresnelAndMiscDirtyCallBack;
  21823. private static _TextureAndMiscDirtyCallBack;
  21824. private static readonly _DirtyCallbackArray;
  21825. private static readonly _RunDirtyCallBacks;
  21826. /**
  21827. * Marks a define in the material to indicate that it needs to be re-computed
  21828. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21829. */
  21830. markAsDirty(flag: number): void;
  21831. /**
  21832. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21833. * @param func defines a function which checks material defines against the submeshes
  21834. */
  21835. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21836. /**
  21837. * Indicates that we need to re-calculated for all submeshes
  21838. */
  21839. protected _markAllSubMeshesAsAllDirty(): void;
  21840. /**
  21841. * Indicates that image processing needs to be re-calculated for all submeshes
  21842. */
  21843. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21844. /**
  21845. * Indicates that textures need to be re-calculated for all submeshes
  21846. */
  21847. protected _markAllSubMeshesAsTexturesDirty(): void;
  21848. /**
  21849. * Indicates that fresnel needs to be re-calculated for all submeshes
  21850. */
  21851. protected _markAllSubMeshesAsFresnelDirty(): void;
  21852. /**
  21853. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21854. */
  21855. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21856. /**
  21857. * Indicates that lights need to be re-calculated for all submeshes
  21858. */
  21859. protected _markAllSubMeshesAsLightsDirty(): void;
  21860. /**
  21861. * Indicates that attributes need to be re-calculated for all submeshes
  21862. */
  21863. protected _markAllSubMeshesAsAttributesDirty(): void;
  21864. /**
  21865. * Indicates that misc needs to be re-calculated for all submeshes
  21866. */
  21867. protected _markAllSubMeshesAsMiscDirty(): void;
  21868. /**
  21869. * Indicates that textures and misc need to be re-calculated for all submeshes
  21870. */
  21871. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21872. /**
  21873. * Disposes the material
  21874. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21875. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21876. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21877. */
  21878. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21879. /** @hidden */
  21880. private releaseVertexArrayObject;
  21881. /**
  21882. * Serializes this material
  21883. * @returns the serialized material object
  21884. */
  21885. serialize(): any;
  21886. /**
  21887. * Creates a material from parsed material data
  21888. * @param parsedMaterial defines parsed material data
  21889. * @param scene defines the hosting scene
  21890. * @param rootUrl defines the root URL to use to load textures
  21891. * @returns a new material
  21892. */
  21893. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21894. }
  21895. }
  21896. declare module "babylonjs/Materials/multiMaterial" {
  21897. import { Nullable } from "babylonjs/types";
  21898. import { Scene } from "babylonjs/scene";
  21899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21900. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21901. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21902. import { Material } from "babylonjs/Materials/material";
  21903. /**
  21904. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21905. * separate meshes. This can be use to improve performances.
  21906. * @see http://doc.babylonjs.com/how_to/multi_materials
  21907. */
  21908. export class MultiMaterial extends Material {
  21909. private _subMaterials;
  21910. /**
  21911. * Gets or Sets the list of Materials used within the multi material.
  21912. * They need to be ordered according to the submeshes order in the associated mesh
  21913. */
  21914. get subMaterials(): Nullable<Material>[];
  21915. set subMaterials(value: Nullable<Material>[]);
  21916. /**
  21917. * Function used to align with Node.getChildren()
  21918. * @returns the list of Materials used within the multi material
  21919. */
  21920. getChildren(): Nullable<Material>[];
  21921. /**
  21922. * Instantiates a new Multi Material
  21923. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21924. * separate meshes. This can be use to improve performances.
  21925. * @see http://doc.babylonjs.com/how_to/multi_materials
  21926. * @param name Define the name in the scene
  21927. * @param scene Define the scene the material belongs to
  21928. */
  21929. constructor(name: string, scene: Scene);
  21930. private _hookArray;
  21931. /**
  21932. * Get one of the submaterial by its index in the submaterials array
  21933. * @param index The index to look the sub material at
  21934. * @returns The Material if the index has been defined
  21935. */
  21936. getSubMaterial(index: number): Nullable<Material>;
  21937. /**
  21938. * Get the list of active textures for the whole sub materials list.
  21939. * @returns All the textures that will be used during the rendering
  21940. */
  21941. getActiveTextures(): BaseTexture[];
  21942. /**
  21943. * Gets the current class name of the material e.g. "MultiMaterial"
  21944. * Mainly use in serialization.
  21945. * @returns the class name
  21946. */
  21947. getClassName(): string;
  21948. /**
  21949. * Checks if the material is ready to render the requested sub mesh
  21950. * @param mesh Define the mesh the submesh belongs to
  21951. * @param subMesh Define the sub mesh to look readyness for
  21952. * @param useInstances Define whether or not the material is used with instances
  21953. * @returns true if ready, otherwise false
  21954. */
  21955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21956. /**
  21957. * Clones the current material and its related sub materials
  21958. * @param name Define the name of the newly cloned material
  21959. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21960. * @returns the cloned material
  21961. */
  21962. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21963. /**
  21964. * Serializes the materials into a JSON representation.
  21965. * @returns the JSON representation
  21966. */
  21967. serialize(): any;
  21968. /**
  21969. * Dispose the material and release its associated resources
  21970. * @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)
  21971. * @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)
  21972. * @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)
  21973. */
  21974. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21975. /**
  21976. * Creates a MultiMaterial from parsed MultiMaterial data.
  21977. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21978. * @param scene defines the hosting scene
  21979. * @returns a new MultiMaterial
  21980. */
  21981. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21982. }
  21983. }
  21984. declare module "babylonjs/Meshes/subMesh" {
  21985. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21986. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21987. import { Engine } from "babylonjs/Engines/engine";
  21988. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21989. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21990. import { Effect } from "babylonjs/Materials/effect";
  21991. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21992. import { Plane } from "babylonjs/Maths/math.plane";
  21993. import { Collider } from "babylonjs/Collisions/collider";
  21994. import { Material } from "babylonjs/Materials/material";
  21995. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21997. import { Mesh } from "babylonjs/Meshes/mesh";
  21998. import { Ray } from "babylonjs/Culling/ray";
  21999. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22000. /**
  22001. * Base class for submeshes
  22002. */
  22003. export class BaseSubMesh {
  22004. /** @hidden */
  22005. _materialDefines: Nullable<MaterialDefines>;
  22006. /** @hidden */
  22007. _materialEffect: Nullable<Effect>;
  22008. /**
  22009. * Gets material defines used by the effect associated to the sub mesh
  22010. */
  22011. get materialDefines(): Nullable<MaterialDefines>;
  22012. /**
  22013. * Sets material defines used by the effect associated to the sub mesh
  22014. */
  22015. set materialDefines(defines: Nullable<MaterialDefines>);
  22016. /**
  22017. * Gets associated effect
  22018. */
  22019. get effect(): Nullable<Effect>;
  22020. /**
  22021. * Sets associated effect (effect used to render this submesh)
  22022. * @param effect defines the effect to associate with
  22023. * @param defines defines the set of defines used to compile this effect
  22024. */
  22025. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22026. }
  22027. /**
  22028. * Defines a subdivision inside a mesh
  22029. */
  22030. export class SubMesh extends BaseSubMesh implements ICullable {
  22031. /** the material index to use */
  22032. materialIndex: number;
  22033. /** vertex index start */
  22034. verticesStart: number;
  22035. /** vertices count */
  22036. verticesCount: number;
  22037. /** index start */
  22038. indexStart: number;
  22039. /** indices count */
  22040. indexCount: number;
  22041. /** @hidden */
  22042. _linesIndexCount: number;
  22043. private _mesh;
  22044. private _renderingMesh;
  22045. private _boundingInfo;
  22046. private _linesIndexBuffer;
  22047. /** @hidden */
  22048. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22049. /** @hidden */
  22050. _trianglePlanes: Plane[];
  22051. /** @hidden */
  22052. _lastColliderTransformMatrix: Nullable<Matrix>;
  22053. /** @hidden */
  22054. _renderId: number;
  22055. /** @hidden */
  22056. _alphaIndex: number;
  22057. /** @hidden */
  22058. _distanceToCamera: number;
  22059. /** @hidden */
  22060. _id: number;
  22061. private _currentMaterial;
  22062. /**
  22063. * Add a new submesh to a mesh
  22064. * @param materialIndex defines the material index to use
  22065. * @param verticesStart defines vertex index start
  22066. * @param verticesCount defines vertices count
  22067. * @param indexStart defines index start
  22068. * @param indexCount defines indices count
  22069. * @param mesh defines the parent mesh
  22070. * @param renderingMesh defines an optional rendering mesh
  22071. * @param createBoundingBox defines if bounding box should be created for this submesh
  22072. * @returns the new submesh
  22073. */
  22074. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22075. /**
  22076. * Creates a new submesh
  22077. * @param materialIndex defines the material index to use
  22078. * @param verticesStart defines vertex index start
  22079. * @param verticesCount defines vertices count
  22080. * @param indexStart defines index start
  22081. * @param indexCount defines indices count
  22082. * @param mesh defines the parent mesh
  22083. * @param renderingMesh defines an optional rendering mesh
  22084. * @param createBoundingBox defines if bounding box should be created for this submesh
  22085. */
  22086. constructor(
  22087. /** the material index to use */
  22088. materialIndex: number,
  22089. /** vertex index start */
  22090. verticesStart: number,
  22091. /** vertices count */
  22092. verticesCount: number,
  22093. /** index start */
  22094. indexStart: number,
  22095. /** indices count */
  22096. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22097. /**
  22098. * Returns true if this submesh covers the entire parent mesh
  22099. * @ignorenaming
  22100. */
  22101. get IsGlobal(): boolean;
  22102. /**
  22103. * Returns the submesh BoudingInfo object
  22104. * @returns current bounding info (or mesh's one if the submesh is global)
  22105. */
  22106. getBoundingInfo(): BoundingInfo;
  22107. /**
  22108. * Sets the submesh BoundingInfo
  22109. * @param boundingInfo defines the new bounding info to use
  22110. * @returns the SubMesh
  22111. */
  22112. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22113. /**
  22114. * Returns the mesh of the current submesh
  22115. * @return the parent mesh
  22116. */
  22117. getMesh(): AbstractMesh;
  22118. /**
  22119. * Returns the rendering mesh of the submesh
  22120. * @returns the rendering mesh (could be different from parent mesh)
  22121. */
  22122. getRenderingMesh(): Mesh;
  22123. /**
  22124. * Returns the submesh material
  22125. * @returns null or the current material
  22126. */
  22127. getMaterial(): Nullable<Material>;
  22128. /**
  22129. * Sets a new updated BoundingInfo object to the submesh
  22130. * @param data defines an optional position array to use to determine the bounding info
  22131. * @returns the SubMesh
  22132. */
  22133. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22134. /** @hidden */
  22135. _checkCollision(collider: Collider): boolean;
  22136. /**
  22137. * Updates the submesh BoundingInfo
  22138. * @param world defines the world matrix to use to update the bounding info
  22139. * @returns the submesh
  22140. */
  22141. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22142. /**
  22143. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22144. * @param frustumPlanes defines the frustum planes
  22145. * @returns true if the submesh is intersecting with the frustum
  22146. */
  22147. isInFrustum(frustumPlanes: Plane[]): boolean;
  22148. /**
  22149. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22150. * @param frustumPlanes defines the frustum planes
  22151. * @returns true if the submesh is inside the frustum
  22152. */
  22153. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22154. /**
  22155. * Renders the submesh
  22156. * @param enableAlphaMode defines if alpha needs to be used
  22157. * @returns the submesh
  22158. */
  22159. render(enableAlphaMode: boolean): SubMesh;
  22160. /**
  22161. * @hidden
  22162. */
  22163. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22164. /**
  22165. * Checks if the submesh intersects with a ray
  22166. * @param ray defines the ray to test
  22167. * @returns true is the passed ray intersects the submesh bounding box
  22168. */
  22169. canIntersects(ray: Ray): boolean;
  22170. /**
  22171. * Intersects current submesh with a ray
  22172. * @param ray defines the ray to test
  22173. * @param positions defines mesh's positions array
  22174. * @param indices defines mesh's indices array
  22175. * @param fastCheck defines if only bounding info should be used
  22176. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22177. * @returns intersection info or null if no intersection
  22178. */
  22179. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22180. /** @hidden */
  22181. private _intersectLines;
  22182. /** @hidden */
  22183. private _intersectUnIndexedLines;
  22184. /** @hidden */
  22185. private _intersectTriangles;
  22186. /** @hidden */
  22187. private _intersectUnIndexedTriangles;
  22188. /** @hidden */
  22189. _rebuild(): void;
  22190. /**
  22191. * Creates a new submesh from the passed mesh
  22192. * @param newMesh defines the new hosting mesh
  22193. * @param newRenderingMesh defines an optional rendering mesh
  22194. * @returns the new submesh
  22195. */
  22196. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22197. /**
  22198. * Release associated resources
  22199. */
  22200. dispose(): void;
  22201. /**
  22202. * Gets the class name
  22203. * @returns the string "SubMesh".
  22204. */
  22205. getClassName(): string;
  22206. /**
  22207. * Creates a new submesh from indices data
  22208. * @param materialIndex the index of the main mesh material
  22209. * @param startIndex the index where to start the copy in the mesh indices array
  22210. * @param indexCount the number of indices to copy then from the startIndex
  22211. * @param mesh the main mesh to create the submesh from
  22212. * @param renderingMesh the optional rendering mesh
  22213. * @returns a new submesh
  22214. */
  22215. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22216. }
  22217. }
  22218. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22219. /**
  22220. * Class used to represent data loading progression
  22221. */
  22222. export class SceneLoaderFlags {
  22223. private static _ForceFullSceneLoadingForIncremental;
  22224. private static _ShowLoadingScreen;
  22225. private static _CleanBoneMatrixWeights;
  22226. private static _loggingLevel;
  22227. /**
  22228. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22229. */
  22230. static get ForceFullSceneLoadingForIncremental(): boolean;
  22231. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22232. /**
  22233. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22234. */
  22235. static get ShowLoadingScreen(): boolean;
  22236. static set ShowLoadingScreen(value: boolean);
  22237. /**
  22238. * Defines the current logging level (while loading the scene)
  22239. * @ignorenaming
  22240. */
  22241. static get loggingLevel(): number;
  22242. static set loggingLevel(value: number);
  22243. /**
  22244. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22245. */
  22246. static get CleanBoneMatrixWeights(): boolean;
  22247. static set CleanBoneMatrixWeights(value: boolean);
  22248. }
  22249. }
  22250. declare module "babylonjs/Meshes/geometry" {
  22251. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22252. import { Scene } from "babylonjs/scene";
  22253. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22254. import { Engine } from "babylonjs/Engines/engine";
  22255. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22256. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22257. import { Effect } from "babylonjs/Materials/effect";
  22258. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22259. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22260. import { Mesh } from "babylonjs/Meshes/mesh";
  22261. /**
  22262. * Class used to store geometry data (vertex buffers + index buffer)
  22263. */
  22264. export class Geometry implements IGetSetVerticesData {
  22265. /**
  22266. * Gets or sets the ID of the geometry
  22267. */
  22268. id: string;
  22269. /**
  22270. * Gets or sets the unique ID of the geometry
  22271. */
  22272. uniqueId: number;
  22273. /**
  22274. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22275. */
  22276. delayLoadState: number;
  22277. /**
  22278. * Gets the file containing the data to load when running in delay load state
  22279. */
  22280. delayLoadingFile: Nullable<string>;
  22281. /**
  22282. * Callback called when the geometry is updated
  22283. */
  22284. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22285. private _scene;
  22286. private _engine;
  22287. private _meshes;
  22288. private _totalVertices;
  22289. /** @hidden */
  22290. _indices: IndicesArray;
  22291. /** @hidden */
  22292. _vertexBuffers: {
  22293. [key: string]: VertexBuffer;
  22294. };
  22295. private _isDisposed;
  22296. private _extend;
  22297. private _boundingBias;
  22298. /** @hidden */
  22299. _delayInfo: Array<string>;
  22300. private _indexBuffer;
  22301. private _indexBufferIsUpdatable;
  22302. /** @hidden */
  22303. _boundingInfo: Nullable<BoundingInfo>;
  22304. /** @hidden */
  22305. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22306. /** @hidden */
  22307. _softwareSkinningFrameId: number;
  22308. private _vertexArrayObjects;
  22309. private _updatable;
  22310. /** @hidden */
  22311. _positions: Nullable<Vector3[]>;
  22312. /**
  22313. * 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
  22314. */
  22315. get boundingBias(): Vector2;
  22316. /**
  22317. * 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
  22318. */
  22319. set boundingBias(value: Vector2);
  22320. /**
  22321. * Static function used to attach a new empty geometry to a mesh
  22322. * @param mesh defines the mesh to attach the geometry to
  22323. * @returns the new Geometry
  22324. */
  22325. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22326. /**
  22327. * Creates a new geometry
  22328. * @param id defines the unique ID
  22329. * @param scene defines the hosting scene
  22330. * @param vertexData defines the VertexData used to get geometry data
  22331. * @param updatable defines if geometry must be updatable (false by default)
  22332. * @param mesh defines the mesh that will be associated with the geometry
  22333. */
  22334. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22335. /**
  22336. * Gets the current extend of the geometry
  22337. */
  22338. get extend(): {
  22339. minimum: Vector3;
  22340. maximum: Vector3;
  22341. };
  22342. /**
  22343. * Gets the hosting scene
  22344. * @returns the hosting Scene
  22345. */
  22346. getScene(): Scene;
  22347. /**
  22348. * Gets the hosting engine
  22349. * @returns the hosting Engine
  22350. */
  22351. getEngine(): Engine;
  22352. /**
  22353. * Defines if the geometry is ready to use
  22354. * @returns true if the geometry is ready to be used
  22355. */
  22356. isReady(): boolean;
  22357. /**
  22358. * Gets a value indicating that the geometry should not be serialized
  22359. */
  22360. get doNotSerialize(): boolean;
  22361. /** @hidden */
  22362. _rebuild(): void;
  22363. /**
  22364. * Affects all geometry data in one call
  22365. * @param vertexData defines the geometry data
  22366. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22367. */
  22368. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22369. /**
  22370. * Set specific vertex data
  22371. * @param kind defines the data kind (Position, normal, etc...)
  22372. * @param data defines the vertex data to use
  22373. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22374. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22375. */
  22376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22377. /**
  22378. * Removes a specific vertex data
  22379. * @param kind defines the data kind (Position, normal, etc...)
  22380. */
  22381. removeVerticesData(kind: string): void;
  22382. /**
  22383. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22384. * @param buffer defines the vertex buffer to use
  22385. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22386. */
  22387. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22388. /**
  22389. * Update a specific vertex buffer
  22390. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22391. * It will do nothing if the buffer is not updatable
  22392. * @param kind defines the data kind (Position, normal, etc...)
  22393. * @param data defines the data to use
  22394. * @param offset defines the offset in the target buffer where to store the data
  22395. * @param useBytes set to true if the offset is in bytes
  22396. */
  22397. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22398. /**
  22399. * Update a specific vertex buffer
  22400. * This function will create a new buffer if the current one is not updatable
  22401. * @param kind defines the data kind (Position, normal, etc...)
  22402. * @param data defines the data to use
  22403. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22404. */
  22405. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22406. private _updateBoundingInfo;
  22407. /** @hidden */
  22408. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22409. /**
  22410. * Gets total number of vertices
  22411. * @returns the total number of vertices
  22412. */
  22413. getTotalVertices(): number;
  22414. /**
  22415. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22416. * @param kind defines the data kind (Position, normal, etc...)
  22417. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22418. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22419. * @returns a float array containing vertex data
  22420. */
  22421. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22422. /**
  22423. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22424. * @param kind defines the data kind (Position, normal, etc...)
  22425. * @returns true if the vertex buffer with the specified kind is updatable
  22426. */
  22427. isVertexBufferUpdatable(kind: string): boolean;
  22428. /**
  22429. * Gets a specific vertex buffer
  22430. * @param kind defines the data kind (Position, normal, etc...)
  22431. * @returns a VertexBuffer
  22432. */
  22433. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22434. /**
  22435. * Returns all vertex buffers
  22436. * @return an object holding all vertex buffers indexed by kind
  22437. */
  22438. getVertexBuffers(): Nullable<{
  22439. [key: string]: VertexBuffer;
  22440. }>;
  22441. /**
  22442. * Gets a boolean indicating if specific vertex buffer is present
  22443. * @param kind defines the data kind (Position, normal, etc...)
  22444. * @returns true if data is present
  22445. */
  22446. isVerticesDataPresent(kind: string): boolean;
  22447. /**
  22448. * Gets a list of all attached data kinds (Position, normal, etc...)
  22449. * @returns a list of string containing all kinds
  22450. */
  22451. getVerticesDataKinds(): string[];
  22452. /**
  22453. * Update index buffer
  22454. * @param indices defines the indices to store in the index buffer
  22455. * @param offset defines the offset in the target buffer where to store the data
  22456. * @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)
  22457. */
  22458. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22459. /**
  22460. * Creates a new index buffer
  22461. * @param indices defines the indices to store in the index buffer
  22462. * @param totalVertices defines the total number of vertices (could be null)
  22463. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22464. */
  22465. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22466. /**
  22467. * Return the total number of indices
  22468. * @returns the total number of indices
  22469. */
  22470. getTotalIndices(): number;
  22471. /**
  22472. * Gets the index buffer array
  22473. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22474. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22475. * @returns the index buffer array
  22476. */
  22477. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22478. /**
  22479. * Gets the index buffer
  22480. * @return the index buffer
  22481. */
  22482. getIndexBuffer(): Nullable<DataBuffer>;
  22483. /** @hidden */
  22484. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22485. /**
  22486. * Release the associated resources for a specific mesh
  22487. * @param mesh defines the source mesh
  22488. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22489. */
  22490. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22491. /**
  22492. * Apply current geometry to a given mesh
  22493. * @param mesh defines the mesh to apply geometry to
  22494. */
  22495. applyToMesh(mesh: Mesh): void;
  22496. private _updateExtend;
  22497. private _applyToMesh;
  22498. private notifyUpdate;
  22499. /**
  22500. * Load the geometry if it was flagged as delay loaded
  22501. * @param scene defines the hosting scene
  22502. * @param onLoaded defines a callback called when the geometry is loaded
  22503. */
  22504. load(scene: Scene, onLoaded?: () => void): void;
  22505. private _queueLoad;
  22506. /**
  22507. * Invert the geometry to move from a right handed system to a left handed one.
  22508. */
  22509. toLeftHanded(): void;
  22510. /** @hidden */
  22511. _resetPointsArrayCache(): void;
  22512. /** @hidden */
  22513. _generatePointsArray(): boolean;
  22514. /**
  22515. * Gets a value indicating if the geometry is disposed
  22516. * @returns true if the geometry was disposed
  22517. */
  22518. isDisposed(): boolean;
  22519. private _disposeVertexArrayObjects;
  22520. /**
  22521. * Free all associated resources
  22522. */
  22523. dispose(): void;
  22524. /**
  22525. * Clone the current geometry into a new geometry
  22526. * @param id defines the unique ID of the new geometry
  22527. * @returns a new geometry object
  22528. */
  22529. copy(id: string): Geometry;
  22530. /**
  22531. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22532. * @return a JSON representation of the current geometry data (without the vertices data)
  22533. */
  22534. serialize(): any;
  22535. private toNumberArray;
  22536. /**
  22537. * Serialize all vertices data into a JSON oject
  22538. * @returns a JSON representation of the current geometry data
  22539. */
  22540. serializeVerticeData(): any;
  22541. /**
  22542. * Extracts a clone of a mesh geometry
  22543. * @param mesh defines the source mesh
  22544. * @param id defines the unique ID of the new geometry object
  22545. * @returns the new geometry object
  22546. */
  22547. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22548. /**
  22549. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22550. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22551. * Be aware Math.random() could cause collisions, but:
  22552. * "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"
  22553. * @returns a string containing a new GUID
  22554. */
  22555. static RandomId(): string;
  22556. /** @hidden */
  22557. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22558. private static _CleanMatricesWeights;
  22559. /**
  22560. * Create a new geometry from persisted data (Using .babylon file format)
  22561. * @param parsedVertexData defines the persisted data
  22562. * @param scene defines the hosting scene
  22563. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22564. * @returns the new geometry object
  22565. */
  22566. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22567. }
  22568. }
  22569. declare module "babylonjs/Meshes/mesh.vertexData" {
  22570. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22571. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22572. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22573. import { Geometry } from "babylonjs/Meshes/geometry";
  22574. import { Mesh } from "babylonjs/Meshes/mesh";
  22575. /**
  22576. * Define an interface for all classes that will get and set the data on vertices
  22577. */
  22578. export interface IGetSetVerticesData {
  22579. /**
  22580. * Gets a boolean indicating if specific vertex data is present
  22581. * @param kind defines the vertex data kind to use
  22582. * @returns true is data kind is present
  22583. */
  22584. isVerticesDataPresent(kind: string): boolean;
  22585. /**
  22586. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22587. * @param kind defines the data kind (Position, normal, etc...)
  22588. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22589. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22590. * @returns a float array containing vertex data
  22591. */
  22592. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22593. /**
  22594. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22595. * @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.
  22596. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22597. * @returns the indices array or an empty array if the mesh has no geometry
  22598. */
  22599. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22600. /**
  22601. * Set specific vertex data
  22602. * @param kind defines the data kind (Position, normal, etc...)
  22603. * @param data defines the vertex data to use
  22604. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22605. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22606. */
  22607. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22608. /**
  22609. * Update a specific associated vertex buffer
  22610. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22611. * - VertexBuffer.PositionKind
  22612. * - VertexBuffer.UVKind
  22613. * - VertexBuffer.UV2Kind
  22614. * - VertexBuffer.UV3Kind
  22615. * - VertexBuffer.UV4Kind
  22616. * - VertexBuffer.UV5Kind
  22617. * - VertexBuffer.UV6Kind
  22618. * - VertexBuffer.ColorKind
  22619. * - VertexBuffer.MatricesIndicesKind
  22620. * - VertexBuffer.MatricesIndicesExtraKind
  22621. * - VertexBuffer.MatricesWeightsKind
  22622. * - VertexBuffer.MatricesWeightsExtraKind
  22623. * @param data defines the data source
  22624. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22625. * @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)
  22626. */
  22627. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22628. /**
  22629. * Creates a new index buffer
  22630. * @param indices defines the indices to store in the index buffer
  22631. * @param totalVertices defines the total number of vertices (could be null)
  22632. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22633. */
  22634. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22635. }
  22636. /**
  22637. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22638. */
  22639. export class VertexData {
  22640. /**
  22641. * Mesh side orientation : usually the external or front surface
  22642. */
  22643. static readonly FRONTSIDE: number;
  22644. /**
  22645. * Mesh side orientation : usually the internal or back surface
  22646. */
  22647. static readonly BACKSIDE: number;
  22648. /**
  22649. * Mesh side orientation : both internal and external or front and back surfaces
  22650. */
  22651. static readonly DOUBLESIDE: number;
  22652. /**
  22653. * Mesh side orientation : by default, `FRONTSIDE`
  22654. */
  22655. static readonly DEFAULTSIDE: number;
  22656. /**
  22657. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22658. */
  22659. positions: Nullable<FloatArray>;
  22660. /**
  22661. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22662. */
  22663. normals: Nullable<FloatArray>;
  22664. /**
  22665. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22666. */
  22667. tangents: Nullable<FloatArray>;
  22668. /**
  22669. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22670. */
  22671. uvs: Nullable<FloatArray>;
  22672. /**
  22673. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22674. */
  22675. uvs2: Nullable<FloatArray>;
  22676. /**
  22677. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22678. */
  22679. uvs3: Nullable<FloatArray>;
  22680. /**
  22681. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22682. */
  22683. uvs4: Nullable<FloatArray>;
  22684. /**
  22685. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22686. */
  22687. uvs5: Nullable<FloatArray>;
  22688. /**
  22689. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22690. */
  22691. uvs6: Nullable<FloatArray>;
  22692. /**
  22693. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22694. */
  22695. colors: Nullable<FloatArray>;
  22696. /**
  22697. * 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).
  22698. */
  22699. matricesIndices: Nullable<FloatArray>;
  22700. /**
  22701. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22702. */
  22703. matricesWeights: Nullable<FloatArray>;
  22704. /**
  22705. * An array extending the number of possible indices
  22706. */
  22707. matricesIndicesExtra: Nullable<FloatArray>;
  22708. /**
  22709. * An array extending the number of possible weights when the number of indices is extended
  22710. */
  22711. matricesWeightsExtra: Nullable<FloatArray>;
  22712. /**
  22713. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22714. */
  22715. indices: Nullable<IndicesArray>;
  22716. /**
  22717. * Uses the passed data array to set the set the values for the specified kind of data
  22718. * @param data a linear array of floating numbers
  22719. * @param kind the type of data that is being set, eg positions, colors etc
  22720. */
  22721. set(data: FloatArray, kind: string): void;
  22722. /**
  22723. * Associates the vertexData to the passed Mesh.
  22724. * Sets it as updatable or not (default `false`)
  22725. * @param mesh the mesh the vertexData is applied to
  22726. * @param updatable when used and having the value true allows new data to update the vertexData
  22727. * @returns the VertexData
  22728. */
  22729. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22730. /**
  22731. * Associates the vertexData to the passed Geometry.
  22732. * Sets it as updatable or not (default `false`)
  22733. * @param geometry the geometry the vertexData is applied to
  22734. * @param updatable when used and having the value true allows new data to update the vertexData
  22735. * @returns VertexData
  22736. */
  22737. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22738. /**
  22739. * Updates the associated mesh
  22740. * @param mesh the mesh to be updated
  22741. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22742. * @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
  22743. * @returns VertexData
  22744. */
  22745. updateMesh(mesh: Mesh): VertexData;
  22746. /**
  22747. * Updates the associated geometry
  22748. * @param geometry the geometry to be updated
  22749. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22750. * @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
  22751. * @returns VertexData.
  22752. */
  22753. updateGeometry(geometry: Geometry): VertexData;
  22754. private _applyTo;
  22755. private _update;
  22756. /**
  22757. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22758. * @param matrix the transforming matrix
  22759. * @returns the VertexData
  22760. */
  22761. transform(matrix: Matrix): VertexData;
  22762. /**
  22763. * Merges the passed VertexData into the current one
  22764. * @param other the VertexData to be merged into the current one
  22765. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22766. * @returns the modified VertexData
  22767. */
  22768. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22769. private _mergeElement;
  22770. private _validate;
  22771. /**
  22772. * Serializes the VertexData
  22773. * @returns a serialized object
  22774. */
  22775. serialize(): any;
  22776. /**
  22777. * Extracts the vertexData from a mesh
  22778. * @param mesh the mesh from which to extract the VertexData
  22779. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22780. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22781. * @returns the object VertexData associated to the passed mesh
  22782. */
  22783. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22784. /**
  22785. * Extracts the vertexData from the geometry
  22786. * @param geometry the geometry from which to extract the VertexData
  22787. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22788. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22789. * @returns the object VertexData associated to the passed mesh
  22790. */
  22791. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22792. private static _ExtractFrom;
  22793. /**
  22794. * Creates the VertexData for a Ribbon
  22795. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22796. * * pathArray array of paths, each of which an array of successive Vector3
  22797. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22798. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22799. * * 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
  22800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22801. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22802. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22803. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22804. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22805. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22806. * @returns the VertexData of the ribbon
  22807. */
  22808. static CreateRibbon(options: {
  22809. pathArray: Vector3[][];
  22810. closeArray?: boolean;
  22811. closePath?: boolean;
  22812. offset?: number;
  22813. sideOrientation?: number;
  22814. frontUVs?: Vector4;
  22815. backUVs?: Vector4;
  22816. invertUV?: boolean;
  22817. uvs?: Vector2[];
  22818. colors?: Color4[];
  22819. }): VertexData;
  22820. /**
  22821. * Creates the VertexData for a box
  22822. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22823. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22824. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22825. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22826. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22827. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22828. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22830. * * 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)
  22831. * * 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)
  22832. * @returns the VertexData of the box
  22833. */
  22834. static CreateBox(options: {
  22835. size?: number;
  22836. width?: number;
  22837. height?: number;
  22838. depth?: number;
  22839. faceUV?: Vector4[];
  22840. faceColors?: Color4[];
  22841. sideOrientation?: number;
  22842. frontUVs?: Vector4;
  22843. backUVs?: Vector4;
  22844. }): VertexData;
  22845. /**
  22846. * Creates the VertexData for a tiled box
  22847. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22848. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22849. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22850. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22851. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22852. * @returns the VertexData of the box
  22853. */
  22854. static CreateTiledBox(options: {
  22855. pattern?: number;
  22856. width?: number;
  22857. height?: number;
  22858. depth?: number;
  22859. tileSize?: number;
  22860. tileWidth?: number;
  22861. tileHeight?: number;
  22862. alignHorizontal?: number;
  22863. alignVertical?: number;
  22864. faceUV?: Vector4[];
  22865. faceColors?: Color4[];
  22866. sideOrientation?: number;
  22867. }): VertexData;
  22868. /**
  22869. * Creates the VertexData for a tiled plane
  22870. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22871. * * pattern a limited pattern arrangement depending on the number
  22872. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22873. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22874. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22876. * * 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)
  22877. * * 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)
  22878. * @returns the VertexData of the tiled plane
  22879. */
  22880. static CreateTiledPlane(options: {
  22881. pattern?: number;
  22882. tileSize?: number;
  22883. tileWidth?: number;
  22884. tileHeight?: number;
  22885. size?: number;
  22886. width?: number;
  22887. height?: number;
  22888. alignHorizontal?: number;
  22889. alignVertical?: number;
  22890. sideOrientation?: number;
  22891. frontUVs?: Vector4;
  22892. backUVs?: Vector4;
  22893. }): VertexData;
  22894. /**
  22895. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22896. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22897. * * segments sets the number of horizontal strips optional, default 32
  22898. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22899. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22900. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22901. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22902. * * 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
  22903. * * 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
  22904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22905. * * 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)
  22906. * * 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)
  22907. * @returns the VertexData of the ellipsoid
  22908. */
  22909. static CreateSphere(options: {
  22910. segments?: number;
  22911. diameter?: number;
  22912. diameterX?: number;
  22913. diameterY?: number;
  22914. diameterZ?: number;
  22915. arc?: number;
  22916. slice?: number;
  22917. sideOrientation?: number;
  22918. frontUVs?: Vector4;
  22919. backUVs?: Vector4;
  22920. }): VertexData;
  22921. /**
  22922. * Creates the VertexData for a cylinder, cone or prism
  22923. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22924. * * height sets the height (y direction) of the cylinder, optional, default 2
  22925. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22926. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22927. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22928. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22929. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22930. * * 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
  22931. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22932. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22933. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22934. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22935. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22936. * * 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)
  22937. * * 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)
  22938. * @returns the VertexData of the cylinder, cone or prism
  22939. */
  22940. static CreateCylinder(options: {
  22941. height?: number;
  22942. diameterTop?: number;
  22943. diameterBottom?: number;
  22944. diameter?: number;
  22945. tessellation?: number;
  22946. subdivisions?: number;
  22947. arc?: number;
  22948. faceColors?: Color4[];
  22949. faceUV?: Vector4[];
  22950. hasRings?: boolean;
  22951. enclose?: boolean;
  22952. sideOrientation?: number;
  22953. frontUVs?: Vector4;
  22954. backUVs?: Vector4;
  22955. }): VertexData;
  22956. /**
  22957. * Creates the VertexData for a torus
  22958. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22959. * * diameter the diameter of the torus, optional default 1
  22960. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22961. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22963. * * 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)
  22964. * * 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)
  22965. * @returns the VertexData of the torus
  22966. */
  22967. static CreateTorus(options: {
  22968. diameter?: number;
  22969. thickness?: number;
  22970. tessellation?: number;
  22971. sideOrientation?: number;
  22972. frontUVs?: Vector4;
  22973. backUVs?: Vector4;
  22974. }): VertexData;
  22975. /**
  22976. * Creates the VertexData of the LineSystem
  22977. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22978. * - lines an array of lines, each line being an array of successive Vector3
  22979. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22980. * @returns the VertexData of the LineSystem
  22981. */
  22982. static CreateLineSystem(options: {
  22983. lines: Vector3[][];
  22984. colors?: Nullable<Color4[][]>;
  22985. }): VertexData;
  22986. /**
  22987. * Create the VertexData for a DashedLines
  22988. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22989. * - points an array successive Vector3
  22990. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22991. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22992. * - dashNb the intended total number of dashes, optional, default 200
  22993. * @returns the VertexData for the DashedLines
  22994. */
  22995. static CreateDashedLines(options: {
  22996. points: Vector3[];
  22997. dashSize?: number;
  22998. gapSize?: number;
  22999. dashNb?: number;
  23000. }): VertexData;
  23001. /**
  23002. * Creates the VertexData for a Ground
  23003. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23004. * - width the width (x direction) of the ground, optional, default 1
  23005. * - height the height (z direction) of the ground, optional, default 1
  23006. * - subdivisions the number of subdivisions per side, optional, default 1
  23007. * @returns the VertexData of the Ground
  23008. */
  23009. static CreateGround(options: {
  23010. width?: number;
  23011. height?: number;
  23012. subdivisions?: number;
  23013. subdivisionsX?: number;
  23014. subdivisionsY?: number;
  23015. }): VertexData;
  23016. /**
  23017. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23018. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23019. * * xmin the ground minimum X coordinate, optional, default -1
  23020. * * zmin the ground minimum Z coordinate, optional, default -1
  23021. * * xmax the ground maximum X coordinate, optional, default 1
  23022. * * zmax the ground maximum Z coordinate, optional, default 1
  23023. * * 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}
  23024. * * 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}
  23025. * @returns the VertexData of the TiledGround
  23026. */
  23027. static CreateTiledGround(options: {
  23028. xmin: number;
  23029. zmin: number;
  23030. xmax: number;
  23031. zmax: number;
  23032. subdivisions?: {
  23033. w: number;
  23034. h: number;
  23035. };
  23036. precision?: {
  23037. w: number;
  23038. h: number;
  23039. };
  23040. }): VertexData;
  23041. /**
  23042. * Creates the VertexData of the Ground designed from a heightmap
  23043. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23044. * * width the width (x direction) of the ground
  23045. * * height the height (z direction) of the ground
  23046. * * subdivisions the number of subdivisions per side
  23047. * * minHeight the minimum altitude on the ground, optional, default 0
  23048. * * maxHeight the maximum altitude on the ground, optional default 1
  23049. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23050. * * buffer the array holding the image color data
  23051. * * bufferWidth the width of image
  23052. * * bufferHeight the height of image
  23053. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23054. * @returns the VertexData of the Ground designed from a heightmap
  23055. */
  23056. static CreateGroundFromHeightMap(options: {
  23057. width: number;
  23058. height: number;
  23059. subdivisions: number;
  23060. minHeight: number;
  23061. maxHeight: number;
  23062. colorFilter: Color3;
  23063. buffer: Uint8Array;
  23064. bufferWidth: number;
  23065. bufferHeight: number;
  23066. alphaFilter: number;
  23067. }): VertexData;
  23068. /**
  23069. * Creates the VertexData for a Plane
  23070. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23071. * * size sets the width and height of the plane to the value of size, optional default 1
  23072. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23073. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23075. * * 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)
  23076. * * 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)
  23077. * @returns the VertexData of the box
  23078. */
  23079. static CreatePlane(options: {
  23080. size?: number;
  23081. width?: number;
  23082. height?: number;
  23083. sideOrientation?: number;
  23084. frontUVs?: Vector4;
  23085. backUVs?: Vector4;
  23086. }): VertexData;
  23087. /**
  23088. * Creates the VertexData of the Disc or regular Polygon
  23089. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23090. * * radius the radius of the disc, optional default 0.5
  23091. * * tessellation the number of polygon sides, optional, default 64
  23092. * * 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
  23093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23094. * * 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)
  23095. * * 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)
  23096. * @returns the VertexData of the box
  23097. */
  23098. static CreateDisc(options: {
  23099. radius?: number;
  23100. tessellation?: number;
  23101. arc?: number;
  23102. sideOrientation?: number;
  23103. frontUVs?: Vector4;
  23104. backUVs?: Vector4;
  23105. }): VertexData;
  23106. /**
  23107. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23108. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23109. * @param polygon a mesh built from polygonTriangulation.build()
  23110. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23111. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23112. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23113. * @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)
  23114. * @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)
  23115. * @returns the VertexData of the Polygon
  23116. */
  23117. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23118. /**
  23119. * Creates the VertexData of the IcoSphere
  23120. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23121. * * radius the radius of the IcoSphere, optional default 1
  23122. * * radiusX allows stretching in the x direction, optional, default radius
  23123. * * radiusY allows stretching in the y direction, optional, default radius
  23124. * * radiusZ allows stretching in the z direction, optional, default radius
  23125. * * flat when true creates a flat shaded mesh, optional, default true
  23126. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23128. * * 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)
  23129. * * 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)
  23130. * @returns the VertexData of the IcoSphere
  23131. */
  23132. static CreateIcoSphere(options: {
  23133. radius?: number;
  23134. radiusX?: number;
  23135. radiusY?: number;
  23136. radiusZ?: number;
  23137. flat?: boolean;
  23138. subdivisions?: number;
  23139. sideOrientation?: number;
  23140. frontUVs?: Vector4;
  23141. backUVs?: Vector4;
  23142. }): VertexData;
  23143. /**
  23144. * Creates the VertexData for a Polyhedron
  23145. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23146. * * type provided types are:
  23147. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23148. * * 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)
  23149. * * size the size of the IcoSphere, optional default 1
  23150. * * sizeX allows stretching in the x direction, optional, default size
  23151. * * sizeY allows stretching in the y direction, optional, default size
  23152. * * sizeZ allows stretching in the z direction, optional, default size
  23153. * * 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
  23154. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23155. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23156. * * flat when true creates a flat shaded mesh, optional, default true
  23157. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23159. * * 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)
  23160. * * 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)
  23161. * @returns the VertexData of the Polyhedron
  23162. */
  23163. static CreatePolyhedron(options: {
  23164. type?: number;
  23165. size?: number;
  23166. sizeX?: number;
  23167. sizeY?: number;
  23168. sizeZ?: number;
  23169. custom?: any;
  23170. faceUV?: Vector4[];
  23171. faceColors?: Color4[];
  23172. flat?: boolean;
  23173. sideOrientation?: number;
  23174. frontUVs?: Vector4;
  23175. backUVs?: Vector4;
  23176. }): VertexData;
  23177. /**
  23178. * Creates the VertexData for a TorusKnot
  23179. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23180. * * radius the radius of the torus knot, optional, default 2
  23181. * * tube the thickness of the tube, optional, default 0.5
  23182. * * radialSegments the number of sides on each tube segments, optional, default 32
  23183. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23184. * * p the number of windings around the z axis, optional, default 2
  23185. * * q the number of windings around the x axis, optional, default 3
  23186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23187. * * 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)
  23188. * * 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)
  23189. * @returns the VertexData of the Torus Knot
  23190. */
  23191. static CreateTorusKnot(options: {
  23192. radius?: number;
  23193. tube?: number;
  23194. radialSegments?: number;
  23195. tubularSegments?: number;
  23196. p?: number;
  23197. q?: number;
  23198. sideOrientation?: number;
  23199. frontUVs?: Vector4;
  23200. backUVs?: Vector4;
  23201. }): VertexData;
  23202. /**
  23203. * Compute normals for given positions and indices
  23204. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23205. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23206. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23207. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23208. * * facetNormals : optional array of facet normals (vector3)
  23209. * * facetPositions : optional array of facet positions (vector3)
  23210. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23211. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23212. * * bInfo : optional bounding info, required for facetPartitioning computation
  23213. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23214. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23215. * * useRightHandedSystem: optional boolean to for right handed system computation
  23216. * * depthSort : optional boolean to enable the facet depth sort computation
  23217. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23218. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23219. */
  23220. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23221. facetNormals?: any;
  23222. facetPositions?: any;
  23223. facetPartitioning?: any;
  23224. ratio?: number;
  23225. bInfo?: any;
  23226. bbSize?: Vector3;
  23227. subDiv?: any;
  23228. useRightHandedSystem?: boolean;
  23229. depthSort?: boolean;
  23230. distanceTo?: Vector3;
  23231. depthSortedFacets?: any;
  23232. }): void;
  23233. /** @hidden */
  23234. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23235. /**
  23236. * Applies VertexData created from the imported parameters to the geometry
  23237. * @param parsedVertexData the parsed data from an imported file
  23238. * @param geometry the geometry to apply the VertexData to
  23239. */
  23240. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23241. }
  23242. }
  23243. declare module "babylonjs/Morph/morphTarget" {
  23244. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23245. import { Observable } from "babylonjs/Misc/observable";
  23246. import { Nullable, FloatArray } from "babylonjs/types";
  23247. import { Scene } from "babylonjs/scene";
  23248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23249. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23250. /**
  23251. * Defines a target to use with MorphTargetManager
  23252. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23253. */
  23254. export class MorphTarget implements IAnimatable {
  23255. /** defines the name of the target */
  23256. name: string;
  23257. /**
  23258. * Gets or sets the list of animations
  23259. */
  23260. animations: import("babylonjs/Animations/animation").Animation[];
  23261. private _scene;
  23262. private _positions;
  23263. private _normals;
  23264. private _tangents;
  23265. private _uvs;
  23266. private _influence;
  23267. private _uniqueId;
  23268. /**
  23269. * Observable raised when the influence changes
  23270. */
  23271. onInfluenceChanged: Observable<boolean>;
  23272. /** @hidden */
  23273. _onDataLayoutChanged: Observable<void>;
  23274. /**
  23275. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23276. */
  23277. get influence(): number;
  23278. set influence(influence: number);
  23279. /**
  23280. * Gets or sets the id of the morph Target
  23281. */
  23282. id: string;
  23283. private _animationPropertiesOverride;
  23284. /**
  23285. * Gets or sets the animation properties override
  23286. */
  23287. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23288. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23289. /**
  23290. * Creates a new MorphTarget
  23291. * @param name defines the name of the target
  23292. * @param influence defines the influence to use
  23293. * @param scene defines the scene the morphtarget belongs to
  23294. */
  23295. constructor(
  23296. /** defines the name of the target */
  23297. name: string, influence?: number, scene?: Nullable<Scene>);
  23298. /**
  23299. * Gets the unique ID of this manager
  23300. */
  23301. get uniqueId(): number;
  23302. /**
  23303. * Gets a boolean defining if the target contains position data
  23304. */
  23305. get hasPositions(): boolean;
  23306. /**
  23307. * Gets a boolean defining if the target contains normal data
  23308. */
  23309. get hasNormals(): boolean;
  23310. /**
  23311. * Gets a boolean defining if the target contains tangent data
  23312. */
  23313. get hasTangents(): boolean;
  23314. /**
  23315. * Gets a boolean defining if the target contains texture coordinates data
  23316. */
  23317. get hasUVs(): boolean;
  23318. /**
  23319. * Affects position data to this target
  23320. * @param data defines the position data to use
  23321. */
  23322. setPositions(data: Nullable<FloatArray>): void;
  23323. /**
  23324. * Gets the position data stored in this target
  23325. * @returns a FloatArray containing the position data (or null if not present)
  23326. */
  23327. getPositions(): Nullable<FloatArray>;
  23328. /**
  23329. * Affects normal data to this target
  23330. * @param data defines the normal data to use
  23331. */
  23332. setNormals(data: Nullable<FloatArray>): void;
  23333. /**
  23334. * Gets the normal data stored in this target
  23335. * @returns a FloatArray containing the normal data (or null if not present)
  23336. */
  23337. getNormals(): Nullable<FloatArray>;
  23338. /**
  23339. * Affects tangent data to this target
  23340. * @param data defines the tangent data to use
  23341. */
  23342. setTangents(data: Nullable<FloatArray>): void;
  23343. /**
  23344. * Gets the tangent data stored in this target
  23345. * @returns a FloatArray containing the tangent data (or null if not present)
  23346. */
  23347. getTangents(): Nullable<FloatArray>;
  23348. /**
  23349. * Affects texture coordinates data to this target
  23350. * @param data defines the texture coordinates data to use
  23351. */
  23352. setUVs(data: Nullable<FloatArray>): void;
  23353. /**
  23354. * Gets the texture coordinates data stored in this target
  23355. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23356. */
  23357. getUVs(): Nullable<FloatArray>;
  23358. /**
  23359. * Clone the current target
  23360. * @returns a new MorphTarget
  23361. */
  23362. clone(): MorphTarget;
  23363. /**
  23364. * Serializes the current target into a Serialization object
  23365. * @returns the serialized object
  23366. */
  23367. serialize(): any;
  23368. /**
  23369. * Returns the string "MorphTarget"
  23370. * @returns "MorphTarget"
  23371. */
  23372. getClassName(): string;
  23373. /**
  23374. * Creates a new target from serialized data
  23375. * @param serializationObject defines the serialized data to use
  23376. * @returns a new MorphTarget
  23377. */
  23378. static Parse(serializationObject: any): MorphTarget;
  23379. /**
  23380. * Creates a MorphTarget from mesh data
  23381. * @param mesh defines the source mesh
  23382. * @param name defines the name to use for the new target
  23383. * @param influence defines the influence to attach to the target
  23384. * @returns a new MorphTarget
  23385. */
  23386. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23387. }
  23388. }
  23389. declare module "babylonjs/Morph/morphTargetManager" {
  23390. import { Nullable } from "babylonjs/types";
  23391. import { Scene } from "babylonjs/scene";
  23392. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23393. /**
  23394. * This class is used to deform meshes using morphing between different targets
  23395. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23396. */
  23397. export class MorphTargetManager {
  23398. private _targets;
  23399. private _targetInfluenceChangedObservers;
  23400. private _targetDataLayoutChangedObservers;
  23401. private _activeTargets;
  23402. private _scene;
  23403. private _influences;
  23404. private _supportsNormals;
  23405. private _supportsTangents;
  23406. private _supportsUVs;
  23407. private _vertexCount;
  23408. private _uniqueId;
  23409. private _tempInfluences;
  23410. /**
  23411. * Gets or sets a boolean indicating if normals must be morphed
  23412. */
  23413. enableNormalMorphing: boolean;
  23414. /**
  23415. * Gets or sets a boolean indicating if tangents must be morphed
  23416. */
  23417. enableTangentMorphing: boolean;
  23418. /**
  23419. * Gets or sets a boolean indicating if UV must be morphed
  23420. */
  23421. enableUVMorphing: boolean;
  23422. /**
  23423. * Creates a new MorphTargetManager
  23424. * @param scene defines the current scene
  23425. */
  23426. constructor(scene?: Nullable<Scene>);
  23427. /**
  23428. * Gets the unique ID of this manager
  23429. */
  23430. get uniqueId(): number;
  23431. /**
  23432. * Gets the number of vertices handled by this manager
  23433. */
  23434. get vertexCount(): number;
  23435. /**
  23436. * Gets a boolean indicating if this manager supports morphing of normals
  23437. */
  23438. get supportsNormals(): boolean;
  23439. /**
  23440. * Gets a boolean indicating if this manager supports morphing of tangents
  23441. */
  23442. get supportsTangents(): boolean;
  23443. /**
  23444. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23445. */
  23446. get supportsUVs(): boolean;
  23447. /**
  23448. * Gets the number of targets stored in this manager
  23449. */
  23450. get numTargets(): number;
  23451. /**
  23452. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23453. */
  23454. get numInfluencers(): number;
  23455. /**
  23456. * Gets the list of influences (one per target)
  23457. */
  23458. get influences(): Float32Array;
  23459. /**
  23460. * Gets the active target at specified index. An active target is a target with an influence > 0
  23461. * @param index defines the index to check
  23462. * @returns the requested target
  23463. */
  23464. getActiveTarget(index: number): MorphTarget;
  23465. /**
  23466. * Gets the target at specified index
  23467. * @param index defines the index to check
  23468. * @returns the requested target
  23469. */
  23470. getTarget(index: number): MorphTarget;
  23471. /**
  23472. * Add a new target to this manager
  23473. * @param target defines the target to add
  23474. */
  23475. addTarget(target: MorphTarget): void;
  23476. /**
  23477. * Removes a target from the manager
  23478. * @param target defines the target to remove
  23479. */
  23480. removeTarget(target: MorphTarget): void;
  23481. /**
  23482. * Clone the current manager
  23483. * @returns a new MorphTargetManager
  23484. */
  23485. clone(): MorphTargetManager;
  23486. /**
  23487. * Serializes the current manager into a Serialization object
  23488. * @returns the serialized object
  23489. */
  23490. serialize(): any;
  23491. private _syncActiveTargets;
  23492. /**
  23493. * Syncrhonize the targets with all the meshes using this morph target manager
  23494. */
  23495. synchronize(): void;
  23496. /**
  23497. * Creates a new MorphTargetManager from serialized data
  23498. * @param serializationObject defines the serialized data
  23499. * @param scene defines the hosting scene
  23500. * @returns the new MorphTargetManager
  23501. */
  23502. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23503. }
  23504. }
  23505. declare module "babylonjs/Meshes/meshLODLevel" {
  23506. import { Mesh } from "babylonjs/Meshes/mesh";
  23507. import { Nullable } from "babylonjs/types";
  23508. /**
  23509. * Class used to represent a specific level of detail of a mesh
  23510. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23511. */
  23512. export class MeshLODLevel {
  23513. /** Defines the distance where this level should start being displayed */
  23514. distance: number;
  23515. /** Defines the mesh to use to render this level */
  23516. mesh: Nullable<Mesh>;
  23517. /**
  23518. * Creates a new LOD level
  23519. * @param distance defines the distance where this level should star being displayed
  23520. * @param mesh defines the mesh to use to render this level
  23521. */
  23522. constructor(
  23523. /** Defines the distance where this level should start being displayed */
  23524. distance: number,
  23525. /** Defines the mesh to use to render this level */
  23526. mesh: Nullable<Mesh>);
  23527. }
  23528. }
  23529. declare module "babylonjs/Meshes/groundMesh" {
  23530. import { Scene } from "babylonjs/scene";
  23531. import { Vector3 } from "babylonjs/Maths/math.vector";
  23532. import { Mesh } from "babylonjs/Meshes/mesh";
  23533. /**
  23534. * Mesh representing the gorund
  23535. */
  23536. export class GroundMesh extends Mesh {
  23537. /** If octree should be generated */
  23538. generateOctree: boolean;
  23539. private _heightQuads;
  23540. /** @hidden */
  23541. _subdivisionsX: number;
  23542. /** @hidden */
  23543. _subdivisionsY: number;
  23544. /** @hidden */
  23545. _width: number;
  23546. /** @hidden */
  23547. _height: number;
  23548. /** @hidden */
  23549. _minX: number;
  23550. /** @hidden */
  23551. _maxX: number;
  23552. /** @hidden */
  23553. _minZ: number;
  23554. /** @hidden */
  23555. _maxZ: number;
  23556. constructor(name: string, scene: Scene);
  23557. /**
  23558. * "GroundMesh"
  23559. * @returns "GroundMesh"
  23560. */
  23561. getClassName(): string;
  23562. /**
  23563. * The minimum of x and y subdivisions
  23564. */
  23565. get subdivisions(): number;
  23566. /**
  23567. * X subdivisions
  23568. */
  23569. get subdivisionsX(): number;
  23570. /**
  23571. * Y subdivisions
  23572. */
  23573. get subdivisionsY(): number;
  23574. /**
  23575. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23576. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23577. * @param chunksCount the number of subdivisions for x and y
  23578. * @param octreeBlocksSize (Default: 32)
  23579. */
  23580. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23581. /**
  23582. * Returns a height (y) value in the Worl system :
  23583. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23584. * @param x x coordinate
  23585. * @param z z coordinate
  23586. * @returns the ground y position if (x, z) are outside the ground surface.
  23587. */
  23588. getHeightAtCoordinates(x: number, z: number): number;
  23589. /**
  23590. * Returns a normalized vector (Vector3) orthogonal to the ground
  23591. * at the ground coordinates (x, z) expressed in the World system.
  23592. * @param x x coordinate
  23593. * @param z z coordinate
  23594. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23595. */
  23596. getNormalAtCoordinates(x: number, z: number): Vector3;
  23597. /**
  23598. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23599. * at the ground coordinates (x, z) expressed in the World system.
  23600. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23601. * @param x x coordinate
  23602. * @param z z coordinate
  23603. * @param ref vector to store the result
  23604. * @returns the GroundMesh.
  23605. */
  23606. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23607. /**
  23608. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23609. * if the ground has been updated.
  23610. * This can be used in the render loop.
  23611. * @returns the GroundMesh.
  23612. */
  23613. updateCoordinateHeights(): GroundMesh;
  23614. private _getFacetAt;
  23615. private _initHeightQuads;
  23616. private _computeHeightQuads;
  23617. /**
  23618. * Serializes this ground mesh
  23619. * @param serializationObject object to write serialization to
  23620. */
  23621. serialize(serializationObject: any): void;
  23622. /**
  23623. * Parses a serialized ground mesh
  23624. * @param parsedMesh the serialized mesh
  23625. * @param scene the scene to create the ground mesh in
  23626. * @returns the created ground mesh
  23627. */
  23628. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23629. }
  23630. }
  23631. declare module "babylonjs/Physics/physicsJoint" {
  23632. import { Vector3 } from "babylonjs/Maths/math.vector";
  23633. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23634. /**
  23635. * Interface for Physics-Joint data
  23636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23637. */
  23638. export interface PhysicsJointData {
  23639. /**
  23640. * The main pivot of the joint
  23641. */
  23642. mainPivot?: Vector3;
  23643. /**
  23644. * The connected pivot of the joint
  23645. */
  23646. connectedPivot?: Vector3;
  23647. /**
  23648. * The main axis of the joint
  23649. */
  23650. mainAxis?: Vector3;
  23651. /**
  23652. * The connected axis of the joint
  23653. */
  23654. connectedAxis?: Vector3;
  23655. /**
  23656. * The collision of the joint
  23657. */
  23658. collision?: boolean;
  23659. /**
  23660. * Native Oimo/Cannon/Energy data
  23661. */
  23662. nativeParams?: any;
  23663. }
  23664. /**
  23665. * This is a holder class for the physics joint created by the physics plugin
  23666. * It holds a set of functions to control the underlying joint
  23667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23668. */
  23669. export class PhysicsJoint {
  23670. /**
  23671. * The type of the physics joint
  23672. */
  23673. type: number;
  23674. /**
  23675. * The data for the physics joint
  23676. */
  23677. jointData: PhysicsJointData;
  23678. private _physicsJoint;
  23679. protected _physicsPlugin: IPhysicsEnginePlugin;
  23680. /**
  23681. * Initializes the physics joint
  23682. * @param type The type of the physics joint
  23683. * @param jointData The data for the physics joint
  23684. */
  23685. constructor(
  23686. /**
  23687. * The type of the physics joint
  23688. */
  23689. type: number,
  23690. /**
  23691. * The data for the physics joint
  23692. */
  23693. jointData: PhysicsJointData);
  23694. /**
  23695. * Gets the physics joint
  23696. */
  23697. get physicsJoint(): any;
  23698. /**
  23699. * Sets the physics joint
  23700. */
  23701. set physicsJoint(newJoint: any);
  23702. /**
  23703. * Sets the physics plugin
  23704. */
  23705. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23706. /**
  23707. * Execute a function that is physics-plugin specific.
  23708. * @param {Function} func the function that will be executed.
  23709. * It accepts two parameters: the physics world and the physics joint
  23710. */
  23711. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23712. /**
  23713. * Distance-Joint type
  23714. */
  23715. static DistanceJoint: number;
  23716. /**
  23717. * Hinge-Joint type
  23718. */
  23719. static HingeJoint: number;
  23720. /**
  23721. * Ball-and-Socket joint type
  23722. */
  23723. static BallAndSocketJoint: number;
  23724. /**
  23725. * Wheel-Joint type
  23726. */
  23727. static WheelJoint: number;
  23728. /**
  23729. * Slider-Joint type
  23730. */
  23731. static SliderJoint: number;
  23732. /**
  23733. * Prismatic-Joint type
  23734. */
  23735. static PrismaticJoint: number;
  23736. /**
  23737. * Universal-Joint type
  23738. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23739. */
  23740. static UniversalJoint: number;
  23741. /**
  23742. * Hinge-Joint 2 type
  23743. */
  23744. static Hinge2Joint: number;
  23745. /**
  23746. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23747. */
  23748. static PointToPointJoint: number;
  23749. /**
  23750. * Spring-Joint type
  23751. */
  23752. static SpringJoint: number;
  23753. /**
  23754. * Lock-Joint type
  23755. */
  23756. static LockJoint: number;
  23757. }
  23758. /**
  23759. * A class representing a physics distance joint
  23760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23761. */
  23762. export class DistanceJoint extends PhysicsJoint {
  23763. /**
  23764. *
  23765. * @param jointData The data for the Distance-Joint
  23766. */
  23767. constructor(jointData: DistanceJointData);
  23768. /**
  23769. * Update the predefined distance.
  23770. * @param maxDistance The maximum preferred distance
  23771. * @param minDistance The minimum preferred distance
  23772. */
  23773. updateDistance(maxDistance: number, minDistance?: number): void;
  23774. }
  23775. /**
  23776. * Represents a Motor-Enabled Joint
  23777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23778. */
  23779. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23780. /**
  23781. * Initializes the Motor-Enabled Joint
  23782. * @param type The type of the joint
  23783. * @param jointData The physica joint data for the joint
  23784. */
  23785. constructor(type: number, jointData: PhysicsJointData);
  23786. /**
  23787. * Set the motor values.
  23788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23789. * @param force the force to apply
  23790. * @param maxForce max force for this motor.
  23791. */
  23792. setMotor(force?: number, maxForce?: number): void;
  23793. /**
  23794. * Set the motor's limits.
  23795. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23796. * @param upperLimit The upper limit of the motor
  23797. * @param lowerLimit The lower limit of the motor
  23798. */
  23799. setLimit(upperLimit: number, lowerLimit?: number): void;
  23800. }
  23801. /**
  23802. * This class represents a single physics Hinge-Joint
  23803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23804. */
  23805. export class HingeJoint extends MotorEnabledJoint {
  23806. /**
  23807. * Initializes the Hinge-Joint
  23808. * @param jointData The joint data for the Hinge-Joint
  23809. */
  23810. constructor(jointData: PhysicsJointData);
  23811. /**
  23812. * Set the motor values.
  23813. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23814. * @param {number} force the force to apply
  23815. * @param {number} maxForce max force for this motor.
  23816. */
  23817. setMotor(force?: number, maxForce?: number): void;
  23818. /**
  23819. * Set the motor's limits.
  23820. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23821. * @param upperLimit The upper limit of the motor
  23822. * @param lowerLimit The lower limit of the motor
  23823. */
  23824. setLimit(upperLimit: number, lowerLimit?: number): void;
  23825. }
  23826. /**
  23827. * This class represents a dual hinge physics joint (same as wheel joint)
  23828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23829. */
  23830. export class Hinge2Joint extends MotorEnabledJoint {
  23831. /**
  23832. * Initializes the Hinge2-Joint
  23833. * @param jointData The joint data for the Hinge2-Joint
  23834. */
  23835. constructor(jointData: PhysicsJointData);
  23836. /**
  23837. * Set the motor values.
  23838. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23839. * @param {number} targetSpeed the speed the motor is to reach
  23840. * @param {number} maxForce max force for this motor.
  23841. * @param {motorIndex} the motor's index, 0 or 1.
  23842. */
  23843. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23844. /**
  23845. * Set the motor limits.
  23846. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23847. * @param {number} upperLimit the upper limit
  23848. * @param {number} lowerLimit lower limit
  23849. * @param {motorIndex} the motor's index, 0 or 1.
  23850. */
  23851. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23852. }
  23853. /**
  23854. * Interface for a motor enabled joint
  23855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23856. */
  23857. export interface IMotorEnabledJoint {
  23858. /**
  23859. * Physics joint
  23860. */
  23861. physicsJoint: any;
  23862. /**
  23863. * Sets the motor of the motor-enabled joint
  23864. * @param force The force of the motor
  23865. * @param maxForce The maximum force of the motor
  23866. * @param motorIndex The index of the motor
  23867. */
  23868. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23869. /**
  23870. * Sets the limit of the motor
  23871. * @param upperLimit The upper limit of the motor
  23872. * @param lowerLimit The lower limit of the motor
  23873. * @param motorIndex The index of the motor
  23874. */
  23875. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23876. }
  23877. /**
  23878. * Joint data for a Distance-Joint
  23879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23880. */
  23881. export interface DistanceJointData extends PhysicsJointData {
  23882. /**
  23883. * Max distance the 2 joint objects can be apart
  23884. */
  23885. maxDistance: number;
  23886. }
  23887. /**
  23888. * Joint data from a spring joint
  23889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23890. */
  23891. export interface SpringJointData extends PhysicsJointData {
  23892. /**
  23893. * Length of the spring
  23894. */
  23895. length: number;
  23896. /**
  23897. * Stiffness of the spring
  23898. */
  23899. stiffness: number;
  23900. /**
  23901. * Damping of the spring
  23902. */
  23903. damping: number;
  23904. /** this callback will be called when applying the force to the impostors. */
  23905. forceApplicationCallback: () => void;
  23906. }
  23907. }
  23908. declare module "babylonjs/Physics/physicsRaycastResult" {
  23909. import { Vector3 } from "babylonjs/Maths/math.vector";
  23910. /**
  23911. * Holds the data for the raycast result
  23912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23913. */
  23914. export class PhysicsRaycastResult {
  23915. private _hasHit;
  23916. private _hitDistance;
  23917. private _hitNormalWorld;
  23918. private _hitPointWorld;
  23919. private _rayFromWorld;
  23920. private _rayToWorld;
  23921. /**
  23922. * Gets if there was a hit
  23923. */
  23924. get hasHit(): boolean;
  23925. /**
  23926. * Gets the distance from the hit
  23927. */
  23928. get hitDistance(): number;
  23929. /**
  23930. * Gets the hit normal/direction in the world
  23931. */
  23932. get hitNormalWorld(): Vector3;
  23933. /**
  23934. * Gets the hit point in the world
  23935. */
  23936. get hitPointWorld(): Vector3;
  23937. /**
  23938. * Gets the ray "start point" of the ray in the world
  23939. */
  23940. get rayFromWorld(): Vector3;
  23941. /**
  23942. * Gets the ray "end point" of the ray in the world
  23943. */
  23944. get rayToWorld(): Vector3;
  23945. /**
  23946. * Sets the hit data (normal & point in world space)
  23947. * @param hitNormalWorld defines the normal in world space
  23948. * @param hitPointWorld defines the point in world space
  23949. */
  23950. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23951. /**
  23952. * Sets the distance from the start point to the hit point
  23953. * @param distance
  23954. */
  23955. setHitDistance(distance: number): void;
  23956. /**
  23957. * Calculates the distance manually
  23958. */
  23959. calculateHitDistance(): void;
  23960. /**
  23961. * Resets all the values to default
  23962. * @param from The from point on world space
  23963. * @param to The to point on world space
  23964. */
  23965. reset(from?: Vector3, to?: Vector3): void;
  23966. }
  23967. /**
  23968. * Interface for the size containing width and height
  23969. */
  23970. interface IXYZ {
  23971. /**
  23972. * X
  23973. */
  23974. x: number;
  23975. /**
  23976. * Y
  23977. */
  23978. y: number;
  23979. /**
  23980. * Z
  23981. */
  23982. z: number;
  23983. }
  23984. }
  23985. declare module "babylonjs/Physics/IPhysicsEngine" {
  23986. import { Nullable } from "babylonjs/types";
  23987. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23989. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23990. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23991. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23992. /**
  23993. * Interface used to describe a physics joint
  23994. */
  23995. export interface PhysicsImpostorJoint {
  23996. /** Defines the main impostor to which the joint is linked */
  23997. mainImpostor: PhysicsImpostor;
  23998. /** Defines the impostor that is connected to the main impostor using this joint */
  23999. connectedImpostor: PhysicsImpostor;
  24000. /** Defines the joint itself */
  24001. joint: PhysicsJoint;
  24002. }
  24003. /** @hidden */
  24004. export interface IPhysicsEnginePlugin {
  24005. world: any;
  24006. name: string;
  24007. setGravity(gravity: Vector3): void;
  24008. setTimeStep(timeStep: number): void;
  24009. getTimeStep(): number;
  24010. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24011. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24012. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24013. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24014. removePhysicsBody(impostor: PhysicsImpostor): void;
  24015. generateJoint(joint: PhysicsImpostorJoint): void;
  24016. removeJoint(joint: PhysicsImpostorJoint): void;
  24017. isSupported(): boolean;
  24018. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24019. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24020. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24021. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24022. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24023. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24024. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24025. getBodyMass(impostor: PhysicsImpostor): number;
  24026. getBodyFriction(impostor: PhysicsImpostor): number;
  24027. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24028. getBodyRestitution(impostor: PhysicsImpostor): number;
  24029. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24030. getBodyPressure?(impostor: PhysicsImpostor): number;
  24031. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24032. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24033. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24034. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24035. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24036. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24037. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24038. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24039. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24040. sleepBody(impostor: PhysicsImpostor): void;
  24041. wakeUpBody(impostor: PhysicsImpostor): void;
  24042. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24043. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24044. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24045. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24046. getRadius(impostor: PhysicsImpostor): number;
  24047. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24048. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24049. dispose(): void;
  24050. }
  24051. /**
  24052. * Interface used to define a physics engine
  24053. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24054. */
  24055. export interface IPhysicsEngine {
  24056. /**
  24057. * Gets the gravity vector used by the simulation
  24058. */
  24059. gravity: Vector3;
  24060. /**
  24061. * Sets the gravity vector used by the simulation
  24062. * @param gravity defines the gravity vector to use
  24063. */
  24064. setGravity(gravity: Vector3): void;
  24065. /**
  24066. * Set the time step of the physics engine.
  24067. * Default is 1/60.
  24068. * To slow it down, enter 1/600 for example.
  24069. * To speed it up, 1/30
  24070. * @param newTimeStep the new timestep to apply to this world.
  24071. */
  24072. setTimeStep(newTimeStep: number): void;
  24073. /**
  24074. * Get the time step of the physics engine.
  24075. * @returns the current time step
  24076. */
  24077. getTimeStep(): number;
  24078. /**
  24079. * Set the sub time step of the physics engine.
  24080. * Default is 0 meaning there is no sub steps
  24081. * To increase physics resolution precision, set a small value (like 1 ms)
  24082. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24083. */
  24084. setSubTimeStep(subTimeStep: number): void;
  24085. /**
  24086. * Get the sub time step of the physics engine.
  24087. * @returns the current sub time step
  24088. */
  24089. getSubTimeStep(): number;
  24090. /**
  24091. * Release all resources
  24092. */
  24093. dispose(): void;
  24094. /**
  24095. * Gets the name of the current physics plugin
  24096. * @returns the name of the plugin
  24097. */
  24098. getPhysicsPluginName(): string;
  24099. /**
  24100. * Adding a new impostor for the impostor tracking.
  24101. * This will be done by the impostor itself.
  24102. * @param impostor the impostor to add
  24103. */
  24104. addImpostor(impostor: PhysicsImpostor): void;
  24105. /**
  24106. * Remove an impostor from the engine.
  24107. * This impostor and its mesh will not longer be updated by the physics engine.
  24108. * @param impostor the impostor to remove
  24109. */
  24110. removeImpostor(impostor: PhysicsImpostor): void;
  24111. /**
  24112. * Add a joint to the physics engine
  24113. * @param mainImpostor defines the main impostor to which the joint is added.
  24114. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24115. * @param joint defines the joint that will connect both impostors.
  24116. */
  24117. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24118. /**
  24119. * Removes a joint from the simulation
  24120. * @param mainImpostor defines the impostor used with the joint
  24121. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24122. * @param joint defines the joint to remove
  24123. */
  24124. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24125. /**
  24126. * Gets the current plugin used to run the simulation
  24127. * @returns current plugin
  24128. */
  24129. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24130. /**
  24131. * Gets the list of physic impostors
  24132. * @returns an array of PhysicsImpostor
  24133. */
  24134. getImpostors(): Array<PhysicsImpostor>;
  24135. /**
  24136. * Gets the impostor for a physics enabled object
  24137. * @param object defines the object impersonated by the impostor
  24138. * @returns the PhysicsImpostor or null if not found
  24139. */
  24140. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24141. /**
  24142. * Gets the impostor for a physics body object
  24143. * @param body defines physics body used by the impostor
  24144. * @returns the PhysicsImpostor or null if not found
  24145. */
  24146. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24147. /**
  24148. * Does a raycast in the physics world
  24149. * @param from when should the ray start?
  24150. * @param to when should the ray end?
  24151. * @returns PhysicsRaycastResult
  24152. */
  24153. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24154. /**
  24155. * Called by the scene. No need to call it.
  24156. * @param delta defines the timespam between frames
  24157. */
  24158. _step(delta: number): void;
  24159. }
  24160. }
  24161. declare module "babylonjs/Physics/physicsImpostor" {
  24162. import { Nullable, IndicesArray } from "babylonjs/types";
  24163. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24164. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24166. import { Scene } from "babylonjs/scene";
  24167. import { Bone } from "babylonjs/Bones/bone";
  24168. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24169. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24170. import { Space } from "babylonjs/Maths/math.axis";
  24171. /**
  24172. * The interface for the physics imposter parameters
  24173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24174. */
  24175. export interface PhysicsImpostorParameters {
  24176. /**
  24177. * The mass of the physics imposter
  24178. */
  24179. mass: number;
  24180. /**
  24181. * The friction of the physics imposter
  24182. */
  24183. friction?: number;
  24184. /**
  24185. * The coefficient of restitution of the physics imposter
  24186. */
  24187. restitution?: number;
  24188. /**
  24189. * The native options of the physics imposter
  24190. */
  24191. nativeOptions?: any;
  24192. /**
  24193. * Specifies if the parent should be ignored
  24194. */
  24195. ignoreParent?: boolean;
  24196. /**
  24197. * Specifies if bi-directional transformations should be disabled
  24198. */
  24199. disableBidirectionalTransformation?: boolean;
  24200. /**
  24201. * The pressure inside the physics imposter, soft object only
  24202. */
  24203. pressure?: number;
  24204. /**
  24205. * The stiffness the physics imposter, soft object only
  24206. */
  24207. stiffness?: number;
  24208. /**
  24209. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24210. */
  24211. velocityIterations?: number;
  24212. /**
  24213. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24214. */
  24215. positionIterations?: number;
  24216. /**
  24217. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24218. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24219. * Add to fix multiple points
  24220. */
  24221. fixedPoints?: number;
  24222. /**
  24223. * The collision margin around a soft object
  24224. */
  24225. margin?: number;
  24226. /**
  24227. * The collision margin around a soft object
  24228. */
  24229. damping?: number;
  24230. /**
  24231. * The path for a rope based on an extrusion
  24232. */
  24233. path?: any;
  24234. /**
  24235. * The shape of an extrusion used for a rope based on an extrusion
  24236. */
  24237. shape?: any;
  24238. }
  24239. /**
  24240. * Interface for a physics-enabled object
  24241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24242. */
  24243. export interface IPhysicsEnabledObject {
  24244. /**
  24245. * The position of the physics-enabled object
  24246. */
  24247. position: Vector3;
  24248. /**
  24249. * The rotation of the physics-enabled object
  24250. */
  24251. rotationQuaternion: Nullable<Quaternion>;
  24252. /**
  24253. * The scale of the physics-enabled object
  24254. */
  24255. scaling: Vector3;
  24256. /**
  24257. * The rotation of the physics-enabled object
  24258. */
  24259. rotation?: Vector3;
  24260. /**
  24261. * The parent of the physics-enabled object
  24262. */
  24263. parent?: any;
  24264. /**
  24265. * The bounding info of the physics-enabled object
  24266. * @returns The bounding info of the physics-enabled object
  24267. */
  24268. getBoundingInfo(): BoundingInfo;
  24269. /**
  24270. * Computes the world matrix
  24271. * @param force Specifies if the world matrix should be computed by force
  24272. * @returns A world matrix
  24273. */
  24274. computeWorldMatrix(force: boolean): Matrix;
  24275. /**
  24276. * Gets the world matrix
  24277. * @returns A world matrix
  24278. */
  24279. getWorldMatrix?(): Matrix;
  24280. /**
  24281. * Gets the child meshes
  24282. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24283. * @returns An array of abstract meshes
  24284. */
  24285. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24286. /**
  24287. * Gets the vertex data
  24288. * @param kind The type of vertex data
  24289. * @returns A nullable array of numbers, or a float32 array
  24290. */
  24291. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24292. /**
  24293. * Gets the indices from the mesh
  24294. * @returns A nullable array of index arrays
  24295. */
  24296. getIndices?(): Nullable<IndicesArray>;
  24297. /**
  24298. * Gets the scene from the mesh
  24299. * @returns the indices array or null
  24300. */
  24301. getScene?(): Scene;
  24302. /**
  24303. * Gets the absolute position from the mesh
  24304. * @returns the absolute position
  24305. */
  24306. getAbsolutePosition(): Vector3;
  24307. /**
  24308. * Gets the absolute pivot point from the mesh
  24309. * @returns the absolute pivot point
  24310. */
  24311. getAbsolutePivotPoint(): Vector3;
  24312. /**
  24313. * Rotates the mesh
  24314. * @param axis The axis of rotation
  24315. * @param amount The amount of rotation
  24316. * @param space The space of the rotation
  24317. * @returns The rotation transform node
  24318. */
  24319. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24320. /**
  24321. * Translates the mesh
  24322. * @param axis The axis of translation
  24323. * @param distance The distance of translation
  24324. * @param space The space of the translation
  24325. * @returns The transform node
  24326. */
  24327. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24328. /**
  24329. * Sets the absolute position of the mesh
  24330. * @param absolutePosition The absolute position of the mesh
  24331. * @returns The transform node
  24332. */
  24333. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24334. /**
  24335. * Gets the class name of the mesh
  24336. * @returns The class name
  24337. */
  24338. getClassName(): string;
  24339. }
  24340. /**
  24341. * Represents a physics imposter
  24342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24343. */
  24344. export class PhysicsImpostor {
  24345. /**
  24346. * The physics-enabled object used as the physics imposter
  24347. */
  24348. object: IPhysicsEnabledObject;
  24349. /**
  24350. * The type of the physics imposter
  24351. */
  24352. type: number;
  24353. private _options;
  24354. private _scene?;
  24355. /**
  24356. * The default object size of the imposter
  24357. */
  24358. static DEFAULT_OBJECT_SIZE: Vector3;
  24359. /**
  24360. * The identity quaternion of the imposter
  24361. */
  24362. static IDENTITY_QUATERNION: Quaternion;
  24363. /** @hidden */
  24364. _pluginData: any;
  24365. private _physicsEngine;
  24366. private _physicsBody;
  24367. private _bodyUpdateRequired;
  24368. private _onBeforePhysicsStepCallbacks;
  24369. private _onAfterPhysicsStepCallbacks;
  24370. /** @hidden */
  24371. _onPhysicsCollideCallbacks: Array<{
  24372. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24373. otherImpostors: Array<PhysicsImpostor>;
  24374. }>;
  24375. private _deltaPosition;
  24376. private _deltaRotation;
  24377. private _deltaRotationConjugated;
  24378. /** @hidden */
  24379. _isFromLine: boolean;
  24380. private _parent;
  24381. private _isDisposed;
  24382. private static _tmpVecs;
  24383. private static _tmpQuat;
  24384. /**
  24385. * Specifies if the physics imposter is disposed
  24386. */
  24387. get isDisposed(): boolean;
  24388. /**
  24389. * Gets the mass of the physics imposter
  24390. */
  24391. get mass(): number;
  24392. set mass(value: number);
  24393. /**
  24394. * Gets the coefficient of friction
  24395. */
  24396. get friction(): number;
  24397. /**
  24398. * Sets the coefficient of friction
  24399. */
  24400. set friction(value: number);
  24401. /**
  24402. * Gets the coefficient of restitution
  24403. */
  24404. get restitution(): number;
  24405. /**
  24406. * Sets the coefficient of restitution
  24407. */
  24408. set restitution(value: number);
  24409. /**
  24410. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24411. */
  24412. get pressure(): number;
  24413. /**
  24414. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24415. */
  24416. set pressure(value: number);
  24417. /**
  24418. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24419. */
  24420. get stiffness(): number;
  24421. /**
  24422. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24423. */
  24424. set stiffness(value: number);
  24425. /**
  24426. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24427. */
  24428. get velocityIterations(): number;
  24429. /**
  24430. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24431. */
  24432. set velocityIterations(value: number);
  24433. /**
  24434. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24435. */
  24436. get positionIterations(): number;
  24437. /**
  24438. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24439. */
  24440. set positionIterations(value: number);
  24441. /**
  24442. * The unique id of the physics imposter
  24443. * set by the physics engine when adding this impostor to the array
  24444. */
  24445. uniqueId: number;
  24446. /**
  24447. * @hidden
  24448. */
  24449. soft: boolean;
  24450. /**
  24451. * @hidden
  24452. */
  24453. segments: number;
  24454. private _joints;
  24455. /**
  24456. * Initializes the physics imposter
  24457. * @param object The physics-enabled object used as the physics imposter
  24458. * @param type The type of the physics imposter
  24459. * @param _options The options for the physics imposter
  24460. * @param _scene The Babylon scene
  24461. */
  24462. constructor(
  24463. /**
  24464. * The physics-enabled object used as the physics imposter
  24465. */
  24466. object: IPhysicsEnabledObject,
  24467. /**
  24468. * The type of the physics imposter
  24469. */
  24470. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24471. /**
  24472. * This function will completly initialize this impostor.
  24473. * It will create a new body - but only if this mesh has no parent.
  24474. * If it has, this impostor will not be used other than to define the impostor
  24475. * of the child mesh.
  24476. * @hidden
  24477. */
  24478. _init(): void;
  24479. private _getPhysicsParent;
  24480. /**
  24481. * Should a new body be generated.
  24482. * @returns boolean specifying if body initialization is required
  24483. */
  24484. isBodyInitRequired(): boolean;
  24485. /**
  24486. * Sets the updated scaling
  24487. * @param updated Specifies if the scaling is updated
  24488. */
  24489. setScalingUpdated(): void;
  24490. /**
  24491. * Force a regeneration of this or the parent's impostor's body.
  24492. * Use under cautious - This will remove all joints already implemented.
  24493. */
  24494. forceUpdate(): void;
  24495. /**
  24496. * Gets the body that holds this impostor. Either its own, or its parent.
  24497. */
  24498. get physicsBody(): any;
  24499. /**
  24500. * Get the parent of the physics imposter
  24501. * @returns Physics imposter or null
  24502. */
  24503. get parent(): Nullable<PhysicsImpostor>;
  24504. /**
  24505. * Sets the parent of the physics imposter
  24506. */
  24507. set parent(value: Nullable<PhysicsImpostor>);
  24508. /**
  24509. * Set the physics body. Used mainly by the physics engine/plugin
  24510. */
  24511. set physicsBody(physicsBody: any);
  24512. /**
  24513. * Resets the update flags
  24514. */
  24515. resetUpdateFlags(): void;
  24516. /**
  24517. * Gets the object extend size
  24518. * @returns the object extend size
  24519. */
  24520. getObjectExtendSize(): Vector3;
  24521. /**
  24522. * Gets the object center
  24523. * @returns The object center
  24524. */
  24525. getObjectCenter(): Vector3;
  24526. /**
  24527. * Get a specific parameter from the options parameters
  24528. * @param paramName The object parameter name
  24529. * @returns The object parameter
  24530. */
  24531. getParam(paramName: string): any;
  24532. /**
  24533. * Sets a specific parameter in the options given to the physics plugin
  24534. * @param paramName The parameter name
  24535. * @param value The value of the parameter
  24536. */
  24537. setParam(paramName: string, value: number): void;
  24538. /**
  24539. * Specifically change the body's mass option. Won't recreate the physics body object
  24540. * @param mass The mass of the physics imposter
  24541. */
  24542. setMass(mass: number): void;
  24543. /**
  24544. * Gets the linear velocity
  24545. * @returns linear velocity or null
  24546. */
  24547. getLinearVelocity(): Nullable<Vector3>;
  24548. /**
  24549. * Sets the linear velocity
  24550. * @param velocity linear velocity or null
  24551. */
  24552. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24553. /**
  24554. * Gets the angular velocity
  24555. * @returns angular velocity or null
  24556. */
  24557. getAngularVelocity(): Nullable<Vector3>;
  24558. /**
  24559. * Sets the angular velocity
  24560. * @param velocity The velocity or null
  24561. */
  24562. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24563. /**
  24564. * Execute a function with the physics plugin native code
  24565. * Provide a function the will have two variables - the world object and the physics body object
  24566. * @param func The function to execute with the physics plugin native code
  24567. */
  24568. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24569. /**
  24570. * Register a function that will be executed before the physics world is stepping forward
  24571. * @param func The function to execute before the physics world is stepped forward
  24572. */
  24573. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24574. /**
  24575. * Unregister a function that will be executed before the physics world is stepping forward
  24576. * @param func The function to execute before the physics world is stepped forward
  24577. */
  24578. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24579. /**
  24580. * Register a function that will be executed after the physics step
  24581. * @param func The function to execute after physics step
  24582. */
  24583. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24584. /**
  24585. * Unregisters a function that will be executed after the physics step
  24586. * @param func The function to execute after physics step
  24587. */
  24588. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24589. /**
  24590. * register a function that will be executed when this impostor collides against a different body
  24591. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24592. * @param func Callback that is executed on collision
  24593. */
  24594. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24595. /**
  24596. * Unregisters the physics imposter on contact
  24597. * @param collideAgainst The physics object to collide against
  24598. * @param func Callback to execute on collision
  24599. */
  24600. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24601. private _tmpQuat;
  24602. private _tmpQuat2;
  24603. /**
  24604. * Get the parent rotation
  24605. * @returns The parent rotation
  24606. */
  24607. getParentsRotation(): Quaternion;
  24608. /**
  24609. * this function is executed by the physics engine.
  24610. */
  24611. beforeStep: () => void;
  24612. /**
  24613. * this function is executed by the physics engine
  24614. */
  24615. afterStep: () => void;
  24616. /**
  24617. * Legacy collision detection event support
  24618. */
  24619. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24620. /**
  24621. * event and body object due to cannon's event-based architecture.
  24622. */
  24623. onCollide: (e: {
  24624. body: any;
  24625. }) => void;
  24626. /**
  24627. * Apply a force
  24628. * @param force The force to apply
  24629. * @param contactPoint The contact point for the force
  24630. * @returns The physics imposter
  24631. */
  24632. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24633. /**
  24634. * Apply an impulse
  24635. * @param force The impulse force
  24636. * @param contactPoint The contact point for the impulse force
  24637. * @returns The physics imposter
  24638. */
  24639. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24640. /**
  24641. * A help function to create a joint
  24642. * @param otherImpostor A physics imposter used to create a joint
  24643. * @param jointType The type of joint
  24644. * @param jointData The data for the joint
  24645. * @returns The physics imposter
  24646. */
  24647. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24648. /**
  24649. * Add a joint to this impostor with a different impostor
  24650. * @param otherImpostor A physics imposter used to add a joint
  24651. * @param joint The joint to add
  24652. * @returns The physics imposter
  24653. */
  24654. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24655. /**
  24656. * Add an anchor to a cloth impostor
  24657. * @param otherImpostor rigid impostor to anchor to
  24658. * @param width ratio across width from 0 to 1
  24659. * @param height ratio up height from 0 to 1
  24660. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24661. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24662. * @returns impostor the soft imposter
  24663. */
  24664. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24665. /**
  24666. * Add a hook to a rope impostor
  24667. * @param otherImpostor rigid impostor to anchor to
  24668. * @param length ratio across rope from 0 to 1
  24669. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24670. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24671. * @returns impostor the rope imposter
  24672. */
  24673. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24674. /**
  24675. * Will keep this body still, in a sleep mode.
  24676. * @returns the physics imposter
  24677. */
  24678. sleep(): PhysicsImpostor;
  24679. /**
  24680. * Wake the body up.
  24681. * @returns The physics imposter
  24682. */
  24683. wakeUp(): PhysicsImpostor;
  24684. /**
  24685. * Clones the physics imposter
  24686. * @param newObject The physics imposter clones to this physics-enabled object
  24687. * @returns A nullable physics imposter
  24688. */
  24689. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24690. /**
  24691. * Disposes the physics imposter
  24692. */
  24693. dispose(): void;
  24694. /**
  24695. * Sets the delta position
  24696. * @param position The delta position amount
  24697. */
  24698. setDeltaPosition(position: Vector3): void;
  24699. /**
  24700. * Sets the delta rotation
  24701. * @param rotation The delta rotation amount
  24702. */
  24703. setDeltaRotation(rotation: Quaternion): void;
  24704. /**
  24705. * Gets the box size of the physics imposter and stores the result in the input parameter
  24706. * @param result Stores the box size
  24707. * @returns The physics imposter
  24708. */
  24709. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24710. /**
  24711. * Gets the radius of the physics imposter
  24712. * @returns Radius of the physics imposter
  24713. */
  24714. getRadius(): number;
  24715. /**
  24716. * Sync a bone with this impostor
  24717. * @param bone The bone to sync to the impostor.
  24718. * @param boneMesh The mesh that the bone is influencing.
  24719. * @param jointPivot The pivot of the joint / bone in local space.
  24720. * @param distToJoint Optional distance from the impostor to the joint.
  24721. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24722. */
  24723. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24724. /**
  24725. * Sync impostor to a bone
  24726. * @param bone The bone that the impostor will be synced to.
  24727. * @param boneMesh The mesh that the bone is influencing.
  24728. * @param jointPivot The pivot of the joint / bone in local space.
  24729. * @param distToJoint Optional distance from the impostor to the joint.
  24730. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24731. * @param boneAxis Optional vector3 axis the bone is aligned with
  24732. */
  24733. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24734. /**
  24735. * No-Imposter type
  24736. */
  24737. static NoImpostor: number;
  24738. /**
  24739. * Sphere-Imposter type
  24740. */
  24741. static SphereImpostor: number;
  24742. /**
  24743. * Box-Imposter type
  24744. */
  24745. static BoxImpostor: number;
  24746. /**
  24747. * Plane-Imposter type
  24748. */
  24749. static PlaneImpostor: number;
  24750. /**
  24751. * Mesh-imposter type
  24752. */
  24753. static MeshImpostor: number;
  24754. /**
  24755. * Capsule-Impostor type (Ammo.js plugin only)
  24756. */
  24757. static CapsuleImpostor: number;
  24758. /**
  24759. * Cylinder-Imposter type
  24760. */
  24761. static CylinderImpostor: number;
  24762. /**
  24763. * Particle-Imposter type
  24764. */
  24765. static ParticleImpostor: number;
  24766. /**
  24767. * Heightmap-Imposter type
  24768. */
  24769. static HeightmapImpostor: number;
  24770. /**
  24771. * ConvexHull-Impostor type (Ammo.js plugin only)
  24772. */
  24773. static ConvexHullImpostor: number;
  24774. /**
  24775. * Custom-Imposter type (Ammo.js plugin only)
  24776. */
  24777. static CustomImpostor: number;
  24778. /**
  24779. * Rope-Imposter type
  24780. */
  24781. static RopeImpostor: number;
  24782. /**
  24783. * Cloth-Imposter type
  24784. */
  24785. static ClothImpostor: number;
  24786. /**
  24787. * Softbody-Imposter type
  24788. */
  24789. static SoftbodyImpostor: number;
  24790. }
  24791. }
  24792. declare module "babylonjs/Meshes/mesh" {
  24793. import { Observable } from "babylonjs/Misc/observable";
  24794. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24795. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24796. import { Camera } from "babylonjs/Cameras/camera";
  24797. import { Scene } from "babylonjs/scene";
  24798. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24799. import { Color4 } from "babylonjs/Maths/math.color";
  24800. import { Engine } from "babylonjs/Engines/engine";
  24801. import { Node } from "babylonjs/node";
  24802. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24803. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24804. import { Buffer } from "babylonjs/Meshes/buffer";
  24805. import { Geometry } from "babylonjs/Meshes/geometry";
  24806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24807. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24808. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24809. import { Effect } from "babylonjs/Materials/effect";
  24810. import { Material } from "babylonjs/Materials/material";
  24811. import { Skeleton } from "babylonjs/Bones/skeleton";
  24812. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24813. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24814. import { Path3D } from "babylonjs/Maths/math.path";
  24815. import { Plane } from "babylonjs/Maths/math.plane";
  24816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24817. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24818. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24819. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24820. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24821. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24822. /**
  24823. * @hidden
  24824. **/
  24825. export class _CreationDataStorage {
  24826. closePath?: boolean;
  24827. closeArray?: boolean;
  24828. idx: number[];
  24829. dashSize: number;
  24830. gapSize: number;
  24831. path3D: Path3D;
  24832. pathArray: Vector3[][];
  24833. arc: number;
  24834. radius: number;
  24835. cap: number;
  24836. tessellation: number;
  24837. }
  24838. /**
  24839. * @hidden
  24840. **/
  24841. class _InstanceDataStorage {
  24842. visibleInstances: any;
  24843. batchCache: _InstancesBatch;
  24844. instancesBufferSize: number;
  24845. instancesBuffer: Nullable<Buffer>;
  24846. instancesData: Float32Array;
  24847. overridenInstanceCount: number;
  24848. isFrozen: boolean;
  24849. previousBatch: Nullable<_InstancesBatch>;
  24850. hardwareInstancedRendering: boolean;
  24851. sideOrientation: number;
  24852. manualUpdate: boolean;
  24853. }
  24854. /**
  24855. * @hidden
  24856. **/
  24857. export class _InstancesBatch {
  24858. mustReturn: boolean;
  24859. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24860. renderSelf: boolean[];
  24861. hardwareInstancedRendering: boolean[];
  24862. }
  24863. /**
  24864. * Class used to represent renderable models
  24865. */
  24866. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24867. /**
  24868. * Mesh side orientation : usually the external or front surface
  24869. */
  24870. static readonly FRONTSIDE: number;
  24871. /**
  24872. * Mesh side orientation : usually the internal or back surface
  24873. */
  24874. static readonly BACKSIDE: number;
  24875. /**
  24876. * Mesh side orientation : both internal and external or front and back surfaces
  24877. */
  24878. static readonly DOUBLESIDE: number;
  24879. /**
  24880. * Mesh side orientation : by default, `FRONTSIDE`
  24881. */
  24882. static readonly DEFAULTSIDE: number;
  24883. /**
  24884. * Mesh cap setting : no cap
  24885. */
  24886. static readonly NO_CAP: number;
  24887. /**
  24888. * Mesh cap setting : one cap at the beginning of the mesh
  24889. */
  24890. static readonly CAP_START: number;
  24891. /**
  24892. * Mesh cap setting : one cap at the end of the mesh
  24893. */
  24894. static readonly CAP_END: number;
  24895. /**
  24896. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24897. */
  24898. static readonly CAP_ALL: number;
  24899. /**
  24900. * Mesh pattern setting : no flip or rotate
  24901. */
  24902. static readonly NO_FLIP: number;
  24903. /**
  24904. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24905. */
  24906. static readonly FLIP_TILE: number;
  24907. /**
  24908. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24909. */
  24910. static readonly ROTATE_TILE: number;
  24911. /**
  24912. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24913. */
  24914. static readonly FLIP_ROW: number;
  24915. /**
  24916. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24917. */
  24918. static readonly ROTATE_ROW: number;
  24919. /**
  24920. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24921. */
  24922. static readonly FLIP_N_ROTATE_TILE: number;
  24923. /**
  24924. * Mesh pattern setting : rotate pattern and rotate
  24925. */
  24926. static readonly FLIP_N_ROTATE_ROW: number;
  24927. /**
  24928. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24929. */
  24930. static readonly CENTER: number;
  24931. /**
  24932. * Mesh tile positioning : part tiles on left
  24933. */
  24934. static readonly LEFT: number;
  24935. /**
  24936. * Mesh tile positioning : part tiles on right
  24937. */
  24938. static readonly RIGHT: number;
  24939. /**
  24940. * Mesh tile positioning : part tiles on top
  24941. */
  24942. static readonly TOP: number;
  24943. /**
  24944. * Mesh tile positioning : part tiles on bottom
  24945. */
  24946. static readonly BOTTOM: number;
  24947. /**
  24948. * Gets the default side orientation.
  24949. * @param orientation the orientation to value to attempt to get
  24950. * @returns the default orientation
  24951. * @hidden
  24952. */
  24953. static _GetDefaultSideOrientation(orientation?: number): number;
  24954. private _internalMeshDataInfo;
  24955. /**
  24956. * An event triggered before rendering the mesh
  24957. */
  24958. get onBeforeRenderObservable(): Observable<Mesh>;
  24959. /**
  24960. * An event triggered before binding the mesh
  24961. */
  24962. get onBeforeBindObservable(): Observable<Mesh>;
  24963. /**
  24964. * An event triggered after rendering the mesh
  24965. */
  24966. get onAfterRenderObservable(): Observable<Mesh>;
  24967. /**
  24968. * An event triggered before drawing the mesh
  24969. */
  24970. get onBeforeDrawObservable(): Observable<Mesh>;
  24971. private _onBeforeDrawObserver;
  24972. /**
  24973. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24974. */
  24975. set onBeforeDraw(callback: () => void);
  24976. get hasInstances(): boolean;
  24977. /**
  24978. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24979. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24980. */
  24981. delayLoadState: number;
  24982. /**
  24983. * Gets the list of instances created from this mesh
  24984. * it is not supposed to be modified manually.
  24985. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24986. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24987. */
  24988. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24989. /**
  24990. * Gets the file containing delay loading data for this mesh
  24991. */
  24992. delayLoadingFile: string;
  24993. /** @hidden */
  24994. _binaryInfo: any;
  24995. /**
  24996. * User defined function used to change how LOD level selection is done
  24997. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24998. */
  24999. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25000. /**
  25001. * Gets or sets the morph target manager
  25002. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25003. */
  25004. get morphTargetManager(): Nullable<MorphTargetManager>;
  25005. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25006. /** @hidden */
  25007. _creationDataStorage: Nullable<_CreationDataStorage>;
  25008. /** @hidden */
  25009. _geometry: Nullable<Geometry>;
  25010. /** @hidden */
  25011. _delayInfo: Array<string>;
  25012. /** @hidden */
  25013. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25014. /** @hidden */
  25015. _instanceDataStorage: _InstanceDataStorage;
  25016. private _effectiveMaterial;
  25017. /** @hidden */
  25018. _shouldGenerateFlatShading: boolean;
  25019. /** @hidden */
  25020. _originalBuilderSideOrientation: number;
  25021. /**
  25022. * Use this property to change the original side orientation defined at construction time
  25023. */
  25024. overrideMaterialSideOrientation: Nullable<number>;
  25025. /**
  25026. * Gets the source mesh (the one used to clone this one from)
  25027. */
  25028. get source(): Nullable<Mesh>;
  25029. /**
  25030. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25031. */
  25032. get isUnIndexed(): boolean;
  25033. set isUnIndexed(value: boolean);
  25034. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25035. get worldMatrixInstancedBuffer(): Float32Array;
  25036. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25037. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25038. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25039. /**
  25040. * @constructor
  25041. * @param name The value used by scene.getMeshByName() to do a lookup.
  25042. * @param scene The scene to add this mesh to.
  25043. * @param parent The parent of this mesh, if it has one
  25044. * @param source An optional Mesh from which geometry is shared, cloned.
  25045. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25046. * When false, achieved by calling a clone(), also passing False.
  25047. * This will make creation of children, recursive.
  25048. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25049. */
  25050. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25051. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25052. doNotInstantiate: boolean;
  25053. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25054. /**
  25055. * Gets the class name
  25056. * @returns the string "Mesh".
  25057. */
  25058. getClassName(): string;
  25059. /** @hidden */
  25060. get _isMesh(): boolean;
  25061. /**
  25062. * Returns a description of this mesh
  25063. * @param fullDetails define if full details about this mesh must be used
  25064. * @returns a descriptive string representing this mesh
  25065. */
  25066. toString(fullDetails?: boolean): string;
  25067. /** @hidden */
  25068. _unBindEffect(): void;
  25069. /**
  25070. * Gets a boolean indicating if this mesh has LOD
  25071. */
  25072. get hasLODLevels(): boolean;
  25073. /**
  25074. * Gets the list of MeshLODLevel associated with the current mesh
  25075. * @returns an array of MeshLODLevel
  25076. */
  25077. getLODLevels(): MeshLODLevel[];
  25078. private _sortLODLevels;
  25079. /**
  25080. * Add a mesh as LOD level triggered at the given distance.
  25081. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25082. * @param distance The distance from the center of the object to show this level
  25083. * @param mesh The mesh to be added as LOD level (can be null)
  25084. * @return This mesh (for chaining)
  25085. */
  25086. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25087. /**
  25088. * Returns the LOD level mesh at the passed distance or null if not found.
  25089. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25090. * @param distance The distance from the center of the object to show this level
  25091. * @returns a Mesh or `null`
  25092. */
  25093. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25094. /**
  25095. * Remove a mesh from the LOD array
  25096. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25097. * @param mesh defines the mesh to be removed
  25098. * @return This mesh (for chaining)
  25099. */
  25100. removeLODLevel(mesh: Mesh): Mesh;
  25101. /**
  25102. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25103. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25104. * @param camera defines the camera to use to compute distance
  25105. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25106. * @return This mesh (for chaining)
  25107. */
  25108. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25109. /**
  25110. * Gets the mesh internal Geometry object
  25111. */
  25112. get geometry(): Nullable<Geometry>;
  25113. /**
  25114. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25115. * @returns the total number of vertices
  25116. */
  25117. getTotalVertices(): number;
  25118. /**
  25119. * Returns the content of an associated vertex buffer
  25120. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25121. * - VertexBuffer.PositionKind
  25122. * - VertexBuffer.UVKind
  25123. * - VertexBuffer.UV2Kind
  25124. * - VertexBuffer.UV3Kind
  25125. * - VertexBuffer.UV4Kind
  25126. * - VertexBuffer.UV5Kind
  25127. * - VertexBuffer.UV6Kind
  25128. * - VertexBuffer.ColorKind
  25129. * - VertexBuffer.MatricesIndicesKind
  25130. * - VertexBuffer.MatricesIndicesExtraKind
  25131. * - VertexBuffer.MatricesWeightsKind
  25132. * - VertexBuffer.MatricesWeightsExtraKind
  25133. * @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
  25134. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25135. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25136. */
  25137. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25138. /**
  25139. * Returns the mesh VertexBuffer object from the requested `kind`
  25140. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25141. * - VertexBuffer.PositionKind
  25142. * - VertexBuffer.NormalKind
  25143. * - VertexBuffer.UVKind
  25144. * - VertexBuffer.UV2Kind
  25145. * - VertexBuffer.UV3Kind
  25146. * - VertexBuffer.UV4Kind
  25147. * - VertexBuffer.UV5Kind
  25148. * - VertexBuffer.UV6Kind
  25149. * - VertexBuffer.ColorKind
  25150. * - VertexBuffer.MatricesIndicesKind
  25151. * - VertexBuffer.MatricesIndicesExtraKind
  25152. * - VertexBuffer.MatricesWeightsKind
  25153. * - VertexBuffer.MatricesWeightsExtraKind
  25154. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25155. */
  25156. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25157. /**
  25158. * Tests if a specific vertex buffer is associated with this mesh
  25159. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25160. * - VertexBuffer.PositionKind
  25161. * - VertexBuffer.NormalKind
  25162. * - VertexBuffer.UVKind
  25163. * - VertexBuffer.UV2Kind
  25164. * - VertexBuffer.UV3Kind
  25165. * - VertexBuffer.UV4Kind
  25166. * - VertexBuffer.UV5Kind
  25167. * - VertexBuffer.UV6Kind
  25168. * - VertexBuffer.ColorKind
  25169. * - VertexBuffer.MatricesIndicesKind
  25170. * - VertexBuffer.MatricesIndicesExtraKind
  25171. * - VertexBuffer.MatricesWeightsKind
  25172. * - VertexBuffer.MatricesWeightsExtraKind
  25173. * @returns a boolean
  25174. */
  25175. isVerticesDataPresent(kind: string): boolean;
  25176. /**
  25177. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25178. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25179. * - VertexBuffer.PositionKind
  25180. * - VertexBuffer.UVKind
  25181. * - VertexBuffer.UV2Kind
  25182. * - VertexBuffer.UV3Kind
  25183. * - VertexBuffer.UV4Kind
  25184. * - VertexBuffer.UV5Kind
  25185. * - VertexBuffer.UV6Kind
  25186. * - VertexBuffer.ColorKind
  25187. * - VertexBuffer.MatricesIndicesKind
  25188. * - VertexBuffer.MatricesIndicesExtraKind
  25189. * - VertexBuffer.MatricesWeightsKind
  25190. * - VertexBuffer.MatricesWeightsExtraKind
  25191. * @returns a boolean
  25192. */
  25193. isVertexBufferUpdatable(kind: string): boolean;
  25194. /**
  25195. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25196. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25197. * - VertexBuffer.PositionKind
  25198. * - VertexBuffer.NormalKind
  25199. * - VertexBuffer.UVKind
  25200. * - VertexBuffer.UV2Kind
  25201. * - VertexBuffer.UV3Kind
  25202. * - VertexBuffer.UV4Kind
  25203. * - VertexBuffer.UV5Kind
  25204. * - VertexBuffer.UV6Kind
  25205. * - VertexBuffer.ColorKind
  25206. * - VertexBuffer.MatricesIndicesKind
  25207. * - VertexBuffer.MatricesIndicesExtraKind
  25208. * - VertexBuffer.MatricesWeightsKind
  25209. * - VertexBuffer.MatricesWeightsExtraKind
  25210. * @returns an array of strings
  25211. */
  25212. getVerticesDataKinds(): string[];
  25213. /**
  25214. * Returns a positive integer : the total number of indices in this mesh geometry.
  25215. * @returns the numner of indices or zero if the mesh has no geometry.
  25216. */
  25217. getTotalIndices(): number;
  25218. /**
  25219. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25220. * @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.
  25221. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25222. * @returns the indices array or an empty array if the mesh has no geometry
  25223. */
  25224. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25225. get isBlocked(): boolean;
  25226. /**
  25227. * Determine if the current mesh is ready to be rendered
  25228. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25229. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25230. * @returns true if all associated assets are ready (material, textures, shaders)
  25231. */
  25232. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25233. /**
  25234. * 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.
  25235. */
  25236. get areNormalsFrozen(): boolean;
  25237. /**
  25238. * 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.
  25239. * @returns the current mesh
  25240. */
  25241. freezeNormals(): Mesh;
  25242. /**
  25243. * 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
  25244. * @returns the current mesh
  25245. */
  25246. unfreezeNormals(): Mesh;
  25247. /**
  25248. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25249. */
  25250. set overridenInstanceCount(count: number);
  25251. /** @hidden */
  25252. _preActivate(): Mesh;
  25253. /** @hidden */
  25254. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25255. /** @hidden */
  25256. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25257. /**
  25258. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25259. * This means the mesh underlying bounding box and sphere are recomputed.
  25260. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25261. * @returns the current mesh
  25262. */
  25263. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25264. /** @hidden */
  25265. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25266. /**
  25267. * This function will subdivide the mesh into multiple submeshes
  25268. * @param count defines the expected number of submeshes
  25269. */
  25270. subdivide(count: number): void;
  25271. /**
  25272. * Copy a FloatArray into a specific associated vertex buffer
  25273. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25274. * - VertexBuffer.PositionKind
  25275. * - VertexBuffer.UVKind
  25276. * - VertexBuffer.UV2Kind
  25277. * - VertexBuffer.UV3Kind
  25278. * - VertexBuffer.UV4Kind
  25279. * - VertexBuffer.UV5Kind
  25280. * - VertexBuffer.UV6Kind
  25281. * - VertexBuffer.ColorKind
  25282. * - VertexBuffer.MatricesIndicesKind
  25283. * - VertexBuffer.MatricesIndicesExtraKind
  25284. * - VertexBuffer.MatricesWeightsKind
  25285. * - VertexBuffer.MatricesWeightsExtraKind
  25286. * @param data defines the data source
  25287. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25288. * @param stride defines the data stride size (can be null)
  25289. * @returns the current mesh
  25290. */
  25291. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25292. /**
  25293. * Delete a vertex buffer associated with this mesh
  25294. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25295. * - VertexBuffer.PositionKind
  25296. * - VertexBuffer.UVKind
  25297. * - VertexBuffer.UV2Kind
  25298. * - VertexBuffer.UV3Kind
  25299. * - VertexBuffer.UV4Kind
  25300. * - VertexBuffer.UV5Kind
  25301. * - VertexBuffer.UV6Kind
  25302. * - VertexBuffer.ColorKind
  25303. * - VertexBuffer.MatricesIndicesKind
  25304. * - VertexBuffer.MatricesIndicesExtraKind
  25305. * - VertexBuffer.MatricesWeightsKind
  25306. * - VertexBuffer.MatricesWeightsExtraKind
  25307. */
  25308. removeVerticesData(kind: string): void;
  25309. /**
  25310. * Flags an associated vertex buffer as updatable
  25311. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25312. * - VertexBuffer.PositionKind
  25313. * - VertexBuffer.UVKind
  25314. * - VertexBuffer.UV2Kind
  25315. * - VertexBuffer.UV3Kind
  25316. * - VertexBuffer.UV4Kind
  25317. * - VertexBuffer.UV5Kind
  25318. * - VertexBuffer.UV6Kind
  25319. * - VertexBuffer.ColorKind
  25320. * - VertexBuffer.MatricesIndicesKind
  25321. * - VertexBuffer.MatricesIndicesExtraKind
  25322. * - VertexBuffer.MatricesWeightsKind
  25323. * - VertexBuffer.MatricesWeightsExtraKind
  25324. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25325. */
  25326. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25327. /**
  25328. * Sets the mesh global Vertex Buffer
  25329. * @param buffer defines the buffer to use
  25330. * @returns the current mesh
  25331. */
  25332. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25333. /**
  25334. * Update a specific associated vertex buffer
  25335. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25336. * - VertexBuffer.PositionKind
  25337. * - VertexBuffer.UVKind
  25338. * - VertexBuffer.UV2Kind
  25339. * - VertexBuffer.UV3Kind
  25340. * - VertexBuffer.UV4Kind
  25341. * - VertexBuffer.UV5Kind
  25342. * - VertexBuffer.UV6Kind
  25343. * - VertexBuffer.ColorKind
  25344. * - VertexBuffer.MatricesIndicesKind
  25345. * - VertexBuffer.MatricesIndicesExtraKind
  25346. * - VertexBuffer.MatricesWeightsKind
  25347. * - VertexBuffer.MatricesWeightsExtraKind
  25348. * @param data defines the data source
  25349. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25350. * @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)
  25351. * @returns the current mesh
  25352. */
  25353. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25354. /**
  25355. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25356. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25357. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25358. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25359. * @returns the current mesh
  25360. */
  25361. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25362. /**
  25363. * Creates a un-shared specific occurence of the geometry for the mesh.
  25364. * @returns the current mesh
  25365. */
  25366. makeGeometryUnique(): Mesh;
  25367. /**
  25368. * Set the index buffer of this mesh
  25369. * @param indices defines the source data
  25370. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25371. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25372. * @returns the current mesh
  25373. */
  25374. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25375. /**
  25376. * Update the current index buffer
  25377. * @param indices defines the source data
  25378. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25379. * @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)
  25380. * @returns the current mesh
  25381. */
  25382. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25383. /**
  25384. * Invert the geometry to move from a right handed system to a left handed one.
  25385. * @returns the current mesh
  25386. */
  25387. toLeftHanded(): Mesh;
  25388. /** @hidden */
  25389. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25390. /** @hidden */
  25391. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25392. /**
  25393. * Registers for this mesh a javascript function called just before the rendering process
  25394. * @param func defines the function to call before rendering this mesh
  25395. * @returns the current mesh
  25396. */
  25397. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25398. /**
  25399. * Disposes a previously registered javascript function called before the rendering
  25400. * @param func defines the function to remove
  25401. * @returns the current mesh
  25402. */
  25403. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25404. /**
  25405. * Registers for this mesh a javascript function called just after the rendering is complete
  25406. * @param func defines the function to call after rendering this mesh
  25407. * @returns the current mesh
  25408. */
  25409. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25410. /**
  25411. * Disposes a previously registered javascript function called after the rendering.
  25412. * @param func defines the function to remove
  25413. * @returns the current mesh
  25414. */
  25415. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25416. /** @hidden */
  25417. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25418. /** @hidden */
  25419. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25420. /** @hidden */
  25421. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25422. /** @hidden */
  25423. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25424. /** @hidden */
  25425. _rebuild(): void;
  25426. /** @hidden */
  25427. _freeze(): void;
  25428. /** @hidden */
  25429. _unFreeze(): void;
  25430. /**
  25431. * 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
  25432. * @param subMesh defines the subMesh to render
  25433. * @param enableAlphaMode defines if alpha mode can be changed
  25434. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25435. * @returns the current mesh
  25436. */
  25437. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25438. private _onBeforeDraw;
  25439. /**
  25440. * Renormalize the mesh and patch it up if there are no weights
  25441. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25442. * However in the case of zero weights then we set just a single influence to 1.
  25443. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25444. */
  25445. cleanMatrixWeights(): void;
  25446. private normalizeSkinFourWeights;
  25447. private normalizeSkinWeightsAndExtra;
  25448. /**
  25449. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25450. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25451. * the user know there was an issue with importing the mesh
  25452. * @returns a validation object with skinned, valid and report string
  25453. */
  25454. validateSkinning(): {
  25455. skinned: boolean;
  25456. valid: boolean;
  25457. report: string;
  25458. };
  25459. /** @hidden */
  25460. _checkDelayState(): Mesh;
  25461. private _queueLoad;
  25462. /**
  25463. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25464. * A mesh is in the frustum if its bounding box intersects the frustum
  25465. * @param frustumPlanes defines the frustum to test
  25466. * @returns true if the mesh is in the frustum planes
  25467. */
  25468. isInFrustum(frustumPlanes: Plane[]): boolean;
  25469. /**
  25470. * Sets the mesh material by the material or multiMaterial `id` property
  25471. * @param id is a string identifying the material or the multiMaterial
  25472. * @returns the current mesh
  25473. */
  25474. setMaterialByID(id: string): Mesh;
  25475. /**
  25476. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25477. * @returns an array of IAnimatable
  25478. */
  25479. getAnimatables(): IAnimatable[];
  25480. /**
  25481. * Modifies the mesh geometry according to the passed transformation matrix.
  25482. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25483. * The mesh normals are modified using the same transformation.
  25484. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25485. * @param transform defines the transform matrix to use
  25486. * @see http://doc.babylonjs.com/resources/baking_transformations
  25487. * @returns the current mesh
  25488. */
  25489. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25490. /**
  25491. * Modifies the mesh geometry according to its own current World Matrix.
  25492. * The mesh World Matrix is then reset.
  25493. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25494. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25495. * @see http://doc.babylonjs.com/resources/baking_transformations
  25496. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25497. * @returns the current mesh
  25498. */
  25499. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25500. /** @hidden */
  25501. get _positions(): Nullable<Vector3[]>;
  25502. /** @hidden */
  25503. _resetPointsArrayCache(): Mesh;
  25504. /** @hidden */
  25505. _generatePointsArray(): boolean;
  25506. /**
  25507. * Returns a new Mesh object generated from the current mesh properties.
  25508. * This method must not get confused with createInstance()
  25509. * @param name is a string, the name given to the new mesh
  25510. * @param newParent can be any Node object (default `null`)
  25511. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25512. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25513. * @returns a new mesh
  25514. */
  25515. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25516. /**
  25517. * Releases resources associated with this mesh.
  25518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25520. */
  25521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25522. /** @hidden */
  25523. _disposeInstanceSpecificData(): void;
  25524. /**
  25525. * Modifies the mesh geometry according to a displacement map.
  25526. * 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.
  25527. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25528. * @param url is a string, the URL from the image file is to be downloaded.
  25529. * @param minHeight is the lower limit of the displacement.
  25530. * @param maxHeight is the upper limit of the displacement.
  25531. * @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.
  25532. * @param uvOffset is an optional vector2 used to offset UV.
  25533. * @param uvScale is an optional vector2 used to scale UV.
  25534. * @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.
  25535. * @returns the Mesh.
  25536. */
  25537. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25538. /**
  25539. * Modifies the mesh geometry according to a displacementMap buffer.
  25540. * 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.
  25541. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25542. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25543. * @param heightMapWidth is the width of the buffer image.
  25544. * @param heightMapHeight is the height of the buffer image.
  25545. * @param minHeight is the lower limit of the displacement.
  25546. * @param maxHeight is the upper limit of the displacement.
  25547. * @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.
  25548. * @param uvOffset is an optional vector2 used to offset UV.
  25549. * @param uvScale is an optional vector2 used to scale UV.
  25550. * @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.
  25551. * @returns the Mesh.
  25552. */
  25553. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25554. /**
  25555. * Modify the mesh to get a flat shading rendering.
  25556. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25557. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25558. * @returns current mesh
  25559. */
  25560. convertToFlatShadedMesh(): Mesh;
  25561. /**
  25562. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25563. * In other words, more vertices, no more indices and a single bigger VBO.
  25564. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25565. * @returns current mesh
  25566. */
  25567. convertToUnIndexedMesh(): Mesh;
  25568. /**
  25569. * Inverses facet orientations.
  25570. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25571. * @param flipNormals will also inverts the normals
  25572. * @returns current mesh
  25573. */
  25574. flipFaces(flipNormals?: boolean): Mesh;
  25575. /**
  25576. * Increase the number of facets and hence vertices in a mesh
  25577. * Vertex normals are interpolated from existing vertex normals
  25578. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25579. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25580. */
  25581. increaseVertices(numberPerEdge: number): void;
  25582. /**
  25583. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25584. * This will undo any application of covertToFlatShadedMesh
  25585. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25586. */
  25587. forceSharedVertices(): void;
  25588. /** @hidden */
  25589. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25590. /** @hidden */
  25591. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25592. /**
  25593. * Creates a new InstancedMesh object from the mesh model.
  25594. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25595. * @param name defines the name of the new instance
  25596. * @returns a new InstancedMesh
  25597. */
  25598. createInstance(name: string): InstancedMesh;
  25599. /**
  25600. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25601. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25602. * @returns the current mesh
  25603. */
  25604. synchronizeInstances(): Mesh;
  25605. /**
  25606. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25607. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25608. * This should be used together with the simplification to avoid disappearing triangles.
  25609. * @param successCallback an optional success callback to be called after the optimization finished.
  25610. * @returns the current mesh
  25611. */
  25612. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25613. /**
  25614. * Serialize current mesh
  25615. * @param serializationObject defines the object which will receive the serialization data
  25616. */
  25617. serialize(serializationObject: any): void;
  25618. /** @hidden */
  25619. _syncGeometryWithMorphTargetManager(): void;
  25620. /** @hidden */
  25621. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25622. /**
  25623. * Returns a new Mesh object parsed from the source provided.
  25624. * @param parsedMesh is the source
  25625. * @param scene defines the hosting scene
  25626. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25627. * @returns a new Mesh
  25628. */
  25629. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25630. /**
  25631. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25632. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25633. * @param name defines the name of the mesh to create
  25634. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25635. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25636. * @param closePath creates a seam between the first and the last points of each path of the path array
  25637. * @param offset is taken in account only if the `pathArray` is containing a single path
  25638. * @param scene defines the hosting scene
  25639. * @param updatable defines if the mesh must be flagged as updatable
  25640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25641. * @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)
  25642. * @returns a new Mesh
  25643. */
  25644. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25645. /**
  25646. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25647. * @param name defines the name of the mesh to create
  25648. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25649. * @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
  25650. * @param scene defines the hosting scene
  25651. * @param updatable defines if the mesh must be flagged as updatable
  25652. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25653. * @returns a new Mesh
  25654. */
  25655. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25656. /**
  25657. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25658. * @param name defines the name of the mesh to create
  25659. * @param size sets the size (float) of each box side (default 1)
  25660. * @param scene defines the hosting scene
  25661. * @param updatable defines if the mesh must be flagged as updatable
  25662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25663. * @returns a new Mesh
  25664. */
  25665. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25666. /**
  25667. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25668. * @param name defines the name of the mesh to create
  25669. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25670. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25671. * @param scene defines the hosting scene
  25672. * @param updatable defines if the mesh must be flagged as updatable
  25673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25674. * @returns a new Mesh
  25675. */
  25676. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25677. /**
  25678. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25679. * @param name defines the name of the mesh to create
  25680. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25681. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25682. * @param scene defines the hosting scene
  25683. * @returns a new Mesh
  25684. */
  25685. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25686. /**
  25687. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25688. * @param name defines the name of the mesh to create
  25689. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25690. * @param diameterTop set the top cap diameter (floats, default 1)
  25691. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25692. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25693. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25694. * @param scene defines the hosting scene
  25695. * @param updatable defines if the mesh must be flagged as updatable
  25696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25697. * @returns a new Mesh
  25698. */
  25699. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25700. /**
  25701. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25702. * @param name defines the name of the mesh to create
  25703. * @param diameter sets the diameter size (float) of the torus (default 1)
  25704. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25705. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25706. * @param scene defines the hosting scene
  25707. * @param updatable defines if the mesh must be flagged as updatable
  25708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25709. * @returns a new Mesh
  25710. */
  25711. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25712. /**
  25713. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25714. * @param name defines the name of the mesh to create
  25715. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25716. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25717. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25718. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25719. * @param p the number of windings on X axis (positive integers, default 2)
  25720. * @param q the number of windings on Y axis (positive integers, default 3)
  25721. * @param scene defines the hosting scene
  25722. * @param updatable defines if the mesh must be flagged as updatable
  25723. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25724. * @returns a new Mesh
  25725. */
  25726. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25727. /**
  25728. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25729. * @param name defines the name of the mesh to create
  25730. * @param points is an array successive Vector3
  25731. * @param scene defines the hosting scene
  25732. * @param updatable defines if the mesh must be flagged as updatable
  25733. * @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).
  25734. * @returns a new Mesh
  25735. */
  25736. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25737. /**
  25738. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25739. * @param name defines the name of the mesh to create
  25740. * @param points is an array successive Vector3
  25741. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25742. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25743. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25744. * @param scene defines the hosting scene
  25745. * @param updatable defines if the mesh must be flagged as updatable
  25746. * @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)
  25747. * @returns a new Mesh
  25748. */
  25749. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25750. /**
  25751. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25752. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25753. * 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.
  25754. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25755. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25756. * Remember you can only change the shape positions, not their number when updating a polygon.
  25757. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25758. * @param name defines the name of the mesh to create
  25759. * @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
  25760. * @param scene defines the hosting scene
  25761. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25762. * @param updatable defines if the mesh must be flagged as updatable
  25763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25764. * @param earcutInjection can be used to inject your own earcut reference
  25765. * @returns a new Mesh
  25766. */
  25767. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25768. /**
  25769. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25770. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25771. * @param name defines the name of the mesh to create
  25772. * @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
  25773. * @param depth defines the height of extrusion
  25774. * @param scene defines the hosting scene
  25775. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25776. * @param updatable defines if the mesh must be flagged as updatable
  25777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25778. * @param earcutInjection can be used to inject your own earcut reference
  25779. * @returns a new Mesh
  25780. */
  25781. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25782. /**
  25783. * Creates an extruded shape mesh.
  25784. * 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
  25785. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25786. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25787. * @param name defines the name of the mesh to create
  25788. * @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
  25789. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25790. * @param scale is the value to scale the shape
  25791. * @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
  25792. * @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
  25793. * @param scene defines the hosting scene
  25794. * @param updatable defines if the mesh must be flagged as updatable
  25795. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25796. * @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)
  25797. * @returns a new Mesh
  25798. */
  25799. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25800. /**
  25801. * Creates an custom extruded shape mesh.
  25802. * The custom extrusion is a parametric shape.
  25803. * It has no predefined shape. Its final shape will depend on the input parameters.
  25804. * Please consider using the same method from the MeshBuilder class instead
  25805. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25806. * @param name defines the name of the mesh to create
  25807. * @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
  25808. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25809. * @param scaleFunction is a custom Javascript function called on each path point
  25810. * @param rotationFunction is a custom Javascript function called on each path point
  25811. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25812. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25813. * @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
  25814. * @param scene defines the hosting scene
  25815. * @param updatable defines if the mesh must be flagged as updatable
  25816. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25817. * @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)
  25818. * @returns a new Mesh
  25819. */
  25820. 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;
  25821. /**
  25822. * Creates lathe mesh.
  25823. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25824. * Please consider using the same method from the MeshBuilder class instead
  25825. * @param name defines the name of the mesh to create
  25826. * @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
  25827. * @param radius is the radius value of the lathe
  25828. * @param tessellation is the side number of the lathe.
  25829. * @param scene defines the hosting scene
  25830. * @param updatable defines if the mesh must be flagged as updatable
  25831. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25832. * @returns a new Mesh
  25833. */
  25834. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25835. /**
  25836. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25837. * @param name defines the name of the mesh to create
  25838. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25839. * @param scene defines the hosting scene
  25840. * @param updatable defines if the mesh must be flagged as updatable
  25841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25842. * @returns a new Mesh
  25843. */
  25844. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25845. /**
  25846. * Creates a ground mesh.
  25847. * Please consider using the same method from the MeshBuilder class instead
  25848. * @param name defines the name of the mesh to create
  25849. * @param width set the width of the ground
  25850. * @param height set the height of the ground
  25851. * @param subdivisions sets the number of subdivisions per side
  25852. * @param scene defines the hosting scene
  25853. * @param updatable defines if the mesh must be flagged as updatable
  25854. * @returns a new Mesh
  25855. */
  25856. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25857. /**
  25858. * Creates a tiled ground mesh.
  25859. * Please consider using the same method from the MeshBuilder class instead
  25860. * @param name defines the name of the mesh to create
  25861. * @param xmin set the ground minimum X coordinate
  25862. * @param zmin set the ground minimum Y coordinate
  25863. * @param xmax set the ground maximum X coordinate
  25864. * @param zmax set the ground maximum Z coordinate
  25865. * @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
  25866. * @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
  25867. * @param scene defines the hosting scene
  25868. * @param updatable defines if the mesh must be flagged as updatable
  25869. * @returns a new Mesh
  25870. */
  25871. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25872. w: number;
  25873. h: number;
  25874. }, precision: {
  25875. w: number;
  25876. h: number;
  25877. }, scene: Scene, updatable?: boolean): Mesh;
  25878. /**
  25879. * Creates a ground mesh from a height map.
  25880. * Please consider using the same method from the MeshBuilder class instead
  25881. * @see http://doc.babylonjs.com/babylon101/height_map
  25882. * @param name defines the name of the mesh to create
  25883. * @param url sets the URL of the height map image resource
  25884. * @param width set the ground width size
  25885. * @param height set the ground height size
  25886. * @param subdivisions sets the number of subdivision per side
  25887. * @param minHeight is the minimum altitude on the ground
  25888. * @param maxHeight is the maximum altitude on the ground
  25889. * @param scene defines the hosting scene
  25890. * @param updatable defines if the mesh must be flagged as updatable
  25891. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25892. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25893. * @returns a new Mesh
  25894. */
  25895. 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;
  25896. /**
  25897. * Creates a tube mesh.
  25898. * The tube is a parametric shape.
  25899. * It has no predefined shape. Its final shape will depend on the input parameters.
  25900. * Please consider using the same method from the MeshBuilder class instead
  25901. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25902. * @param name defines the name of the mesh to create
  25903. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25904. * @param radius sets the tube radius size
  25905. * @param tessellation is the number of sides on the tubular surface
  25906. * @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
  25907. * @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
  25908. * @param scene defines the hosting scene
  25909. * @param updatable defines if the mesh must be flagged as updatable
  25910. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25911. * @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)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25915. (i: number, distance: number): number;
  25916. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25917. /**
  25918. * Creates a polyhedron mesh.
  25919. * Please consider using the same method from the MeshBuilder class instead.
  25920. * * 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
  25921. * * The parameter `size` (positive float, default 1) sets the polygon size
  25922. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25923. * * 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`
  25924. * * 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
  25925. * * 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)`)
  25926. * * 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
  25927. * * 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
  25928. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25929. * * If you create a double-sided mesh, you can choose what parts of 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
  25930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25931. * @param name defines the name of the mesh to create
  25932. * @param options defines the options used to create the mesh
  25933. * @param scene defines the hosting scene
  25934. * @returns a new Mesh
  25935. */
  25936. static CreatePolyhedron(name: string, options: {
  25937. type?: number;
  25938. size?: number;
  25939. sizeX?: number;
  25940. sizeY?: number;
  25941. sizeZ?: number;
  25942. custom?: any;
  25943. faceUV?: Vector4[];
  25944. faceColors?: Color4[];
  25945. updatable?: boolean;
  25946. sideOrientation?: number;
  25947. }, scene: Scene): Mesh;
  25948. /**
  25949. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25950. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25951. * * 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`)
  25952. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25953. * * 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
  25954. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25955. * * If you create a double-sided mesh, you can choose what parts of 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
  25956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25957. * @param name defines the name of the mesh
  25958. * @param options defines the options used to create the mesh
  25959. * @param scene defines the hosting scene
  25960. * @returns a new Mesh
  25961. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25962. */
  25963. static CreateIcoSphere(name: string, options: {
  25964. radius?: number;
  25965. flat?: boolean;
  25966. subdivisions?: number;
  25967. sideOrientation?: number;
  25968. updatable?: boolean;
  25969. }, scene: Scene): Mesh;
  25970. /**
  25971. * Creates a decal mesh.
  25972. * Please consider using the same method from the MeshBuilder class instead.
  25973. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25974. * @param name defines the name of the mesh
  25975. * @param sourceMesh defines the mesh receiving the decal
  25976. * @param position sets the position of the decal in world coordinates
  25977. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25978. * @param size sets the decal scaling
  25979. * @param angle sets the angle to rotate the decal
  25980. * @returns a new Mesh
  25981. */
  25982. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25983. /**
  25984. * Prepare internal position array for software CPU skinning
  25985. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25986. */
  25987. setPositionsForCPUSkinning(): Float32Array;
  25988. /**
  25989. * Prepare internal normal array for software CPU skinning
  25990. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25991. */
  25992. setNormalsForCPUSkinning(): Float32Array;
  25993. /**
  25994. * Updates the vertex buffer by applying transformation from the bones
  25995. * @param skeleton defines the skeleton to apply to current mesh
  25996. * @returns the current mesh
  25997. */
  25998. applySkeleton(skeleton: Skeleton): Mesh;
  25999. /**
  26000. * 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
  26001. * @param meshes defines the list of meshes to scan
  26002. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26003. */
  26004. static MinMax(meshes: AbstractMesh[]): {
  26005. min: Vector3;
  26006. max: Vector3;
  26007. };
  26008. /**
  26009. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26010. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26011. * @returns a vector3
  26012. */
  26013. static Center(meshesOrMinMaxVector: {
  26014. min: Vector3;
  26015. max: Vector3;
  26016. } | AbstractMesh[]): Vector3;
  26017. /**
  26018. * Merge the array of meshes into a single mesh for performance reasons.
  26019. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26020. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26021. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26022. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26023. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26024. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26025. * @returns a new mesh
  26026. */
  26027. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26028. /** @hidden */
  26029. addInstance(instance: InstancedMesh): void;
  26030. /** @hidden */
  26031. removeInstance(instance: InstancedMesh): void;
  26032. }
  26033. }
  26034. declare module "babylonjs/Cameras/camera" {
  26035. import { SmartArray } from "babylonjs/Misc/smartArray";
  26036. import { Observable } from "babylonjs/Misc/observable";
  26037. import { Nullable } from "babylonjs/types";
  26038. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26039. import { Scene } from "babylonjs/scene";
  26040. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26041. import { Node } from "babylonjs/node";
  26042. import { Mesh } from "babylonjs/Meshes/mesh";
  26043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26044. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26045. import { Viewport } from "babylonjs/Maths/math.viewport";
  26046. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26047. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26048. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26049. import { Ray } from "babylonjs/Culling/ray";
  26050. /**
  26051. * This is the base class of all the camera used in the application.
  26052. * @see http://doc.babylonjs.com/features/cameras
  26053. */
  26054. export class Camera extends Node {
  26055. /** @hidden */
  26056. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26057. /**
  26058. * This is the default projection mode used by the cameras.
  26059. * It helps recreating a feeling of perspective and better appreciate depth.
  26060. * This is the best way to simulate real life cameras.
  26061. */
  26062. static readonly PERSPECTIVE_CAMERA: number;
  26063. /**
  26064. * This helps creating camera with an orthographic mode.
  26065. * 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.
  26066. */
  26067. static readonly ORTHOGRAPHIC_CAMERA: number;
  26068. /**
  26069. * This is the default FOV mode for perspective cameras.
  26070. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26071. */
  26072. static readonly FOVMODE_VERTICAL_FIXED: number;
  26073. /**
  26074. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26075. */
  26076. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26077. /**
  26078. * This specifies ther is no need for a camera rig.
  26079. * Basically only one eye is rendered corresponding to the camera.
  26080. */
  26081. static readonly RIG_MODE_NONE: number;
  26082. /**
  26083. * Simulates a camera Rig with one blue eye and one red eye.
  26084. * This can be use with 3d blue and red glasses.
  26085. */
  26086. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26087. /**
  26088. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26089. */
  26090. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26091. /**
  26092. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26093. */
  26094. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26095. /**
  26096. * Defines that both eyes of the camera will be rendered over under each other.
  26097. */
  26098. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26099. /**
  26100. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26101. */
  26102. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26103. /**
  26104. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26105. */
  26106. static readonly RIG_MODE_VR: number;
  26107. /**
  26108. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26109. */
  26110. static readonly RIG_MODE_WEBVR: number;
  26111. /**
  26112. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26113. */
  26114. static readonly RIG_MODE_CUSTOM: number;
  26115. /**
  26116. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26117. */
  26118. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26119. /**
  26120. * Define the input manager associated with the camera.
  26121. */
  26122. inputs: CameraInputsManager<Camera>;
  26123. /** @hidden */
  26124. _position: Vector3;
  26125. /**
  26126. * Define the current local position of the camera in the scene
  26127. */
  26128. get position(): Vector3;
  26129. set position(newPosition: Vector3);
  26130. /**
  26131. * The vector the camera should consider as up.
  26132. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26133. */
  26134. upVector: Vector3;
  26135. /**
  26136. * Define the current limit on the left side for an orthographic camera
  26137. * In scene unit
  26138. */
  26139. orthoLeft: Nullable<number>;
  26140. /**
  26141. * Define the current limit on the right side for an orthographic camera
  26142. * In scene unit
  26143. */
  26144. orthoRight: Nullable<number>;
  26145. /**
  26146. * Define the current limit on the bottom side for an orthographic camera
  26147. * In scene unit
  26148. */
  26149. orthoBottom: Nullable<number>;
  26150. /**
  26151. * Define the current limit on the top side for an orthographic camera
  26152. * In scene unit
  26153. */
  26154. orthoTop: Nullable<number>;
  26155. /**
  26156. * Field Of View is set in Radians. (default is 0.8)
  26157. */
  26158. fov: number;
  26159. /**
  26160. * Define the minimum distance the camera can see from.
  26161. * This is important to note that the depth buffer are not infinite and the closer it starts
  26162. * the more your scene might encounter depth fighting issue.
  26163. */
  26164. minZ: number;
  26165. /**
  26166. * Define the maximum distance the camera can see to.
  26167. * This is important to note that the depth buffer are not infinite and the further it end
  26168. * the more your scene might encounter depth fighting issue.
  26169. */
  26170. maxZ: number;
  26171. /**
  26172. * Define the default inertia of the camera.
  26173. * This helps giving a smooth feeling to the camera movement.
  26174. */
  26175. inertia: number;
  26176. /**
  26177. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26178. */
  26179. mode: number;
  26180. /**
  26181. * Define whether the camera is intermediate.
  26182. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26183. */
  26184. isIntermediate: boolean;
  26185. /**
  26186. * Define the viewport of the camera.
  26187. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26188. */
  26189. viewport: Viewport;
  26190. /**
  26191. * Restricts the camera to viewing objects with the same layerMask.
  26192. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26193. */
  26194. layerMask: number;
  26195. /**
  26196. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26197. */
  26198. fovMode: number;
  26199. /**
  26200. * Rig mode of the camera.
  26201. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26202. * This is normally controlled byt the camera themselves as internal use.
  26203. */
  26204. cameraRigMode: number;
  26205. /**
  26206. * Defines the distance between both "eyes" in case of a RIG
  26207. */
  26208. interaxialDistance: number;
  26209. /**
  26210. * Defines if stereoscopic rendering is done side by side or over under.
  26211. */
  26212. isStereoscopicSideBySide: boolean;
  26213. /**
  26214. * 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
  26215. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26216. * else in the scene. (Eg. security camera)
  26217. *
  26218. * 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)
  26219. */
  26220. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26221. /**
  26222. * When set, the camera will render to this render target instead of the default canvas
  26223. *
  26224. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26225. */
  26226. outputRenderTarget: Nullable<RenderTargetTexture>;
  26227. /**
  26228. * Observable triggered when the camera view matrix has changed.
  26229. */
  26230. onViewMatrixChangedObservable: Observable<Camera>;
  26231. /**
  26232. * Observable triggered when the camera Projection matrix has changed.
  26233. */
  26234. onProjectionMatrixChangedObservable: Observable<Camera>;
  26235. /**
  26236. * Observable triggered when the inputs have been processed.
  26237. */
  26238. onAfterCheckInputsObservable: Observable<Camera>;
  26239. /**
  26240. * Observable triggered when reset has been called and applied to the camera.
  26241. */
  26242. onRestoreStateObservable: Observable<Camera>;
  26243. /**
  26244. * Is this camera a part of a rig system?
  26245. */
  26246. isRigCamera: boolean;
  26247. /**
  26248. * If isRigCamera set to true this will be set with the parent camera.
  26249. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26250. */
  26251. rigParent?: Camera;
  26252. /** @hidden */
  26253. _cameraRigParams: any;
  26254. /** @hidden */
  26255. _rigCameras: Camera[];
  26256. /** @hidden */
  26257. _rigPostProcess: Nullable<PostProcess>;
  26258. protected _webvrViewMatrix: Matrix;
  26259. /** @hidden */
  26260. _skipRendering: boolean;
  26261. /** @hidden */
  26262. _projectionMatrix: Matrix;
  26263. /** @hidden */
  26264. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26265. /** @hidden */
  26266. _activeMeshes: SmartArray<AbstractMesh>;
  26267. protected _globalPosition: Vector3;
  26268. /** @hidden */
  26269. _computedViewMatrix: Matrix;
  26270. private _doNotComputeProjectionMatrix;
  26271. private _transformMatrix;
  26272. private _frustumPlanes;
  26273. private _refreshFrustumPlanes;
  26274. private _storedFov;
  26275. private _stateStored;
  26276. /**
  26277. * Instantiates a new camera object.
  26278. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26279. * @see http://doc.babylonjs.com/features/cameras
  26280. * @param name Defines the name of the camera in the scene
  26281. * @param position Defines the position of the camera
  26282. * @param scene Defines the scene the camera belongs too
  26283. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26284. */
  26285. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26286. /**
  26287. * Store current camera state (fov, position, etc..)
  26288. * @returns the camera
  26289. */
  26290. storeState(): Camera;
  26291. /**
  26292. * Restores the camera state values if it has been stored. You must call storeState() first
  26293. */
  26294. protected _restoreStateValues(): boolean;
  26295. /**
  26296. * Restored camera state. You must call storeState() first.
  26297. * @returns true if restored and false otherwise
  26298. */
  26299. restoreState(): boolean;
  26300. /**
  26301. * Gets the class name of the camera.
  26302. * @returns the class name
  26303. */
  26304. getClassName(): string;
  26305. /** @hidden */
  26306. readonly _isCamera: boolean;
  26307. /**
  26308. * Gets a string representation of the camera useful for debug purpose.
  26309. * @param fullDetails Defines that a more verboe level of logging is required
  26310. * @returns the string representation
  26311. */
  26312. toString(fullDetails?: boolean): string;
  26313. /**
  26314. * Gets the current world space position of the camera.
  26315. */
  26316. get globalPosition(): Vector3;
  26317. /**
  26318. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26319. * @returns the active meshe list
  26320. */
  26321. getActiveMeshes(): SmartArray<AbstractMesh>;
  26322. /**
  26323. * Check whether a mesh is part of the current active mesh list of the camera
  26324. * @param mesh Defines the mesh to check
  26325. * @returns true if active, false otherwise
  26326. */
  26327. isActiveMesh(mesh: Mesh): boolean;
  26328. /**
  26329. * Is this camera ready to be used/rendered
  26330. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26331. * @return true if the camera is ready
  26332. */
  26333. isReady(completeCheck?: boolean): boolean;
  26334. /** @hidden */
  26335. _initCache(): void;
  26336. /** @hidden */
  26337. _updateCache(ignoreParentClass?: boolean): void;
  26338. /** @hidden */
  26339. _isSynchronized(): boolean;
  26340. /** @hidden */
  26341. _isSynchronizedViewMatrix(): boolean;
  26342. /** @hidden */
  26343. _isSynchronizedProjectionMatrix(): boolean;
  26344. /**
  26345. * Attach the input controls to a specific dom element to get the input from.
  26346. * @param element Defines the element the controls should be listened from
  26347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26348. */
  26349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26350. /**
  26351. * Detach the current controls from the specified dom element.
  26352. * @param element Defines the element to stop listening the inputs from
  26353. */
  26354. detachControl(element: HTMLElement): void;
  26355. /**
  26356. * Update the camera state according to the different inputs gathered during the frame.
  26357. */
  26358. update(): void;
  26359. /** @hidden */
  26360. _checkInputs(): void;
  26361. /** @hidden */
  26362. get rigCameras(): Camera[];
  26363. /**
  26364. * Gets the post process used by the rig cameras
  26365. */
  26366. get rigPostProcess(): Nullable<PostProcess>;
  26367. /**
  26368. * Internal, gets the first post proces.
  26369. * @returns the first post process to be run on this camera.
  26370. */
  26371. _getFirstPostProcess(): Nullable<PostProcess>;
  26372. private _cascadePostProcessesToRigCams;
  26373. /**
  26374. * Attach a post process to the camera.
  26375. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26376. * @param postProcess The post process to attach to the camera
  26377. * @param insertAt The position of the post process in case several of them are in use in the scene
  26378. * @returns the position the post process has been inserted at
  26379. */
  26380. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26381. /**
  26382. * Detach a post process to the camera.
  26383. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26384. * @param postProcess The post process to detach from the camera
  26385. */
  26386. detachPostProcess(postProcess: PostProcess): void;
  26387. /**
  26388. * Gets the current world matrix of the camera
  26389. */
  26390. getWorldMatrix(): Matrix;
  26391. /** @hidden */
  26392. _getViewMatrix(): Matrix;
  26393. /**
  26394. * Gets the current view matrix of the camera.
  26395. * @param force forces the camera to recompute the matrix without looking at the cached state
  26396. * @returns the view matrix
  26397. */
  26398. getViewMatrix(force?: boolean): Matrix;
  26399. /**
  26400. * Freeze the projection matrix.
  26401. * It will prevent the cache check of the camera projection compute and can speed up perf
  26402. * if no parameter of the camera are meant to change
  26403. * @param projection Defines manually a projection if necessary
  26404. */
  26405. freezeProjectionMatrix(projection?: Matrix): void;
  26406. /**
  26407. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26408. */
  26409. unfreezeProjectionMatrix(): void;
  26410. /**
  26411. * Gets the current projection matrix of the camera.
  26412. * @param force forces the camera to recompute the matrix without looking at the cached state
  26413. * @returns the projection matrix
  26414. */
  26415. getProjectionMatrix(force?: boolean): Matrix;
  26416. /**
  26417. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26418. * @returns a Matrix
  26419. */
  26420. getTransformationMatrix(): Matrix;
  26421. private _updateFrustumPlanes;
  26422. /**
  26423. * Checks if a cullable object (mesh...) is in the camera frustum
  26424. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26425. * @param target The object to check
  26426. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26427. * @returns true if the object is in frustum otherwise false
  26428. */
  26429. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26430. /**
  26431. * Checks if a cullable object (mesh...) is in the camera frustum
  26432. * Unlike isInFrustum this cheks the full bounding box
  26433. * @param target The object to check
  26434. * @returns true if the object is in frustum otherwise false
  26435. */
  26436. isCompletelyInFrustum(target: ICullable): boolean;
  26437. /**
  26438. * Gets a ray in the forward direction from the camera.
  26439. * @param length Defines the length of the ray to create
  26440. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26441. * @param origin Defines the start point of the ray which defaults to the camera position
  26442. * @returns the forward ray
  26443. */
  26444. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26445. /**
  26446. * Releases resources associated with this node.
  26447. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26448. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26449. */
  26450. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26451. /** @hidden */
  26452. _isLeftCamera: boolean;
  26453. /**
  26454. * Gets the left camera of a rig setup in case of Rigged Camera
  26455. */
  26456. get isLeftCamera(): boolean;
  26457. /** @hidden */
  26458. _isRightCamera: boolean;
  26459. /**
  26460. * Gets the right camera of a rig setup in case of Rigged Camera
  26461. */
  26462. get isRightCamera(): boolean;
  26463. /**
  26464. * Gets the left camera of a rig setup in case of Rigged Camera
  26465. */
  26466. get leftCamera(): Nullable<FreeCamera>;
  26467. /**
  26468. * Gets the right camera of a rig setup in case of Rigged Camera
  26469. */
  26470. get rightCamera(): Nullable<FreeCamera>;
  26471. /**
  26472. * Gets the left camera target of a rig setup in case of Rigged Camera
  26473. * @returns the target position
  26474. */
  26475. getLeftTarget(): Nullable<Vector3>;
  26476. /**
  26477. * Gets the right camera target of a rig setup in case of Rigged Camera
  26478. * @returns the target position
  26479. */
  26480. getRightTarget(): Nullable<Vector3>;
  26481. /**
  26482. * @hidden
  26483. */
  26484. setCameraRigMode(mode: number, rigParams: any): void;
  26485. /** @hidden */
  26486. static _setStereoscopicRigMode(camera: Camera): void;
  26487. /** @hidden */
  26488. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26489. /** @hidden */
  26490. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26491. /** @hidden */
  26492. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26493. /** @hidden */
  26494. _getVRProjectionMatrix(): Matrix;
  26495. protected _updateCameraRotationMatrix(): void;
  26496. protected _updateWebVRCameraRotationMatrix(): void;
  26497. /**
  26498. * This function MUST be overwritten by the different WebVR cameras available.
  26499. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26500. * @hidden
  26501. */
  26502. _getWebVRProjectionMatrix(): Matrix;
  26503. /**
  26504. * This function MUST be overwritten by the different WebVR cameras available.
  26505. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26506. * @hidden
  26507. */
  26508. _getWebVRViewMatrix(): Matrix;
  26509. /** @hidden */
  26510. setCameraRigParameter(name: string, value: any): void;
  26511. /**
  26512. * needs to be overridden by children so sub has required properties to be copied
  26513. * @hidden
  26514. */
  26515. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26516. /**
  26517. * May need to be overridden by children
  26518. * @hidden
  26519. */
  26520. _updateRigCameras(): void;
  26521. /** @hidden */
  26522. _setupInputs(): void;
  26523. /**
  26524. * Serialiaze the camera setup to a json represention
  26525. * @returns the JSON representation
  26526. */
  26527. serialize(): any;
  26528. /**
  26529. * Clones the current camera.
  26530. * @param name The cloned camera name
  26531. * @returns the cloned camera
  26532. */
  26533. clone(name: string): Camera;
  26534. /**
  26535. * Gets the direction of the camera relative to a given local axis.
  26536. * @param localAxis Defines the reference axis to provide a relative direction.
  26537. * @return the direction
  26538. */
  26539. getDirection(localAxis: Vector3): Vector3;
  26540. /**
  26541. * Returns the current camera absolute rotation
  26542. */
  26543. get absoluteRotation(): Quaternion;
  26544. /**
  26545. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26546. * @param localAxis Defines the reference axis to provide a relative direction.
  26547. * @param result Defines the vector to store the result in
  26548. */
  26549. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26550. /**
  26551. * Gets a camera constructor for a given camera type
  26552. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26553. * @param name The name of the camera the result will be able to instantiate
  26554. * @param scene The scene the result will construct the camera in
  26555. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26556. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26557. * @returns a factory method to construc the camera
  26558. */
  26559. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26560. /**
  26561. * Compute the world matrix of the camera.
  26562. * @returns the camera world matrix
  26563. */
  26564. computeWorldMatrix(): Matrix;
  26565. /**
  26566. * Parse a JSON and creates the camera from the parsed information
  26567. * @param parsedCamera The JSON to parse
  26568. * @param scene The scene to instantiate the camera in
  26569. * @returns the newly constructed camera
  26570. */
  26571. static Parse(parsedCamera: any, scene: Scene): Camera;
  26572. }
  26573. }
  26574. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26575. import { Nullable } from "babylonjs/types";
  26576. import { Scene } from "babylonjs/scene";
  26577. import { Vector4 } from "babylonjs/Maths/math.vector";
  26578. import { Mesh } from "babylonjs/Meshes/mesh";
  26579. /**
  26580. * Class containing static functions to help procedurally build meshes
  26581. */
  26582. export class DiscBuilder {
  26583. /**
  26584. * Creates a plane polygonal mesh. By default, this is a disc
  26585. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26586. * * 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
  26587. * * 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
  26588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26591. * @param name defines the name of the mesh
  26592. * @param options defines the options used to create the mesh
  26593. * @param scene defines the hosting scene
  26594. * @returns the plane polygonal mesh
  26595. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26596. */
  26597. static CreateDisc(name: string, options: {
  26598. radius?: number;
  26599. tessellation?: number;
  26600. arc?: number;
  26601. updatable?: boolean;
  26602. sideOrientation?: number;
  26603. frontUVs?: Vector4;
  26604. backUVs?: Vector4;
  26605. }, scene?: Nullable<Scene>): Mesh;
  26606. }
  26607. }
  26608. declare module "babylonjs/Materials/fresnelParameters" {
  26609. import { Color3 } from "babylonjs/Maths/math.color";
  26610. /**
  26611. * This represents all the required information to add a fresnel effect on a material:
  26612. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26613. */
  26614. export class FresnelParameters {
  26615. private _isEnabled;
  26616. /**
  26617. * Define if the fresnel effect is enable or not.
  26618. */
  26619. get isEnabled(): boolean;
  26620. set isEnabled(value: boolean);
  26621. /**
  26622. * Define the color used on edges (grazing angle)
  26623. */
  26624. leftColor: Color3;
  26625. /**
  26626. * Define the color used on center
  26627. */
  26628. rightColor: Color3;
  26629. /**
  26630. * Define bias applied to computed fresnel term
  26631. */
  26632. bias: number;
  26633. /**
  26634. * Defined the power exponent applied to fresnel term
  26635. */
  26636. power: number;
  26637. /**
  26638. * Clones the current fresnel and its valuues
  26639. * @returns a clone fresnel configuration
  26640. */
  26641. clone(): FresnelParameters;
  26642. /**
  26643. * Serializes the current fresnel parameters to a JSON representation.
  26644. * @return the JSON serialization
  26645. */
  26646. serialize(): any;
  26647. /**
  26648. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26649. * @param parsedFresnelParameters Define the JSON representation
  26650. * @returns the parsed parameters
  26651. */
  26652. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26653. }
  26654. }
  26655. declare module "babylonjs/Materials/pushMaterial" {
  26656. import { Nullable } from "babylonjs/types";
  26657. import { Scene } from "babylonjs/scene";
  26658. import { Matrix } from "babylonjs/Maths/math.vector";
  26659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26660. import { Mesh } from "babylonjs/Meshes/mesh";
  26661. import { Material } from "babylonjs/Materials/material";
  26662. import { Effect } from "babylonjs/Materials/effect";
  26663. /**
  26664. * Base class of materials working in push mode in babylon JS
  26665. * @hidden
  26666. */
  26667. export class PushMaterial extends Material {
  26668. protected _activeEffect: Effect;
  26669. protected _normalMatrix: Matrix;
  26670. /**
  26671. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26672. * This means that the material can keep using a previous shader while a new one is being compiled.
  26673. * This is mostly used when shader parallel compilation is supported (true by default)
  26674. */
  26675. allowShaderHotSwapping: boolean;
  26676. constructor(name: string, scene: Scene);
  26677. getEffect(): Effect;
  26678. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26679. /**
  26680. * Binds the given world matrix to the active effect
  26681. *
  26682. * @param world the matrix to bind
  26683. */
  26684. bindOnlyWorldMatrix(world: Matrix): void;
  26685. /**
  26686. * Binds the given normal matrix to the active effect
  26687. *
  26688. * @param normalMatrix the matrix to bind
  26689. */
  26690. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26691. bind(world: Matrix, mesh?: Mesh): void;
  26692. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26693. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26694. }
  26695. }
  26696. declare module "babylonjs/Materials/materialFlags" {
  26697. /**
  26698. * This groups all the flags used to control the materials channel.
  26699. */
  26700. export class MaterialFlags {
  26701. private static _DiffuseTextureEnabled;
  26702. /**
  26703. * Are diffuse textures enabled in the application.
  26704. */
  26705. static get DiffuseTextureEnabled(): boolean;
  26706. static set DiffuseTextureEnabled(value: boolean);
  26707. private static _AmbientTextureEnabled;
  26708. /**
  26709. * Are ambient textures enabled in the application.
  26710. */
  26711. static get AmbientTextureEnabled(): boolean;
  26712. static set AmbientTextureEnabled(value: boolean);
  26713. private static _OpacityTextureEnabled;
  26714. /**
  26715. * Are opacity textures enabled in the application.
  26716. */
  26717. static get OpacityTextureEnabled(): boolean;
  26718. static set OpacityTextureEnabled(value: boolean);
  26719. private static _ReflectionTextureEnabled;
  26720. /**
  26721. * Are reflection textures enabled in the application.
  26722. */
  26723. static get ReflectionTextureEnabled(): boolean;
  26724. static set ReflectionTextureEnabled(value: boolean);
  26725. private static _EmissiveTextureEnabled;
  26726. /**
  26727. * Are emissive textures enabled in the application.
  26728. */
  26729. static get EmissiveTextureEnabled(): boolean;
  26730. static set EmissiveTextureEnabled(value: boolean);
  26731. private static _SpecularTextureEnabled;
  26732. /**
  26733. * Are specular textures enabled in the application.
  26734. */
  26735. static get SpecularTextureEnabled(): boolean;
  26736. static set SpecularTextureEnabled(value: boolean);
  26737. private static _BumpTextureEnabled;
  26738. /**
  26739. * Are bump textures enabled in the application.
  26740. */
  26741. static get BumpTextureEnabled(): boolean;
  26742. static set BumpTextureEnabled(value: boolean);
  26743. private static _LightmapTextureEnabled;
  26744. /**
  26745. * Are lightmap textures enabled in the application.
  26746. */
  26747. static get LightmapTextureEnabled(): boolean;
  26748. static set LightmapTextureEnabled(value: boolean);
  26749. private static _RefractionTextureEnabled;
  26750. /**
  26751. * Are refraction textures enabled in the application.
  26752. */
  26753. static get RefractionTextureEnabled(): boolean;
  26754. static set RefractionTextureEnabled(value: boolean);
  26755. private static _ColorGradingTextureEnabled;
  26756. /**
  26757. * Are color grading textures enabled in the application.
  26758. */
  26759. static get ColorGradingTextureEnabled(): boolean;
  26760. static set ColorGradingTextureEnabled(value: boolean);
  26761. private static _FresnelEnabled;
  26762. /**
  26763. * Are fresnels enabled in the application.
  26764. */
  26765. static get FresnelEnabled(): boolean;
  26766. static set FresnelEnabled(value: boolean);
  26767. private static _ClearCoatTextureEnabled;
  26768. /**
  26769. * Are clear coat textures enabled in the application.
  26770. */
  26771. static get ClearCoatTextureEnabled(): boolean;
  26772. static set ClearCoatTextureEnabled(value: boolean);
  26773. private static _ClearCoatBumpTextureEnabled;
  26774. /**
  26775. * Are clear coat bump textures enabled in the application.
  26776. */
  26777. static get ClearCoatBumpTextureEnabled(): boolean;
  26778. static set ClearCoatBumpTextureEnabled(value: boolean);
  26779. private static _ClearCoatTintTextureEnabled;
  26780. /**
  26781. * Are clear coat tint textures enabled in the application.
  26782. */
  26783. static get ClearCoatTintTextureEnabled(): boolean;
  26784. static set ClearCoatTintTextureEnabled(value: boolean);
  26785. private static _SheenTextureEnabled;
  26786. /**
  26787. * Are sheen textures enabled in the application.
  26788. */
  26789. static get SheenTextureEnabled(): boolean;
  26790. static set SheenTextureEnabled(value: boolean);
  26791. private static _AnisotropicTextureEnabled;
  26792. /**
  26793. * Are anisotropic textures enabled in the application.
  26794. */
  26795. static get AnisotropicTextureEnabled(): boolean;
  26796. static set AnisotropicTextureEnabled(value: boolean);
  26797. private static _ThicknessTextureEnabled;
  26798. /**
  26799. * Are thickness textures enabled in the application.
  26800. */
  26801. static get ThicknessTextureEnabled(): boolean;
  26802. static set ThicknessTextureEnabled(value: boolean);
  26803. }
  26804. }
  26805. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26806. /** @hidden */
  26807. export var defaultFragmentDeclaration: {
  26808. name: string;
  26809. shader: string;
  26810. };
  26811. }
  26812. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26813. /** @hidden */
  26814. export var defaultUboDeclaration: {
  26815. name: string;
  26816. shader: string;
  26817. };
  26818. }
  26819. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26820. /** @hidden */
  26821. export var lightFragmentDeclaration: {
  26822. name: string;
  26823. shader: string;
  26824. };
  26825. }
  26826. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26827. /** @hidden */
  26828. export var lightUboDeclaration: {
  26829. name: string;
  26830. shader: string;
  26831. };
  26832. }
  26833. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26834. /** @hidden */
  26835. export var lightsFragmentFunctions: {
  26836. name: string;
  26837. shader: string;
  26838. };
  26839. }
  26840. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26841. /** @hidden */
  26842. export var shadowsFragmentFunctions: {
  26843. name: string;
  26844. shader: string;
  26845. };
  26846. }
  26847. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26848. /** @hidden */
  26849. export var fresnelFunction: {
  26850. name: string;
  26851. shader: string;
  26852. };
  26853. }
  26854. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26855. /** @hidden */
  26856. export var reflectionFunction: {
  26857. name: string;
  26858. shader: string;
  26859. };
  26860. }
  26861. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26862. /** @hidden */
  26863. export var bumpFragmentFunctions: {
  26864. name: string;
  26865. shader: string;
  26866. };
  26867. }
  26868. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26869. /** @hidden */
  26870. export var logDepthDeclaration: {
  26871. name: string;
  26872. shader: string;
  26873. };
  26874. }
  26875. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26876. /** @hidden */
  26877. export var bumpFragment: {
  26878. name: string;
  26879. shader: string;
  26880. };
  26881. }
  26882. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26883. /** @hidden */
  26884. export var depthPrePass: {
  26885. name: string;
  26886. shader: string;
  26887. };
  26888. }
  26889. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26890. /** @hidden */
  26891. export var lightFragment: {
  26892. name: string;
  26893. shader: string;
  26894. };
  26895. }
  26896. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26897. /** @hidden */
  26898. export var logDepthFragment: {
  26899. name: string;
  26900. shader: string;
  26901. };
  26902. }
  26903. declare module "babylonjs/Shaders/default.fragment" {
  26904. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26905. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26906. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26907. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26908. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26909. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26910. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26911. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26912. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26913. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26914. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26915. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26916. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26917. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26918. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26919. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26920. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26921. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26922. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26923. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26924. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26925. /** @hidden */
  26926. export var defaultPixelShader: {
  26927. name: string;
  26928. shader: string;
  26929. };
  26930. }
  26931. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26932. /** @hidden */
  26933. export var defaultVertexDeclaration: {
  26934. name: string;
  26935. shader: string;
  26936. };
  26937. }
  26938. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26939. /** @hidden */
  26940. export var bumpVertexDeclaration: {
  26941. name: string;
  26942. shader: string;
  26943. };
  26944. }
  26945. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26946. /** @hidden */
  26947. export var bumpVertex: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26953. /** @hidden */
  26954. export var fogVertex: {
  26955. name: string;
  26956. shader: string;
  26957. };
  26958. }
  26959. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26960. /** @hidden */
  26961. export var shadowsVertex: {
  26962. name: string;
  26963. shader: string;
  26964. };
  26965. }
  26966. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26967. /** @hidden */
  26968. export var pointCloudVertex: {
  26969. name: string;
  26970. shader: string;
  26971. };
  26972. }
  26973. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26974. /** @hidden */
  26975. export var logDepthVertex: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Shaders/default.vertex" {
  26981. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26982. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26983. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26984. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26985. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26986. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26987. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26988. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26989. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26990. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26992. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26993. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26995. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26996. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26997. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26998. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26999. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27000. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27001. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27002. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27003. /** @hidden */
  27004. export var defaultVertexShader: {
  27005. name: string;
  27006. shader: string;
  27007. };
  27008. }
  27009. declare module "babylonjs/Materials/standardMaterial" {
  27010. import { SmartArray } from "babylonjs/Misc/smartArray";
  27011. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27012. import { Nullable } from "babylonjs/types";
  27013. import { Scene } from "babylonjs/scene";
  27014. import { Matrix } from "babylonjs/Maths/math.vector";
  27015. import { Color3 } from "babylonjs/Maths/math.color";
  27016. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27018. import { Mesh } from "babylonjs/Meshes/mesh";
  27019. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27020. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27021. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27022. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27023. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27026. import "babylonjs/Shaders/default.fragment";
  27027. import "babylonjs/Shaders/default.vertex";
  27028. /** @hidden */
  27029. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27030. MAINUV1: boolean;
  27031. MAINUV2: boolean;
  27032. DIFFUSE: boolean;
  27033. DIFFUSEDIRECTUV: number;
  27034. AMBIENT: boolean;
  27035. AMBIENTDIRECTUV: number;
  27036. OPACITY: boolean;
  27037. OPACITYDIRECTUV: number;
  27038. OPACITYRGB: boolean;
  27039. REFLECTION: boolean;
  27040. EMISSIVE: boolean;
  27041. EMISSIVEDIRECTUV: number;
  27042. SPECULAR: boolean;
  27043. SPECULARDIRECTUV: number;
  27044. BUMP: boolean;
  27045. BUMPDIRECTUV: number;
  27046. PARALLAX: boolean;
  27047. PARALLAXOCCLUSION: boolean;
  27048. SPECULAROVERALPHA: boolean;
  27049. CLIPPLANE: boolean;
  27050. CLIPPLANE2: boolean;
  27051. CLIPPLANE3: boolean;
  27052. CLIPPLANE4: boolean;
  27053. CLIPPLANE5: boolean;
  27054. CLIPPLANE6: boolean;
  27055. ALPHATEST: boolean;
  27056. DEPTHPREPASS: boolean;
  27057. ALPHAFROMDIFFUSE: boolean;
  27058. POINTSIZE: boolean;
  27059. FOG: boolean;
  27060. SPECULARTERM: boolean;
  27061. DIFFUSEFRESNEL: boolean;
  27062. OPACITYFRESNEL: boolean;
  27063. REFLECTIONFRESNEL: boolean;
  27064. REFRACTIONFRESNEL: boolean;
  27065. EMISSIVEFRESNEL: boolean;
  27066. FRESNEL: boolean;
  27067. NORMAL: boolean;
  27068. UV1: boolean;
  27069. UV2: boolean;
  27070. VERTEXCOLOR: boolean;
  27071. VERTEXALPHA: boolean;
  27072. NUM_BONE_INFLUENCERS: number;
  27073. BonesPerMesh: number;
  27074. BONETEXTURE: boolean;
  27075. INSTANCES: boolean;
  27076. GLOSSINESS: boolean;
  27077. ROUGHNESS: boolean;
  27078. EMISSIVEASILLUMINATION: boolean;
  27079. LINKEMISSIVEWITHDIFFUSE: boolean;
  27080. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27081. LIGHTMAP: boolean;
  27082. LIGHTMAPDIRECTUV: number;
  27083. OBJECTSPACE_NORMALMAP: boolean;
  27084. USELIGHTMAPASSHADOWMAP: boolean;
  27085. REFLECTIONMAP_3D: boolean;
  27086. REFLECTIONMAP_SPHERICAL: boolean;
  27087. REFLECTIONMAP_PLANAR: boolean;
  27088. REFLECTIONMAP_CUBIC: boolean;
  27089. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27090. REFLECTIONMAP_PROJECTION: boolean;
  27091. REFLECTIONMAP_SKYBOX: boolean;
  27092. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27093. REFLECTIONMAP_EXPLICIT: boolean;
  27094. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27095. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27096. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27097. INVERTCUBICMAP: boolean;
  27098. LOGARITHMICDEPTH: boolean;
  27099. REFRACTION: boolean;
  27100. REFRACTIONMAP_3D: boolean;
  27101. REFLECTIONOVERALPHA: boolean;
  27102. TWOSIDEDLIGHTING: boolean;
  27103. SHADOWFLOAT: boolean;
  27104. MORPHTARGETS: boolean;
  27105. MORPHTARGETS_NORMAL: boolean;
  27106. MORPHTARGETS_TANGENT: boolean;
  27107. MORPHTARGETS_UV: boolean;
  27108. NUM_MORPH_INFLUENCERS: number;
  27109. NONUNIFORMSCALING: boolean;
  27110. PREMULTIPLYALPHA: boolean;
  27111. IMAGEPROCESSING: boolean;
  27112. VIGNETTE: boolean;
  27113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27114. VIGNETTEBLENDMODEOPAQUE: boolean;
  27115. TONEMAPPING: boolean;
  27116. TONEMAPPING_ACES: boolean;
  27117. CONTRAST: boolean;
  27118. COLORCURVES: boolean;
  27119. COLORGRADING: boolean;
  27120. COLORGRADING3D: boolean;
  27121. SAMPLER3DGREENDEPTH: boolean;
  27122. SAMPLER3DBGRMAP: boolean;
  27123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27124. MULTIVIEW: boolean;
  27125. /**
  27126. * If the reflection texture on this material is in linear color space
  27127. * @hidden
  27128. */
  27129. IS_REFLECTION_LINEAR: boolean;
  27130. /**
  27131. * If the refraction texture on this material is in linear color space
  27132. * @hidden
  27133. */
  27134. IS_REFRACTION_LINEAR: boolean;
  27135. EXPOSURE: boolean;
  27136. constructor();
  27137. setReflectionMode(modeToEnable: string): void;
  27138. }
  27139. /**
  27140. * This is the default material used in Babylon. It is the best trade off between quality
  27141. * and performances.
  27142. * @see http://doc.babylonjs.com/babylon101/materials
  27143. */
  27144. export class StandardMaterial extends PushMaterial {
  27145. private _diffuseTexture;
  27146. /**
  27147. * The basic texture of the material as viewed under a light.
  27148. */
  27149. diffuseTexture: Nullable<BaseTexture>;
  27150. private _ambientTexture;
  27151. /**
  27152. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27153. */
  27154. ambientTexture: Nullable<BaseTexture>;
  27155. private _opacityTexture;
  27156. /**
  27157. * Define the transparency of the material from a texture.
  27158. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27159. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27160. */
  27161. opacityTexture: Nullable<BaseTexture>;
  27162. private _reflectionTexture;
  27163. /**
  27164. * Define the texture used to display the reflection.
  27165. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27166. */
  27167. reflectionTexture: Nullable<BaseTexture>;
  27168. private _emissiveTexture;
  27169. /**
  27170. * Define texture of the material as if self lit.
  27171. * This will be mixed in the final result even in the absence of light.
  27172. */
  27173. emissiveTexture: Nullable<BaseTexture>;
  27174. private _specularTexture;
  27175. /**
  27176. * Define how the color and intensity of the highlight given by the light in the material.
  27177. */
  27178. specularTexture: Nullable<BaseTexture>;
  27179. private _bumpTexture;
  27180. /**
  27181. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27182. * 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.
  27183. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27184. */
  27185. bumpTexture: Nullable<BaseTexture>;
  27186. private _lightmapTexture;
  27187. /**
  27188. * Complex lighting can be computationally expensive to compute at runtime.
  27189. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27190. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27191. */
  27192. lightmapTexture: Nullable<BaseTexture>;
  27193. private _refractionTexture;
  27194. /**
  27195. * Define the texture used to display the refraction.
  27196. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27197. */
  27198. refractionTexture: Nullable<BaseTexture>;
  27199. /**
  27200. * The color of the material lit by the environmental background lighting.
  27201. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27202. */
  27203. ambientColor: Color3;
  27204. /**
  27205. * The basic color of the material as viewed under a light.
  27206. */
  27207. diffuseColor: Color3;
  27208. /**
  27209. * Define how the color and intensity of the highlight given by the light in the material.
  27210. */
  27211. specularColor: Color3;
  27212. /**
  27213. * Define the color of the material as if self lit.
  27214. * This will be mixed in the final result even in the absence of light.
  27215. */
  27216. emissiveColor: Color3;
  27217. /**
  27218. * Defines how sharp are the highlights in the material.
  27219. * The bigger the value the sharper giving a more glossy feeling to the result.
  27220. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27221. */
  27222. specularPower: number;
  27223. private _useAlphaFromDiffuseTexture;
  27224. /**
  27225. * Does the transparency come from the diffuse texture alpha channel.
  27226. */
  27227. useAlphaFromDiffuseTexture: boolean;
  27228. private _useEmissiveAsIllumination;
  27229. /**
  27230. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27231. */
  27232. useEmissiveAsIllumination: boolean;
  27233. private _linkEmissiveWithDiffuse;
  27234. /**
  27235. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27236. * the emissive level when the final color is close to one.
  27237. */
  27238. linkEmissiveWithDiffuse: boolean;
  27239. private _useSpecularOverAlpha;
  27240. /**
  27241. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27242. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27243. */
  27244. useSpecularOverAlpha: boolean;
  27245. private _useReflectionOverAlpha;
  27246. /**
  27247. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27248. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27249. */
  27250. useReflectionOverAlpha: boolean;
  27251. private _disableLighting;
  27252. /**
  27253. * Does lights from the scene impacts this material.
  27254. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27255. */
  27256. disableLighting: boolean;
  27257. private _useObjectSpaceNormalMap;
  27258. /**
  27259. * Allows using an object space normal map (instead of tangent space).
  27260. */
  27261. useObjectSpaceNormalMap: boolean;
  27262. private _useParallax;
  27263. /**
  27264. * Is parallax enabled or not.
  27265. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27266. */
  27267. useParallax: boolean;
  27268. private _useParallaxOcclusion;
  27269. /**
  27270. * Is parallax occlusion enabled or not.
  27271. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27272. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27273. */
  27274. useParallaxOcclusion: boolean;
  27275. /**
  27276. * 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.
  27277. */
  27278. parallaxScaleBias: number;
  27279. private _roughness;
  27280. /**
  27281. * Helps to define how blurry the reflections should appears in the material.
  27282. */
  27283. roughness: number;
  27284. /**
  27285. * In case of refraction, define the value of the index of refraction.
  27286. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27287. */
  27288. indexOfRefraction: number;
  27289. /**
  27290. * Invert the refraction texture alongside the y axis.
  27291. * It can be useful with procedural textures or probe for instance.
  27292. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27293. */
  27294. invertRefractionY: boolean;
  27295. /**
  27296. * Defines the alpha limits in alpha test mode.
  27297. */
  27298. alphaCutOff: number;
  27299. private _useLightmapAsShadowmap;
  27300. /**
  27301. * In case of light mapping, define whether the map contains light or shadow informations.
  27302. */
  27303. useLightmapAsShadowmap: boolean;
  27304. private _diffuseFresnelParameters;
  27305. /**
  27306. * Define the diffuse fresnel parameters of the material.
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27308. */
  27309. diffuseFresnelParameters: FresnelParameters;
  27310. private _opacityFresnelParameters;
  27311. /**
  27312. * Define the opacity fresnel parameters of the material.
  27313. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27314. */
  27315. opacityFresnelParameters: FresnelParameters;
  27316. private _reflectionFresnelParameters;
  27317. /**
  27318. * Define the reflection fresnel parameters of the material.
  27319. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27320. */
  27321. reflectionFresnelParameters: FresnelParameters;
  27322. private _refractionFresnelParameters;
  27323. /**
  27324. * Define the refraction fresnel parameters of the material.
  27325. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27326. */
  27327. refractionFresnelParameters: FresnelParameters;
  27328. private _emissiveFresnelParameters;
  27329. /**
  27330. * Define the emissive fresnel parameters of the material.
  27331. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27332. */
  27333. emissiveFresnelParameters: FresnelParameters;
  27334. private _useReflectionFresnelFromSpecular;
  27335. /**
  27336. * If true automatically deducts the fresnels values from the material specularity.
  27337. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27338. */
  27339. useReflectionFresnelFromSpecular: boolean;
  27340. private _useGlossinessFromSpecularMapAlpha;
  27341. /**
  27342. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27343. */
  27344. useGlossinessFromSpecularMapAlpha: boolean;
  27345. private _maxSimultaneousLights;
  27346. /**
  27347. * Defines the maximum number of lights that can be used in the material
  27348. */
  27349. maxSimultaneousLights: number;
  27350. private _invertNormalMapX;
  27351. /**
  27352. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27353. */
  27354. invertNormalMapX: boolean;
  27355. private _invertNormalMapY;
  27356. /**
  27357. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27358. */
  27359. invertNormalMapY: boolean;
  27360. private _twoSidedLighting;
  27361. /**
  27362. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27363. */
  27364. twoSidedLighting: boolean;
  27365. /**
  27366. * Default configuration related to image processing available in the standard Material.
  27367. */
  27368. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27369. /**
  27370. * Gets the image processing configuration used either in this material.
  27371. */
  27372. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27373. /**
  27374. * Sets the Default image processing configuration used either in the this material.
  27375. *
  27376. * If sets to null, the scene one is in use.
  27377. */
  27378. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27379. /**
  27380. * Keep track of the image processing observer to allow dispose and replace.
  27381. */
  27382. private _imageProcessingObserver;
  27383. /**
  27384. * Attaches a new image processing configuration to the Standard Material.
  27385. * @param configuration
  27386. */
  27387. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27388. /**
  27389. * Gets wether the color curves effect is enabled.
  27390. */
  27391. get cameraColorCurvesEnabled(): boolean;
  27392. /**
  27393. * Sets wether the color curves effect is enabled.
  27394. */
  27395. set cameraColorCurvesEnabled(value: boolean);
  27396. /**
  27397. * Gets wether the color grading effect is enabled.
  27398. */
  27399. get cameraColorGradingEnabled(): boolean;
  27400. /**
  27401. * Gets wether the color grading effect is enabled.
  27402. */
  27403. set cameraColorGradingEnabled(value: boolean);
  27404. /**
  27405. * Gets wether tonemapping is enabled or not.
  27406. */
  27407. get cameraToneMappingEnabled(): boolean;
  27408. /**
  27409. * Sets wether tonemapping is enabled or not
  27410. */
  27411. set cameraToneMappingEnabled(value: boolean);
  27412. /**
  27413. * The camera exposure used on this material.
  27414. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27415. * This corresponds to a photographic exposure.
  27416. */
  27417. get cameraExposure(): number;
  27418. /**
  27419. * The camera exposure used on this material.
  27420. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27421. * This corresponds to a photographic exposure.
  27422. */
  27423. set cameraExposure(value: number);
  27424. /**
  27425. * Gets The camera contrast used on this material.
  27426. */
  27427. get cameraContrast(): number;
  27428. /**
  27429. * Sets The camera contrast used on this material.
  27430. */
  27431. set cameraContrast(value: number);
  27432. /**
  27433. * Gets the Color Grading 2D Lookup Texture.
  27434. */
  27435. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27436. /**
  27437. * Sets the Color Grading 2D Lookup Texture.
  27438. */
  27439. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27440. /**
  27441. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27442. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27443. * 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;
  27444. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27445. */
  27446. get cameraColorCurves(): Nullable<ColorCurves>;
  27447. /**
  27448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27450. * 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;
  27451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27452. */
  27453. set cameraColorCurves(value: Nullable<ColorCurves>);
  27454. /**
  27455. * Custom callback helping to override the default shader used in the material.
  27456. */
  27457. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27458. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27459. protected _worldViewProjectionMatrix: Matrix;
  27460. protected _globalAmbientColor: Color3;
  27461. protected _useLogarithmicDepth: boolean;
  27462. protected _rebuildInParallel: boolean;
  27463. /**
  27464. * Instantiates a new standard material.
  27465. * This is the default material used in Babylon. It is the best trade off between quality
  27466. * and performances.
  27467. * @see http://doc.babylonjs.com/babylon101/materials
  27468. * @param name Define the name of the material in the scene
  27469. * @param scene Define the scene the material belong to
  27470. */
  27471. constructor(name: string, scene: Scene);
  27472. /**
  27473. * Gets a boolean indicating that current material needs to register RTT
  27474. */
  27475. get hasRenderTargetTextures(): boolean;
  27476. /**
  27477. * Gets the current class name of the material e.g. "StandardMaterial"
  27478. * Mainly use in serialization.
  27479. * @returns the class name
  27480. */
  27481. getClassName(): string;
  27482. /**
  27483. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27484. * You can try switching to logarithmic depth.
  27485. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27486. */
  27487. get useLogarithmicDepth(): boolean;
  27488. set useLogarithmicDepth(value: boolean);
  27489. /**
  27490. * Specifies if the material will require alpha blending
  27491. * @returns a boolean specifying if alpha blending is needed
  27492. */
  27493. needAlphaBlending(): boolean;
  27494. /**
  27495. * Specifies if this material should be rendered in alpha test mode
  27496. * @returns a boolean specifying if an alpha test is needed.
  27497. */
  27498. needAlphaTesting(): boolean;
  27499. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27500. /**
  27501. * Get the texture used for alpha test purpose.
  27502. * @returns the diffuse texture in case of the standard material.
  27503. */
  27504. getAlphaTestTexture(): Nullable<BaseTexture>;
  27505. /**
  27506. * Get if the submesh is ready to be used and all its information available.
  27507. * Child classes can use it to update shaders
  27508. * @param mesh defines the mesh to check
  27509. * @param subMesh defines which submesh to check
  27510. * @param useInstances specifies that instances should be used
  27511. * @returns a boolean indicating that the submesh is ready or not
  27512. */
  27513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27514. /**
  27515. * Builds the material UBO layouts.
  27516. * Used internally during the effect preparation.
  27517. */
  27518. buildUniformLayout(): void;
  27519. /**
  27520. * Unbinds the material from the mesh
  27521. */
  27522. unbind(): void;
  27523. /**
  27524. * Binds the submesh to this material by preparing the effect and shader to draw
  27525. * @param world defines the world transformation matrix
  27526. * @param mesh defines the mesh containing the submesh
  27527. * @param subMesh defines the submesh to bind the material to
  27528. */
  27529. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27530. /**
  27531. * Get the list of animatables in the material.
  27532. * @returns the list of animatables object used in the material
  27533. */
  27534. getAnimatables(): IAnimatable[];
  27535. /**
  27536. * Gets the active textures from the material
  27537. * @returns an array of textures
  27538. */
  27539. getActiveTextures(): BaseTexture[];
  27540. /**
  27541. * Specifies if the material uses a texture
  27542. * @param texture defines the texture to check against the material
  27543. * @returns a boolean specifying if the material uses the texture
  27544. */
  27545. hasTexture(texture: BaseTexture): boolean;
  27546. /**
  27547. * Disposes the material
  27548. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27549. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27550. */
  27551. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27552. /**
  27553. * Makes a duplicate of the material, and gives it a new name
  27554. * @param name defines the new name for the duplicated material
  27555. * @returns the cloned material
  27556. */
  27557. clone(name: string): StandardMaterial;
  27558. /**
  27559. * Serializes this material in a JSON representation
  27560. * @returns the serialized material object
  27561. */
  27562. serialize(): any;
  27563. /**
  27564. * Creates a standard material from parsed material data
  27565. * @param source defines the JSON representation of the material
  27566. * @param scene defines the hosting scene
  27567. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27568. * @returns a new standard material
  27569. */
  27570. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27571. /**
  27572. * Are diffuse textures enabled in the application.
  27573. */
  27574. static get DiffuseTextureEnabled(): boolean;
  27575. static set DiffuseTextureEnabled(value: boolean);
  27576. /**
  27577. * Are ambient textures enabled in the application.
  27578. */
  27579. static get AmbientTextureEnabled(): boolean;
  27580. static set AmbientTextureEnabled(value: boolean);
  27581. /**
  27582. * Are opacity textures enabled in the application.
  27583. */
  27584. static get OpacityTextureEnabled(): boolean;
  27585. static set OpacityTextureEnabled(value: boolean);
  27586. /**
  27587. * Are reflection textures enabled in the application.
  27588. */
  27589. static get ReflectionTextureEnabled(): boolean;
  27590. static set ReflectionTextureEnabled(value: boolean);
  27591. /**
  27592. * Are emissive textures enabled in the application.
  27593. */
  27594. static get EmissiveTextureEnabled(): boolean;
  27595. static set EmissiveTextureEnabled(value: boolean);
  27596. /**
  27597. * Are specular textures enabled in the application.
  27598. */
  27599. static get SpecularTextureEnabled(): boolean;
  27600. static set SpecularTextureEnabled(value: boolean);
  27601. /**
  27602. * Are bump textures enabled in the application.
  27603. */
  27604. static get BumpTextureEnabled(): boolean;
  27605. static set BumpTextureEnabled(value: boolean);
  27606. /**
  27607. * Are lightmap textures enabled in the application.
  27608. */
  27609. static get LightmapTextureEnabled(): boolean;
  27610. static set LightmapTextureEnabled(value: boolean);
  27611. /**
  27612. * Are refraction textures enabled in the application.
  27613. */
  27614. static get RefractionTextureEnabled(): boolean;
  27615. static set RefractionTextureEnabled(value: boolean);
  27616. /**
  27617. * Are color grading textures enabled in the application.
  27618. */
  27619. static get ColorGradingTextureEnabled(): boolean;
  27620. static set ColorGradingTextureEnabled(value: boolean);
  27621. /**
  27622. * Are fresnels enabled in the application.
  27623. */
  27624. static get FresnelEnabled(): boolean;
  27625. static set FresnelEnabled(value: boolean);
  27626. }
  27627. }
  27628. declare module "babylonjs/Particles/solidParticleSystem" {
  27629. import { Nullable } from "babylonjs/types";
  27630. import { Vector3 } from "babylonjs/Maths/math.vector";
  27631. import { Mesh } from "babylonjs/Meshes/mesh";
  27632. import { Scene, IDisposable } from "babylonjs/scene";
  27633. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27634. import { Material } from "babylonjs/Materials/material";
  27635. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27636. /**
  27637. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27638. *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.
  27639. * The SPS is also a particle system. It provides some methods to manage the particles.
  27640. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27641. *
  27642. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27643. */
  27644. export class SolidParticleSystem implements IDisposable {
  27645. /**
  27646. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27647. * Example : var p = SPS.particles[i];
  27648. */
  27649. particles: SolidParticle[];
  27650. /**
  27651. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27652. */
  27653. nbParticles: number;
  27654. /**
  27655. * If the particles must ever face the camera (default false). Useful for planar particles.
  27656. */
  27657. billboard: boolean;
  27658. /**
  27659. * Recompute normals when adding a shape
  27660. */
  27661. recomputeNormals: boolean;
  27662. /**
  27663. * This a counter ofr your own usage. It's not set by any SPS functions.
  27664. */
  27665. counter: number;
  27666. /**
  27667. * The SPS name. This name is also given to the underlying mesh.
  27668. */
  27669. name: string;
  27670. /**
  27671. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27672. */
  27673. mesh: Mesh;
  27674. /**
  27675. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27676. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27677. */
  27678. vars: any;
  27679. /**
  27680. * This array is populated when the SPS is set as 'pickable'.
  27681. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27682. * Each element of this array is an object `{idx: int, faceId: int}`.
  27683. * `idx` is the picked particle index in the `SPS.particles` array
  27684. * `faceId` is the picked face index counted within this particle.
  27685. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27686. */
  27687. pickedParticles: {
  27688. idx: number;
  27689. faceId: number;
  27690. }[];
  27691. /**
  27692. * This array is populated when `enableDepthSort` is set to true.
  27693. * Each element of this array is an instance of the class DepthSortedParticle.
  27694. */
  27695. depthSortedParticles: DepthSortedParticle[];
  27696. /**
  27697. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27698. * @hidden
  27699. */
  27700. _bSphereOnly: boolean;
  27701. /**
  27702. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27703. * @hidden
  27704. */
  27705. _bSphereRadiusFactor: number;
  27706. private _scene;
  27707. private _positions;
  27708. private _indices;
  27709. private _normals;
  27710. private _colors;
  27711. private _uvs;
  27712. private _indices32;
  27713. private _positions32;
  27714. private _normals32;
  27715. private _fixedNormal32;
  27716. private _colors32;
  27717. private _uvs32;
  27718. private _index;
  27719. private _updatable;
  27720. private _pickable;
  27721. private _isVisibilityBoxLocked;
  27722. private _alwaysVisible;
  27723. private _depthSort;
  27724. private _expandable;
  27725. private _shapeCounter;
  27726. private _copy;
  27727. private _color;
  27728. private _computeParticleColor;
  27729. private _computeParticleTexture;
  27730. private _computeParticleRotation;
  27731. private _computeParticleVertex;
  27732. private _computeBoundingBox;
  27733. private _depthSortParticles;
  27734. private _camera;
  27735. private _mustUnrotateFixedNormals;
  27736. private _particlesIntersect;
  27737. private _needs32Bits;
  27738. private _isNotBuilt;
  27739. private _lastParticleId;
  27740. private _idxOfId;
  27741. private _multimaterialEnabled;
  27742. private _useModelMaterial;
  27743. private _indicesByMaterial;
  27744. private _materialIndexes;
  27745. private _depthSortFunction;
  27746. private _materialSortFunction;
  27747. private _materials;
  27748. private _multimaterial;
  27749. private _materialIndexesById;
  27750. private _defaultMaterial;
  27751. private _autoUpdateSubMeshes;
  27752. /**
  27753. * Creates a SPS (Solid Particle System) object.
  27754. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27755. * @param scene (Scene) is the scene in which the SPS is added.
  27756. * @param options defines the options of the sps e.g.
  27757. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27758. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27759. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27760. * * 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.
  27761. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27762. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27763. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27764. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27765. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27766. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27767. */
  27768. constructor(name: string, scene: Scene, options?: {
  27769. updatable?: boolean;
  27770. isPickable?: boolean;
  27771. enableDepthSort?: boolean;
  27772. particleIntersection?: boolean;
  27773. boundingSphereOnly?: boolean;
  27774. bSphereRadiusFactor?: number;
  27775. expandable?: boolean;
  27776. useModelMaterial?: boolean;
  27777. enableMultiMaterial?: boolean;
  27778. });
  27779. /**
  27780. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27781. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27782. * @returns the created mesh
  27783. */
  27784. buildMesh(): Mesh;
  27785. /**
  27786. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27787. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27788. * Thus the particles generated from `digest()` have their property `position` set yet.
  27789. * @param mesh ( Mesh ) is the mesh to be digested
  27790. * @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
  27791. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27792. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27793. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27794. * @returns the current SPS
  27795. */
  27796. digest(mesh: Mesh, options?: {
  27797. facetNb?: number;
  27798. number?: number;
  27799. delta?: number;
  27800. storage?: [];
  27801. }): SolidParticleSystem;
  27802. /**
  27803. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27804. * @hidden
  27805. */
  27806. private _unrotateFixedNormals;
  27807. /**
  27808. * Resets the temporary working copy particle
  27809. * @hidden
  27810. */
  27811. private _resetCopy;
  27812. /**
  27813. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27814. * @param p the current index in the positions array to be updated
  27815. * @param ind the current index in the indices array
  27816. * @param shape a Vector3 array, the shape geometry
  27817. * @param positions the positions array to be updated
  27818. * @param meshInd the shape indices array
  27819. * @param indices the indices array to be updated
  27820. * @param meshUV the shape uv array
  27821. * @param uvs the uv array to be updated
  27822. * @param meshCol the shape color array
  27823. * @param colors the color array to be updated
  27824. * @param meshNor the shape normals array
  27825. * @param normals the normals array to be updated
  27826. * @param idx the particle index
  27827. * @param idxInShape the particle index in its shape
  27828. * @param options the addShape() method passed options
  27829. * @model the particle model
  27830. * @hidden
  27831. */
  27832. private _meshBuilder;
  27833. /**
  27834. * Returns a shape Vector3 array from positions float array
  27835. * @param positions float array
  27836. * @returns a vector3 array
  27837. * @hidden
  27838. */
  27839. private _posToShape;
  27840. /**
  27841. * Returns a shapeUV array from a float uvs (array deep copy)
  27842. * @param uvs as a float array
  27843. * @returns a shapeUV array
  27844. * @hidden
  27845. */
  27846. private _uvsToShapeUV;
  27847. /**
  27848. * Adds a new particle object in the particles array
  27849. * @param idx particle index in particles array
  27850. * @param id particle id
  27851. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27852. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27853. * @param model particle ModelShape object
  27854. * @param shapeId model shape identifier
  27855. * @param idxInShape index of the particle in the current model
  27856. * @param bInfo model bounding info object
  27857. * @param storage target storage array, if any
  27858. * @hidden
  27859. */
  27860. private _addParticle;
  27861. /**
  27862. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27863. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27864. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27865. * @param nb (positive integer) the number of particles to be created from this model
  27866. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27867. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27868. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27869. * @returns the number of shapes in the system
  27870. */
  27871. addShape(mesh: Mesh, nb: number, options?: {
  27872. positionFunction?: any;
  27873. vertexFunction?: any;
  27874. storage?: [];
  27875. }): number;
  27876. /**
  27877. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27878. * @hidden
  27879. */
  27880. private _rebuildParticle;
  27881. /**
  27882. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27883. * @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.
  27884. * @returns the SPS.
  27885. */
  27886. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27887. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27888. * Returns an array with the removed particles.
  27889. * 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.
  27890. * The SPS can't be empty so at least one particle needs to remain in place.
  27891. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27892. * @param start index of the first particle to remove
  27893. * @param end index of the last particle to remove (included)
  27894. * @returns an array populated with the removed particles
  27895. */
  27896. removeParticles(start: number, end: number): SolidParticle[];
  27897. /**
  27898. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27899. * @param solidParticleArray an array populated with Solid Particles objects
  27900. * @returns the SPS
  27901. */
  27902. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27903. /**
  27904. * Creates a new particle and modifies the SPS mesh geometry :
  27905. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27906. * - calls _addParticle() to populate the particle array
  27907. * factorized code from addShape() and insertParticlesFromArray()
  27908. * @param idx particle index in the particles array
  27909. * @param i particle index in its shape
  27910. * @param modelShape particle ModelShape object
  27911. * @param shape shape vertex array
  27912. * @param meshInd shape indices array
  27913. * @param meshUV shape uv array
  27914. * @param meshCol shape color array
  27915. * @param meshNor shape normals array
  27916. * @param bbInfo shape bounding info
  27917. * @param storage target particle storage
  27918. * @options addShape() passed options
  27919. * @hidden
  27920. */
  27921. private _insertNewParticle;
  27922. /**
  27923. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27924. * This method calls `updateParticle()` for each particle of the SPS.
  27925. * For an animated SPS, it is usually called within the render loop.
  27926. * 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.
  27927. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27928. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27929. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27930. * @returns the SPS.
  27931. */
  27932. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27933. /**
  27934. * Disposes the SPS.
  27935. */
  27936. dispose(): void;
  27937. /**
  27938. * Returns a SolidParticle object from its identifier : particle.id
  27939. * @param id (integer) the particle Id
  27940. * @returns the searched particle or null if not found in the SPS.
  27941. */
  27942. getParticleById(id: number): Nullable<SolidParticle>;
  27943. /**
  27944. * Returns a new array populated with the particles having the passed shapeId.
  27945. * @param shapeId (integer) the shape identifier
  27946. * @returns a new solid particle array
  27947. */
  27948. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27949. /**
  27950. * Populates the passed array "ref" with the particles having the passed shapeId.
  27951. * @param shapeId the shape identifier
  27952. * @returns the SPS
  27953. * @param ref
  27954. */
  27955. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27956. /**
  27957. * Computes the required SubMeshes according the materials assigned to the particles.
  27958. * @returns the solid particle system.
  27959. * Does nothing if called before the SPS mesh is built.
  27960. */
  27961. computeSubMeshes(): SolidParticleSystem;
  27962. /**
  27963. * Sorts the solid particles by material when MultiMaterial is enabled.
  27964. * Updates the indices32 array.
  27965. * Updates the indicesByMaterial array.
  27966. * Updates the mesh indices array.
  27967. * @returns the SPS
  27968. * @hidden
  27969. */
  27970. private _sortParticlesByMaterial;
  27971. /**
  27972. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27973. * @hidden
  27974. */
  27975. private _setMaterialIndexesById;
  27976. /**
  27977. * Returns an array with unique values of Materials from the passed array
  27978. * @param array the material array to be checked and filtered
  27979. * @hidden
  27980. */
  27981. private _filterUniqueMaterialId;
  27982. /**
  27983. * Sets a new Standard Material as _defaultMaterial if not already set.
  27984. * @hidden
  27985. */
  27986. private _setDefaultMaterial;
  27987. /**
  27988. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27989. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27990. * @returns the SPS.
  27991. */
  27992. refreshVisibleSize(): SolidParticleSystem;
  27993. /**
  27994. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27995. * @param size the size (float) of the visibility box
  27996. * note : this doesn't lock the SPS mesh bounding box.
  27997. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27998. */
  27999. setVisibilityBox(size: number): void;
  28000. /**
  28001. * Gets whether the SPS as always visible or not
  28002. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28003. */
  28004. get isAlwaysVisible(): boolean;
  28005. /**
  28006. * Sets the SPS as always visible or not
  28007. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28008. */
  28009. set isAlwaysVisible(val: boolean);
  28010. /**
  28011. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28012. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28013. */
  28014. set isVisibilityBoxLocked(val: boolean);
  28015. /**
  28016. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28018. */
  28019. get isVisibilityBoxLocked(): boolean;
  28020. /**
  28021. * Tells to `setParticles()` to compute the particle rotations or not.
  28022. * Default value : true. The SPS is faster when it's set to false.
  28023. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28024. */
  28025. set computeParticleRotation(val: boolean);
  28026. /**
  28027. * Tells to `setParticles()` to compute the particle colors or not.
  28028. * Default value : true. The SPS is faster when it's set to false.
  28029. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28030. */
  28031. set computeParticleColor(val: boolean);
  28032. set computeParticleTexture(val: boolean);
  28033. /**
  28034. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28035. * Default value : false. The SPS is faster when it's set to false.
  28036. * Note : the particle custom vertex positions aren't stored values.
  28037. */
  28038. set computeParticleVertex(val: boolean);
  28039. /**
  28040. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28041. */
  28042. set computeBoundingBox(val: boolean);
  28043. /**
  28044. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28045. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28046. * Default : `true`
  28047. */
  28048. set depthSortParticles(val: boolean);
  28049. /**
  28050. * Gets if `setParticles()` computes the particle rotations or not.
  28051. * Default value : true. The SPS is faster when it's set to false.
  28052. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28053. */
  28054. get computeParticleRotation(): boolean;
  28055. /**
  28056. * Gets if `setParticles()` computes the particle colors or not.
  28057. * Default value : true. The SPS is faster when it's set to false.
  28058. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28059. */
  28060. get computeParticleColor(): boolean;
  28061. /**
  28062. * Gets if `setParticles()` computes the particle textures or not.
  28063. * Default value : true. The SPS is faster when it's set to false.
  28064. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28065. */
  28066. get computeParticleTexture(): boolean;
  28067. /**
  28068. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28069. * Default value : false. The SPS is faster when it's set to false.
  28070. * Note : the particle custom vertex positions aren't stored values.
  28071. */
  28072. get computeParticleVertex(): boolean;
  28073. /**
  28074. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28075. */
  28076. get computeBoundingBox(): boolean;
  28077. /**
  28078. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28079. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28080. * Default : `true`
  28081. */
  28082. get depthSortParticles(): boolean;
  28083. /**
  28084. * Gets if the SPS is created as expandable at construction time.
  28085. * Default : `false`
  28086. */
  28087. get expandable(): boolean;
  28088. /**
  28089. * Gets if the SPS supports the Multi Materials
  28090. */
  28091. get multimaterialEnabled(): boolean;
  28092. /**
  28093. * Gets if the SPS uses the model materials for its own multimaterial.
  28094. */
  28095. get useModelMaterial(): boolean;
  28096. /**
  28097. * The SPS used material array.
  28098. */
  28099. get materials(): Material[];
  28100. /**
  28101. * Sets the SPS MultiMaterial from the passed materials.
  28102. * Note : the passed array is internally copied and not used then by reference.
  28103. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28104. */
  28105. setMultiMaterial(materials: Material[]): void;
  28106. /**
  28107. * The SPS computed multimaterial object
  28108. */
  28109. get multimaterial(): MultiMaterial;
  28110. set multimaterial(mm: MultiMaterial);
  28111. /**
  28112. * If the subMeshes must be updated on the next call to setParticles()
  28113. */
  28114. get autoUpdateSubMeshes(): boolean;
  28115. set autoUpdateSubMeshes(val: boolean);
  28116. /**
  28117. * This function does nothing. It may be overwritten to set all the particle first values.
  28118. * The SPS doesn't call this function, you may have to call it by your own.
  28119. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28120. */
  28121. initParticles(): void;
  28122. /**
  28123. * This function does nothing. It may be overwritten to recycle a particle.
  28124. * The SPS doesn't call this function, you may have to call it by your own.
  28125. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28126. * @param particle The particle to recycle
  28127. * @returns the recycled particle
  28128. */
  28129. recycleParticle(particle: SolidParticle): SolidParticle;
  28130. /**
  28131. * Updates a particle : this function should be overwritten by the user.
  28132. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28133. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28134. * @example : just set a particle position or velocity and recycle conditions
  28135. * @param particle The particle to update
  28136. * @returns the updated particle
  28137. */
  28138. updateParticle(particle: SolidParticle): SolidParticle;
  28139. /**
  28140. * Updates a vertex of a particle : it can be overwritten by the user.
  28141. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28142. * @param particle the current particle
  28143. * @param vertex the current index of the current particle
  28144. * @param pt the index of the current vertex in the particle shape
  28145. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28146. * @example : just set a vertex particle position
  28147. * @returns the updated vertex
  28148. */
  28149. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28150. /**
  28151. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28152. * This does nothing and may be overwritten by the user.
  28153. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28154. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28155. * @param update the boolean update value actually passed to setParticles()
  28156. */
  28157. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28158. /**
  28159. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28160. * This will be passed three parameters.
  28161. * This does nothing and may be overwritten by the user.
  28162. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28163. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28164. * @param update the boolean update value actually passed to setParticles()
  28165. */
  28166. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28167. }
  28168. }
  28169. declare module "babylonjs/Particles/solidParticle" {
  28170. import { Nullable } from "babylonjs/types";
  28171. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28172. import { Color4 } from "babylonjs/Maths/math.color";
  28173. import { Mesh } from "babylonjs/Meshes/mesh";
  28174. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28175. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28176. import { Plane } from "babylonjs/Maths/math.plane";
  28177. import { Material } from "babylonjs/Materials/material";
  28178. /**
  28179. * Represents one particle of a solid particle system.
  28180. */
  28181. export class SolidParticle {
  28182. /**
  28183. * particle global index
  28184. */
  28185. idx: number;
  28186. /**
  28187. * particle identifier
  28188. */
  28189. id: number;
  28190. /**
  28191. * The color of the particle
  28192. */
  28193. color: Nullable<Color4>;
  28194. /**
  28195. * The world space position of the particle.
  28196. */
  28197. position: Vector3;
  28198. /**
  28199. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28200. */
  28201. rotation: Vector3;
  28202. /**
  28203. * The world space rotation quaternion of the particle.
  28204. */
  28205. rotationQuaternion: Nullable<Quaternion>;
  28206. /**
  28207. * The scaling of the particle.
  28208. */
  28209. scaling: Vector3;
  28210. /**
  28211. * The uvs of the particle.
  28212. */
  28213. uvs: Vector4;
  28214. /**
  28215. * The current speed of the particle.
  28216. */
  28217. velocity: Vector3;
  28218. /**
  28219. * The pivot point in the particle local space.
  28220. */
  28221. pivot: Vector3;
  28222. /**
  28223. * Must the particle be translated from its pivot point in its local space ?
  28224. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28225. * Default : false
  28226. */
  28227. translateFromPivot: boolean;
  28228. /**
  28229. * Is the particle active or not ?
  28230. */
  28231. alive: boolean;
  28232. /**
  28233. * Is the particle visible or not ?
  28234. */
  28235. isVisible: boolean;
  28236. /**
  28237. * Index of this particle in the global "positions" array (Internal use)
  28238. * @hidden
  28239. */
  28240. _pos: number;
  28241. /**
  28242. * @hidden Index of this particle in the global "indices" array (Internal use)
  28243. */
  28244. _ind: number;
  28245. /**
  28246. * @hidden ModelShape of this particle (Internal use)
  28247. */
  28248. _model: ModelShape;
  28249. /**
  28250. * ModelShape id of this particle
  28251. */
  28252. shapeId: number;
  28253. /**
  28254. * Index of the particle in its shape id
  28255. */
  28256. idxInShape: number;
  28257. /**
  28258. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28259. */
  28260. _modelBoundingInfo: BoundingInfo;
  28261. /**
  28262. * @hidden Particle BoundingInfo object (Internal use)
  28263. */
  28264. _boundingInfo: BoundingInfo;
  28265. /**
  28266. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28267. */
  28268. _sps: SolidParticleSystem;
  28269. /**
  28270. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28271. */
  28272. _stillInvisible: boolean;
  28273. /**
  28274. * @hidden Last computed particle rotation matrix
  28275. */
  28276. _rotationMatrix: number[];
  28277. /**
  28278. * Parent particle Id, if any.
  28279. * Default null.
  28280. */
  28281. parentId: Nullable<number>;
  28282. /**
  28283. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28284. */
  28285. materialIndex: Nullable<number>;
  28286. /**
  28287. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28288. * The possible values are :
  28289. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28290. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28291. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28293. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28294. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28295. * */
  28296. cullingStrategy: number;
  28297. /**
  28298. * @hidden Internal global position in the SPS.
  28299. */
  28300. _globalPosition: Vector3;
  28301. /**
  28302. * Creates a Solid Particle object.
  28303. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28304. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28305. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28306. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28307. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28308. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28309. * @param shapeId (integer) is the model shape identifier in the SPS.
  28310. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28311. * @param sps defines the sps it is associated to
  28312. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28313. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28314. */
  28315. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28316. /**
  28317. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28318. * @param target the particle target
  28319. * @returns the current particle
  28320. */
  28321. copyToRef(target: SolidParticle): SolidParticle;
  28322. /**
  28323. * Legacy support, changed scale to scaling
  28324. */
  28325. get scale(): Vector3;
  28326. /**
  28327. * Legacy support, changed scale to scaling
  28328. */
  28329. set scale(scale: Vector3);
  28330. /**
  28331. * Legacy support, changed quaternion to rotationQuaternion
  28332. */
  28333. get quaternion(): Nullable<Quaternion>;
  28334. /**
  28335. * Legacy support, changed quaternion to rotationQuaternion
  28336. */
  28337. set quaternion(q: Nullable<Quaternion>);
  28338. /**
  28339. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28340. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28341. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28342. * @returns true if it intersects
  28343. */
  28344. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28345. /**
  28346. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28347. * A particle is in the frustum if its bounding box intersects the frustum
  28348. * @param frustumPlanes defines the frustum to test
  28349. * @returns true if the particle is in the frustum planes
  28350. */
  28351. isInFrustum(frustumPlanes: Plane[]): boolean;
  28352. /**
  28353. * get the rotation matrix of the particle
  28354. * @hidden
  28355. */
  28356. getRotationMatrix(m: Matrix): void;
  28357. }
  28358. /**
  28359. * Represents the shape of the model used by one particle of a solid particle system.
  28360. * SPS internal tool, don't use it manually.
  28361. */
  28362. export class ModelShape {
  28363. /**
  28364. * The shape id
  28365. * @hidden
  28366. */
  28367. shapeID: number;
  28368. /**
  28369. * flat array of model positions (internal use)
  28370. * @hidden
  28371. */
  28372. _shape: Vector3[];
  28373. /**
  28374. * flat array of model UVs (internal use)
  28375. * @hidden
  28376. */
  28377. _shapeUV: number[];
  28378. /**
  28379. * color array of the model
  28380. * @hidden
  28381. */
  28382. _shapeColors: number[];
  28383. /**
  28384. * indices array of the model
  28385. * @hidden
  28386. */
  28387. _indices: number[];
  28388. /**
  28389. * normals array of the model
  28390. * @hidden
  28391. */
  28392. _normals: number[];
  28393. /**
  28394. * length of the shape in the model indices array (internal use)
  28395. * @hidden
  28396. */
  28397. _indicesLength: number;
  28398. /**
  28399. * Custom position function (internal use)
  28400. * @hidden
  28401. */
  28402. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28403. /**
  28404. * Custom vertex function (internal use)
  28405. * @hidden
  28406. */
  28407. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28408. /**
  28409. * Model material (internal use)
  28410. * @hidden
  28411. */
  28412. _material: Nullable<Material>;
  28413. /**
  28414. * 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.
  28415. * SPS internal tool, don't use it manually.
  28416. * @hidden
  28417. */
  28418. 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>);
  28419. }
  28420. /**
  28421. * Represents a Depth Sorted Particle in the solid particle system.
  28422. * @hidden
  28423. */
  28424. export class DepthSortedParticle {
  28425. /**
  28426. * Index of the particle in the "indices" array
  28427. */
  28428. ind: number;
  28429. /**
  28430. * Length of the particle shape in the "indices" array
  28431. */
  28432. indicesLength: number;
  28433. /**
  28434. * Squared distance from the particle to the camera
  28435. */
  28436. sqDistance: number;
  28437. /**
  28438. * Material index when used with MultiMaterials
  28439. */
  28440. materialIndex: number;
  28441. /**
  28442. * Creates a new sorted particle
  28443. * @param materialIndex
  28444. */
  28445. constructor(ind: number, indLength: number, materialIndex: number);
  28446. }
  28447. }
  28448. declare module "babylonjs/Collisions/meshCollisionData" {
  28449. import { Collider } from "babylonjs/Collisions/collider";
  28450. import { Vector3 } from "babylonjs/Maths/math.vector";
  28451. import { Nullable } from "babylonjs/types";
  28452. import { Observer } from "babylonjs/Misc/observable";
  28453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28454. /**
  28455. * @hidden
  28456. */
  28457. export class _MeshCollisionData {
  28458. _checkCollisions: boolean;
  28459. _collisionMask: number;
  28460. _collisionGroup: number;
  28461. _collider: Nullable<Collider>;
  28462. _oldPositionForCollisions: Vector3;
  28463. _diffPositionForCollisions: Vector3;
  28464. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28465. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28466. }
  28467. }
  28468. declare module "babylonjs/Meshes/abstractMesh" {
  28469. import { Observable } from "babylonjs/Misc/observable";
  28470. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28471. import { Camera } from "babylonjs/Cameras/camera";
  28472. import { Scene, IDisposable } from "babylonjs/scene";
  28473. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28474. import { Node } from "babylonjs/node";
  28475. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28476. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28478. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28479. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28480. import { Material } from "babylonjs/Materials/material";
  28481. import { Light } from "babylonjs/Lights/light";
  28482. import { Skeleton } from "babylonjs/Bones/skeleton";
  28483. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28484. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28485. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28486. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28487. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28488. import { Plane } from "babylonjs/Maths/math.plane";
  28489. import { Ray } from "babylonjs/Culling/ray";
  28490. import { Collider } from "babylonjs/Collisions/collider";
  28491. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28492. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28493. /** @hidden */
  28494. class _FacetDataStorage {
  28495. facetPositions: Vector3[];
  28496. facetNormals: Vector3[];
  28497. facetPartitioning: number[][];
  28498. facetNb: number;
  28499. partitioningSubdivisions: number;
  28500. partitioningBBoxRatio: number;
  28501. facetDataEnabled: boolean;
  28502. facetParameters: any;
  28503. bbSize: Vector3;
  28504. subDiv: {
  28505. max: number;
  28506. X: number;
  28507. Y: number;
  28508. Z: number;
  28509. };
  28510. facetDepthSort: boolean;
  28511. facetDepthSortEnabled: boolean;
  28512. depthSortedIndices: IndicesArray;
  28513. depthSortedFacets: {
  28514. ind: number;
  28515. sqDistance: number;
  28516. }[];
  28517. facetDepthSortFunction: (f1: {
  28518. ind: number;
  28519. sqDistance: number;
  28520. }, f2: {
  28521. ind: number;
  28522. sqDistance: number;
  28523. }) => number;
  28524. facetDepthSortFrom: Vector3;
  28525. facetDepthSortOrigin: Vector3;
  28526. invertedMatrix: Matrix;
  28527. }
  28528. /**
  28529. * @hidden
  28530. **/
  28531. class _InternalAbstractMeshDataInfo {
  28532. _hasVertexAlpha: boolean;
  28533. _useVertexColors: boolean;
  28534. _numBoneInfluencers: number;
  28535. _applyFog: boolean;
  28536. _receiveShadows: boolean;
  28537. _facetData: _FacetDataStorage;
  28538. _visibility: number;
  28539. _skeleton: Nullable<Skeleton>;
  28540. _layerMask: number;
  28541. _computeBonesUsingShaders: boolean;
  28542. _isActive: boolean;
  28543. _onlyForInstances: boolean;
  28544. _isActiveIntermediate: boolean;
  28545. _onlyForInstancesIntermediate: boolean;
  28546. _actAsRegularMesh: boolean;
  28547. }
  28548. /**
  28549. * Class used to store all common mesh properties
  28550. */
  28551. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28552. /** No occlusion */
  28553. static OCCLUSION_TYPE_NONE: number;
  28554. /** Occlusion set to optimisitic */
  28555. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28556. /** Occlusion set to strict */
  28557. static OCCLUSION_TYPE_STRICT: number;
  28558. /** Use an accurante occlusion algorithm */
  28559. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28560. /** Use a conservative occlusion algorithm */
  28561. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28562. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28563. * Test order :
  28564. * Is the bounding sphere outside the frustum ?
  28565. * If not, are the bounding box vertices outside the frustum ?
  28566. * It not, then the cullable object is in the frustum.
  28567. */
  28568. static readonly CULLINGSTRATEGY_STANDARD: number;
  28569. /** Culling strategy : Bounding Sphere Only.
  28570. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28571. * It's also less accurate than the standard because some not visible objects can still be selected.
  28572. * Test : is the bounding sphere outside the frustum ?
  28573. * If not, then the cullable object is in the frustum.
  28574. */
  28575. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28576. /** Culling strategy : Optimistic Inclusion.
  28577. * This in an inclusion test first, then the standard exclusion test.
  28578. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28579. * 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.
  28580. * Anyway, it's as accurate as the standard strategy.
  28581. * Test :
  28582. * Is the cullable object bounding sphere center in the frustum ?
  28583. * If not, apply the default culling strategy.
  28584. */
  28585. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28586. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28587. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28588. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28589. * 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.
  28590. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28591. * Test :
  28592. * Is the cullable object bounding sphere center in the frustum ?
  28593. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28594. */
  28595. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28596. /**
  28597. * No billboard
  28598. */
  28599. static get BILLBOARDMODE_NONE(): number;
  28600. /** Billboard on X axis */
  28601. static get BILLBOARDMODE_X(): number;
  28602. /** Billboard on Y axis */
  28603. static get BILLBOARDMODE_Y(): number;
  28604. /** Billboard on Z axis */
  28605. static get BILLBOARDMODE_Z(): number;
  28606. /** Billboard on all axes */
  28607. static get BILLBOARDMODE_ALL(): number;
  28608. /** Billboard on using position instead of orientation */
  28609. static get BILLBOARDMODE_USE_POSITION(): number;
  28610. /** @hidden */
  28611. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28612. /**
  28613. * The culling strategy to use to check whether the mesh must be rendered or not.
  28614. * This value can be changed at any time and will be used on the next render mesh selection.
  28615. * The possible values are :
  28616. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28617. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28618. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28619. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28620. * Please read each static variable documentation to get details about the culling process.
  28621. * */
  28622. cullingStrategy: number;
  28623. /**
  28624. * Gets the number of facets in the mesh
  28625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28626. */
  28627. get facetNb(): number;
  28628. /**
  28629. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28631. */
  28632. get partitioningSubdivisions(): number;
  28633. set partitioningSubdivisions(nb: number);
  28634. /**
  28635. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28636. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28638. */
  28639. get partitioningBBoxRatio(): number;
  28640. set partitioningBBoxRatio(ratio: number);
  28641. /**
  28642. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28643. * Works only for updatable meshes.
  28644. * Doesn't work with multi-materials
  28645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28646. */
  28647. get mustDepthSortFacets(): boolean;
  28648. set mustDepthSortFacets(sort: boolean);
  28649. /**
  28650. * The location (Vector3) where the facet depth sort must be computed from.
  28651. * By default, the active camera position.
  28652. * Used only when facet depth sort is enabled
  28653. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28654. */
  28655. get facetDepthSortFrom(): Vector3;
  28656. set facetDepthSortFrom(location: Vector3);
  28657. /**
  28658. * gets a boolean indicating if facetData is enabled
  28659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28660. */
  28661. get isFacetDataEnabled(): boolean;
  28662. /** @hidden */
  28663. _updateNonUniformScalingState(value: boolean): boolean;
  28664. /**
  28665. * An event triggered when this mesh collides with another one
  28666. */
  28667. onCollideObservable: Observable<AbstractMesh>;
  28668. /** Set a function to call when this mesh collides with another one */
  28669. set onCollide(callback: () => void);
  28670. /**
  28671. * An event triggered when the collision's position changes
  28672. */
  28673. onCollisionPositionChangeObservable: Observable<Vector3>;
  28674. /** Set a function to call when the collision's position changes */
  28675. set onCollisionPositionChange(callback: () => void);
  28676. /**
  28677. * An event triggered when material is changed
  28678. */
  28679. onMaterialChangedObservable: Observable<AbstractMesh>;
  28680. /**
  28681. * Gets or sets the orientation for POV movement & rotation
  28682. */
  28683. definedFacingForward: boolean;
  28684. /** @hidden */
  28685. _occlusionQuery: Nullable<WebGLQuery>;
  28686. /** @hidden */
  28687. _renderingGroup: Nullable<RenderingGroup>;
  28688. /**
  28689. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28690. */
  28691. get visibility(): number;
  28692. /**
  28693. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28694. */
  28695. set visibility(value: number);
  28696. /** Gets or sets the alpha index used to sort transparent meshes
  28697. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28698. */
  28699. alphaIndex: number;
  28700. /**
  28701. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28702. */
  28703. isVisible: boolean;
  28704. /**
  28705. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28706. */
  28707. isPickable: boolean;
  28708. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28709. showSubMeshesBoundingBox: boolean;
  28710. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28712. */
  28713. isBlocker: boolean;
  28714. /**
  28715. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28716. */
  28717. enablePointerMoveEvents: boolean;
  28718. /**
  28719. * Specifies the rendering group id for this mesh (0 by default)
  28720. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28721. */
  28722. renderingGroupId: number;
  28723. private _material;
  28724. /** Gets or sets current material */
  28725. get material(): Nullable<Material>;
  28726. set material(value: Nullable<Material>);
  28727. /**
  28728. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28729. * @see http://doc.babylonjs.com/babylon101/shadows
  28730. */
  28731. get receiveShadows(): boolean;
  28732. set receiveShadows(value: boolean);
  28733. /** Defines color to use when rendering outline */
  28734. outlineColor: Color3;
  28735. /** Define width to use when rendering outline */
  28736. outlineWidth: number;
  28737. /** Defines color to use when rendering overlay */
  28738. overlayColor: Color3;
  28739. /** Defines alpha to use when rendering overlay */
  28740. overlayAlpha: number;
  28741. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28742. get hasVertexAlpha(): boolean;
  28743. set hasVertexAlpha(value: boolean);
  28744. /** 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) */
  28745. get useVertexColors(): boolean;
  28746. set useVertexColors(value: boolean);
  28747. /**
  28748. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28749. */
  28750. get computeBonesUsingShaders(): boolean;
  28751. set computeBonesUsingShaders(value: boolean);
  28752. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28753. get numBoneInfluencers(): number;
  28754. set numBoneInfluencers(value: number);
  28755. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28756. get applyFog(): boolean;
  28757. set applyFog(value: boolean);
  28758. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28759. useOctreeForRenderingSelection: boolean;
  28760. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28761. useOctreeForPicking: boolean;
  28762. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28763. useOctreeForCollisions: boolean;
  28764. /**
  28765. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28766. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28767. */
  28768. get layerMask(): number;
  28769. set layerMask(value: number);
  28770. /**
  28771. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28772. */
  28773. alwaysSelectAsActiveMesh: boolean;
  28774. /**
  28775. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28776. */
  28777. doNotSyncBoundingInfo: boolean;
  28778. /**
  28779. * Gets or sets the current action manager
  28780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28781. */
  28782. actionManager: Nullable<AbstractActionManager>;
  28783. private _meshCollisionData;
  28784. /**
  28785. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28786. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28787. */
  28788. ellipsoid: Vector3;
  28789. /**
  28790. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28791. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28792. */
  28793. ellipsoidOffset: Vector3;
  28794. /**
  28795. * Gets or sets a collision mask used to mask collisions (default is -1).
  28796. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28797. */
  28798. get collisionMask(): number;
  28799. set collisionMask(mask: number);
  28800. /**
  28801. * Gets or sets the current collision group mask (-1 by default).
  28802. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28803. */
  28804. get collisionGroup(): number;
  28805. set collisionGroup(mask: number);
  28806. /**
  28807. * Defines edge width used when edgesRenderer is enabled
  28808. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28809. */
  28810. edgesWidth: number;
  28811. /**
  28812. * Defines edge color used when edgesRenderer is enabled
  28813. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28814. */
  28815. edgesColor: Color4;
  28816. /** @hidden */
  28817. _edgesRenderer: Nullable<IEdgesRenderer>;
  28818. /** @hidden */
  28819. _masterMesh: Nullable<AbstractMesh>;
  28820. /** @hidden */
  28821. _boundingInfo: Nullable<BoundingInfo>;
  28822. /** @hidden */
  28823. _renderId: number;
  28824. /**
  28825. * Gets or sets the list of subMeshes
  28826. * @see http://doc.babylonjs.com/how_to/multi_materials
  28827. */
  28828. subMeshes: SubMesh[];
  28829. /** @hidden */
  28830. _intersectionsInProgress: AbstractMesh[];
  28831. /** @hidden */
  28832. _unIndexed: boolean;
  28833. /** @hidden */
  28834. _lightSources: Light[];
  28835. /** Gets the list of lights affecting that mesh */
  28836. get lightSources(): Light[];
  28837. /** @hidden */
  28838. get _positions(): Nullable<Vector3[]>;
  28839. /** @hidden */
  28840. _waitingData: {
  28841. lods: Nullable<any>;
  28842. actions: Nullable<any>;
  28843. freezeWorldMatrix: Nullable<boolean>;
  28844. };
  28845. /** @hidden */
  28846. _bonesTransformMatrices: Nullable<Float32Array>;
  28847. /** @hidden */
  28848. _transformMatrixTexture: Nullable<RawTexture>;
  28849. /**
  28850. * Gets or sets a skeleton to apply skining transformations
  28851. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28852. */
  28853. set skeleton(value: Nullable<Skeleton>);
  28854. get skeleton(): Nullable<Skeleton>;
  28855. /**
  28856. * An event triggered when the mesh is rebuilt.
  28857. */
  28858. onRebuildObservable: Observable<AbstractMesh>;
  28859. /**
  28860. * Creates a new AbstractMesh
  28861. * @param name defines the name of the mesh
  28862. * @param scene defines the hosting scene
  28863. */
  28864. constructor(name: string, scene?: Nullable<Scene>);
  28865. /**
  28866. * Returns the string "AbstractMesh"
  28867. * @returns "AbstractMesh"
  28868. */
  28869. getClassName(): string;
  28870. /**
  28871. * Gets a string representation of the current mesh
  28872. * @param fullDetails defines a boolean indicating if full details must be included
  28873. * @returns a string representation of the current mesh
  28874. */
  28875. toString(fullDetails?: boolean): string;
  28876. /**
  28877. * @hidden
  28878. */
  28879. protected _getEffectiveParent(): Nullable<Node>;
  28880. /** @hidden */
  28881. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28882. /** @hidden */
  28883. _rebuild(): void;
  28884. /** @hidden */
  28885. _resyncLightSources(): void;
  28886. /** @hidden */
  28887. _resyncLightSource(light: Light): void;
  28888. /** @hidden */
  28889. _unBindEffect(): void;
  28890. /** @hidden */
  28891. _removeLightSource(light: Light, dispose: boolean): void;
  28892. private _markSubMeshesAsDirty;
  28893. /** @hidden */
  28894. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28895. /** @hidden */
  28896. _markSubMeshesAsAttributesDirty(): void;
  28897. /** @hidden */
  28898. _markSubMeshesAsMiscDirty(): void;
  28899. /**
  28900. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28901. */
  28902. get scaling(): Vector3;
  28903. set scaling(newScaling: Vector3);
  28904. /**
  28905. * Returns true if the mesh is blocked. Implemented by child classes
  28906. */
  28907. get isBlocked(): boolean;
  28908. /**
  28909. * Returns the mesh itself by default. Implemented by child classes
  28910. * @param camera defines the camera to use to pick the right LOD level
  28911. * @returns the currentAbstractMesh
  28912. */
  28913. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28914. /**
  28915. * Returns 0 by default. Implemented by child classes
  28916. * @returns an integer
  28917. */
  28918. getTotalVertices(): number;
  28919. /**
  28920. * Returns a positive integer : the total number of indices in this mesh geometry.
  28921. * @returns the numner of indices or zero if the mesh has no geometry.
  28922. */
  28923. getTotalIndices(): number;
  28924. /**
  28925. * Returns null by default. Implemented by child classes
  28926. * @returns null
  28927. */
  28928. getIndices(): Nullable<IndicesArray>;
  28929. /**
  28930. * Returns the array of the requested vertex data kind. Implemented by child classes
  28931. * @param kind defines the vertex data kind to use
  28932. * @returns null
  28933. */
  28934. getVerticesData(kind: string): Nullable<FloatArray>;
  28935. /**
  28936. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28937. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28938. * Note that a new underlying VertexBuffer object is created each call.
  28939. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28940. * @param kind defines vertex data kind:
  28941. * * VertexBuffer.PositionKind
  28942. * * VertexBuffer.UVKind
  28943. * * VertexBuffer.UV2Kind
  28944. * * VertexBuffer.UV3Kind
  28945. * * VertexBuffer.UV4Kind
  28946. * * VertexBuffer.UV5Kind
  28947. * * VertexBuffer.UV6Kind
  28948. * * VertexBuffer.ColorKind
  28949. * * VertexBuffer.MatricesIndicesKind
  28950. * * VertexBuffer.MatricesIndicesExtraKind
  28951. * * VertexBuffer.MatricesWeightsKind
  28952. * * VertexBuffer.MatricesWeightsExtraKind
  28953. * @param data defines the data source
  28954. * @param updatable defines if the data must be flagged as updatable (or static)
  28955. * @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
  28956. * @returns the current mesh
  28957. */
  28958. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28959. /**
  28960. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28961. * If the mesh has no geometry, it is simply returned as it is.
  28962. * @param kind defines vertex data kind:
  28963. * * VertexBuffer.PositionKind
  28964. * * VertexBuffer.UVKind
  28965. * * VertexBuffer.UV2Kind
  28966. * * VertexBuffer.UV3Kind
  28967. * * VertexBuffer.UV4Kind
  28968. * * VertexBuffer.UV5Kind
  28969. * * VertexBuffer.UV6Kind
  28970. * * VertexBuffer.ColorKind
  28971. * * VertexBuffer.MatricesIndicesKind
  28972. * * VertexBuffer.MatricesIndicesExtraKind
  28973. * * VertexBuffer.MatricesWeightsKind
  28974. * * VertexBuffer.MatricesWeightsExtraKind
  28975. * @param data defines the data source
  28976. * @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
  28977. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28978. * @returns the current mesh
  28979. */
  28980. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28981. /**
  28982. * Sets the mesh indices,
  28983. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28984. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28985. * @param totalVertices Defines the total number of vertices
  28986. * @returns the current mesh
  28987. */
  28988. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28989. /**
  28990. * Gets a boolean indicating if specific vertex data is present
  28991. * @param kind defines the vertex data kind to use
  28992. * @returns true is data kind is present
  28993. */
  28994. isVerticesDataPresent(kind: string): boolean;
  28995. /**
  28996. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28997. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28998. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28999. * @returns a BoundingInfo
  29000. */
  29001. getBoundingInfo(): BoundingInfo;
  29002. /**
  29003. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29004. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29005. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29006. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29007. * @returns the current mesh
  29008. */
  29009. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29010. /**
  29011. * Overwrite the current bounding info
  29012. * @param boundingInfo defines the new bounding info
  29013. * @returns the current mesh
  29014. */
  29015. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29016. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29017. get useBones(): boolean;
  29018. /** @hidden */
  29019. _preActivate(): void;
  29020. /** @hidden */
  29021. _preActivateForIntermediateRendering(renderId: number): void;
  29022. /** @hidden */
  29023. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29024. /** @hidden */
  29025. _postActivate(): void;
  29026. /** @hidden */
  29027. _freeze(): void;
  29028. /** @hidden */
  29029. _unFreeze(): void;
  29030. /**
  29031. * Gets the current world matrix
  29032. * @returns a Matrix
  29033. */
  29034. getWorldMatrix(): Matrix;
  29035. /** @hidden */
  29036. _getWorldMatrixDeterminant(): number;
  29037. /**
  29038. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29039. */
  29040. get isAnInstance(): boolean;
  29041. /**
  29042. * Gets a boolean indicating if this mesh has instances
  29043. */
  29044. get hasInstances(): boolean;
  29045. /**
  29046. * Perform relative position change from the point of view of behind the front of the mesh.
  29047. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29048. * Supports definition of mesh facing forward or backward
  29049. * @param amountRight defines the distance on the right axis
  29050. * @param amountUp defines the distance on the up axis
  29051. * @param amountForward defines the distance on the forward axis
  29052. * @returns the current mesh
  29053. */
  29054. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29055. /**
  29056. * Calculate relative position change from the point of view of behind the front of the mesh.
  29057. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29058. * Supports definition of mesh facing forward or backward
  29059. * @param amountRight defines the distance on the right axis
  29060. * @param amountUp defines the distance on the up axis
  29061. * @param amountForward defines the distance on the forward axis
  29062. * @returns the new displacement vector
  29063. */
  29064. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29065. /**
  29066. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29067. * Supports definition of mesh facing forward or backward
  29068. * @param flipBack defines the flip
  29069. * @param twirlClockwise defines the twirl
  29070. * @param tiltRight defines the tilt
  29071. * @returns the current mesh
  29072. */
  29073. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29074. /**
  29075. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29076. * Supports definition of mesh facing forward or backward.
  29077. * @param flipBack defines the flip
  29078. * @param twirlClockwise defines the twirl
  29079. * @param tiltRight defines the tilt
  29080. * @returns the new rotation vector
  29081. */
  29082. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29083. /**
  29084. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29085. * This means the mesh underlying bounding box and sphere are recomputed.
  29086. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29087. * @returns the current mesh
  29088. */
  29089. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29090. /** @hidden */
  29091. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29092. /** @hidden */
  29093. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29094. /** @hidden */
  29095. _updateBoundingInfo(): AbstractMesh;
  29096. /** @hidden */
  29097. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29098. /** @hidden */
  29099. protected _afterComputeWorldMatrix(): void;
  29100. /** @hidden */
  29101. get _effectiveMesh(): AbstractMesh;
  29102. /**
  29103. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29104. * A mesh is in the frustum if its bounding box intersects the frustum
  29105. * @param frustumPlanes defines the frustum to test
  29106. * @returns true if the mesh is in the frustum planes
  29107. */
  29108. isInFrustum(frustumPlanes: Plane[]): boolean;
  29109. /**
  29110. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29111. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29112. * @param frustumPlanes defines the frustum to test
  29113. * @returns true if the mesh is completely in the frustum planes
  29114. */
  29115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29116. /**
  29117. * True if the mesh intersects another mesh or a SolidParticle object
  29118. * @param mesh defines a target mesh or SolidParticle to test
  29119. * @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)
  29120. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29121. * @returns true if there is an intersection
  29122. */
  29123. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29124. /**
  29125. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29126. * @param point defines the point to test
  29127. * @returns true if there is an intersection
  29128. */
  29129. intersectsPoint(point: Vector3): boolean;
  29130. /**
  29131. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29132. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29133. */
  29134. get checkCollisions(): boolean;
  29135. set checkCollisions(collisionEnabled: boolean);
  29136. /**
  29137. * Gets Collider object used to compute collisions (not physics)
  29138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29139. */
  29140. get collider(): Nullable<Collider>;
  29141. /**
  29142. * Move the mesh using collision engine
  29143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29144. * @param displacement defines the requested displacement vector
  29145. * @returns the current mesh
  29146. */
  29147. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29148. private _onCollisionPositionChange;
  29149. /** @hidden */
  29150. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29151. /** @hidden */
  29152. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29153. /** @hidden */
  29154. _checkCollision(collider: Collider): AbstractMesh;
  29155. /** @hidden */
  29156. _generatePointsArray(): boolean;
  29157. /**
  29158. * Checks if the passed Ray intersects with the mesh
  29159. * @param ray defines the ray to use
  29160. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29161. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29162. * @returns the picking info
  29163. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29164. */
  29165. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29166. /**
  29167. * Clones the current mesh
  29168. * @param name defines the mesh name
  29169. * @param newParent defines the new mesh parent
  29170. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29171. * @returns the new mesh
  29172. */
  29173. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29174. /**
  29175. * Disposes all the submeshes of the current meshnp
  29176. * @returns the current mesh
  29177. */
  29178. releaseSubMeshes(): AbstractMesh;
  29179. /**
  29180. * Releases resources associated with this abstract mesh.
  29181. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29182. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29183. */
  29184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29185. /**
  29186. * Adds the passed mesh as a child to the current mesh
  29187. * @param mesh defines the child mesh
  29188. * @returns the current mesh
  29189. */
  29190. addChild(mesh: AbstractMesh): AbstractMesh;
  29191. /**
  29192. * Removes the passed mesh from the current mesh children list
  29193. * @param mesh defines the child mesh
  29194. * @returns the current mesh
  29195. */
  29196. removeChild(mesh: AbstractMesh): AbstractMesh;
  29197. /** @hidden */
  29198. private _initFacetData;
  29199. /**
  29200. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29201. * This method can be called within the render loop.
  29202. * 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
  29203. * @returns the current mesh
  29204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29205. */
  29206. updateFacetData(): AbstractMesh;
  29207. /**
  29208. * Returns the facetLocalNormals array.
  29209. * The normals are expressed in the mesh local spac
  29210. * @returns an array of Vector3
  29211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29212. */
  29213. getFacetLocalNormals(): Vector3[];
  29214. /**
  29215. * Returns the facetLocalPositions array.
  29216. * The facet positions are expressed in the mesh local space
  29217. * @returns an array of Vector3
  29218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29219. */
  29220. getFacetLocalPositions(): Vector3[];
  29221. /**
  29222. * Returns the facetLocalPartioning array
  29223. * @returns an array of array of numbers
  29224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29225. */
  29226. getFacetLocalPartitioning(): number[][];
  29227. /**
  29228. * Returns the i-th facet position in the world system.
  29229. * This method allocates a new Vector3 per call
  29230. * @param i defines the facet index
  29231. * @returns a new Vector3
  29232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29233. */
  29234. getFacetPosition(i: number): Vector3;
  29235. /**
  29236. * Sets the reference Vector3 with the i-th facet position in the world system
  29237. * @param i defines the facet index
  29238. * @param ref defines the target vector
  29239. * @returns the current mesh
  29240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29241. */
  29242. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29243. /**
  29244. * Returns the i-th facet normal in the world system.
  29245. * This method allocates a new Vector3 per call
  29246. * @param i defines the facet index
  29247. * @returns a new Vector3
  29248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29249. */
  29250. getFacetNormal(i: number): Vector3;
  29251. /**
  29252. * Sets the reference Vector3 with the i-th facet normal in the world system
  29253. * @param i defines the facet index
  29254. * @param ref defines the target vector
  29255. * @returns the current mesh
  29256. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29257. */
  29258. getFacetNormalToRef(i: number, ref: Vector3): this;
  29259. /**
  29260. * 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)
  29261. * @param x defines x coordinate
  29262. * @param y defines y coordinate
  29263. * @param z defines z coordinate
  29264. * @returns the array of facet indexes
  29265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29266. */
  29267. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29268. /**
  29269. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29270. * @param projected sets as the (x,y,z) world projection on the facet
  29271. * @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
  29272. * @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
  29273. * @param x defines x coordinate
  29274. * @param y defines y coordinate
  29275. * @param z defines z coordinate
  29276. * @returns the face index if found (or null instead)
  29277. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29278. */
  29279. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29280. /**
  29281. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29282. * @param projected sets as the (x,y,z) local projection on the facet
  29283. * @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
  29284. * @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
  29285. * @param x defines x coordinate
  29286. * @param y defines y coordinate
  29287. * @param z defines z coordinate
  29288. * @returns the face index if found (or null instead)
  29289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29290. */
  29291. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29292. /**
  29293. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29294. * @returns the parameters
  29295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29296. */
  29297. getFacetDataParameters(): any;
  29298. /**
  29299. * Disables the feature FacetData and frees the related memory
  29300. * @returns the current mesh
  29301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29302. */
  29303. disableFacetData(): AbstractMesh;
  29304. /**
  29305. * Updates the AbstractMesh indices array
  29306. * @param indices defines the data source
  29307. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29308. * @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)
  29309. * @returns the current mesh
  29310. */
  29311. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29312. /**
  29313. * Creates new normals data for the mesh
  29314. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29315. * @returns the current mesh
  29316. */
  29317. createNormals(updatable: boolean): AbstractMesh;
  29318. /**
  29319. * Align the mesh with a normal
  29320. * @param normal defines the normal to use
  29321. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29322. * @returns the current mesh
  29323. */
  29324. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29325. /** @hidden */
  29326. _checkOcclusionQuery(): boolean;
  29327. /**
  29328. * Disables the mesh edge rendering mode
  29329. * @returns the currentAbstractMesh
  29330. */
  29331. disableEdgesRendering(): AbstractMesh;
  29332. /**
  29333. * Enables the edge rendering mode on the mesh.
  29334. * This mode makes the mesh edges visible
  29335. * @param epsilon defines the maximal distance between two angles to detect a face
  29336. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29337. * @returns the currentAbstractMesh
  29338. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29339. */
  29340. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29341. }
  29342. }
  29343. declare module "babylonjs/Actions/actionEvent" {
  29344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29345. import { Nullable } from "babylonjs/types";
  29346. import { Sprite } from "babylonjs/Sprites/sprite";
  29347. import { Scene } from "babylonjs/scene";
  29348. import { Vector2 } from "babylonjs/Maths/math.vector";
  29349. /**
  29350. * Interface used to define ActionEvent
  29351. */
  29352. export interface IActionEvent {
  29353. /** The mesh or sprite that triggered the action */
  29354. source: any;
  29355. /** The X mouse cursor position at the time of the event */
  29356. pointerX: number;
  29357. /** The Y mouse cursor position at the time of the event */
  29358. pointerY: number;
  29359. /** The mesh that is currently pointed at (can be null) */
  29360. meshUnderPointer: Nullable<AbstractMesh>;
  29361. /** the original (browser) event that triggered the ActionEvent */
  29362. sourceEvent?: any;
  29363. /** additional data for the event */
  29364. additionalData?: any;
  29365. }
  29366. /**
  29367. * ActionEvent is the event being sent when an action is triggered.
  29368. */
  29369. export class ActionEvent implements IActionEvent {
  29370. /** The mesh or sprite that triggered the action */
  29371. source: any;
  29372. /** The X mouse cursor position at the time of the event */
  29373. pointerX: number;
  29374. /** The Y mouse cursor position at the time of the event */
  29375. pointerY: number;
  29376. /** The mesh that is currently pointed at (can be null) */
  29377. meshUnderPointer: Nullable<AbstractMesh>;
  29378. /** the original (browser) event that triggered the ActionEvent */
  29379. sourceEvent?: any;
  29380. /** additional data for the event */
  29381. additionalData?: any;
  29382. /**
  29383. * Creates a new ActionEvent
  29384. * @param source The mesh or sprite that triggered the action
  29385. * @param pointerX The X mouse cursor position at the time of the event
  29386. * @param pointerY The Y mouse cursor position at the time of the event
  29387. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29388. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29389. * @param additionalData additional data for the event
  29390. */
  29391. constructor(
  29392. /** The mesh or sprite that triggered the action */
  29393. source: any,
  29394. /** The X mouse cursor position at the time of the event */
  29395. pointerX: number,
  29396. /** The Y mouse cursor position at the time of the event */
  29397. pointerY: number,
  29398. /** The mesh that is currently pointed at (can be null) */
  29399. meshUnderPointer: Nullable<AbstractMesh>,
  29400. /** the original (browser) event that triggered the ActionEvent */
  29401. sourceEvent?: any,
  29402. /** additional data for the event */
  29403. additionalData?: any);
  29404. /**
  29405. * Helper function to auto-create an ActionEvent from a source mesh.
  29406. * @param source The source mesh that triggered the event
  29407. * @param evt The original (browser) event
  29408. * @param additionalData additional data for the event
  29409. * @returns the new ActionEvent
  29410. */
  29411. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29412. /**
  29413. * Helper function to auto-create an ActionEvent from a source sprite
  29414. * @param source The source sprite that triggered the event
  29415. * @param scene Scene associated with the sprite
  29416. * @param evt The original (browser) event
  29417. * @param additionalData additional data for the event
  29418. * @returns the new ActionEvent
  29419. */
  29420. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29421. /**
  29422. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29423. * @param scene the scene where the event occurred
  29424. * @param evt The original (browser) event
  29425. * @returns the new ActionEvent
  29426. */
  29427. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29428. /**
  29429. * Helper function to auto-create an ActionEvent from a primitive
  29430. * @param prim defines the target primitive
  29431. * @param pointerPos defines the pointer position
  29432. * @param evt The original (browser) event
  29433. * @param additionalData additional data for the event
  29434. * @returns the new ActionEvent
  29435. */
  29436. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29437. }
  29438. }
  29439. declare module "babylonjs/Actions/abstractActionManager" {
  29440. import { IDisposable } from "babylonjs/scene";
  29441. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29442. import { IAction } from "babylonjs/Actions/action";
  29443. import { Nullable } from "babylonjs/types";
  29444. /**
  29445. * Abstract class used to decouple action Manager from scene and meshes.
  29446. * Do not instantiate.
  29447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29448. */
  29449. export abstract class AbstractActionManager implements IDisposable {
  29450. /** Gets the list of active triggers */
  29451. static Triggers: {
  29452. [key: string]: number;
  29453. };
  29454. /** Gets the cursor to use when hovering items */
  29455. hoverCursor: string;
  29456. /** Gets the list of actions */
  29457. actions: IAction[];
  29458. /**
  29459. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29460. */
  29461. isRecursive: boolean;
  29462. /**
  29463. * Releases all associated resources
  29464. */
  29465. abstract dispose(): void;
  29466. /**
  29467. * Does this action manager has pointer triggers
  29468. */
  29469. abstract get hasPointerTriggers(): boolean;
  29470. /**
  29471. * Does this action manager has pick triggers
  29472. */
  29473. abstract get hasPickTriggers(): boolean;
  29474. /**
  29475. * Process a specific trigger
  29476. * @param trigger defines the trigger to process
  29477. * @param evt defines the event details to be processed
  29478. */
  29479. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29480. /**
  29481. * Does this action manager handles actions of any of the given triggers
  29482. * @param triggers defines the triggers to be tested
  29483. * @return a boolean indicating whether one (or more) of the triggers is handled
  29484. */
  29485. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29486. /**
  29487. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29488. * speed.
  29489. * @param triggerA defines the trigger to be tested
  29490. * @param triggerB defines the trigger to be tested
  29491. * @return a boolean indicating whether one (or more) of the triggers is handled
  29492. */
  29493. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29494. /**
  29495. * Does this action manager handles actions of a given trigger
  29496. * @param trigger defines the trigger to be tested
  29497. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29498. * @return whether the trigger is handled
  29499. */
  29500. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29501. /**
  29502. * Serialize this manager to a JSON object
  29503. * @param name defines the property name to store this manager
  29504. * @returns a JSON representation of this manager
  29505. */
  29506. abstract serialize(name: string): any;
  29507. /**
  29508. * Registers an action to this action manager
  29509. * @param action defines the action to be registered
  29510. * @return the action amended (prepared) after registration
  29511. */
  29512. abstract registerAction(action: IAction): Nullable<IAction>;
  29513. /**
  29514. * Unregisters an action to this action manager
  29515. * @param action defines the action to be unregistered
  29516. * @return a boolean indicating whether the action has been unregistered
  29517. */
  29518. abstract unregisterAction(action: IAction): Boolean;
  29519. /**
  29520. * Does exist one action manager with at least one trigger
  29521. **/
  29522. static get HasTriggers(): boolean;
  29523. /**
  29524. * Does exist one action manager with at least one pick trigger
  29525. **/
  29526. static get HasPickTriggers(): boolean;
  29527. /**
  29528. * Does exist one action manager that handles actions of a given trigger
  29529. * @param trigger defines the trigger to be tested
  29530. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29531. **/
  29532. static HasSpecificTrigger(trigger: number): boolean;
  29533. }
  29534. }
  29535. declare module "babylonjs/node" {
  29536. import { Scene } from "babylonjs/scene";
  29537. import { Nullable } from "babylonjs/types";
  29538. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29539. import { Engine } from "babylonjs/Engines/engine";
  29540. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29541. import { Observable } from "babylonjs/Misc/observable";
  29542. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29543. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29544. import { Animatable } from "babylonjs/Animations/animatable";
  29545. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29546. import { Animation } from "babylonjs/Animations/animation";
  29547. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29549. /**
  29550. * Defines how a node can be built from a string name.
  29551. */
  29552. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29553. /**
  29554. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29555. */
  29556. export class Node implements IBehaviorAware<Node> {
  29557. /** @hidden */
  29558. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29559. private static _NodeConstructors;
  29560. /**
  29561. * Add a new node constructor
  29562. * @param type defines the type name of the node to construct
  29563. * @param constructorFunc defines the constructor function
  29564. */
  29565. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29566. /**
  29567. * Returns a node constructor based on type name
  29568. * @param type defines the type name
  29569. * @param name defines the new node name
  29570. * @param scene defines the hosting scene
  29571. * @param options defines optional options to transmit to constructors
  29572. * @returns the new constructor or null
  29573. */
  29574. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29575. /**
  29576. * Gets or sets the name of the node
  29577. */
  29578. name: string;
  29579. /**
  29580. * Gets or sets the id of the node
  29581. */
  29582. id: string;
  29583. /**
  29584. * Gets or sets the unique id of the node
  29585. */
  29586. uniqueId: number;
  29587. /**
  29588. * Gets or sets a string used to store user defined state for the node
  29589. */
  29590. state: string;
  29591. /**
  29592. * Gets or sets an object used to store user defined information for the node
  29593. */
  29594. metadata: any;
  29595. /**
  29596. * For internal use only. Please do not use.
  29597. */
  29598. reservedDataStore: any;
  29599. /**
  29600. * List of inspectable custom properties (used by the Inspector)
  29601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29602. */
  29603. inspectableCustomProperties: IInspectable[];
  29604. private _doNotSerialize;
  29605. /**
  29606. * Gets or sets a boolean used to define if the node must be serialized
  29607. */
  29608. get doNotSerialize(): boolean;
  29609. set doNotSerialize(value: boolean);
  29610. /** @hidden */
  29611. _isDisposed: boolean;
  29612. /**
  29613. * Gets a list of Animations associated with the node
  29614. */
  29615. animations: import("babylonjs/Animations/animation").Animation[];
  29616. protected _ranges: {
  29617. [name: string]: Nullable<AnimationRange>;
  29618. };
  29619. /**
  29620. * Callback raised when the node is ready to be used
  29621. */
  29622. onReady: Nullable<(node: Node) => void>;
  29623. private _isEnabled;
  29624. private _isParentEnabled;
  29625. private _isReady;
  29626. /** @hidden */
  29627. _currentRenderId: number;
  29628. private _parentUpdateId;
  29629. /** @hidden */
  29630. _childUpdateId: number;
  29631. /** @hidden */
  29632. _waitingParentId: Nullable<string>;
  29633. /** @hidden */
  29634. _scene: Scene;
  29635. /** @hidden */
  29636. _cache: any;
  29637. private _parentNode;
  29638. private _children;
  29639. /** @hidden */
  29640. _worldMatrix: Matrix;
  29641. /** @hidden */
  29642. _worldMatrixDeterminant: number;
  29643. /** @hidden */
  29644. _worldMatrixDeterminantIsDirty: boolean;
  29645. /** @hidden */
  29646. private _sceneRootNodesIndex;
  29647. /**
  29648. * Gets a boolean indicating if the node has been disposed
  29649. * @returns true if the node was disposed
  29650. */
  29651. isDisposed(): boolean;
  29652. /**
  29653. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29654. * @see https://doc.babylonjs.com/how_to/parenting
  29655. */
  29656. set parent(parent: Nullable<Node>);
  29657. get parent(): Nullable<Node>;
  29658. /** @hidden */
  29659. _addToSceneRootNodes(): void;
  29660. /** @hidden */
  29661. _removeFromSceneRootNodes(): void;
  29662. private _animationPropertiesOverride;
  29663. /**
  29664. * Gets or sets the animation properties override
  29665. */
  29666. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29667. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29668. /**
  29669. * Gets a string idenfifying the name of the class
  29670. * @returns "Node" string
  29671. */
  29672. getClassName(): string;
  29673. /** @hidden */
  29674. readonly _isNode: boolean;
  29675. /**
  29676. * An event triggered when the mesh is disposed
  29677. */
  29678. onDisposeObservable: Observable<Node>;
  29679. private _onDisposeObserver;
  29680. /**
  29681. * Sets a callback that will be raised when the node will be disposed
  29682. */
  29683. set onDispose(callback: () => void);
  29684. /**
  29685. * Creates a new Node
  29686. * @param name the name and id to be given to this node
  29687. * @param scene the scene this node will be added to
  29688. */
  29689. constructor(name: string, scene?: Nullable<Scene>);
  29690. /**
  29691. * Gets the scene of the node
  29692. * @returns a scene
  29693. */
  29694. getScene(): Scene;
  29695. /**
  29696. * Gets the engine of the node
  29697. * @returns a Engine
  29698. */
  29699. getEngine(): Engine;
  29700. private _behaviors;
  29701. /**
  29702. * Attach a behavior to the node
  29703. * @see http://doc.babylonjs.com/features/behaviour
  29704. * @param behavior defines the behavior to attach
  29705. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29706. * @returns the current Node
  29707. */
  29708. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29709. /**
  29710. * Remove an attached behavior
  29711. * @see http://doc.babylonjs.com/features/behaviour
  29712. * @param behavior defines the behavior to attach
  29713. * @returns the current Node
  29714. */
  29715. removeBehavior(behavior: Behavior<Node>): Node;
  29716. /**
  29717. * Gets the list of attached behaviors
  29718. * @see http://doc.babylonjs.com/features/behaviour
  29719. */
  29720. get behaviors(): Behavior<Node>[];
  29721. /**
  29722. * Gets an attached behavior by name
  29723. * @param name defines the name of the behavior to look for
  29724. * @see http://doc.babylonjs.com/features/behaviour
  29725. * @returns null if behavior was not found else the requested behavior
  29726. */
  29727. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29728. /**
  29729. * Returns the latest update of the World matrix
  29730. * @returns a Matrix
  29731. */
  29732. getWorldMatrix(): Matrix;
  29733. /** @hidden */
  29734. _getWorldMatrixDeterminant(): number;
  29735. /**
  29736. * Returns directly the latest state of the mesh World matrix.
  29737. * A Matrix is returned.
  29738. */
  29739. get worldMatrixFromCache(): Matrix;
  29740. /** @hidden */
  29741. _initCache(): void;
  29742. /** @hidden */
  29743. updateCache(force?: boolean): void;
  29744. /** @hidden */
  29745. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29746. /** @hidden */
  29747. _updateCache(ignoreParentClass?: boolean): void;
  29748. /** @hidden */
  29749. _isSynchronized(): boolean;
  29750. /** @hidden */
  29751. _markSyncedWithParent(): void;
  29752. /** @hidden */
  29753. isSynchronizedWithParent(): boolean;
  29754. /** @hidden */
  29755. isSynchronized(): boolean;
  29756. /**
  29757. * Is this node ready to be used/rendered
  29758. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29759. * @return true if the node is ready
  29760. */
  29761. isReady(completeCheck?: boolean): boolean;
  29762. /**
  29763. * Is this node enabled?
  29764. * 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
  29765. * @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
  29766. * @return whether this node (and its parent) is enabled
  29767. */
  29768. isEnabled(checkAncestors?: boolean): boolean;
  29769. /** @hidden */
  29770. protected _syncParentEnabledState(): void;
  29771. /**
  29772. * Set the enabled state of this node
  29773. * @param value defines the new enabled state
  29774. */
  29775. setEnabled(value: boolean): void;
  29776. /**
  29777. * Is this node a descendant of the given node?
  29778. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29779. * @param ancestor defines the parent node to inspect
  29780. * @returns a boolean indicating if this node is a descendant of the given node
  29781. */
  29782. isDescendantOf(ancestor: Node): boolean;
  29783. /** @hidden */
  29784. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29785. /**
  29786. * Will return all nodes that have this node as ascendant
  29787. * @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
  29788. * @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
  29789. * @return all children nodes of all types
  29790. */
  29791. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29792. /**
  29793. * Get all child-meshes of this node
  29794. * @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)
  29795. * @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
  29796. * @returns an array of AbstractMesh
  29797. */
  29798. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29799. /**
  29800. * Get all direct children of this node
  29801. * @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
  29802. * @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)
  29803. * @returns an array of Node
  29804. */
  29805. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29806. /** @hidden */
  29807. _setReady(state: boolean): void;
  29808. /**
  29809. * Get an animation by name
  29810. * @param name defines the name of the animation to look for
  29811. * @returns null if not found else the requested animation
  29812. */
  29813. getAnimationByName(name: string): Nullable<Animation>;
  29814. /**
  29815. * Creates an animation range for this node
  29816. * @param name defines the name of the range
  29817. * @param from defines the starting key
  29818. * @param to defines the end key
  29819. */
  29820. createAnimationRange(name: string, from: number, to: number): void;
  29821. /**
  29822. * Delete a specific animation range
  29823. * @param name defines the name of the range to delete
  29824. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29825. */
  29826. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29827. /**
  29828. * Get an animation range by name
  29829. * @param name defines the name of the animation range to look for
  29830. * @returns null if not found else the requested animation range
  29831. */
  29832. getAnimationRange(name: string): Nullable<AnimationRange>;
  29833. /**
  29834. * Gets the list of all animation ranges defined on this node
  29835. * @returns an array
  29836. */
  29837. getAnimationRanges(): Nullable<AnimationRange>[];
  29838. /**
  29839. * Will start the animation sequence
  29840. * @param name defines the range frames for animation sequence
  29841. * @param loop defines if the animation should loop (false by default)
  29842. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29843. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29844. * @returns the object created for this animation. If range does not exist, it will return null
  29845. */
  29846. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29847. /**
  29848. * Serialize animation ranges into a JSON compatible object
  29849. * @returns serialization object
  29850. */
  29851. serializeAnimationRanges(): any;
  29852. /**
  29853. * Computes the world matrix of the node
  29854. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29855. * @returns the world matrix
  29856. */
  29857. computeWorldMatrix(force?: boolean): Matrix;
  29858. /**
  29859. * Releases resources associated with this node.
  29860. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29861. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29862. */
  29863. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29864. /**
  29865. * Parse animation range data from a serialization object and store them into a given node
  29866. * @param node defines where to store the animation ranges
  29867. * @param parsedNode defines the serialization object to read data from
  29868. * @param scene defines the hosting scene
  29869. */
  29870. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29871. /**
  29872. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29873. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29874. * @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
  29875. * @returns the new bounding vectors
  29876. */
  29877. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29878. min: Vector3;
  29879. max: Vector3;
  29880. };
  29881. }
  29882. }
  29883. declare module "babylonjs/Animations/animation" {
  29884. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29885. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29886. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29887. import { Nullable } from "babylonjs/types";
  29888. import { Scene } from "babylonjs/scene";
  29889. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29890. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29891. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29892. import { Node } from "babylonjs/node";
  29893. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29894. import { Size } from "babylonjs/Maths/math.size";
  29895. import { Animatable } from "babylonjs/Animations/animatable";
  29896. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29897. /**
  29898. * @hidden
  29899. */
  29900. export class _IAnimationState {
  29901. key: number;
  29902. repeatCount: number;
  29903. workValue?: any;
  29904. loopMode?: number;
  29905. offsetValue?: any;
  29906. highLimitValue?: any;
  29907. }
  29908. /**
  29909. * Class used to store any kind of animation
  29910. */
  29911. export class Animation {
  29912. /**Name of the animation */
  29913. name: string;
  29914. /**Property to animate */
  29915. targetProperty: string;
  29916. /**The frames per second of the animation */
  29917. framePerSecond: number;
  29918. /**The data type of the animation */
  29919. dataType: number;
  29920. /**The loop mode of the animation */
  29921. loopMode?: number | undefined;
  29922. /**Specifies if blending should be enabled */
  29923. enableBlending?: boolean | undefined;
  29924. /**
  29925. * Use matrix interpolation instead of using direct key value when animating matrices
  29926. */
  29927. static AllowMatricesInterpolation: boolean;
  29928. /**
  29929. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29930. */
  29931. static AllowMatrixDecomposeForInterpolation: boolean;
  29932. /**
  29933. * Stores the key frames of the animation
  29934. */
  29935. private _keys;
  29936. /**
  29937. * Stores the easing function of the animation
  29938. */
  29939. private _easingFunction;
  29940. /**
  29941. * @hidden Internal use only
  29942. */
  29943. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29944. /**
  29945. * The set of event that will be linked to this animation
  29946. */
  29947. private _events;
  29948. /**
  29949. * Stores an array of target property paths
  29950. */
  29951. targetPropertyPath: string[];
  29952. /**
  29953. * Stores the blending speed of the animation
  29954. */
  29955. blendingSpeed: number;
  29956. /**
  29957. * Stores the animation ranges for the animation
  29958. */
  29959. private _ranges;
  29960. /**
  29961. * @hidden Internal use
  29962. */
  29963. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29964. /**
  29965. * Sets up an animation
  29966. * @param property The property to animate
  29967. * @param animationType The animation type to apply
  29968. * @param framePerSecond The frames per second of the animation
  29969. * @param easingFunction The easing function used in the animation
  29970. * @returns The created animation
  29971. */
  29972. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29973. /**
  29974. * Create and start an animation on a node
  29975. * @param name defines the name of the global animation that will be run on all nodes
  29976. * @param node defines the root node where the animation will take place
  29977. * @param targetProperty defines property to animate
  29978. * @param framePerSecond defines the number of frame per second yo use
  29979. * @param totalFrame defines the number of frames in total
  29980. * @param from defines the initial value
  29981. * @param to defines the final value
  29982. * @param loopMode defines which loop mode you want to use (off by default)
  29983. * @param easingFunction defines the easing function to use (linear by default)
  29984. * @param onAnimationEnd defines the callback to call when animation end
  29985. * @returns the animatable created for this animation
  29986. */
  29987. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29988. /**
  29989. * Create and start an animation on a node and its descendants
  29990. * @param name defines the name of the global animation that will be run on all nodes
  29991. * @param node defines the root node where the animation will take place
  29992. * @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
  29993. * @param targetProperty defines property to animate
  29994. * @param framePerSecond defines the number of frame per second to use
  29995. * @param totalFrame defines the number of frames in total
  29996. * @param from defines the initial value
  29997. * @param to defines the final value
  29998. * @param loopMode defines which loop mode you want to use (off by default)
  29999. * @param easingFunction defines the easing function to use (linear by default)
  30000. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30001. * @returns the list of animatables created for all nodes
  30002. * @example https://www.babylonjs-playground.com/#MH0VLI
  30003. */
  30004. 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[]>;
  30005. /**
  30006. * Creates a new animation, merges it with the existing animations and starts it
  30007. * @param name Name of the animation
  30008. * @param node Node which contains the scene that begins the animations
  30009. * @param targetProperty Specifies which property to animate
  30010. * @param framePerSecond The frames per second of the animation
  30011. * @param totalFrame The total number of frames
  30012. * @param from The frame at the beginning of the animation
  30013. * @param to The frame at the end of the animation
  30014. * @param loopMode Specifies the loop mode of the animation
  30015. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30016. * @param onAnimationEnd Callback to run once the animation is complete
  30017. * @returns Nullable animation
  30018. */
  30019. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30020. /**
  30021. * Transition property of an host to the target Value
  30022. * @param property The property to transition
  30023. * @param targetValue The target Value of the property
  30024. * @param host The object where the property to animate belongs
  30025. * @param scene Scene used to run the animation
  30026. * @param frameRate Framerate (in frame/s) to use
  30027. * @param transition The transition type we want to use
  30028. * @param duration The duration of the animation, in milliseconds
  30029. * @param onAnimationEnd Callback trigger at the end of the animation
  30030. * @returns Nullable animation
  30031. */
  30032. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30033. /**
  30034. * Return the array of runtime animations currently using this animation
  30035. */
  30036. get runtimeAnimations(): RuntimeAnimation[];
  30037. /**
  30038. * Specifies if any of the runtime animations are currently running
  30039. */
  30040. get hasRunningRuntimeAnimations(): boolean;
  30041. /**
  30042. * Initializes the animation
  30043. * @param name Name of the animation
  30044. * @param targetProperty Property to animate
  30045. * @param framePerSecond The frames per second of the animation
  30046. * @param dataType The data type of the animation
  30047. * @param loopMode The loop mode of the animation
  30048. * @param enableBlending Specifies if blending should be enabled
  30049. */
  30050. constructor(
  30051. /**Name of the animation */
  30052. name: string,
  30053. /**Property to animate */
  30054. targetProperty: string,
  30055. /**The frames per second of the animation */
  30056. framePerSecond: number,
  30057. /**The data type of the animation */
  30058. dataType: number,
  30059. /**The loop mode of the animation */
  30060. loopMode?: number | undefined,
  30061. /**Specifies if blending should be enabled */
  30062. enableBlending?: boolean | undefined);
  30063. /**
  30064. * Converts the animation to a string
  30065. * @param fullDetails support for multiple levels of logging within scene loading
  30066. * @returns String form of the animation
  30067. */
  30068. toString(fullDetails?: boolean): string;
  30069. /**
  30070. * Add an event to this animation
  30071. * @param event Event to add
  30072. */
  30073. addEvent(event: AnimationEvent): void;
  30074. /**
  30075. * Remove all events found at the given frame
  30076. * @param frame The frame to remove events from
  30077. */
  30078. removeEvents(frame: number): void;
  30079. /**
  30080. * Retrieves all the events from the animation
  30081. * @returns Events from the animation
  30082. */
  30083. getEvents(): AnimationEvent[];
  30084. /**
  30085. * Creates an animation range
  30086. * @param name Name of the animation range
  30087. * @param from Starting frame of the animation range
  30088. * @param to Ending frame of the animation
  30089. */
  30090. createRange(name: string, from: number, to: number): void;
  30091. /**
  30092. * Deletes an animation range by name
  30093. * @param name Name of the animation range to delete
  30094. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30095. */
  30096. deleteRange(name: string, deleteFrames?: boolean): void;
  30097. /**
  30098. * Gets the animation range by name, or null if not defined
  30099. * @param name Name of the animation range
  30100. * @returns Nullable animation range
  30101. */
  30102. getRange(name: string): Nullable<AnimationRange>;
  30103. /**
  30104. * Gets the key frames from the animation
  30105. * @returns The key frames of the animation
  30106. */
  30107. getKeys(): Array<IAnimationKey>;
  30108. /**
  30109. * Gets the highest frame rate of the animation
  30110. * @returns Highest frame rate of the animation
  30111. */
  30112. getHighestFrame(): number;
  30113. /**
  30114. * Gets the easing function of the animation
  30115. * @returns Easing function of the animation
  30116. */
  30117. getEasingFunction(): IEasingFunction;
  30118. /**
  30119. * Sets the easing function of the animation
  30120. * @param easingFunction A custom mathematical formula for animation
  30121. */
  30122. setEasingFunction(easingFunction: EasingFunction): void;
  30123. /**
  30124. * Interpolates a scalar linearly
  30125. * @param startValue Start value of the animation curve
  30126. * @param endValue End value of the animation curve
  30127. * @param gradient Scalar amount to interpolate
  30128. * @returns Interpolated scalar value
  30129. */
  30130. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30131. /**
  30132. * Interpolates a scalar cubically
  30133. * @param startValue Start value of the animation curve
  30134. * @param outTangent End tangent of the animation
  30135. * @param endValue End value of the animation curve
  30136. * @param inTangent Start tangent of the animation curve
  30137. * @param gradient Scalar amount to interpolate
  30138. * @returns Interpolated scalar value
  30139. */
  30140. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30141. /**
  30142. * Interpolates a quaternion using a spherical linear interpolation
  30143. * @param startValue Start value of the animation curve
  30144. * @param endValue End value of the animation curve
  30145. * @param gradient Scalar amount to interpolate
  30146. * @returns Interpolated quaternion value
  30147. */
  30148. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30149. /**
  30150. * Interpolates a quaternion cubically
  30151. * @param startValue Start value of the animation curve
  30152. * @param outTangent End tangent of the animation curve
  30153. * @param endValue End value of the animation curve
  30154. * @param inTangent Start tangent of the animation curve
  30155. * @param gradient Scalar amount to interpolate
  30156. * @returns Interpolated quaternion value
  30157. */
  30158. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30159. /**
  30160. * Interpolates a Vector3 linearl
  30161. * @param startValue Start value of the animation curve
  30162. * @param endValue End value of the animation curve
  30163. * @param gradient Scalar amount to interpolate
  30164. * @returns Interpolated scalar value
  30165. */
  30166. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30167. /**
  30168. * Interpolates a Vector3 cubically
  30169. * @param startValue Start value of the animation curve
  30170. * @param outTangent End tangent of the animation
  30171. * @param endValue End value of the animation curve
  30172. * @param inTangent Start tangent of the animation curve
  30173. * @param gradient Scalar amount to interpolate
  30174. * @returns InterpolatedVector3 value
  30175. */
  30176. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30177. /**
  30178. * Interpolates a Vector2 linearly
  30179. * @param startValue Start value of the animation curve
  30180. * @param endValue End value of the animation curve
  30181. * @param gradient Scalar amount to interpolate
  30182. * @returns Interpolated Vector2 value
  30183. */
  30184. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30185. /**
  30186. * Interpolates a Vector2 cubically
  30187. * @param startValue Start value of the animation curve
  30188. * @param outTangent End tangent of the animation
  30189. * @param endValue End value of the animation curve
  30190. * @param inTangent Start tangent of the animation curve
  30191. * @param gradient Scalar amount to interpolate
  30192. * @returns Interpolated Vector2 value
  30193. */
  30194. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30195. /**
  30196. * Interpolates a size linearly
  30197. * @param startValue Start value of the animation curve
  30198. * @param endValue End value of the animation curve
  30199. * @param gradient Scalar amount to interpolate
  30200. * @returns Interpolated Size value
  30201. */
  30202. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30203. /**
  30204. * Interpolates a Color3 linearly
  30205. * @param startValue Start value of the animation curve
  30206. * @param endValue End value of the animation curve
  30207. * @param gradient Scalar amount to interpolate
  30208. * @returns Interpolated Color3 value
  30209. */
  30210. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30211. /**
  30212. * Interpolates a Color4 linearly
  30213. * @param startValue Start value of the animation curve
  30214. * @param endValue End value of the animation curve
  30215. * @param gradient Scalar amount to interpolate
  30216. * @returns Interpolated Color3 value
  30217. */
  30218. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30219. /**
  30220. * @hidden Internal use only
  30221. */
  30222. _getKeyValue(value: any): any;
  30223. /**
  30224. * @hidden Internal use only
  30225. */
  30226. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30227. /**
  30228. * Defines the function to use to interpolate matrices
  30229. * @param startValue defines the start matrix
  30230. * @param endValue defines the end matrix
  30231. * @param gradient defines the gradient between both matrices
  30232. * @param result defines an optional target matrix where to store the interpolation
  30233. * @returns the interpolated matrix
  30234. */
  30235. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30236. /**
  30237. * Makes a copy of the animation
  30238. * @returns Cloned animation
  30239. */
  30240. clone(): Animation;
  30241. /**
  30242. * Sets the key frames of the animation
  30243. * @param values The animation key frames to set
  30244. */
  30245. setKeys(values: Array<IAnimationKey>): void;
  30246. /**
  30247. * Serializes the animation to an object
  30248. * @returns Serialized object
  30249. */
  30250. serialize(): any;
  30251. /**
  30252. * Float animation type
  30253. */
  30254. static readonly ANIMATIONTYPE_FLOAT: number;
  30255. /**
  30256. * Vector3 animation type
  30257. */
  30258. static readonly ANIMATIONTYPE_VECTOR3: number;
  30259. /**
  30260. * Quaternion animation type
  30261. */
  30262. static readonly ANIMATIONTYPE_QUATERNION: number;
  30263. /**
  30264. * Matrix animation type
  30265. */
  30266. static readonly ANIMATIONTYPE_MATRIX: number;
  30267. /**
  30268. * Color3 animation type
  30269. */
  30270. static readonly ANIMATIONTYPE_COLOR3: number;
  30271. /**
  30272. * Color3 animation type
  30273. */
  30274. static readonly ANIMATIONTYPE_COLOR4: number;
  30275. /**
  30276. * Vector2 animation type
  30277. */
  30278. static readonly ANIMATIONTYPE_VECTOR2: number;
  30279. /**
  30280. * Size animation type
  30281. */
  30282. static readonly ANIMATIONTYPE_SIZE: number;
  30283. /**
  30284. * Relative Loop Mode
  30285. */
  30286. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30287. /**
  30288. * Cycle Loop Mode
  30289. */
  30290. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30291. /**
  30292. * Constant Loop Mode
  30293. */
  30294. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30295. /** @hidden */
  30296. static _UniversalLerp(left: any, right: any, amount: number): any;
  30297. /**
  30298. * Parses an animation object and creates an animation
  30299. * @param parsedAnimation Parsed animation object
  30300. * @returns Animation object
  30301. */
  30302. static Parse(parsedAnimation: any): Animation;
  30303. /**
  30304. * Appends the serialized animations from the source animations
  30305. * @param source Source containing the animations
  30306. * @param destination Target to store the animations
  30307. */
  30308. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30309. }
  30310. }
  30311. declare module "babylonjs/Animations/animatable.interface" {
  30312. import { Nullable } from "babylonjs/types";
  30313. import { Animation } from "babylonjs/Animations/animation";
  30314. /**
  30315. * Interface containing an array of animations
  30316. */
  30317. export interface IAnimatable {
  30318. /**
  30319. * Array of animations
  30320. */
  30321. animations: Nullable<Array<Animation>>;
  30322. }
  30323. }
  30324. declare module "babylonjs/Misc/decorators" {
  30325. import { Nullable } from "babylonjs/types";
  30326. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30327. import { Scene } from "babylonjs/scene";
  30328. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30329. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30330. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30331. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30332. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30333. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30334. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30335. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30336. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30337. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30338. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30339. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30340. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30341. /**
  30342. * Decorator used to define property that can be serialized as reference to a camera
  30343. * @param sourceName defines the name of the property to decorate
  30344. */
  30345. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30346. /**
  30347. * Class used to help serialization objects
  30348. */
  30349. export class SerializationHelper {
  30350. /** @hidden */
  30351. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30352. /** @hidden */
  30353. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30354. /** @hidden */
  30355. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30356. /** @hidden */
  30357. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30358. /**
  30359. * Appends the serialized animations from the source animations
  30360. * @param source Source containing the animations
  30361. * @param destination Target to store the animations
  30362. */
  30363. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30364. /**
  30365. * Static function used to serialized a specific entity
  30366. * @param entity defines the entity to serialize
  30367. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30368. * @returns a JSON compatible object representing the serialization of the entity
  30369. */
  30370. static Serialize<T>(entity: T, serializationObject?: any): any;
  30371. /**
  30372. * Creates a new entity from a serialization data object
  30373. * @param creationFunction defines a function used to instanciated the new entity
  30374. * @param source defines the source serialization data
  30375. * @param scene defines the hosting scene
  30376. * @param rootUrl defines the root url for resources
  30377. * @returns a new entity
  30378. */
  30379. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30380. /**
  30381. * Clones an object
  30382. * @param creationFunction defines the function used to instanciate the new object
  30383. * @param source defines the source object
  30384. * @returns the cloned object
  30385. */
  30386. static Clone<T>(creationFunction: () => T, source: T): T;
  30387. /**
  30388. * Instanciates a new object based on a source one (some data will be shared between both object)
  30389. * @param creationFunction defines the function used to instanciate the new object
  30390. * @param source defines the source object
  30391. * @returns the new object
  30392. */
  30393. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30394. }
  30395. }
  30396. declare module "babylonjs/Misc/guid" {
  30397. /**
  30398. * Class used to manipulate GUIDs
  30399. */
  30400. export class GUID {
  30401. /**
  30402. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30403. * Be aware Math.random() could cause collisions, but:
  30404. * "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"
  30405. * @returns a pseudo random id
  30406. */
  30407. static RandomId(): string;
  30408. }
  30409. }
  30410. declare module "babylonjs/Materials/Textures/baseTexture" {
  30411. import { Observable } from "babylonjs/Misc/observable";
  30412. import { Nullable } from "babylonjs/types";
  30413. import { Scene } from "babylonjs/scene";
  30414. import { Matrix } from "babylonjs/Maths/math.vector";
  30415. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30416. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30417. import { ISize } from "babylonjs/Maths/math.size";
  30418. import "babylonjs/Misc/fileTools";
  30419. /**
  30420. * Base class of all the textures in babylon.
  30421. * It groups all the common properties the materials, post process, lights... might need
  30422. * in order to make a correct use of the texture.
  30423. */
  30424. export class BaseTexture implements IAnimatable {
  30425. /**
  30426. * Default anisotropic filtering level for the application.
  30427. * It is set to 4 as a good tradeoff between perf and quality.
  30428. */
  30429. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30430. /**
  30431. * Gets or sets the unique id of the texture
  30432. */
  30433. uniqueId: number;
  30434. /**
  30435. * Define the name of the texture.
  30436. */
  30437. name: string;
  30438. /**
  30439. * Gets or sets an object used to store user defined information.
  30440. */
  30441. metadata: any;
  30442. /**
  30443. * For internal use only. Please do not use.
  30444. */
  30445. reservedDataStore: any;
  30446. private _hasAlpha;
  30447. /**
  30448. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30449. */
  30450. set hasAlpha(value: boolean);
  30451. get hasAlpha(): boolean;
  30452. /**
  30453. * Defines if the alpha value should be determined via the rgb values.
  30454. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30455. */
  30456. getAlphaFromRGB: boolean;
  30457. /**
  30458. * Intensity or strength of the texture.
  30459. * It is commonly used by materials to fine tune the intensity of the texture
  30460. */
  30461. level: number;
  30462. /**
  30463. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30464. * This is part of the texture as textures usually maps to one uv set.
  30465. */
  30466. coordinatesIndex: number;
  30467. private _coordinatesMode;
  30468. /**
  30469. * How a texture is mapped.
  30470. *
  30471. * | Value | Type | Description |
  30472. * | ----- | ----------------------------------- | ----------- |
  30473. * | 0 | EXPLICIT_MODE | |
  30474. * | 1 | SPHERICAL_MODE | |
  30475. * | 2 | PLANAR_MODE | |
  30476. * | 3 | CUBIC_MODE | |
  30477. * | 4 | PROJECTION_MODE | |
  30478. * | 5 | SKYBOX_MODE | |
  30479. * | 6 | INVCUBIC_MODE | |
  30480. * | 7 | EQUIRECTANGULAR_MODE | |
  30481. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30482. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30483. */
  30484. set coordinatesMode(value: number);
  30485. get coordinatesMode(): number;
  30486. /**
  30487. * | Value | Type | Description |
  30488. * | ----- | ------------------ | ----------- |
  30489. * | 0 | CLAMP_ADDRESSMODE | |
  30490. * | 1 | WRAP_ADDRESSMODE | |
  30491. * | 2 | MIRROR_ADDRESSMODE | |
  30492. */
  30493. wrapU: number;
  30494. /**
  30495. * | Value | Type | Description |
  30496. * | ----- | ------------------ | ----------- |
  30497. * | 0 | CLAMP_ADDRESSMODE | |
  30498. * | 1 | WRAP_ADDRESSMODE | |
  30499. * | 2 | MIRROR_ADDRESSMODE | |
  30500. */
  30501. wrapV: number;
  30502. /**
  30503. * | Value | Type | Description |
  30504. * | ----- | ------------------ | ----------- |
  30505. * | 0 | CLAMP_ADDRESSMODE | |
  30506. * | 1 | WRAP_ADDRESSMODE | |
  30507. * | 2 | MIRROR_ADDRESSMODE | |
  30508. */
  30509. wrapR: number;
  30510. /**
  30511. * With compliant hardware and browser (supporting anisotropic filtering)
  30512. * this defines the level of anisotropic filtering in the texture.
  30513. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30514. */
  30515. anisotropicFilteringLevel: number;
  30516. /**
  30517. * Define if the texture is a cube texture or if false a 2d texture.
  30518. */
  30519. get isCube(): boolean;
  30520. set isCube(value: boolean);
  30521. /**
  30522. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30523. */
  30524. get is3D(): boolean;
  30525. set is3D(value: boolean);
  30526. /**
  30527. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30528. */
  30529. get is2DArray(): boolean;
  30530. set is2DArray(value: boolean);
  30531. /**
  30532. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30533. * HDR texture are usually stored in linear space.
  30534. * This only impacts the PBR and Background materials
  30535. */
  30536. gammaSpace: boolean;
  30537. /**
  30538. * Gets or sets whether or not the texture contains RGBD data.
  30539. */
  30540. get isRGBD(): boolean;
  30541. set isRGBD(value: boolean);
  30542. /**
  30543. * Is Z inverted in the texture (useful in a cube texture).
  30544. */
  30545. invertZ: boolean;
  30546. /**
  30547. * Are mip maps generated for this texture or not.
  30548. */
  30549. get noMipmap(): boolean;
  30550. /**
  30551. * @hidden
  30552. */
  30553. lodLevelInAlpha: boolean;
  30554. /**
  30555. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30556. */
  30557. get lodGenerationOffset(): number;
  30558. set lodGenerationOffset(value: number);
  30559. /**
  30560. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30561. */
  30562. get lodGenerationScale(): number;
  30563. set lodGenerationScale(value: number);
  30564. /**
  30565. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30566. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30567. * average roughness values.
  30568. */
  30569. get linearSpecularLOD(): boolean;
  30570. set linearSpecularLOD(value: boolean);
  30571. /**
  30572. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30573. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30574. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30575. */
  30576. get irradianceTexture(): Nullable<BaseTexture>;
  30577. set irradianceTexture(value: Nullable<BaseTexture>);
  30578. /**
  30579. * Define if the texture is a render target.
  30580. */
  30581. isRenderTarget: boolean;
  30582. /**
  30583. * Define the unique id of the texture in the scene.
  30584. */
  30585. get uid(): string;
  30586. /**
  30587. * Return a string representation of the texture.
  30588. * @returns the texture as a string
  30589. */
  30590. toString(): string;
  30591. /**
  30592. * Get the class name of the texture.
  30593. * @returns "BaseTexture"
  30594. */
  30595. getClassName(): string;
  30596. /**
  30597. * Define the list of animation attached to the texture.
  30598. */
  30599. animations: import("babylonjs/Animations/animation").Animation[];
  30600. /**
  30601. * An event triggered when the texture is disposed.
  30602. */
  30603. onDisposeObservable: Observable<BaseTexture>;
  30604. private _onDisposeObserver;
  30605. /**
  30606. * Callback triggered when the texture has been disposed.
  30607. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30608. */
  30609. set onDispose(callback: () => void);
  30610. /**
  30611. * Define the current state of the loading sequence when in delayed load mode.
  30612. */
  30613. delayLoadState: number;
  30614. private _scene;
  30615. /** @hidden */
  30616. _texture: Nullable<InternalTexture>;
  30617. private _uid;
  30618. /**
  30619. * Define if the texture is preventinga material to render or not.
  30620. * If not and the texture is not ready, the engine will use a default black texture instead.
  30621. */
  30622. get isBlocking(): boolean;
  30623. /**
  30624. * Instantiates a new BaseTexture.
  30625. * Base class of all the textures in babylon.
  30626. * It groups all the common properties the materials, post process, lights... might need
  30627. * in order to make a correct use of the texture.
  30628. * @param scene Define the scene the texture blongs to
  30629. */
  30630. constructor(scene: Nullable<Scene>);
  30631. /**
  30632. * Get the scene the texture belongs to.
  30633. * @returns the scene or null if undefined
  30634. */
  30635. getScene(): Nullable<Scene>;
  30636. /**
  30637. * Get the texture transform matrix used to offset tile the texture for istance.
  30638. * @returns the transformation matrix
  30639. */
  30640. getTextureMatrix(): Matrix;
  30641. /**
  30642. * Get the texture reflection matrix used to rotate/transform the reflection.
  30643. * @returns the reflection matrix
  30644. */
  30645. getReflectionTextureMatrix(): Matrix;
  30646. /**
  30647. * Get the underlying lower level texture from Babylon.
  30648. * @returns the insternal texture
  30649. */
  30650. getInternalTexture(): Nullable<InternalTexture>;
  30651. /**
  30652. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30653. * @returns true if ready or not blocking
  30654. */
  30655. isReadyOrNotBlocking(): boolean;
  30656. /**
  30657. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30658. * @returns true if fully ready
  30659. */
  30660. isReady(): boolean;
  30661. private _cachedSize;
  30662. /**
  30663. * Get the size of the texture.
  30664. * @returns the texture size.
  30665. */
  30666. getSize(): ISize;
  30667. /**
  30668. * Get the base size of the texture.
  30669. * It can be different from the size if the texture has been resized for POT for instance
  30670. * @returns the base size
  30671. */
  30672. getBaseSize(): ISize;
  30673. /**
  30674. * Update the sampling mode of the texture.
  30675. * Default is Trilinear mode.
  30676. *
  30677. * | Value | Type | Description |
  30678. * | ----- | ------------------ | ----------- |
  30679. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30680. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30681. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30682. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30683. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30684. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30685. * | 7 | NEAREST_LINEAR | |
  30686. * | 8 | NEAREST_NEAREST | |
  30687. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30688. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30689. * | 11 | LINEAR_LINEAR | |
  30690. * | 12 | LINEAR_NEAREST | |
  30691. *
  30692. * > _mag_: magnification filter (close to the viewer)
  30693. * > _min_: minification filter (far from the viewer)
  30694. * > _mip_: filter used between mip map levels
  30695. *@param samplingMode Define the new sampling mode of the texture
  30696. */
  30697. updateSamplingMode(samplingMode: number): void;
  30698. /**
  30699. * Scales the texture if is `canRescale()`
  30700. * @param ratio the resize factor we want to use to rescale
  30701. */
  30702. scale(ratio: number): void;
  30703. /**
  30704. * Get if the texture can rescale.
  30705. */
  30706. get canRescale(): boolean;
  30707. /** @hidden */
  30708. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30709. /** @hidden */
  30710. _rebuild(): void;
  30711. /**
  30712. * Triggers the load sequence in delayed load mode.
  30713. */
  30714. delayLoad(): void;
  30715. /**
  30716. * Clones the texture.
  30717. * @returns the cloned texture
  30718. */
  30719. clone(): Nullable<BaseTexture>;
  30720. /**
  30721. * Get the texture underlying type (INT, FLOAT...)
  30722. */
  30723. get textureType(): number;
  30724. /**
  30725. * Get the texture underlying format (RGB, RGBA...)
  30726. */
  30727. get textureFormat(): number;
  30728. /**
  30729. * Indicates that textures need to be re-calculated for all materials
  30730. */
  30731. protected _markAllSubMeshesAsTexturesDirty(): void;
  30732. /**
  30733. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30734. * This will returns an RGBA array buffer containing either in values (0-255) or
  30735. * float values (0-1) depending of the underlying buffer type.
  30736. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30737. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30738. * @param buffer defines a user defined buffer to fill with data (can be null)
  30739. * @returns The Array buffer containing the pixels data.
  30740. */
  30741. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30742. /**
  30743. * Release and destroy the underlying lower level texture aka internalTexture.
  30744. */
  30745. releaseInternalTexture(): void;
  30746. /** @hidden */
  30747. get _lodTextureHigh(): Nullable<BaseTexture>;
  30748. /** @hidden */
  30749. get _lodTextureMid(): Nullable<BaseTexture>;
  30750. /** @hidden */
  30751. get _lodTextureLow(): Nullable<BaseTexture>;
  30752. /**
  30753. * Dispose the texture and release its associated resources.
  30754. */
  30755. dispose(): void;
  30756. /**
  30757. * Serialize the texture into a JSON representation that can be parsed later on.
  30758. * @returns the JSON representation of the texture
  30759. */
  30760. serialize(): any;
  30761. /**
  30762. * Helper function to be called back once a list of texture contains only ready textures.
  30763. * @param textures Define the list of textures to wait for
  30764. * @param callback Define the callback triggered once the entire list will be ready
  30765. */
  30766. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30767. }
  30768. }
  30769. declare module "babylonjs/Materials/effect" {
  30770. import { Observable } from "babylonjs/Misc/observable";
  30771. import { Nullable } from "babylonjs/types";
  30772. import { IDisposable } from "babylonjs/scene";
  30773. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30774. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30775. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30776. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30777. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30778. import { Engine } from "babylonjs/Engines/engine";
  30779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30782. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30783. /**
  30784. * Options to be used when creating an effect.
  30785. */
  30786. export interface IEffectCreationOptions {
  30787. /**
  30788. * Atrributes that will be used in the shader.
  30789. */
  30790. attributes: string[];
  30791. /**
  30792. * Uniform varible names that will be set in the shader.
  30793. */
  30794. uniformsNames: string[];
  30795. /**
  30796. * Uniform buffer variable names that will be set in the shader.
  30797. */
  30798. uniformBuffersNames: string[];
  30799. /**
  30800. * Sampler texture variable names that will be set in the shader.
  30801. */
  30802. samplers: string[];
  30803. /**
  30804. * Define statements that will be set in the shader.
  30805. */
  30806. defines: any;
  30807. /**
  30808. * Possible fallbacks for this effect to improve performance when needed.
  30809. */
  30810. fallbacks: Nullable<IEffectFallbacks>;
  30811. /**
  30812. * Callback that will be called when the shader is compiled.
  30813. */
  30814. onCompiled: Nullable<(effect: Effect) => void>;
  30815. /**
  30816. * Callback that will be called if an error occurs during shader compilation.
  30817. */
  30818. onError: Nullable<(effect: Effect, errors: string) => void>;
  30819. /**
  30820. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30821. */
  30822. indexParameters?: any;
  30823. /**
  30824. * Max number of lights that can be used in the shader.
  30825. */
  30826. maxSimultaneousLights?: number;
  30827. /**
  30828. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30829. */
  30830. transformFeedbackVaryings?: Nullable<string[]>;
  30831. }
  30832. /**
  30833. * Effect containing vertex and fragment shader that can be executed on an object.
  30834. */
  30835. export class Effect implements IDisposable {
  30836. /**
  30837. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30838. */
  30839. static ShadersRepository: string;
  30840. /**
  30841. * Name of the effect.
  30842. */
  30843. name: any;
  30844. /**
  30845. * String container all the define statements that should be set on the shader.
  30846. */
  30847. defines: string;
  30848. /**
  30849. * Callback that will be called when the shader is compiled.
  30850. */
  30851. onCompiled: Nullable<(effect: Effect) => void>;
  30852. /**
  30853. * Callback that will be called if an error occurs during shader compilation.
  30854. */
  30855. onError: Nullable<(effect: Effect, errors: string) => void>;
  30856. /**
  30857. * Callback that will be called when effect is bound.
  30858. */
  30859. onBind: Nullable<(effect: Effect) => void>;
  30860. /**
  30861. * Unique ID of the effect.
  30862. */
  30863. uniqueId: number;
  30864. /**
  30865. * Observable that will be called when the shader is compiled.
  30866. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30867. */
  30868. onCompileObservable: Observable<Effect>;
  30869. /**
  30870. * Observable that will be called if an error occurs during shader compilation.
  30871. */
  30872. onErrorObservable: Observable<Effect>;
  30873. /** @hidden */
  30874. _onBindObservable: Nullable<Observable<Effect>>;
  30875. /**
  30876. * @hidden
  30877. * Specifies if the effect was previously ready
  30878. */
  30879. _wasPreviouslyReady: boolean;
  30880. /**
  30881. * Observable that will be called when effect is bound.
  30882. */
  30883. get onBindObservable(): Observable<Effect>;
  30884. /** @hidden */
  30885. _bonesComputationForcedToCPU: boolean;
  30886. private static _uniqueIdSeed;
  30887. private _engine;
  30888. private _uniformBuffersNames;
  30889. private _uniformsNames;
  30890. private _samplerList;
  30891. private _samplers;
  30892. private _isReady;
  30893. private _compilationError;
  30894. private _allFallbacksProcessed;
  30895. private _attributesNames;
  30896. private _attributes;
  30897. private _attributeLocationByName;
  30898. private _uniforms;
  30899. /**
  30900. * Key for the effect.
  30901. * @hidden
  30902. */
  30903. _key: string;
  30904. private _indexParameters;
  30905. private _fallbacks;
  30906. private _vertexSourceCode;
  30907. private _fragmentSourceCode;
  30908. private _vertexSourceCodeOverride;
  30909. private _fragmentSourceCodeOverride;
  30910. private _transformFeedbackVaryings;
  30911. /**
  30912. * Compiled shader to webGL program.
  30913. * @hidden
  30914. */
  30915. _pipelineContext: Nullable<IPipelineContext>;
  30916. private _valueCache;
  30917. private static _baseCache;
  30918. /**
  30919. * Instantiates an effect.
  30920. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30921. * @param baseName Name of the effect.
  30922. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30923. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30924. * @param samplers List of sampler variables that will be passed to the shader.
  30925. * @param engine Engine to be used to render the effect
  30926. * @param defines Define statements to be added to the shader.
  30927. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30928. * @param onCompiled Callback that will be called when the shader is compiled.
  30929. * @param onError Callback that will be called if an error occurs during shader compilation.
  30930. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30931. */
  30932. 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);
  30933. private _useFinalCode;
  30934. /**
  30935. * Unique key for this effect
  30936. */
  30937. get key(): string;
  30938. /**
  30939. * If the effect has been compiled and prepared.
  30940. * @returns if the effect is compiled and prepared.
  30941. */
  30942. isReady(): boolean;
  30943. private _isReadyInternal;
  30944. /**
  30945. * The engine the effect was initialized with.
  30946. * @returns the engine.
  30947. */
  30948. getEngine(): Engine;
  30949. /**
  30950. * The pipeline context for this effect
  30951. * @returns the associated pipeline context
  30952. */
  30953. getPipelineContext(): Nullable<IPipelineContext>;
  30954. /**
  30955. * The set of names of attribute variables for the shader.
  30956. * @returns An array of attribute names.
  30957. */
  30958. getAttributesNames(): string[];
  30959. /**
  30960. * Returns the attribute at the given index.
  30961. * @param index The index of the attribute.
  30962. * @returns The location of the attribute.
  30963. */
  30964. getAttributeLocation(index: number): number;
  30965. /**
  30966. * Returns the attribute based on the name of the variable.
  30967. * @param name of the attribute to look up.
  30968. * @returns the attribute location.
  30969. */
  30970. getAttributeLocationByName(name: string): number;
  30971. /**
  30972. * The number of attributes.
  30973. * @returns the numnber of attributes.
  30974. */
  30975. getAttributesCount(): number;
  30976. /**
  30977. * Gets the index of a uniform variable.
  30978. * @param uniformName of the uniform to look up.
  30979. * @returns the index.
  30980. */
  30981. getUniformIndex(uniformName: string): number;
  30982. /**
  30983. * Returns the attribute based on the name of the variable.
  30984. * @param uniformName of the uniform to look up.
  30985. * @returns the location of the uniform.
  30986. */
  30987. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30988. /**
  30989. * Returns an array of sampler variable names
  30990. * @returns The array of sampler variable neames.
  30991. */
  30992. getSamplers(): string[];
  30993. /**
  30994. * The error from the last compilation.
  30995. * @returns the error string.
  30996. */
  30997. getCompilationError(): string;
  30998. /**
  30999. * Gets a boolean indicating that all fallbacks were used during compilation
  31000. * @returns true if all fallbacks were used
  31001. */
  31002. allFallbacksProcessed(): boolean;
  31003. /**
  31004. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31005. * @param func The callback to be used.
  31006. */
  31007. executeWhenCompiled(func: (effect: Effect) => void): void;
  31008. private _checkIsReady;
  31009. private _loadShader;
  31010. /**
  31011. * Recompiles the webGL program
  31012. * @param vertexSourceCode The source code for the vertex shader.
  31013. * @param fragmentSourceCode The source code for the fragment shader.
  31014. * @param onCompiled Callback called when completed.
  31015. * @param onError Callback called on error.
  31016. * @hidden
  31017. */
  31018. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31019. /**
  31020. * Prepares the effect
  31021. * @hidden
  31022. */
  31023. _prepareEffect(): void;
  31024. private _processCompilationErrors;
  31025. /**
  31026. * Checks if the effect is supported. (Must be called after compilation)
  31027. */
  31028. get isSupported(): boolean;
  31029. /**
  31030. * Binds a texture to the engine to be used as output of the shader.
  31031. * @param channel Name of the output variable.
  31032. * @param texture Texture to bind.
  31033. * @hidden
  31034. */
  31035. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31036. /**
  31037. * Sets a texture on the engine to be used in the shader.
  31038. * @param channel Name of the sampler variable.
  31039. * @param texture Texture to set.
  31040. */
  31041. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31042. /**
  31043. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31044. * @param channel Name of the sampler variable.
  31045. * @param texture Texture to set.
  31046. */
  31047. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31048. /**
  31049. * Sets an array of textures on the engine to be used in the shader.
  31050. * @param channel Name of the variable.
  31051. * @param textures Textures to set.
  31052. */
  31053. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31054. /**
  31055. * 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)
  31056. * @param channel Name of the sampler variable.
  31057. * @param postProcess Post process to get the input texture from.
  31058. */
  31059. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31060. /**
  31061. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31062. * 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)
  31063. * @param channel Name of the sampler variable.
  31064. * @param postProcess Post process to get the output texture from.
  31065. */
  31066. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31067. /** @hidden */
  31068. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31069. /** @hidden */
  31070. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31071. /** @hidden */
  31072. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31073. /** @hidden */
  31074. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31075. /**
  31076. * Binds a buffer to a uniform.
  31077. * @param buffer Buffer to bind.
  31078. * @param name Name of the uniform variable to bind to.
  31079. */
  31080. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31081. /**
  31082. * Binds block to a uniform.
  31083. * @param blockName Name of the block to bind.
  31084. * @param index Index to bind.
  31085. */
  31086. bindUniformBlock(blockName: string, index: number): void;
  31087. /**
  31088. * Sets an interger value on a uniform variable.
  31089. * @param uniformName Name of the variable.
  31090. * @param value Value to be set.
  31091. * @returns this effect.
  31092. */
  31093. setInt(uniformName: string, value: number): Effect;
  31094. /**
  31095. * Sets an int array on a uniform variable.
  31096. * @param uniformName Name of the variable.
  31097. * @param array array to be set.
  31098. * @returns this effect.
  31099. */
  31100. setIntArray(uniformName: string, array: Int32Array): Effect;
  31101. /**
  31102. * 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)
  31103. * @param uniformName Name of the variable.
  31104. * @param array array to be set.
  31105. * @returns this effect.
  31106. */
  31107. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31108. /**
  31109. * 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)
  31110. * @param uniformName Name of the variable.
  31111. * @param array array to be set.
  31112. * @returns this effect.
  31113. */
  31114. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31115. /**
  31116. * 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)
  31117. * @param uniformName Name of the variable.
  31118. * @param array array to be set.
  31119. * @returns this effect.
  31120. */
  31121. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31122. /**
  31123. * Sets an float array on a uniform variable.
  31124. * @param uniformName Name of the variable.
  31125. * @param array array to be set.
  31126. * @returns this effect.
  31127. */
  31128. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31129. /**
  31130. * 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)
  31131. * @param uniformName Name of the variable.
  31132. * @param array array to be set.
  31133. * @returns this effect.
  31134. */
  31135. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31136. /**
  31137. * 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)
  31138. * @param uniformName Name of the variable.
  31139. * @param array array to be set.
  31140. * @returns this effect.
  31141. */
  31142. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31143. /**
  31144. * 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)
  31145. * @param uniformName Name of the variable.
  31146. * @param array array to be set.
  31147. * @returns this effect.
  31148. */
  31149. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31150. /**
  31151. * Sets an array on a uniform variable.
  31152. * @param uniformName Name of the variable.
  31153. * @param array array to be set.
  31154. * @returns this effect.
  31155. */
  31156. setArray(uniformName: string, array: number[]): Effect;
  31157. /**
  31158. * 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)
  31159. * @param uniformName Name of the variable.
  31160. * @param array array to be set.
  31161. * @returns this effect.
  31162. */
  31163. setArray2(uniformName: string, array: number[]): Effect;
  31164. /**
  31165. * 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)
  31166. * @param uniformName Name of the variable.
  31167. * @param array array to be set.
  31168. * @returns this effect.
  31169. */
  31170. setArray3(uniformName: string, array: number[]): Effect;
  31171. /**
  31172. * 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)
  31173. * @param uniformName Name of the variable.
  31174. * @param array array to be set.
  31175. * @returns this effect.
  31176. */
  31177. setArray4(uniformName: string, array: number[]): Effect;
  31178. /**
  31179. * Sets matrices on a uniform variable.
  31180. * @param uniformName Name of the variable.
  31181. * @param matrices matrices to be set.
  31182. * @returns this effect.
  31183. */
  31184. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31185. /**
  31186. * Sets matrix on a uniform variable.
  31187. * @param uniformName Name of the variable.
  31188. * @param matrix matrix to be set.
  31189. * @returns this effect.
  31190. */
  31191. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31192. /**
  31193. * 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)
  31194. * @param uniformName Name of the variable.
  31195. * @param matrix matrix to be set.
  31196. * @returns this effect.
  31197. */
  31198. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31199. /**
  31200. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31201. * @param uniformName Name of the variable.
  31202. * @param matrix matrix to be set.
  31203. * @returns this effect.
  31204. */
  31205. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31206. /**
  31207. * Sets a float on a uniform variable.
  31208. * @param uniformName Name of the variable.
  31209. * @param value value to be set.
  31210. * @returns this effect.
  31211. */
  31212. setFloat(uniformName: string, value: number): Effect;
  31213. /**
  31214. * Sets a boolean on a uniform variable.
  31215. * @param uniformName Name of the variable.
  31216. * @param bool value to be set.
  31217. * @returns this effect.
  31218. */
  31219. setBool(uniformName: string, bool: boolean): Effect;
  31220. /**
  31221. * Sets a Vector2 on a uniform variable.
  31222. * @param uniformName Name of the variable.
  31223. * @param vector2 vector2 to be set.
  31224. * @returns this effect.
  31225. */
  31226. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31227. /**
  31228. * Sets a float2 on a uniform variable.
  31229. * @param uniformName Name of the variable.
  31230. * @param x First float in float2.
  31231. * @param y Second float in float2.
  31232. * @returns this effect.
  31233. */
  31234. setFloat2(uniformName: string, x: number, y: number): Effect;
  31235. /**
  31236. * Sets a Vector3 on a uniform variable.
  31237. * @param uniformName Name of the variable.
  31238. * @param vector3 Value to be set.
  31239. * @returns this effect.
  31240. */
  31241. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31242. /**
  31243. * Sets a float3 on a uniform variable.
  31244. * @param uniformName Name of the variable.
  31245. * @param x First float in float3.
  31246. * @param y Second float in float3.
  31247. * @param z Third float in float3.
  31248. * @returns this effect.
  31249. */
  31250. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31251. /**
  31252. * Sets a Vector4 on a uniform variable.
  31253. * @param uniformName Name of the variable.
  31254. * @param vector4 Value to be set.
  31255. * @returns this effect.
  31256. */
  31257. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31258. /**
  31259. * Sets a float4 on a uniform variable.
  31260. * @param uniformName Name of the variable.
  31261. * @param x First float in float4.
  31262. * @param y Second float in float4.
  31263. * @param z Third float in float4.
  31264. * @param w Fourth float in float4.
  31265. * @returns this effect.
  31266. */
  31267. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31268. /**
  31269. * Sets a Color3 on a uniform variable.
  31270. * @param uniformName Name of the variable.
  31271. * @param color3 Value to be set.
  31272. * @returns this effect.
  31273. */
  31274. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31275. /**
  31276. * Sets a Color4 on a uniform variable.
  31277. * @param uniformName Name of the variable.
  31278. * @param color3 Value to be set.
  31279. * @param alpha Alpha value to be set.
  31280. * @returns this effect.
  31281. */
  31282. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31283. /**
  31284. * Sets a Color4 on a uniform variable
  31285. * @param uniformName defines the name of the variable
  31286. * @param color4 defines the value to be set
  31287. * @returns this effect.
  31288. */
  31289. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31290. /** Release all associated resources */
  31291. dispose(): void;
  31292. /**
  31293. * This function will add a new shader to the shader store
  31294. * @param name the name of the shader
  31295. * @param pixelShader optional pixel shader content
  31296. * @param vertexShader optional vertex shader content
  31297. */
  31298. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31299. /**
  31300. * Store of each shader (The can be looked up using effect.key)
  31301. */
  31302. static ShadersStore: {
  31303. [key: string]: string;
  31304. };
  31305. /**
  31306. * Store of each included file for a shader (The can be looked up using effect.key)
  31307. */
  31308. static IncludesShadersStore: {
  31309. [key: string]: string;
  31310. };
  31311. /**
  31312. * Resets the cache of effects.
  31313. */
  31314. static ResetCache(): void;
  31315. }
  31316. }
  31317. declare module "babylonjs/Engines/engineCapabilities" {
  31318. /**
  31319. * Interface used to describe the capabilities of the engine relatively to the current browser
  31320. */
  31321. export interface EngineCapabilities {
  31322. /** Maximum textures units per fragment shader */
  31323. maxTexturesImageUnits: number;
  31324. /** Maximum texture units per vertex shader */
  31325. maxVertexTextureImageUnits: number;
  31326. /** Maximum textures units in the entire pipeline */
  31327. maxCombinedTexturesImageUnits: number;
  31328. /** Maximum texture size */
  31329. maxTextureSize: number;
  31330. /** Maximum texture samples */
  31331. maxSamples?: number;
  31332. /** Maximum cube texture size */
  31333. maxCubemapTextureSize: number;
  31334. /** Maximum render texture size */
  31335. maxRenderTextureSize: number;
  31336. /** Maximum number of vertex attributes */
  31337. maxVertexAttribs: number;
  31338. /** Maximum number of varyings */
  31339. maxVaryingVectors: number;
  31340. /** Maximum number of uniforms per vertex shader */
  31341. maxVertexUniformVectors: number;
  31342. /** Maximum number of uniforms per fragment shader */
  31343. maxFragmentUniformVectors: number;
  31344. /** Defines if standard derivates (dx/dy) are supported */
  31345. standardDerivatives: boolean;
  31346. /** Defines if s3tc texture compression is supported */
  31347. s3tc?: WEBGL_compressed_texture_s3tc;
  31348. /** Defines if pvrtc texture compression is supported */
  31349. pvrtc: any;
  31350. /** Defines if etc1 texture compression is supported */
  31351. etc1: any;
  31352. /** Defines if etc2 texture compression is supported */
  31353. etc2: any;
  31354. /** Defines if astc texture compression is supported */
  31355. astc: any;
  31356. /** Defines if float textures are supported */
  31357. textureFloat: boolean;
  31358. /** Defines if vertex array objects are supported */
  31359. vertexArrayObject: boolean;
  31360. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31361. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31362. /** Gets the maximum level of anisotropy supported */
  31363. maxAnisotropy: number;
  31364. /** Defines if instancing is supported */
  31365. instancedArrays: boolean;
  31366. /** Defines if 32 bits indices are supported */
  31367. uintIndices: boolean;
  31368. /** Defines if high precision shaders are supported */
  31369. highPrecisionShaderSupported: boolean;
  31370. /** Defines if depth reading in the fragment shader is supported */
  31371. fragmentDepthSupported: boolean;
  31372. /** Defines if float texture linear filtering is supported*/
  31373. textureFloatLinearFiltering: boolean;
  31374. /** Defines if rendering to float textures is supported */
  31375. textureFloatRender: boolean;
  31376. /** Defines if half float textures are supported*/
  31377. textureHalfFloat: boolean;
  31378. /** Defines if half float texture linear filtering is supported*/
  31379. textureHalfFloatLinearFiltering: boolean;
  31380. /** Defines if rendering to half float textures is supported */
  31381. textureHalfFloatRender: boolean;
  31382. /** Defines if textureLOD shader command is supported */
  31383. textureLOD: boolean;
  31384. /** Defines if draw buffers extension is supported */
  31385. drawBuffersExtension: boolean;
  31386. /** Defines if depth textures are supported */
  31387. depthTextureExtension: boolean;
  31388. /** Defines if float color buffer are supported */
  31389. colorBufferFloat: boolean;
  31390. /** Gets disjoint timer query extension (null if not supported) */
  31391. timerQuery?: EXT_disjoint_timer_query;
  31392. /** Defines if timestamp can be used with timer query */
  31393. canUseTimestampForTimerQuery: boolean;
  31394. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31395. multiview?: any;
  31396. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31397. oculusMultiview?: any;
  31398. /** Function used to let the system compiles shaders in background */
  31399. parallelShaderCompile?: {
  31400. COMPLETION_STATUS_KHR: number;
  31401. };
  31402. /** Max number of texture samples for MSAA */
  31403. maxMSAASamples: number;
  31404. /** Defines if the blend min max extension is supported */
  31405. blendMinMax: boolean;
  31406. }
  31407. }
  31408. declare module "babylonjs/States/depthCullingState" {
  31409. import { Nullable } from "babylonjs/types";
  31410. /**
  31411. * @hidden
  31412. **/
  31413. export class DepthCullingState {
  31414. private _isDepthTestDirty;
  31415. private _isDepthMaskDirty;
  31416. private _isDepthFuncDirty;
  31417. private _isCullFaceDirty;
  31418. private _isCullDirty;
  31419. private _isZOffsetDirty;
  31420. private _isFrontFaceDirty;
  31421. private _depthTest;
  31422. private _depthMask;
  31423. private _depthFunc;
  31424. private _cull;
  31425. private _cullFace;
  31426. private _zOffset;
  31427. private _frontFace;
  31428. /**
  31429. * Initializes the state.
  31430. */
  31431. constructor();
  31432. get isDirty(): boolean;
  31433. get zOffset(): number;
  31434. set zOffset(value: number);
  31435. get cullFace(): Nullable<number>;
  31436. set cullFace(value: Nullable<number>);
  31437. get cull(): Nullable<boolean>;
  31438. set cull(value: Nullable<boolean>);
  31439. get depthFunc(): Nullable<number>;
  31440. set depthFunc(value: Nullable<number>);
  31441. get depthMask(): boolean;
  31442. set depthMask(value: boolean);
  31443. get depthTest(): boolean;
  31444. set depthTest(value: boolean);
  31445. get frontFace(): Nullable<number>;
  31446. set frontFace(value: Nullable<number>);
  31447. reset(): void;
  31448. apply(gl: WebGLRenderingContext): void;
  31449. }
  31450. }
  31451. declare module "babylonjs/States/stencilState" {
  31452. /**
  31453. * @hidden
  31454. **/
  31455. export class StencilState {
  31456. /** 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 */
  31457. static readonly ALWAYS: number;
  31458. /** Passed to stencilOperation to specify that stencil value must be kept */
  31459. static readonly KEEP: number;
  31460. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31461. static readonly REPLACE: number;
  31462. private _isStencilTestDirty;
  31463. private _isStencilMaskDirty;
  31464. private _isStencilFuncDirty;
  31465. private _isStencilOpDirty;
  31466. private _stencilTest;
  31467. private _stencilMask;
  31468. private _stencilFunc;
  31469. private _stencilFuncRef;
  31470. private _stencilFuncMask;
  31471. private _stencilOpStencilFail;
  31472. private _stencilOpDepthFail;
  31473. private _stencilOpStencilDepthPass;
  31474. get isDirty(): boolean;
  31475. get stencilFunc(): number;
  31476. set stencilFunc(value: number);
  31477. get stencilFuncRef(): number;
  31478. set stencilFuncRef(value: number);
  31479. get stencilFuncMask(): number;
  31480. set stencilFuncMask(value: number);
  31481. get stencilOpStencilFail(): number;
  31482. set stencilOpStencilFail(value: number);
  31483. get stencilOpDepthFail(): number;
  31484. set stencilOpDepthFail(value: number);
  31485. get stencilOpStencilDepthPass(): number;
  31486. set stencilOpStencilDepthPass(value: number);
  31487. get stencilMask(): number;
  31488. set stencilMask(value: number);
  31489. get stencilTest(): boolean;
  31490. set stencilTest(value: boolean);
  31491. constructor();
  31492. reset(): void;
  31493. apply(gl: WebGLRenderingContext): void;
  31494. }
  31495. }
  31496. declare module "babylonjs/States/alphaCullingState" {
  31497. /**
  31498. * @hidden
  31499. **/
  31500. export class AlphaState {
  31501. private _isAlphaBlendDirty;
  31502. private _isBlendFunctionParametersDirty;
  31503. private _isBlendEquationParametersDirty;
  31504. private _isBlendConstantsDirty;
  31505. private _alphaBlend;
  31506. private _blendFunctionParameters;
  31507. private _blendEquationParameters;
  31508. private _blendConstants;
  31509. /**
  31510. * Initializes the state.
  31511. */
  31512. constructor();
  31513. get isDirty(): boolean;
  31514. get alphaBlend(): boolean;
  31515. set alphaBlend(value: boolean);
  31516. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31517. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31518. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31519. reset(): void;
  31520. apply(gl: WebGLRenderingContext): void;
  31521. }
  31522. }
  31523. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31524. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31525. /** @hidden */
  31526. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31527. attributeProcessor(attribute: string): string;
  31528. varyingProcessor(varying: string, isFragment: boolean): string;
  31529. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31530. }
  31531. }
  31532. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31533. /**
  31534. * Interface for attribute information associated with buffer instanciation
  31535. */
  31536. export interface InstancingAttributeInfo {
  31537. /**
  31538. * Name of the GLSL attribute
  31539. * if attribute index is not specified, this is used to retrieve the index from the effect
  31540. */
  31541. attributeName: string;
  31542. /**
  31543. * Index/offset of the attribute in the vertex shader
  31544. * if not specified, this will be computes from the name.
  31545. */
  31546. index?: number;
  31547. /**
  31548. * size of the attribute, 1, 2, 3 or 4
  31549. */
  31550. attributeSize: number;
  31551. /**
  31552. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31553. */
  31554. offset: number;
  31555. /**
  31556. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31557. * default to 1
  31558. */
  31559. divisor?: number;
  31560. /**
  31561. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31562. * default is FLOAT
  31563. */
  31564. attributeType?: number;
  31565. /**
  31566. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31567. */
  31568. normalized?: boolean;
  31569. }
  31570. }
  31571. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31573. import { Nullable } from "babylonjs/types";
  31574. module "babylonjs/Engines/thinEngine" {
  31575. interface ThinEngine {
  31576. /**
  31577. * Update a video texture
  31578. * @param texture defines the texture to update
  31579. * @param video defines the video element to use
  31580. * @param invertY defines if data must be stored with Y axis inverted
  31581. */
  31582. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31583. }
  31584. }
  31585. }
  31586. declare module "babylonjs/Materials/Textures/videoTexture" {
  31587. import { Observable } from "babylonjs/Misc/observable";
  31588. import { Nullable } from "babylonjs/types";
  31589. import { Scene } from "babylonjs/scene";
  31590. import { Texture } from "babylonjs/Materials/Textures/texture";
  31591. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31592. /**
  31593. * Settings for finer control over video usage
  31594. */
  31595. export interface VideoTextureSettings {
  31596. /**
  31597. * Applies `autoplay` to video, if specified
  31598. */
  31599. autoPlay?: boolean;
  31600. /**
  31601. * Applies `loop` to video, if specified
  31602. */
  31603. loop?: boolean;
  31604. /**
  31605. * Automatically updates internal texture from video at every frame in the render loop
  31606. */
  31607. autoUpdateTexture: boolean;
  31608. /**
  31609. * Image src displayed during the video loading or until the user interacts with the video.
  31610. */
  31611. poster?: string;
  31612. }
  31613. /**
  31614. * If you want to display a video in your scene, this is the special texture for that.
  31615. * This special texture works similar to other textures, with the exception of a few parameters.
  31616. * @see https://doc.babylonjs.com/how_to/video_texture
  31617. */
  31618. export class VideoTexture extends Texture {
  31619. /**
  31620. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31621. */
  31622. readonly autoUpdateTexture: boolean;
  31623. /**
  31624. * The video instance used by the texture internally
  31625. */
  31626. readonly video: HTMLVideoElement;
  31627. private _onUserActionRequestedObservable;
  31628. /**
  31629. * Event triggerd when a dom action is required by the user to play the video.
  31630. * This happens due to recent changes in browser policies preventing video to auto start.
  31631. */
  31632. get onUserActionRequestedObservable(): Observable<Texture>;
  31633. private _generateMipMaps;
  31634. private _engine;
  31635. private _stillImageCaptured;
  31636. private _displayingPosterTexture;
  31637. private _settings;
  31638. private _createInternalTextureOnEvent;
  31639. private _frameId;
  31640. private _currentSrc;
  31641. /**
  31642. * Creates a video texture.
  31643. * If you want to display a video in your scene, this is the special texture for that.
  31644. * This special texture works similar to other textures, with the exception of a few parameters.
  31645. * @see https://doc.babylonjs.com/how_to/video_texture
  31646. * @param name optional name, will detect from video source, if not defined
  31647. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31648. * @param scene is obviously the current scene.
  31649. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31650. * @param invertY is false by default but can be used to invert video on Y axis
  31651. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31652. * @param settings allows finer control over video usage
  31653. */
  31654. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31655. private _getName;
  31656. private _getVideo;
  31657. private _createInternalTexture;
  31658. private reset;
  31659. /**
  31660. * @hidden Internal method to initiate `update`.
  31661. */
  31662. _rebuild(): void;
  31663. /**
  31664. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31665. */
  31666. update(): void;
  31667. /**
  31668. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31669. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31670. */
  31671. updateTexture(isVisible: boolean): void;
  31672. protected _updateInternalTexture: () => void;
  31673. /**
  31674. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31675. * @param url New url.
  31676. */
  31677. updateURL(url: string): void;
  31678. /**
  31679. * Clones the texture.
  31680. * @returns the cloned texture
  31681. */
  31682. clone(): VideoTexture;
  31683. /**
  31684. * Dispose the texture and release its associated resources.
  31685. */
  31686. dispose(): void;
  31687. /**
  31688. * Creates a video texture straight from a stream.
  31689. * @param scene Define the scene the texture should be created in
  31690. * @param stream Define the stream the texture should be created from
  31691. * @returns The created video texture as a promise
  31692. */
  31693. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31694. /**
  31695. * Creates a video texture straight from your WebCam video feed.
  31696. * @param scene Define the scene the texture should be created in
  31697. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31698. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31699. * @returns The created video texture as a promise
  31700. */
  31701. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31702. minWidth: number;
  31703. maxWidth: number;
  31704. minHeight: number;
  31705. maxHeight: number;
  31706. deviceId: string;
  31707. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31708. /**
  31709. * Creates a video texture straight from your WebCam video feed.
  31710. * @param scene Define the scene the texture should be created in
  31711. * @param onReady Define a callback to triggered once the texture will be ready
  31712. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31713. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31714. */
  31715. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31716. minWidth: number;
  31717. maxWidth: number;
  31718. minHeight: number;
  31719. maxHeight: number;
  31720. deviceId: string;
  31721. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31722. }
  31723. }
  31724. declare module "babylonjs/Engines/thinEngine" {
  31725. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31726. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31727. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31728. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31729. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31730. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31731. import { Observable } from "babylonjs/Misc/observable";
  31732. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31733. import { StencilState } from "babylonjs/States/stencilState";
  31734. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31735. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31736. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31737. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31738. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31739. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31740. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31741. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31742. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31744. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31745. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31746. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31747. import { WebRequest } from "babylonjs/Misc/webRequest";
  31748. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31749. /**
  31750. * Defines the interface used by objects working like Scene
  31751. * @hidden
  31752. */
  31753. interface ISceneLike {
  31754. _addPendingData(data: any): void;
  31755. _removePendingData(data: any): void;
  31756. offlineProvider: IOfflineProvider;
  31757. }
  31758. /** Interface defining initialization parameters for Engine class */
  31759. export interface EngineOptions extends WebGLContextAttributes {
  31760. /**
  31761. * Defines if the engine should no exceed a specified device ratio
  31762. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31763. */
  31764. limitDeviceRatio?: number;
  31765. /**
  31766. * Defines if webvr should be enabled automatically
  31767. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31768. */
  31769. autoEnableWebVR?: boolean;
  31770. /**
  31771. * Defines if webgl2 should be turned off even if supported
  31772. * @see http://doc.babylonjs.com/features/webgl2
  31773. */
  31774. disableWebGL2Support?: boolean;
  31775. /**
  31776. * Defines if webaudio should be initialized as well
  31777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31778. */
  31779. audioEngine?: boolean;
  31780. /**
  31781. * Defines if animations should run using a deterministic lock step
  31782. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31783. */
  31784. deterministicLockstep?: boolean;
  31785. /** Defines the maximum steps to use with deterministic lock step mode */
  31786. lockstepMaxSteps?: number;
  31787. /** Defines the seconds between each deterministic lock step */
  31788. timeStep?: number;
  31789. /**
  31790. * Defines that engine should ignore context lost events
  31791. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31792. */
  31793. doNotHandleContextLost?: boolean;
  31794. /**
  31795. * Defines that engine should ignore modifying touch action attribute and style
  31796. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31797. */
  31798. doNotHandleTouchAction?: boolean;
  31799. /**
  31800. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31801. */
  31802. useHighPrecisionFloats?: boolean;
  31803. }
  31804. /**
  31805. * The base engine class (root of all engines)
  31806. */
  31807. export class ThinEngine {
  31808. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31809. static ExceptionList: ({
  31810. key: string;
  31811. capture: string;
  31812. captureConstraint: number;
  31813. targets: string[];
  31814. } | {
  31815. key: string;
  31816. capture: null;
  31817. captureConstraint: null;
  31818. targets: string[];
  31819. })[];
  31820. /** @hidden */
  31821. static _TextureLoaders: IInternalTextureLoader[];
  31822. /**
  31823. * Returns the current npm package of the sdk
  31824. */
  31825. static get NpmPackage(): string;
  31826. /**
  31827. * Returns the current version of the framework
  31828. */
  31829. static get Version(): string;
  31830. /**
  31831. * Returns a string describing the current engine
  31832. */
  31833. get description(): string;
  31834. /**
  31835. * Gets or sets the epsilon value used by collision engine
  31836. */
  31837. static CollisionsEpsilon: number;
  31838. /**
  31839. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31840. */
  31841. static get ShadersRepository(): string;
  31842. static set ShadersRepository(value: string);
  31843. /**
  31844. * Gets or sets the textures that the engine should not attempt to load as compressed
  31845. */
  31846. protected _excludedCompressedTextures: string[];
  31847. /**
  31848. * Filters the compressed texture formats to only include
  31849. * files that are not included in the skippable list
  31850. *
  31851. * @param url the current extension
  31852. * @param textureFormatInUse the current compressed texture format
  31853. * @returns "format" string
  31854. */
  31855. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31856. /** @hidden */
  31857. _shaderProcessor: IShaderProcessor;
  31858. /**
  31859. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31860. */
  31861. forcePOTTextures: boolean;
  31862. /**
  31863. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31864. */
  31865. isFullscreen: boolean;
  31866. /**
  31867. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31868. */
  31869. cullBackFaces: boolean;
  31870. /**
  31871. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31872. */
  31873. renderEvenInBackground: boolean;
  31874. /**
  31875. * Gets or sets a boolean indicating that cache can be kept between frames
  31876. */
  31877. preventCacheWipeBetweenFrames: boolean;
  31878. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31879. validateShaderPrograms: boolean;
  31880. /**
  31881. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31882. * This can provide greater z depth for distant objects.
  31883. */
  31884. useReverseDepthBuffer: boolean;
  31885. /**
  31886. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31887. */
  31888. disableUniformBuffers: boolean;
  31889. /** @hidden */
  31890. _uniformBuffers: UniformBuffer[];
  31891. /**
  31892. * Gets a boolean indicating that the engine supports uniform buffers
  31893. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31894. */
  31895. get supportsUniformBuffers(): boolean;
  31896. /** @hidden */
  31897. _gl: WebGLRenderingContext;
  31898. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31899. protected _windowIsBackground: boolean;
  31900. protected _webGLVersion: number;
  31901. protected _creationOptions: EngineOptions;
  31902. protected _highPrecisionShadersAllowed: boolean;
  31903. /** @hidden */
  31904. get _shouldUseHighPrecisionShader(): boolean;
  31905. /**
  31906. * Gets a boolean indicating that only power of 2 textures are supported
  31907. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31908. */
  31909. get needPOTTextures(): boolean;
  31910. /** @hidden */
  31911. _badOS: boolean;
  31912. /** @hidden */
  31913. _badDesktopOS: boolean;
  31914. private _hardwareScalingLevel;
  31915. /** @hidden */
  31916. _caps: EngineCapabilities;
  31917. private _isStencilEnable;
  31918. private _glVersion;
  31919. private _glRenderer;
  31920. private _glVendor;
  31921. /** @hidden */
  31922. _videoTextureSupported: boolean;
  31923. protected _renderingQueueLaunched: boolean;
  31924. protected _activeRenderLoops: (() => void)[];
  31925. /**
  31926. * Observable signaled when a context lost event is raised
  31927. */
  31928. onContextLostObservable: Observable<ThinEngine>;
  31929. /**
  31930. * Observable signaled when a context restored event is raised
  31931. */
  31932. onContextRestoredObservable: Observable<ThinEngine>;
  31933. private _onContextLost;
  31934. private _onContextRestored;
  31935. protected _contextWasLost: boolean;
  31936. /** @hidden */
  31937. _doNotHandleContextLost: boolean;
  31938. /**
  31939. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31941. */
  31942. get doNotHandleContextLost(): boolean;
  31943. set doNotHandleContextLost(value: boolean);
  31944. /**
  31945. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31946. */
  31947. disableVertexArrayObjects: boolean;
  31948. /** @hidden */
  31949. protected _colorWrite: boolean;
  31950. /** @hidden */
  31951. protected _colorWriteChanged: boolean;
  31952. /** @hidden */
  31953. protected _depthCullingState: DepthCullingState;
  31954. /** @hidden */
  31955. protected _stencilState: StencilState;
  31956. /** @hidden */
  31957. _alphaState: AlphaState;
  31958. /** @hidden */
  31959. _alphaMode: number;
  31960. /** @hidden */
  31961. _alphaEquation: number;
  31962. /** @hidden */
  31963. _internalTexturesCache: InternalTexture[];
  31964. /** @hidden */
  31965. protected _activeChannel: number;
  31966. private _currentTextureChannel;
  31967. /** @hidden */
  31968. protected _boundTexturesCache: {
  31969. [key: string]: Nullable<InternalTexture>;
  31970. };
  31971. /** @hidden */
  31972. protected _currentEffect: Nullable<Effect>;
  31973. /** @hidden */
  31974. protected _currentProgram: Nullable<WebGLProgram>;
  31975. private _compiledEffects;
  31976. private _vertexAttribArraysEnabled;
  31977. /** @hidden */
  31978. protected _cachedViewport: Nullable<IViewportLike>;
  31979. private _cachedVertexArrayObject;
  31980. /** @hidden */
  31981. protected _cachedVertexBuffers: any;
  31982. /** @hidden */
  31983. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31984. /** @hidden */
  31985. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31986. /** @hidden */
  31987. _currentRenderTarget: Nullable<InternalTexture>;
  31988. private _uintIndicesCurrentlySet;
  31989. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31990. /** @hidden */
  31991. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31992. private _currentBufferPointers;
  31993. private _currentInstanceLocations;
  31994. private _currentInstanceBuffers;
  31995. private _textureUnits;
  31996. /** @hidden */
  31997. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31998. /** @hidden */
  31999. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32000. /** @hidden */
  32001. _boundRenderFunction: any;
  32002. private _vaoRecordInProgress;
  32003. private _mustWipeVertexAttributes;
  32004. private _emptyTexture;
  32005. private _emptyCubeTexture;
  32006. private _emptyTexture3D;
  32007. private _emptyTexture2DArray;
  32008. /** @hidden */
  32009. _frameHandler: number;
  32010. private _nextFreeTextureSlots;
  32011. private _maxSimultaneousTextures;
  32012. private _activeRequests;
  32013. protected _texturesSupported: string[];
  32014. /** @hidden */
  32015. _textureFormatInUse: Nullable<string>;
  32016. protected get _supportsHardwareTextureRescaling(): boolean;
  32017. /**
  32018. * Gets the list of texture formats supported
  32019. */
  32020. get texturesSupported(): Array<string>;
  32021. /**
  32022. * Gets the list of texture formats in use
  32023. */
  32024. get textureFormatInUse(): Nullable<string>;
  32025. /**
  32026. * Gets the current viewport
  32027. */
  32028. get currentViewport(): Nullable<IViewportLike>;
  32029. /**
  32030. * Gets the default empty texture
  32031. */
  32032. get emptyTexture(): InternalTexture;
  32033. /**
  32034. * Gets the default empty 3D texture
  32035. */
  32036. get emptyTexture3D(): InternalTexture;
  32037. /**
  32038. * Gets the default empty 2D array texture
  32039. */
  32040. get emptyTexture2DArray(): InternalTexture;
  32041. /**
  32042. * Gets the default empty cube texture
  32043. */
  32044. get emptyCubeTexture(): InternalTexture;
  32045. /**
  32046. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32047. */
  32048. readonly premultipliedAlpha: boolean;
  32049. /**
  32050. * Observable event triggered before each texture is initialized
  32051. */
  32052. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32053. /**
  32054. * Creates a new engine
  32055. * @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
  32056. * @param antialias defines enable antialiasing (default: false)
  32057. * @param options defines further options to be sent to the getContext() function
  32058. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32059. */
  32060. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32061. private _rebuildInternalTextures;
  32062. private _rebuildEffects;
  32063. /**
  32064. * Gets a boolean indicating if all created effects are ready
  32065. * @returns true if all effects are ready
  32066. */
  32067. areAllEffectsReady(): boolean;
  32068. protected _rebuildBuffers(): void;
  32069. private _initGLContext;
  32070. /**
  32071. * Gets version of the current webGL context
  32072. */
  32073. get webGLVersion(): number;
  32074. /**
  32075. * Gets a string idenfifying the name of the class
  32076. * @returns "Engine" string
  32077. */
  32078. getClassName(): string;
  32079. /**
  32080. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32081. */
  32082. get isStencilEnable(): boolean;
  32083. /** @hidden */
  32084. _prepareWorkingCanvas(): void;
  32085. /**
  32086. * Reset the texture cache to empty state
  32087. */
  32088. resetTextureCache(): void;
  32089. /**
  32090. * Gets an object containing information about the current webGL context
  32091. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32092. */
  32093. getGlInfo(): {
  32094. vendor: string;
  32095. renderer: string;
  32096. version: string;
  32097. };
  32098. /**
  32099. * Defines the hardware scaling level.
  32100. * By default the hardware scaling level is computed from the window device ratio.
  32101. * 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.
  32102. * @param level defines the level to use
  32103. */
  32104. setHardwareScalingLevel(level: number): void;
  32105. /**
  32106. * Gets the current hardware scaling level.
  32107. * By default the hardware scaling level is computed from the window device ratio.
  32108. * 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.
  32109. * @returns a number indicating the current hardware scaling level
  32110. */
  32111. getHardwareScalingLevel(): number;
  32112. /**
  32113. * Gets the list of loaded textures
  32114. * @returns an array containing all loaded textures
  32115. */
  32116. getLoadedTexturesCache(): InternalTexture[];
  32117. /**
  32118. * Gets the object containing all engine capabilities
  32119. * @returns the EngineCapabilities object
  32120. */
  32121. getCaps(): EngineCapabilities;
  32122. /**
  32123. * stop executing a render loop function and remove it from the execution array
  32124. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32125. */
  32126. stopRenderLoop(renderFunction?: () => void): void;
  32127. /** @hidden */
  32128. _renderLoop(): void;
  32129. /**
  32130. * Gets the HTML canvas attached with the current webGL context
  32131. * @returns a HTML canvas
  32132. */
  32133. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32134. /**
  32135. * Gets host window
  32136. * @returns the host window object
  32137. */
  32138. getHostWindow(): Nullable<Window>;
  32139. /**
  32140. * Gets the current render width
  32141. * @param useScreen defines if screen size must be used (or the current render target if any)
  32142. * @returns a number defining the current render width
  32143. */
  32144. getRenderWidth(useScreen?: boolean): number;
  32145. /**
  32146. * Gets the current render height
  32147. * @param useScreen defines if screen size must be used (or the current render target if any)
  32148. * @returns a number defining the current render height
  32149. */
  32150. getRenderHeight(useScreen?: boolean): number;
  32151. /**
  32152. * Can be used to override the current requestAnimationFrame requester.
  32153. * @hidden
  32154. */
  32155. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32156. /**
  32157. * Register and execute a render loop. The engine can have more than one render function
  32158. * @param renderFunction defines the function to continuously execute
  32159. */
  32160. runRenderLoop(renderFunction: () => void): void;
  32161. /**
  32162. * Clear the current render buffer or the current render target (if any is set up)
  32163. * @param color defines the color to use
  32164. * @param backBuffer defines if the back buffer must be cleared
  32165. * @param depth defines if the depth buffer must be cleared
  32166. * @param stencil defines if the stencil buffer must be cleared
  32167. */
  32168. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32169. private _viewportCached;
  32170. /** @hidden */
  32171. _viewport(x: number, y: number, width: number, height: number): void;
  32172. /**
  32173. * Set the WebGL's viewport
  32174. * @param viewport defines the viewport element to be used
  32175. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32176. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32177. */
  32178. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32179. /**
  32180. * Begin a new frame
  32181. */
  32182. beginFrame(): void;
  32183. /**
  32184. * Enf the current frame
  32185. */
  32186. endFrame(): void;
  32187. /**
  32188. * Resize the view according to the canvas' size
  32189. */
  32190. resize(): void;
  32191. /**
  32192. * Force a specific size of the canvas
  32193. * @param width defines the new canvas' width
  32194. * @param height defines the new canvas' height
  32195. */
  32196. setSize(width: number, height: number): void;
  32197. /**
  32198. * Binds the frame buffer to the specified texture.
  32199. * @param texture The texture to render to or null for the default canvas
  32200. * @param faceIndex The face of the texture to render to in case of cube texture
  32201. * @param requiredWidth The width of the target to render to
  32202. * @param requiredHeight The height of the target to render to
  32203. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32204. * @param lodLevel defines the lod level to bind to the frame buffer
  32205. * @param layer defines the 2d array index to bind to frame buffer to
  32206. */
  32207. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32208. /** @hidden */
  32209. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32210. /**
  32211. * Unbind the current render target texture from the webGL context
  32212. * @param texture defines the render target texture to unbind
  32213. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32214. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32215. */
  32216. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32217. /**
  32218. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32219. */
  32220. flushFramebuffer(): void;
  32221. /**
  32222. * Unbind the current render target and bind the default framebuffer
  32223. */
  32224. restoreDefaultFramebuffer(): void;
  32225. /** @hidden */
  32226. protected _resetVertexBufferBinding(): void;
  32227. /**
  32228. * Creates a vertex buffer
  32229. * @param data the data for the vertex buffer
  32230. * @returns the new WebGL static buffer
  32231. */
  32232. createVertexBuffer(data: DataArray): DataBuffer;
  32233. private _createVertexBuffer;
  32234. /**
  32235. * Creates a dynamic vertex buffer
  32236. * @param data the data for the dynamic vertex buffer
  32237. * @returns the new WebGL dynamic buffer
  32238. */
  32239. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32240. protected _resetIndexBufferBinding(): void;
  32241. /**
  32242. * Creates a new index buffer
  32243. * @param indices defines the content of the index buffer
  32244. * @param updatable defines if the index buffer must be updatable
  32245. * @returns a new webGL buffer
  32246. */
  32247. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32248. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32249. /**
  32250. * Bind a webGL buffer to the webGL context
  32251. * @param buffer defines the buffer to bind
  32252. */
  32253. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32254. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32255. private bindBuffer;
  32256. /**
  32257. * update the bound buffer with the given data
  32258. * @param data defines the data to update
  32259. */
  32260. updateArrayBuffer(data: Float32Array): void;
  32261. private _vertexAttribPointer;
  32262. /** @hidden */
  32263. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32264. private _bindVertexBuffersAttributes;
  32265. /**
  32266. * Records a vertex array object
  32267. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32268. * @param vertexBuffers defines the list of vertex buffers to store
  32269. * @param indexBuffer defines the index buffer to store
  32270. * @param effect defines the effect to store
  32271. * @returns the new vertex array object
  32272. */
  32273. recordVertexArrayObject(vertexBuffers: {
  32274. [key: string]: VertexBuffer;
  32275. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32276. /**
  32277. * Bind a specific vertex array object
  32278. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32279. * @param vertexArrayObject defines the vertex array object to bind
  32280. * @param indexBuffer defines the index buffer to bind
  32281. */
  32282. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32283. /**
  32284. * Bind webGl buffers directly to the webGL context
  32285. * @param vertexBuffer defines the vertex buffer to bind
  32286. * @param indexBuffer defines the index buffer to bind
  32287. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32288. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32289. * @param effect defines the effect associated with the vertex buffer
  32290. */
  32291. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32292. private _unbindVertexArrayObject;
  32293. /**
  32294. * Bind a list of vertex buffers to the webGL context
  32295. * @param vertexBuffers defines the list of vertex buffers to bind
  32296. * @param indexBuffer defines the index buffer to bind
  32297. * @param effect defines the effect associated with the vertex buffers
  32298. */
  32299. bindBuffers(vertexBuffers: {
  32300. [key: string]: Nullable<VertexBuffer>;
  32301. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32302. /**
  32303. * Unbind all instance attributes
  32304. */
  32305. unbindInstanceAttributes(): void;
  32306. /**
  32307. * Release and free the memory of a vertex array object
  32308. * @param vao defines the vertex array object to delete
  32309. */
  32310. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32311. /** @hidden */
  32312. _releaseBuffer(buffer: DataBuffer): boolean;
  32313. protected _deleteBuffer(buffer: DataBuffer): void;
  32314. /**
  32315. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32316. * @param instancesBuffer defines the webGL buffer to update and bind
  32317. * @param data defines the data to store in the buffer
  32318. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32319. */
  32320. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32321. /**
  32322. * Bind the content of a webGL buffer used with instantiation
  32323. * @param instancesBuffer defines the webGL buffer to bind
  32324. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32325. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32326. */
  32327. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32328. /**
  32329. * Disable the instance attribute corresponding to the name in parameter
  32330. * @param name defines the name of the attribute to disable
  32331. */
  32332. disableInstanceAttributeByName(name: string): void;
  32333. /**
  32334. * Disable the instance attribute corresponding to the location in parameter
  32335. * @param attributeLocation defines the attribute location of the attribute to disable
  32336. */
  32337. disableInstanceAttribute(attributeLocation: number): void;
  32338. /**
  32339. * Disable the attribute corresponding to the location in parameter
  32340. * @param attributeLocation defines the attribute location of the attribute to disable
  32341. */
  32342. disableAttributeByIndex(attributeLocation: number): void;
  32343. /**
  32344. * Send a draw order
  32345. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32346. * @param indexStart defines the starting index
  32347. * @param indexCount defines the number of index to draw
  32348. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32349. */
  32350. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32351. /**
  32352. * Draw a list of points
  32353. * @param verticesStart defines the index of first vertex to draw
  32354. * @param verticesCount defines the count of vertices to draw
  32355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32356. */
  32357. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32358. /**
  32359. * Draw a list of unindexed primitives
  32360. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32361. * @param verticesStart defines the index of first vertex to draw
  32362. * @param verticesCount defines the count of vertices to draw
  32363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32364. */
  32365. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32366. /**
  32367. * Draw a list of indexed primitives
  32368. * @param fillMode defines the primitive to use
  32369. * @param indexStart defines the starting index
  32370. * @param indexCount defines the number of index to draw
  32371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32372. */
  32373. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32374. /**
  32375. * Draw a list of unindexed primitives
  32376. * @param fillMode defines the primitive to use
  32377. * @param verticesStart defines the index of first vertex to draw
  32378. * @param verticesCount defines the count of vertices to draw
  32379. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32380. */
  32381. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32382. private _drawMode;
  32383. /** @hidden */
  32384. protected _reportDrawCall(): void;
  32385. /** @hidden */
  32386. _releaseEffect(effect: Effect): void;
  32387. /** @hidden */
  32388. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32389. /**
  32390. * Create a new effect (used to store vertex/fragment shaders)
  32391. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32392. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32393. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32394. * @param samplers defines an array of string used to represent textures
  32395. * @param defines defines the string containing the defines to use to compile the shaders
  32396. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32397. * @param onCompiled defines a function to call when the effect creation is successful
  32398. * @param onError defines a function to call when the effect creation has failed
  32399. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32400. * @returns the new Effect
  32401. */
  32402. 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;
  32403. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32404. private _compileShader;
  32405. private _compileRawShader;
  32406. /**
  32407. * Directly creates a webGL program
  32408. * @param pipelineContext defines the pipeline context to attach to
  32409. * @param vertexCode defines the vertex shader code to use
  32410. * @param fragmentCode defines the fragment shader code to use
  32411. * @param context defines the webGL context to use (if not set, the current one will be used)
  32412. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32413. * @returns the new webGL program
  32414. */
  32415. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32416. /**
  32417. * Creates a webGL program
  32418. * @param pipelineContext defines the pipeline context to attach to
  32419. * @param vertexCode defines the vertex shader code to use
  32420. * @param fragmentCode defines the fragment shader code to use
  32421. * @param defines defines the string containing the defines to use to compile the shaders
  32422. * @param context defines the webGL context to use (if not set, the current one will be used)
  32423. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32424. * @returns the new webGL program
  32425. */
  32426. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32427. /**
  32428. * Creates a new pipeline context
  32429. * @returns the new pipeline
  32430. */
  32431. createPipelineContext(): IPipelineContext;
  32432. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32433. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32434. /** @hidden */
  32435. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32436. /** @hidden */
  32437. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32438. /** @hidden */
  32439. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32440. /**
  32441. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32442. * @param pipelineContext defines the pipeline context to use
  32443. * @param uniformsNames defines the list of uniform names
  32444. * @returns an array of webGL uniform locations
  32445. */
  32446. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32447. /**
  32448. * Gets the lsit of active attributes for a given webGL program
  32449. * @param pipelineContext defines the pipeline context to use
  32450. * @param attributesNames defines the list of attribute names to get
  32451. * @returns an array of indices indicating the offset of each attribute
  32452. */
  32453. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32454. /**
  32455. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32456. * @param effect defines the effect to activate
  32457. */
  32458. enableEffect(effect: Nullable<Effect>): void;
  32459. /**
  32460. * Set the value of an uniform to a number (int)
  32461. * @param uniform defines the webGL uniform location where to store the value
  32462. * @param value defines the int number to store
  32463. */
  32464. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32465. /**
  32466. * Set the value of an uniform to an array of int32
  32467. * @param uniform defines the webGL uniform location where to store the value
  32468. * @param array defines the array of int32 to store
  32469. */
  32470. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32471. /**
  32472. * Set the value of an uniform to an array of int32 (stored as vec2)
  32473. * @param uniform defines the webGL uniform location where to store the value
  32474. * @param array defines the array of int32 to store
  32475. */
  32476. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32477. /**
  32478. * Set the value of an uniform to an array of int32 (stored as vec3)
  32479. * @param uniform defines the webGL uniform location where to store the value
  32480. * @param array defines the array of int32 to store
  32481. */
  32482. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32483. /**
  32484. * Set the value of an uniform to an array of int32 (stored as vec4)
  32485. * @param uniform defines the webGL uniform location where to store the value
  32486. * @param array defines the array of int32 to store
  32487. */
  32488. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32489. /**
  32490. * Set the value of an uniform to an array of number
  32491. * @param uniform defines the webGL uniform location where to store the value
  32492. * @param array defines the array of number to store
  32493. */
  32494. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32495. /**
  32496. * Set the value of an uniform to an array of number (stored as vec2)
  32497. * @param uniform defines the webGL uniform location where to store the value
  32498. * @param array defines the array of number to store
  32499. */
  32500. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32501. /**
  32502. * Set the value of an uniform to an array of number (stored as vec3)
  32503. * @param uniform defines the webGL uniform location where to store the value
  32504. * @param array defines the array of number to store
  32505. */
  32506. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32507. /**
  32508. * Set the value of an uniform to an array of number (stored as vec4)
  32509. * @param uniform defines the webGL uniform location where to store the value
  32510. * @param array defines the array of number to store
  32511. */
  32512. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32513. /**
  32514. * Set the value of an uniform to an array of float32 (stored as matrices)
  32515. * @param uniform defines the webGL uniform location where to store the value
  32516. * @param matrices defines the array of float32 to store
  32517. */
  32518. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32519. /**
  32520. * Set the value of an uniform to a matrix (3x3)
  32521. * @param uniform defines the webGL uniform location where to store the value
  32522. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32523. */
  32524. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32525. /**
  32526. * Set the value of an uniform to a matrix (2x2)
  32527. * @param uniform defines the webGL uniform location where to store the value
  32528. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32529. */
  32530. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32531. /**
  32532. * Set the value of an uniform to a number (float)
  32533. * @param uniform defines the webGL uniform location where to store the value
  32534. * @param value defines the float number to store
  32535. */
  32536. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32537. /**
  32538. * Set the value of an uniform to a vec2
  32539. * @param uniform defines the webGL uniform location where to store the value
  32540. * @param x defines the 1st component of the value
  32541. * @param y defines the 2nd component of the value
  32542. */
  32543. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32544. /**
  32545. * Set the value of an uniform to a vec3
  32546. * @param uniform defines the webGL uniform location where to store the value
  32547. * @param x defines the 1st component of the value
  32548. * @param y defines the 2nd component of the value
  32549. * @param z defines the 3rd component of the value
  32550. */
  32551. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32552. /**
  32553. * Set the value of an uniform to a vec4
  32554. * @param uniform defines the webGL uniform location where to store the value
  32555. * @param x defines the 1st component of the value
  32556. * @param y defines the 2nd component of the value
  32557. * @param z defines the 3rd component of the value
  32558. * @param w defines the 4th component of the value
  32559. */
  32560. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32561. /**
  32562. * Apply all cached states (depth, culling, stencil and alpha)
  32563. */
  32564. applyStates(): void;
  32565. /**
  32566. * Enable or disable color writing
  32567. * @param enable defines the state to set
  32568. */
  32569. setColorWrite(enable: boolean): void;
  32570. /**
  32571. * Gets a boolean indicating if color writing is enabled
  32572. * @returns the current color writing state
  32573. */
  32574. getColorWrite(): boolean;
  32575. /**
  32576. * Gets the depth culling state manager
  32577. */
  32578. get depthCullingState(): DepthCullingState;
  32579. /**
  32580. * Gets the alpha state manager
  32581. */
  32582. get alphaState(): AlphaState;
  32583. /**
  32584. * Gets the stencil state manager
  32585. */
  32586. get stencilState(): StencilState;
  32587. /**
  32588. * Clears the list of texture accessible through engine.
  32589. * This can help preventing texture load conflict due to name collision.
  32590. */
  32591. clearInternalTexturesCache(): void;
  32592. /**
  32593. * Force the entire cache to be cleared
  32594. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32595. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32596. */
  32597. wipeCaches(bruteForce?: boolean): void;
  32598. /** @hidden */
  32599. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32600. min: number;
  32601. mag: number;
  32602. };
  32603. /** @hidden */
  32604. _createTexture(): WebGLTexture;
  32605. /**
  32606. * Usually called from Texture.ts.
  32607. * Passed information to create a WebGLTexture
  32608. * @param urlArg defines a value which contains one of the following:
  32609. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32610. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32611. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32613. * @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)
  32614. * @param scene needed for loading to the correct scene
  32615. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32616. * @param onLoad optional callback to be called upon successful completion
  32617. * @param onError optional callback to be called upon failure
  32618. * @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
  32619. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32620. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32621. * @param forcedExtension defines the extension to use to pick the right loader
  32622. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32623. * @param mimeType defines an optional mime type
  32624. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32625. */
  32626. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32627. /**
  32628. * Loads an image as an HTMLImageElement.
  32629. * @param input url string, ArrayBuffer, or Blob to load
  32630. * @param onLoad callback called when the image successfully loads
  32631. * @param onError callback called when the image fails to load
  32632. * @param offlineProvider offline provider for caching
  32633. * @param mimeType optional mime type
  32634. * @returns the HTMLImageElement of the loaded image
  32635. * @hidden
  32636. */
  32637. 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>;
  32638. /**
  32639. * @hidden
  32640. */
  32641. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32642. /**
  32643. * Creates a raw texture
  32644. * @param data defines the data to store in the texture
  32645. * @param width defines the width of the texture
  32646. * @param height defines the height of the texture
  32647. * @param format defines the format of the data
  32648. * @param generateMipMaps defines if the engine should generate the mip levels
  32649. * @param invertY defines if data must be stored with Y axis inverted
  32650. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32651. * @param compression defines the compression used (null by default)
  32652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32653. * @returns the raw texture inside an InternalTexture
  32654. */
  32655. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32656. /**
  32657. * Creates a new raw cube texture
  32658. * @param data defines the array of data to use to create each face
  32659. * @param size defines the size of the textures
  32660. * @param format defines the format of the data
  32661. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32662. * @param generateMipMaps defines if the engine should generate the mip levels
  32663. * @param invertY defines if data must be stored with Y axis inverted
  32664. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32665. * @param compression defines the compression used (null by default)
  32666. * @returns the cube texture as an InternalTexture
  32667. */
  32668. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32669. /**
  32670. * Creates a new raw 3D texture
  32671. * @param data defines the data used to create the texture
  32672. * @param width defines the width of the texture
  32673. * @param height defines the height of the texture
  32674. * @param depth defines the depth of the texture
  32675. * @param format defines the format of the texture
  32676. * @param generateMipMaps defines if the engine must generate mip levels
  32677. * @param invertY defines if data must be stored with Y axis inverted
  32678. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32679. * @param compression defines the compressed used (can be null)
  32680. * @param textureType defines the compressed used (can be null)
  32681. * @returns a new raw 3D texture (stored in an InternalTexture)
  32682. */
  32683. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32684. /**
  32685. * Creates a new raw 2D array texture
  32686. * @param data defines the data used to create the texture
  32687. * @param width defines the width of the texture
  32688. * @param height defines the height of the texture
  32689. * @param depth defines the number of layers of the texture
  32690. * @param format defines the format of the texture
  32691. * @param generateMipMaps defines if the engine must generate mip levels
  32692. * @param invertY defines if data must be stored with Y axis inverted
  32693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32694. * @param compression defines the compressed used (can be null)
  32695. * @param textureType defines the compressed used (can be null)
  32696. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32697. */
  32698. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32699. private _unpackFlipYCached;
  32700. /**
  32701. * In case you are sharing the context with other applications, it might
  32702. * be interested to not cache the unpack flip y state to ensure a consistent
  32703. * value would be set.
  32704. */
  32705. enableUnpackFlipYCached: boolean;
  32706. /** @hidden */
  32707. _unpackFlipY(value: boolean): void;
  32708. /** @hidden */
  32709. _getUnpackAlignement(): number;
  32710. private _getTextureTarget;
  32711. /**
  32712. * Update the sampling mode of a given texture
  32713. * @param samplingMode defines the required sampling mode
  32714. * @param texture defines the texture to update
  32715. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32716. */
  32717. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32718. /**
  32719. * Update the sampling mode of a given texture
  32720. * @param texture defines the texture to update
  32721. * @param wrapU defines the texture wrap mode of the u coordinates
  32722. * @param wrapV defines the texture wrap mode of the v coordinates
  32723. * @param wrapR defines the texture wrap mode of the r coordinates
  32724. */
  32725. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32726. /** @hidden */
  32727. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32728. width: number;
  32729. height: number;
  32730. layers?: number;
  32731. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32732. /** @hidden */
  32733. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32734. /** @hidden */
  32735. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32736. /**
  32737. * Update a portion of an internal texture
  32738. * @param texture defines the texture to update
  32739. * @param imageData defines the data to store into the texture
  32740. * @param xOffset defines the x coordinates of the update rectangle
  32741. * @param yOffset defines the y coordinates of the update rectangle
  32742. * @param width defines the width of the update rectangle
  32743. * @param height defines the height of the update rectangle
  32744. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32745. * @param lod defines the lod level to update (0 by default)
  32746. */
  32747. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32748. /** @hidden */
  32749. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32750. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32751. private _prepareWebGLTexture;
  32752. /** @hidden */
  32753. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32754. private _getDepthStencilBuffer;
  32755. /** @hidden */
  32756. _releaseFramebufferObjects(texture: InternalTexture): void;
  32757. /** @hidden */
  32758. _releaseTexture(texture: InternalTexture): void;
  32759. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32760. protected _setProgram(program: WebGLProgram): void;
  32761. protected _boundUniforms: {
  32762. [key: number]: WebGLUniformLocation;
  32763. };
  32764. /**
  32765. * Binds an effect to the webGL context
  32766. * @param effect defines the effect to bind
  32767. */
  32768. bindSamplers(effect: Effect): void;
  32769. private _activateCurrentTexture;
  32770. /** @hidden */
  32771. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32772. /** @hidden */
  32773. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32774. /**
  32775. * Unbind all textures from the webGL context
  32776. */
  32777. unbindAllTextures(): void;
  32778. /**
  32779. * Sets a texture to the according uniform.
  32780. * @param channel The texture channel
  32781. * @param uniform The uniform to set
  32782. * @param texture The texture to apply
  32783. */
  32784. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32785. private _bindSamplerUniformToChannel;
  32786. private _getTextureWrapMode;
  32787. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32788. /**
  32789. * Sets an array of texture to the webGL context
  32790. * @param channel defines the channel where the texture array must be set
  32791. * @param uniform defines the associated uniform location
  32792. * @param textures defines the array of textures to bind
  32793. */
  32794. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32795. /** @hidden */
  32796. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32797. private _setTextureParameterFloat;
  32798. private _setTextureParameterInteger;
  32799. /**
  32800. * Unbind all vertex attributes from the webGL context
  32801. */
  32802. unbindAllAttributes(): void;
  32803. /**
  32804. * 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
  32805. */
  32806. releaseEffects(): void;
  32807. /**
  32808. * Dispose and release all associated resources
  32809. */
  32810. dispose(): void;
  32811. /**
  32812. * Attach a new callback raised when context lost event is fired
  32813. * @param callback defines the callback to call
  32814. */
  32815. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32816. /**
  32817. * Attach a new callback raised when context restored event is fired
  32818. * @param callback defines the callback to call
  32819. */
  32820. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32821. /**
  32822. * Get the current error code of the webGL context
  32823. * @returns the error code
  32824. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32825. */
  32826. getError(): number;
  32827. private _canRenderToFloatFramebuffer;
  32828. private _canRenderToHalfFloatFramebuffer;
  32829. private _canRenderToFramebuffer;
  32830. /** @hidden */
  32831. _getWebGLTextureType(type: number): number;
  32832. /** @hidden */
  32833. _getInternalFormat(format: number): number;
  32834. /** @hidden */
  32835. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32836. /** @hidden */
  32837. _getRGBAMultiSampleBufferFormat(type: number): number;
  32838. /** @hidden */
  32839. _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;
  32840. /**
  32841. * Loads a file from a url
  32842. * @param url url to load
  32843. * @param onSuccess callback called when the file successfully loads
  32844. * @param onProgress callback called while file is loading (if the server supports this mode)
  32845. * @param offlineProvider defines the offline provider for caching
  32846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32847. * @param onError callback called when the file fails to load
  32848. * @returns a file request object
  32849. * @hidden
  32850. */
  32851. 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;
  32852. /**
  32853. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32854. * @param x defines the x coordinate of the rectangle where pixels must be read
  32855. * @param y defines the y coordinate of the rectangle where pixels must be read
  32856. * @param width defines the width of the rectangle where pixels must be read
  32857. * @param height defines the height of the rectangle where pixels must be read
  32858. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32859. * @returns a Uint8Array containing RGBA colors
  32860. */
  32861. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32862. private static _isSupported;
  32863. /**
  32864. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32865. * @returns true if the engine can be created
  32866. * @ignorenaming
  32867. */
  32868. static isSupported(): boolean;
  32869. /**
  32870. * Find the next highest power of two.
  32871. * @param x Number to start search from.
  32872. * @return Next highest power of two.
  32873. */
  32874. static CeilingPOT(x: number): number;
  32875. /**
  32876. * Find the next lowest power of two.
  32877. * @param x Number to start search from.
  32878. * @return Next lowest power of two.
  32879. */
  32880. static FloorPOT(x: number): number;
  32881. /**
  32882. * Find the nearest power of two.
  32883. * @param x Number to start search from.
  32884. * @return Next nearest power of two.
  32885. */
  32886. static NearestPOT(x: number): number;
  32887. /**
  32888. * Get the closest exponent of two
  32889. * @param value defines the value to approximate
  32890. * @param max defines the maximum value to return
  32891. * @param mode defines how to define the closest value
  32892. * @returns closest exponent of two of the given value
  32893. */
  32894. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32895. /**
  32896. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32897. * @param func - the function to be called
  32898. * @param requester - the object that will request the next frame. Falls back to window.
  32899. * @returns frame number
  32900. */
  32901. static QueueNewFrame(func: () => void, requester?: any): number;
  32902. /**
  32903. * Gets host document
  32904. * @returns the host document object
  32905. */
  32906. getHostDocument(): Nullable<Document>;
  32907. }
  32908. }
  32909. declare module "babylonjs/Maths/sphericalPolynomial" {
  32910. import { Vector3 } from "babylonjs/Maths/math.vector";
  32911. import { Color3 } from "babylonjs/Maths/math.color";
  32912. /**
  32913. * Class representing spherical harmonics coefficients to the 3rd degree
  32914. */
  32915. export class SphericalHarmonics {
  32916. /**
  32917. * Defines whether or not the harmonics have been prescaled for rendering.
  32918. */
  32919. preScaled: boolean;
  32920. /**
  32921. * The l0,0 coefficients of the spherical harmonics
  32922. */
  32923. l00: Vector3;
  32924. /**
  32925. * The l1,-1 coefficients of the spherical harmonics
  32926. */
  32927. l1_1: Vector3;
  32928. /**
  32929. * The l1,0 coefficients of the spherical harmonics
  32930. */
  32931. l10: Vector3;
  32932. /**
  32933. * The l1,1 coefficients of the spherical harmonics
  32934. */
  32935. l11: Vector3;
  32936. /**
  32937. * The l2,-2 coefficients of the spherical harmonics
  32938. */
  32939. l2_2: Vector3;
  32940. /**
  32941. * The l2,-1 coefficients of the spherical harmonics
  32942. */
  32943. l2_1: Vector3;
  32944. /**
  32945. * The l2,0 coefficients of the spherical harmonics
  32946. */
  32947. l20: Vector3;
  32948. /**
  32949. * The l2,1 coefficients of the spherical harmonics
  32950. */
  32951. l21: Vector3;
  32952. /**
  32953. * The l2,2 coefficients of the spherical harmonics
  32954. */
  32955. l22: Vector3;
  32956. /**
  32957. * Adds a light to the spherical harmonics
  32958. * @param direction the direction of the light
  32959. * @param color the color of the light
  32960. * @param deltaSolidAngle the delta solid angle of the light
  32961. */
  32962. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32963. /**
  32964. * Scales the spherical harmonics by the given amount
  32965. * @param scale the amount to scale
  32966. */
  32967. scaleInPlace(scale: number): void;
  32968. /**
  32969. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32970. *
  32971. * ```
  32972. * E_lm = A_l * L_lm
  32973. * ```
  32974. *
  32975. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32976. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32977. * the scaling factors are given in equation 9.
  32978. */
  32979. convertIncidentRadianceToIrradiance(): void;
  32980. /**
  32981. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32982. *
  32983. * ```
  32984. * L = (1/pi) * E * rho
  32985. * ```
  32986. *
  32987. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32988. */
  32989. convertIrradianceToLambertianRadiance(): void;
  32990. /**
  32991. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32992. * required operations at run time.
  32993. *
  32994. * This is simply done by scaling back the SH with Ylm constants parameter.
  32995. * The trigonometric part being applied by the shader at run time.
  32996. */
  32997. preScaleForRendering(): void;
  32998. /**
  32999. * Constructs a spherical harmonics from an array.
  33000. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33001. * @returns the spherical harmonics
  33002. */
  33003. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33004. /**
  33005. * Gets the spherical harmonics from polynomial
  33006. * @param polynomial the spherical polynomial
  33007. * @returns the spherical harmonics
  33008. */
  33009. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33010. }
  33011. /**
  33012. * Class representing spherical polynomial coefficients to the 3rd degree
  33013. */
  33014. export class SphericalPolynomial {
  33015. private _harmonics;
  33016. /**
  33017. * The spherical harmonics used to create the polynomials.
  33018. */
  33019. get preScaledHarmonics(): SphericalHarmonics;
  33020. /**
  33021. * The x coefficients of the spherical polynomial
  33022. */
  33023. x: Vector3;
  33024. /**
  33025. * The y coefficients of the spherical polynomial
  33026. */
  33027. y: Vector3;
  33028. /**
  33029. * The z coefficients of the spherical polynomial
  33030. */
  33031. z: Vector3;
  33032. /**
  33033. * The xx coefficients of the spherical polynomial
  33034. */
  33035. xx: Vector3;
  33036. /**
  33037. * The yy coefficients of the spherical polynomial
  33038. */
  33039. yy: Vector3;
  33040. /**
  33041. * The zz coefficients of the spherical polynomial
  33042. */
  33043. zz: Vector3;
  33044. /**
  33045. * The xy coefficients of the spherical polynomial
  33046. */
  33047. xy: Vector3;
  33048. /**
  33049. * The yz coefficients of the spherical polynomial
  33050. */
  33051. yz: Vector3;
  33052. /**
  33053. * The zx coefficients of the spherical polynomial
  33054. */
  33055. zx: Vector3;
  33056. /**
  33057. * Adds an ambient color to the spherical polynomial
  33058. * @param color the color to add
  33059. */
  33060. addAmbient(color: Color3): void;
  33061. /**
  33062. * Scales the spherical polynomial by the given amount
  33063. * @param scale the amount to scale
  33064. */
  33065. scaleInPlace(scale: number): void;
  33066. /**
  33067. * Gets the spherical polynomial from harmonics
  33068. * @param harmonics the spherical harmonics
  33069. * @returns the spherical polynomial
  33070. */
  33071. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33072. /**
  33073. * Constructs a spherical polynomial from an array.
  33074. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33075. * @returns the spherical polynomial
  33076. */
  33077. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33078. }
  33079. }
  33080. declare module "babylonjs/Materials/Textures/internalTexture" {
  33081. import { Observable } from "babylonjs/Misc/observable";
  33082. import { Nullable, int } from "babylonjs/types";
  33083. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33085. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33086. /**
  33087. * Defines the source of the internal texture
  33088. */
  33089. export enum InternalTextureSource {
  33090. /**
  33091. * The source of the texture data is unknown
  33092. */
  33093. Unknown = 0,
  33094. /**
  33095. * Texture data comes from an URL
  33096. */
  33097. Url = 1,
  33098. /**
  33099. * Texture data is only used for temporary storage
  33100. */
  33101. Temp = 2,
  33102. /**
  33103. * Texture data comes from raw data (ArrayBuffer)
  33104. */
  33105. Raw = 3,
  33106. /**
  33107. * Texture content is dynamic (video or dynamic texture)
  33108. */
  33109. Dynamic = 4,
  33110. /**
  33111. * Texture content is generated by rendering to it
  33112. */
  33113. RenderTarget = 5,
  33114. /**
  33115. * Texture content is part of a multi render target process
  33116. */
  33117. MultiRenderTarget = 6,
  33118. /**
  33119. * Texture data comes from a cube data file
  33120. */
  33121. Cube = 7,
  33122. /**
  33123. * Texture data comes from a raw cube data
  33124. */
  33125. CubeRaw = 8,
  33126. /**
  33127. * Texture data come from a prefiltered cube data file
  33128. */
  33129. CubePrefiltered = 9,
  33130. /**
  33131. * Texture content is raw 3D data
  33132. */
  33133. Raw3D = 10,
  33134. /**
  33135. * Texture content is raw 2D array data
  33136. */
  33137. Raw2DArray = 11,
  33138. /**
  33139. * Texture content is a depth texture
  33140. */
  33141. Depth = 12,
  33142. /**
  33143. * Texture data comes from a raw cube data encoded with RGBD
  33144. */
  33145. CubeRawRGBD = 13
  33146. }
  33147. /**
  33148. * Class used to store data associated with WebGL texture data for the engine
  33149. * This class should not be used directly
  33150. */
  33151. export class InternalTexture {
  33152. /** @hidden */
  33153. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33154. /**
  33155. * Defines if the texture is ready
  33156. */
  33157. isReady: boolean;
  33158. /**
  33159. * Defines if the texture is a cube texture
  33160. */
  33161. isCube: boolean;
  33162. /**
  33163. * Defines if the texture contains 3D data
  33164. */
  33165. is3D: boolean;
  33166. /**
  33167. * Defines if the texture contains 2D array data
  33168. */
  33169. is2DArray: boolean;
  33170. /**
  33171. * Defines if the texture contains multiview data
  33172. */
  33173. isMultiview: boolean;
  33174. /**
  33175. * Gets the URL used to load this texture
  33176. */
  33177. url: string;
  33178. /**
  33179. * Gets the sampling mode of the texture
  33180. */
  33181. samplingMode: number;
  33182. /**
  33183. * Gets a boolean indicating if the texture needs mipmaps generation
  33184. */
  33185. generateMipMaps: boolean;
  33186. /**
  33187. * Gets the number of samples used by the texture (WebGL2+ only)
  33188. */
  33189. samples: number;
  33190. /**
  33191. * Gets the type of the texture (int, float...)
  33192. */
  33193. type: number;
  33194. /**
  33195. * Gets the format of the texture (RGB, RGBA...)
  33196. */
  33197. format: number;
  33198. /**
  33199. * Observable called when the texture is loaded
  33200. */
  33201. onLoadedObservable: Observable<InternalTexture>;
  33202. /**
  33203. * Gets the width of the texture
  33204. */
  33205. width: number;
  33206. /**
  33207. * Gets the height of the texture
  33208. */
  33209. height: number;
  33210. /**
  33211. * Gets the depth of the texture
  33212. */
  33213. depth: number;
  33214. /**
  33215. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33216. */
  33217. baseWidth: number;
  33218. /**
  33219. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33220. */
  33221. baseHeight: number;
  33222. /**
  33223. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33224. */
  33225. baseDepth: number;
  33226. /**
  33227. * Gets a boolean indicating if the texture is inverted on Y axis
  33228. */
  33229. invertY: boolean;
  33230. /** @hidden */
  33231. _invertVScale: boolean;
  33232. /** @hidden */
  33233. _associatedChannel: number;
  33234. /** @hidden */
  33235. _source: InternalTextureSource;
  33236. /** @hidden */
  33237. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33238. /** @hidden */
  33239. _bufferView: Nullable<ArrayBufferView>;
  33240. /** @hidden */
  33241. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33242. /** @hidden */
  33243. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33244. /** @hidden */
  33245. _size: number;
  33246. /** @hidden */
  33247. _extension: string;
  33248. /** @hidden */
  33249. _files: Nullable<string[]>;
  33250. /** @hidden */
  33251. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33252. /** @hidden */
  33253. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33254. /** @hidden */
  33255. _framebuffer: Nullable<WebGLFramebuffer>;
  33256. /** @hidden */
  33257. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33258. /** @hidden */
  33259. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33260. /** @hidden */
  33261. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33262. /** @hidden */
  33263. _attachments: Nullable<number[]>;
  33264. /** @hidden */
  33265. _cachedCoordinatesMode: Nullable<number>;
  33266. /** @hidden */
  33267. _cachedWrapU: Nullable<number>;
  33268. /** @hidden */
  33269. _cachedWrapV: Nullable<number>;
  33270. /** @hidden */
  33271. _cachedWrapR: Nullable<number>;
  33272. /** @hidden */
  33273. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33274. /** @hidden */
  33275. _isDisabled: boolean;
  33276. /** @hidden */
  33277. _compression: Nullable<string>;
  33278. /** @hidden */
  33279. _generateStencilBuffer: boolean;
  33280. /** @hidden */
  33281. _generateDepthBuffer: boolean;
  33282. /** @hidden */
  33283. _comparisonFunction: number;
  33284. /** @hidden */
  33285. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33286. /** @hidden */
  33287. _lodGenerationScale: number;
  33288. /** @hidden */
  33289. _lodGenerationOffset: number;
  33290. /** @hidden */
  33291. _depthStencilTexture: Nullable<InternalTexture>;
  33292. /** @hidden */
  33293. _colorTextureArray: Nullable<WebGLTexture>;
  33294. /** @hidden */
  33295. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33296. /** @hidden */
  33297. _lodTextureHigh: Nullable<BaseTexture>;
  33298. /** @hidden */
  33299. _lodTextureMid: Nullable<BaseTexture>;
  33300. /** @hidden */
  33301. _lodTextureLow: Nullable<BaseTexture>;
  33302. /** @hidden */
  33303. _isRGBD: boolean;
  33304. /** @hidden */
  33305. _linearSpecularLOD: boolean;
  33306. /** @hidden */
  33307. _irradianceTexture: Nullable<BaseTexture>;
  33308. /** @hidden */
  33309. _webGLTexture: Nullable<WebGLTexture>;
  33310. /** @hidden */
  33311. _references: number;
  33312. private _engine;
  33313. /**
  33314. * Gets the Engine the texture belongs to.
  33315. * @returns The babylon engine
  33316. */
  33317. getEngine(): ThinEngine;
  33318. /**
  33319. * Gets the data source type of the texture
  33320. */
  33321. get source(): InternalTextureSource;
  33322. /**
  33323. * Creates a new InternalTexture
  33324. * @param engine defines the engine to use
  33325. * @param source defines the type of data that will be used
  33326. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33327. */
  33328. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33329. /**
  33330. * Increments the number of references (ie. the number of Texture that point to it)
  33331. */
  33332. incrementReferences(): void;
  33333. /**
  33334. * Change the size of the texture (not the size of the content)
  33335. * @param width defines the new width
  33336. * @param height defines the new height
  33337. * @param depth defines the new depth (1 by default)
  33338. */
  33339. updateSize(width: int, height: int, depth?: int): void;
  33340. /** @hidden */
  33341. _rebuild(): void;
  33342. /** @hidden */
  33343. _swapAndDie(target: InternalTexture): void;
  33344. /**
  33345. * Dispose the current allocated resources
  33346. */
  33347. dispose(): void;
  33348. }
  33349. }
  33350. declare module "babylonjs/Audio/analyser" {
  33351. import { Scene } from "babylonjs/scene";
  33352. /**
  33353. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33355. */
  33356. export class Analyser {
  33357. /**
  33358. * Gets or sets the smoothing
  33359. * @ignorenaming
  33360. */
  33361. SMOOTHING: number;
  33362. /**
  33363. * Gets or sets the FFT table size
  33364. * @ignorenaming
  33365. */
  33366. FFT_SIZE: number;
  33367. /**
  33368. * Gets or sets the bar graph amplitude
  33369. * @ignorenaming
  33370. */
  33371. BARGRAPHAMPLITUDE: number;
  33372. /**
  33373. * Gets or sets the position of the debug canvas
  33374. * @ignorenaming
  33375. */
  33376. DEBUGCANVASPOS: {
  33377. x: number;
  33378. y: number;
  33379. };
  33380. /**
  33381. * Gets or sets the debug canvas size
  33382. * @ignorenaming
  33383. */
  33384. DEBUGCANVASSIZE: {
  33385. width: number;
  33386. height: number;
  33387. };
  33388. private _byteFreqs;
  33389. private _byteTime;
  33390. private _floatFreqs;
  33391. private _webAudioAnalyser;
  33392. private _debugCanvas;
  33393. private _debugCanvasContext;
  33394. private _scene;
  33395. private _registerFunc;
  33396. private _audioEngine;
  33397. /**
  33398. * Creates a new analyser
  33399. * @param scene defines hosting scene
  33400. */
  33401. constructor(scene: Scene);
  33402. /**
  33403. * Get the number of data values you will have to play with for the visualization
  33404. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33405. * @returns a number
  33406. */
  33407. getFrequencyBinCount(): number;
  33408. /**
  33409. * Gets the current frequency data as a byte array
  33410. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33411. * @returns a Uint8Array
  33412. */
  33413. getByteFrequencyData(): Uint8Array;
  33414. /**
  33415. * Gets the current waveform as a byte array
  33416. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33417. * @returns a Uint8Array
  33418. */
  33419. getByteTimeDomainData(): Uint8Array;
  33420. /**
  33421. * Gets the current frequency data as a float array
  33422. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33423. * @returns a Float32Array
  33424. */
  33425. getFloatFrequencyData(): Float32Array;
  33426. /**
  33427. * Renders the debug canvas
  33428. */
  33429. drawDebugCanvas(): void;
  33430. /**
  33431. * Stops rendering the debug canvas and removes it
  33432. */
  33433. stopDebugCanvas(): void;
  33434. /**
  33435. * Connects two audio nodes
  33436. * @param inputAudioNode defines first node to connect
  33437. * @param outputAudioNode defines second node to connect
  33438. */
  33439. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33440. /**
  33441. * Releases all associated resources
  33442. */
  33443. dispose(): void;
  33444. }
  33445. }
  33446. declare module "babylonjs/Audio/audioEngine" {
  33447. import { IDisposable } from "babylonjs/scene";
  33448. import { Analyser } from "babylonjs/Audio/analyser";
  33449. import { Nullable } from "babylonjs/types";
  33450. import { Observable } from "babylonjs/Misc/observable";
  33451. /**
  33452. * This represents an audio engine and it is responsible
  33453. * to play, synchronize and analyse sounds throughout the application.
  33454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33455. */
  33456. export interface IAudioEngine extends IDisposable {
  33457. /**
  33458. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33459. */
  33460. readonly canUseWebAudio: boolean;
  33461. /**
  33462. * Gets the current AudioContext if available.
  33463. */
  33464. readonly audioContext: Nullable<AudioContext>;
  33465. /**
  33466. * The master gain node defines the global audio volume of your audio engine.
  33467. */
  33468. readonly masterGain: GainNode;
  33469. /**
  33470. * Gets whether or not mp3 are supported by your browser.
  33471. */
  33472. readonly isMP3supported: boolean;
  33473. /**
  33474. * Gets whether or not ogg are supported by your browser.
  33475. */
  33476. readonly isOGGsupported: boolean;
  33477. /**
  33478. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33479. * @ignoreNaming
  33480. */
  33481. WarnedWebAudioUnsupported: boolean;
  33482. /**
  33483. * Defines if the audio engine relies on a custom unlocked button.
  33484. * In this case, the embedded button will not be displayed.
  33485. */
  33486. useCustomUnlockedButton: boolean;
  33487. /**
  33488. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33489. */
  33490. readonly unlocked: boolean;
  33491. /**
  33492. * Event raised when audio has been unlocked on the browser.
  33493. */
  33494. onAudioUnlockedObservable: Observable<AudioEngine>;
  33495. /**
  33496. * Event raised when audio has been locked on the browser.
  33497. */
  33498. onAudioLockedObservable: Observable<AudioEngine>;
  33499. /**
  33500. * Flags the audio engine in Locked state.
  33501. * This happens due to new browser policies preventing audio to autoplay.
  33502. */
  33503. lock(): void;
  33504. /**
  33505. * Unlocks the audio engine once a user action has been done on the dom.
  33506. * This is helpful to resume play once browser policies have been satisfied.
  33507. */
  33508. unlock(): void;
  33509. }
  33510. /**
  33511. * This represents the default audio engine used in babylon.
  33512. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33514. */
  33515. export class AudioEngine implements IAudioEngine {
  33516. private _audioContext;
  33517. private _audioContextInitialized;
  33518. private _muteButton;
  33519. private _hostElement;
  33520. /**
  33521. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33522. */
  33523. canUseWebAudio: boolean;
  33524. /**
  33525. * The master gain node defines the global audio volume of your audio engine.
  33526. */
  33527. masterGain: GainNode;
  33528. /**
  33529. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33530. * @ignoreNaming
  33531. */
  33532. WarnedWebAudioUnsupported: boolean;
  33533. /**
  33534. * Gets whether or not mp3 are supported by your browser.
  33535. */
  33536. isMP3supported: boolean;
  33537. /**
  33538. * Gets whether or not ogg are supported by your browser.
  33539. */
  33540. isOGGsupported: boolean;
  33541. /**
  33542. * Gets whether audio has been unlocked on the device.
  33543. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33544. * a user interaction has happened.
  33545. */
  33546. unlocked: boolean;
  33547. /**
  33548. * Defines if the audio engine relies on a custom unlocked button.
  33549. * In this case, the embedded button will not be displayed.
  33550. */
  33551. useCustomUnlockedButton: boolean;
  33552. /**
  33553. * Event raised when audio has been unlocked on the browser.
  33554. */
  33555. onAudioUnlockedObservable: Observable<AudioEngine>;
  33556. /**
  33557. * Event raised when audio has been locked on the browser.
  33558. */
  33559. onAudioLockedObservable: Observable<AudioEngine>;
  33560. /**
  33561. * Gets the current AudioContext if available.
  33562. */
  33563. get audioContext(): Nullable<AudioContext>;
  33564. private _connectedAnalyser;
  33565. /**
  33566. * Instantiates a new audio engine.
  33567. *
  33568. * There should be only one per page as some browsers restrict the number
  33569. * of audio contexts you can create.
  33570. * @param hostElement defines the host element where to display the mute icon if necessary
  33571. */
  33572. constructor(hostElement?: Nullable<HTMLElement>);
  33573. /**
  33574. * Flags the audio engine in Locked state.
  33575. * This happens due to new browser policies preventing audio to autoplay.
  33576. */
  33577. lock(): void;
  33578. /**
  33579. * Unlocks the audio engine once a user action has been done on the dom.
  33580. * This is helpful to resume play once browser policies have been satisfied.
  33581. */
  33582. unlock(): void;
  33583. private _resumeAudioContext;
  33584. private _initializeAudioContext;
  33585. private _tryToRun;
  33586. private _triggerRunningState;
  33587. private _triggerSuspendedState;
  33588. private _displayMuteButton;
  33589. private _moveButtonToTopLeft;
  33590. private _onResize;
  33591. private _hideMuteButton;
  33592. /**
  33593. * Destroy and release the resources associated with the audio ccontext.
  33594. */
  33595. dispose(): void;
  33596. /**
  33597. * Gets the global volume sets on the master gain.
  33598. * @returns the global volume if set or -1 otherwise
  33599. */
  33600. getGlobalVolume(): number;
  33601. /**
  33602. * Sets the global volume of your experience (sets on the master gain).
  33603. * @param newVolume Defines the new global volume of the application
  33604. */
  33605. setGlobalVolume(newVolume: number): void;
  33606. /**
  33607. * Connect the audio engine to an audio analyser allowing some amazing
  33608. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33610. * @param analyser The analyser to connect to the engine
  33611. */
  33612. connectToAnalyser(analyser: Analyser): void;
  33613. }
  33614. }
  33615. declare module "babylonjs/Loading/loadingScreen" {
  33616. /**
  33617. * Interface used to present a loading screen while loading a scene
  33618. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33619. */
  33620. export interface ILoadingScreen {
  33621. /**
  33622. * Function called to display the loading screen
  33623. */
  33624. displayLoadingUI: () => void;
  33625. /**
  33626. * Function called to hide the loading screen
  33627. */
  33628. hideLoadingUI: () => void;
  33629. /**
  33630. * Gets or sets the color to use for the background
  33631. */
  33632. loadingUIBackgroundColor: string;
  33633. /**
  33634. * Gets or sets the text to display while loading
  33635. */
  33636. loadingUIText: string;
  33637. }
  33638. /**
  33639. * Class used for the default loading screen
  33640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33641. */
  33642. export class DefaultLoadingScreen implements ILoadingScreen {
  33643. private _renderingCanvas;
  33644. private _loadingText;
  33645. private _loadingDivBackgroundColor;
  33646. private _loadingDiv;
  33647. private _loadingTextDiv;
  33648. /** Gets or sets the logo url to use for the default loading screen */
  33649. static DefaultLogoUrl: string;
  33650. /** Gets or sets the spinner url to use for the default loading screen */
  33651. static DefaultSpinnerUrl: string;
  33652. /**
  33653. * Creates a new default loading screen
  33654. * @param _renderingCanvas defines the canvas used to render the scene
  33655. * @param _loadingText defines the default text to display
  33656. * @param _loadingDivBackgroundColor defines the default background color
  33657. */
  33658. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33659. /**
  33660. * Function called to display the loading screen
  33661. */
  33662. displayLoadingUI(): void;
  33663. /**
  33664. * Function called to hide the loading screen
  33665. */
  33666. hideLoadingUI(): void;
  33667. /**
  33668. * Gets or sets the text to display while loading
  33669. */
  33670. set loadingUIText(text: string);
  33671. get loadingUIText(): string;
  33672. /**
  33673. * Gets or sets the color to use for the background
  33674. */
  33675. get loadingUIBackgroundColor(): string;
  33676. set loadingUIBackgroundColor(color: string);
  33677. private _resizeLoadingUI;
  33678. }
  33679. }
  33680. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33681. /**
  33682. * Interface for any object that can request an animation frame
  33683. */
  33684. export interface ICustomAnimationFrameRequester {
  33685. /**
  33686. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33687. */
  33688. renderFunction?: Function;
  33689. /**
  33690. * Called to request the next frame to render to
  33691. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33692. */
  33693. requestAnimationFrame: Function;
  33694. /**
  33695. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33696. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33697. */
  33698. requestID?: number;
  33699. }
  33700. }
  33701. declare module "babylonjs/Misc/performanceMonitor" {
  33702. /**
  33703. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33704. */
  33705. export class PerformanceMonitor {
  33706. private _enabled;
  33707. private _rollingFrameTime;
  33708. private _lastFrameTimeMs;
  33709. /**
  33710. * constructor
  33711. * @param frameSampleSize The number of samples required to saturate the sliding window
  33712. */
  33713. constructor(frameSampleSize?: number);
  33714. /**
  33715. * Samples current frame
  33716. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33717. */
  33718. sampleFrame(timeMs?: number): void;
  33719. /**
  33720. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33721. */
  33722. get averageFrameTime(): number;
  33723. /**
  33724. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33725. */
  33726. get averageFrameTimeVariance(): number;
  33727. /**
  33728. * Returns the frame time of the most recent frame
  33729. */
  33730. get instantaneousFrameTime(): number;
  33731. /**
  33732. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33733. */
  33734. get averageFPS(): number;
  33735. /**
  33736. * Returns the average framerate in frames per second using the most recent frame time
  33737. */
  33738. get instantaneousFPS(): number;
  33739. /**
  33740. * Returns true if enough samples have been taken to completely fill the sliding window
  33741. */
  33742. get isSaturated(): boolean;
  33743. /**
  33744. * Enables contributions to the sliding window sample set
  33745. */
  33746. enable(): void;
  33747. /**
  33748. * Disables contributions to the sliding window sample set
  33749. * Samples will not be interpolated over the disabled period
  33750. */
  33751. disable(): void;
  33752. /**
  33753. * Returns true if sampling is enabled
  33754. */
  33755. get isEnabled(): boolean;
  33756. /**
  33757. * Resets performance monitor
  33758. */
  33759. reset(): void;
  33760. }
  33761. /**
  33762. * RollingAverage
  33763. *
  33764. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33765. */
  33766. export class RollingAverage {
  33767. /**
  33768. * Current average
  33769. */
  33770. average: number;
  33771. /**
  33772. * Current variance
  33773. */
  33774. variance: number;
  33775. protected _samples: Array<number>;
  33776. protected _sampleCount: number;
  33777. protected _pos: number;
  33778. protected _m2: number;
  33779. /**
  33780. * constructor
  33781. * @param length The number of samples required to saturate the sliding window
  33782. */
  33783. constructor(length: number);
  33784. /**
  33785. * Adds a sample to the sample set
  33786. * @param v The sample value
  33787. */
  33788. add(v: number): void;
  33789. /**
  33790. * Returns previously added values or null if outside of history or outside the sliding window domain
  33791. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33792. * @return Value previously recorded with add() or null if outside of range
  33793. */
  33794. history(i: number): number;
  33795. /**
  33796. * Returns true if enough samples have been taken to completely fill the sliding window
  33797. * @return true if sample-set saturated
  33798. */
  33799. isSaturated(): boolean;
  33800. /**
  33801. * Resets the rolling average (equivalent to 0 samples taken so far)
  33802. */
  33803. reset(): void;
  33804. /**
  33805. * Wraps a value around the sample range boundaries
  33806. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33807. * @return Wrapped position in sample range
  33808. */
  33809. protected _wrapPosition(i: number): number;
  33810. }
  33811. }
  33812. declare module "babylonjs/Misc/perfCounter" {
  33813. /**
  33814. * This class is used to track a performance counter which is number based.
  33815. * The user has access to many properties which give statistics of different nature.
  33816. *
  33817. * The implementer can track two kinds of Performance Counter: time and count.
  33818. * 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.
  33819. * 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.
  33820. */
  33821. export class PerfCounter {
  33822. /**
  33823. * Gets or sets a global boolean to turn on and off all the counters
  33824. */
  33825. static Enabled: boolean;
  33826. /**
  33827. * Returns the smallest value ever
  33828. */
  33829. get min(): number;
  33830. /**
  33831. * Returns the biggest value ever
  33832. */
  33833. get max(): number;
  33834. /**
  33835. * Returns the average value since the performance counter is running
  33836. */
  33837. get average(): number;
  33838. /**
  33839. * Returns the average value of the last second the counter was monitored
  33840. */
  33841. get lastSecAverage(): number;
  33842. /**
  33843. * Returns the current value
  33844. */
  33845. get current(): number;
  33846. /**
  33847. * Gets the accumulated total
  33848. */
  33849. get total(): number;
  33850. /**
  33851. * Gets the total value count
  33852. */
  33853. get count(): number;
  33854. /**
  33855. * Creates a new counter
  33856. */
  33857. constructor();
  33858. /**
  33859. * Call this method to start monitoring a new frame.
  33860. * 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.
  33861. */
  33862. fetchNewFrame(): void;
  33863. /**
  33864. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33865. * @param newCount the count value to add to the monitored count
  33866. * @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.
  33867. */
  33868. addCount(newCount: number, fetchResult: boolean): void;
  33869. /**
  33870. * Start monitoring this performance counter
  33871. */
  33872. beginMonitoring(): void;
  33873. /**
  33874. * Compute the time lapsed since the previous beginMonitoring() call.
  33875. * @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
  33876. */
  33877. endMonitoring(newFrame?: boolean): void;
  33878. private _fetchResult;
  33879. private _startMonitoringTime;
  33880. private _min;
  33881. private _max;
  33882. private _average;
  33883. private _current;
  33884. private _totalValueCount;
  33885. private _totalAccumulated;
  33886. private _lastSecAverage;
  33887. private _lastSecAccumulated;
  33888. private _lastSecTime;
  33889. private _lastSecValueCount;
  33890. }
  33891. }
  33892. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33893. module "babylonjs/Engines/thinEngine" {
  33894. interface ThinEngine {
  33895. /**
  33896. * Sets alpha constants used by some alpha blending modes
  33897. * @param r defines the red component
  33898. * @param g defines the green component
  33899. * @param b defines the blue component
  33900. * @param a defines the alpha component
  33901. */
  33902. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33903. /**
  33904. * Sets the current alpha mode
  33905. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33906. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33907. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33908. */
  33909. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33910. /**
  33911. * Gets the current alpha mode
  33912. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33913. * @returns the current alpha mode
  33914. */
  33915. getAlphaMode(): number;
  33916. /**
  33917. * Sets the current alpha equation
  33918. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33919. */
  33920. setAlphaEquation(equation: number): void;
  33921. /**
  33922. * Gets the current alpha equation.
  33923. * @returns the current alpha equation
  33924. */
  33925. getAlphaEquation(): number;
  33926. }
  33927. }
  33928. }
  33929. declare module "babylonjs/Engines/engine" {
  33930. import { Observable } from "babylonjs/Misc/observable";
  33931. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33932. import { Scene } from "babylonjs/scene";
  33933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33934. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33935. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33936. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33937. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33938. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33939. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33940. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33941. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33942. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33943. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33944. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33945. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33946. import "babylonjs/Engines/Extensions/engine.alpha";
  33947. import { Material } from "babylonjs/Materials/material";
  33948. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33949. /**
  33950. * Defines the interface used by display changed events
  33951. */
  33952. export interface IDisplayChangedEventArgs {
  33953. /** Gets the vrDisplay object (if any) */
  33954. vrDisplay: Nullable<any>;
  33955. /** Gets a boolean indicating if webVR is supported */
  33956. vrSupported: boolean;
  33957. }
  33958. /**
  33959. * Defines the interface used by objects containing a viewport (like a camera)
  33960. */
  33961. interface IViewportOwnerLike {
  33962. /**
  33963. * Gets or sets the viewport
  33964. */
  33965. viewport: IViewportLike;
  33966. }
  33967. /**
  33968. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33969. */
  33970. export class Engine extends ThinEngine {
  33971. /** Defines that alpha blending is disabled */
  33972. static readonly ALPHA_DISABLE: number;
  33973. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33974. static readonly ALPHA_ADD: number;
  33975. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33976. static readonly ALPHA_COMBINE: number;
  33977. /** Defines that alpha blending to DEST - SRC * DEST */
  33978. static readonly ALPHA_SUBTRACT: number;
  33979. /** Defines that alpha blending to SRC * DEST */
  33980. static readonly ALPHA_MULTIPLY: number;
  33981. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33982. static readonly ALPHA_MAXIMIZED: number;
  33983. /** Defines that alpha blending to SRC + DEST */
  33984. static readonly ALPHA_ONEONE: number;
  33985. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33986. static readonly ALPHA_PREMULTIPLIED: number;
  33987. /**
  33988. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33989. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33990. */
  33991. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33992. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33993. static readonly ALPHA_INTERPOLATE: number;
  33994. /**
  33995. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33996. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33997. */
  33998. static readonly ALPHA_SCREENMODE: number;
  33999. /** Defines that the ressource is not delayed*/
  34000. static readonly DELAYLOADSTATE_NONE: number;
  34001. /** Defines that the ressource was successfully delay loaded */
  34002. static readonly DELAYLOADSTATE_LOADED: number;
  34003. /** Defines that the ressource is currently delay loading */
  34004. static readonly DELAYLOADSTATE_LOADING: number;
  34005. /** Defines that the ressource is delayed and has not started loading */
  34006. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34008. static readonly NEVER: number;
  34009. /** 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 */
  34010. static readonly ALWAYS: number;
  34011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34012. static readonly LESS: number;
  34013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34014. static readonly EQUAL: number;
  34015. /** 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 */
  34016. static readonly LEQUAL: number;
  34017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34018. static readonly GREATER: number;
  34019. /** 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 */
  34020. static readonly GEQUAL: number;
  34021. /** 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 */
  34022. static readonly NOTEQUAL: number;
  34023. /** Passed to stencilOperation to specify that stencil value must be kept */
  34024. static readonly KEEP: number;
  34025. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34026. static readonly REPLACE: number;
  34027. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34028. static readonly INCR: number;
  34029. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34030. static readonly DECR: number;
  34031. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34032. static readonly INVERT: number;
  34033. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34034. static readonly INCR_WRAP: number;
  34035. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34036. static readonly DECR_WRAP: number;
  34037. /** Texture is not repeating outside of 0..1 UVs */
  34038. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34039. /** Texture is repeating outside of 0..1 UVs */
  34040. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34041. /** Texture is repeating and mirrored */
  34042. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34043. /** ALPHA */
  34044. static readonly TEXTUREFORMAT_ALPHA: number;
  34045. /** LUMINANCE */
  34046. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34047. /** LUMINANCE_ALPHA */
  34048. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34049. /** RGB */
  34050. static readonly TEXTUREFORMAT_RGB: number;
  34051. /** RGBA */
  34052. static readonly TEXTUREFORMAT_RGBA: number;
  34053. /** RED */
  34054. static readonly TEXTUREFORMAT_RED: number;
  34055. /** RED (2nd reference) */
  34056. static readonly TEXTUREFORMAT_R: number;
  34057. /** RG */
  34058. static readonly TEXTUREFORMAT_RG: number;
  34059. /** RED_INTEGER */
  34060. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34061. /** RED_INTEGER (2nd reference) */
  34062. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34063. /** RG_INTEGER */
  34064. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34065. /** RGB_INTEGER */
  34066. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34067. /** RGBA_INTEGER */
  34068. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34069. /** UNSIGNED_BYTE */
  34070. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34071. /** UNSIGNED_BYTE (2nd reference) */
  34072. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34073. /** FLOAT */
  34074. static readonly TEXTURETYPE_FLOAT: number;
  34075. /** HALF_FLOAT */
  34076. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34077. /** BYTE */
  34078. static readonly TEXTURETYPE_BYTE: number;
  34079. /** SHORT */
  34080. static readonly TEXTURETYPE_SHORT: number;
  34081. /** UNSIGNED_SHORT */
  34082. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34083. /** INT */
  34084. static readonly TEXTURETYPE_INT: number;
  34085. /** UNSIGNED_INT */
  34086. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34087. /** UNSIGNED_SHORT_4_4_4_4 */
  34088. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34089. /** UNSIGNED_SHORT_5_5_5_1 */
  34090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34091. /** UNSIGNED_SHORT_5_6_5 */
  34092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34093. /** UNSIGNED_INT_2_10_10_10_REV */
  34094. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34095. /** UNSIGNED_INT_24_8 */
  34096. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34097. /** UNSIGNED_INT_10F_11F_11F_REV */
  34098. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34099. /** UNSIGNED_INT_5_9_9_9_REV */
  34100. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34101. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34102. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34103. /** nearest is mag = nearest and min = nearest and mip = linear */
  34104. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34106. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34107. /** Trilinear is mag = linear and min = linear and mip = linear */
  34108. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34109. /** nearest is mag = nearest and min = nearest and mip = linear */
  34110. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34112. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34113. /** Trilinear is mag = linear and min = linear and mip = linear */
  34114. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34115. /** mag = nearest and min = nearest and mip = nearest */
  34116. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34117. /** mag = nearest and min = linear and mip = nearest */
  34118. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34119. /** mag = nearest and min = linear and mip = linear */
  34120. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34121. /** mag = nearest and min = linear and mip = none */
  34122. static readonly TEXTURE_NEAREST_LINEAR: number;
  34123. /** mag = nearest and min = nearest and mip = none */
  34124. static readonly TEXTURE_NEAREST_NEAREST: number;
  34125. /** mag = linear and min = nearest and mip = nearest */
  34126. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34127. /** mag = linear and min = nearest and mip = linear */
  34128. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34129. /** mag = linear and min = linear and mip = none */
  34130. static readonly TEXTURE_LINEAR_LINEAR: number;
  34131. /** mag = linear and min = nearest and mip = none */
  34132. static readonly TEXTURE_LINEAR_NEAREST: number;
  34133. /** Explicit coordinates mode */
  34134. static readonly TEXTURE_EXPLICIT_MODE: number;
  34135. /** Spherical coordinates mode */
  34136. static readonly TEXTURE_SPHERICAL_MODE: number;
  34137. /** Planar coordinates mode */
  34138. static readonly TEXTURE_PLANAR_MODE: number;
  34139. /** Cubic coordinates mode */
  34140. static readonly TEXTURE_CUBIC_MODE: number;
  34141. /** Projection coordinates mode */
  34142. static readonly TEXTURE_PROJECTION_MODE: number;
  34143. /** Skybox coordinates mode */
  34144. static readonly TEXTURE_SKYBOX_MODE: number;
  34145. /** Inverse Cubic coordinates mode */
  34146. static readonly TEXTURE_INVCUBIC_MODE: number;
  34147. /** Equirectangular coordinates mode */
  34148. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34149. /** Equirectangular Fixed coordinates mode */
  34150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34151. /** Equirectangular Fixed Mirrored coordinates mode */
  34152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34153. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34154. static readonly SCALEMODE_FLOOR: number;
  34155. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34156. static readonly SCALEMODE_NEAREST: number;
  34157. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34158. static readonly SCALEMODE_CEILING: number;
  34159. /**
  34160. * Returns the current npm package of the sdk
  34161. */
  34162. static get NpmPackage(): string;
  34163. /**
  34164. * Returns the current version of the framework
  34165. */
  34166. static get Version(): string;
  34167. /** Gets the list of created engines */
  34168. static get Instances(): Engine[];
  34169. /**
  34170. * Gets the latest created engine
  34171. */
  34172. static get LastCreatedEngine(): Nullable<Engine>;
  34173. /**
  34174. * Gets the latest created scene
  34175. */
  34176. static get LastCreatedScene(): Nullable<Scene>;
  34177. /**
  34178. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34179. * @param flag defines which part of the materials must be marked as dirty
  34180. * @param predicate defines a predicate used to filter which materials should be affected
  34181. */
  34182. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34183. /**
  34184. * Method called to create the default loading screen.
  34185. * This can be overriden in your own app.
  34186. * @param canvas The rendering canvas element
  34187. * @returns The loading screen
  34188. */
  34189. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34190. /**
  34191. * Method called to create the default rescale post process on each engine.
  34192. */
  34193. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34194. /**
  34195. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34196. **/
  34197. enableOfflineSupport: boolean;
  34198. /**
  34199. * 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)
  34200. **/
  34201. disableManifestCheck: boolean;
  34202. /**
  34203. * Gets the list of created scenes
  34204. */
  34205. scenes: Scene[];
  34206. /**
  34207. * Event raised when a new scene is created
  34208. */
  34209. onNewSceneAddedObservable: Observable<Scene>;
  34210. /**
  34211. * Gets the list of created postprocesses
  34212. */
  34213. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34214. /**
  34215. * Gets a boolean indicating if the pointer is currently locked
  34216. */
  34217. isPointerLock: boolean;
  34218. /**
  34219. * Observable event triggered each time the rendering canvas is resized
  34220. */
  34221. onResizeObservable: Observable<Engine>;
  34222. /**
  34223. * Observable event triggered each time the canvas loses focus
  34224. */
  34225. onCanvasBlurObservable: Observable<Engine>;
  34226. /**
  34227. * Observable event triggered each time the canvas gains focus
  34228. */
  34229. onCanvasFocusObservable: Observable<Engine>;
  34230. /**
  34231. * Observable event triggered each time the canvas receives pointerout event
  34232. */
  34233. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34234. /**
  34235. * Observable raised when the engine begins a new frame
  34236. */
  34237. onBeginFrameObservable: Observable<Engine>;
  34238. /**
  34239. * If set, will be used to request the next animation frame for the render loop
  34240. */
  34241. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34242. /**
  34243. * Observable raised when the engine ends the current frame
  34244. */
  34245. onEndFrameObservable: Observable<Engine>;
  34246. /**
  34247. * Observable raised when the engine is about to compile a shader
  34248. */
  34249. onBeforeShaderCompilationObservable: Observable<Engine>;
  34250. /**
  34251. * Observable raised when the engine has jsut compiled a shader
  34252. */
  34253. onAfterShaderCompilationObservable: Observable<Engine>;
  34254. /**
  34255. * Gets the audio engine
  34256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34257. * @ignorenaming
  34258. */
  34259. static audioEngine: IAudioEngine;
  34260. /**
  34261. * Default AudioEngine factory responsible of creating the Audio Engine.
  34262. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34263. */
  34264. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34265. /**
  34266. * Default offline support factory responsible of creating a tool used to store data locally.
  34267. * By default, this will create a Database object if the workload has been embedded.
  34268. */
  34269. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34270. private _loadingScreen;
  34271. private _pointerLockRequested;
  34272. private _dummyFramebuffer;
  34273. private _rescalePostProcess;
  34274. private _deterministicLockstep;
  34275. private _lockstepMaxSteps;
  34276. private _timeStep;
  34277. protected get _supportsHardwareTextureRescaling(): boolean;
  34278. private _fps;
  34279. private _deltaTime;
  34280. /** @hidden */
  34281. _drawCalls: PerfCounter;
  34282. /** 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 */
  34283. canvasTabIndex: number;
  34284. /**
  34285. * Turn this value on if you want to pause FPS computation when in background
  34286. */
  34287. disablePerformanceMonitorInBackground: boolean;
  34288. private _performanceMonitor;
  34289. /**
  34290. * Gets the performance monitor attached to this engine
  34291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34292. */
  34293. get performanceMonitor(): PerformanceMonitor;
  34294. private _onFocus;
  34295. private _onBlur;
  34296. private _onCanvasPointerOut;
  34297. private _onCanvasBlur;
  34298. private _onCanvasFocus;
  34299. private _onFullscreenChange;
  34300. private _onPointerLockChange;
  34301. /**
  34302. * Gets the HTML element used to attach event listeners
  34303. * @returns a HTML element
  34304. */
  34305. getInputElement(): Nullable<HTMLElement>;
  34306. /**
  34307. * Creates a new engine
  34308. * @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
  34309. * @param antialias defines enable antialiasing (default: false)
  34310. * @param options defines further options to be sent to the getContext() function
  34311. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34312. */
  34313. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34314. /**
  34315. * Gets current aspect ratio
  34316. * @param viewportOwner defines the camera to use to get the aspect ratio
  34317. * @param useScreen defines if screen size must be used (or the current render target if any)
  34318. * @returns a number defining the aspect ratio
  34319. */
  34320. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34321. /**
  34322. * Gets current screen aspect ratio
  34323. * @returns a number defining the aspect ratio
  34324. */
  34325. getScreenAspectRatio(): number;
  34326. /**
  34327. * Gets the client rect of the HTML canvas attached with the current webGL context
  34328. * @returns a client rectanglee
  34329. */
  34330. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34331. /**
  34332. * Gets the client rect of the HTML element used for events
  34333. * @returns a client rectanglee
  34334. */
  34335. getInputElementClientRect(): Nullable<ClientRect>;
  34336. /**
  34337. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34338. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34339. * @returns true if engine is in deterministic lock step mode
  34340. */
  34341. isDeterministicLockStep(): boolean;
  34342. /**
  34343. * Gets the max steps when engine is running in deterministic lock step
  34344. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34345. * @returns the max steps
  34346. */
  34347. getLockstepMaxSteps(): number;
  34348. /**
  34349. * Returns the time in ms between steps when using deterministic lock step.
  34350. * @returns time step in (ms)
  34351. */
  34352. getTimeStep(): number;
  34353. /**
  34354. * Force the mipmap generation for the given render target texture
  34355. * @param texture defines the render target texture to use
  34356. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34357. */
  34358. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34359. /** States */
  34360. /**
  34361. * Set various states to the webGL context
  34362. * @param culling defines backface culling state
  34363. * @param zOffset defines the value to apply to zOffset (0 by default)
  34364. * @param force defines if states must be applied even if cache is up to date
  34365. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34366. */
  34367. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34368. /**
  34369. * Set the z offset to apply to current rendering
  34370. * @param value defines the offset to apply
  34371. */
  34372. setZOffset(value: number): void;
  34373. /**
  34374. * Gets the current value of the zOffset
  34375. * @returns the current zOffset state
  34376. */
  34377. getZOffset(): number;
  34378. /**
  34379. * Enable or disable depth buffering
  34380. * @param enable defines the state to set
  34381. */
  34382. setDepthBuffer(enable: boolean): void;
  34383. /**
  34384. * Gets a boolean indicating if depth writing is enabled
  34385. * @returns the current depth writing state
  34386. */
  34387. getDepthWrite(): boolean;
  34388. /**
  34389. * Enable or disable depth writing
  34390. * @param enable defines the state to set
  34391. */
  34392. setDepthWrite(enable: boolean): void;
  34393. /**
  34394. * Gets a boolean indicating if stencil buffer is enabled
  34395. * @returns the current stencil buffer state
  34396. */
  34397. getStencilBuffer(): boolean;
  34398. /**
  34399. * Enable or disable the stencil buffer
  34400. * @param enable defines if the stencil buffer must be enabled or disabled
  34401. */
  34402. setStencilBuffer(enable: boolean): void;
  34403. /**
  34404. * Gets the current stencil mask
  34405. * @returns a number defining the new stencil mask to use
  34406. */
  34407. getStencilMask(): number;
  34408. /**
  34409. * Sets the current stencil mask
  34410. * @param mask defines the new stencil mask to use
  34411. */
  34412. setStencilMask(mask: number): void;
  34413. /**
  34414. * Gets the current stencil function
  34415. * @returns a number defining the stencil function to use
  34416. */
  34417. getStencilFunction(): number;
  34418. /**
  34419. * Gets the current stencil reference value
  34420. * @returns a number defining the stencil reference value to use
  34421. */
  34422. getStencilFunctionReference(): number;
  34423. /**
  34424. * Gets the current stencil mask
  34425. * @returns a number defining the stencil mask to use
  34426. */
  34427. getStencilFunctionMask(): number;
  34428. /**
  34429. * Sets the current stencil function
  34430. * @param stencilFunc defines the new stencil function to use
  34431. */
  34432. setStencilFunction(stencilFunc: number): void;
  34433. /**
  34434. * Sets the current stencil reference
  34435. * @param reference defines the new stencil reference to use
  34436. */
  34437. setStencilFunctionReference(reference: number): void;
  34438. /**
  34439. * Sets the current stencil mask
  34440. * @param mask defines the new stencil mask to use
  34441. */
  34442. setStencilFunctionMask(mask: number): void;
  34443. /**
  34444. * Gets the current stencil operation when stencil fails
  34445. * @returns a number defining stencil operation to use when stencil fails
  34446. */
  34447. getStencilOperationFail(): number;
  34448. /**
  34449. * Gets the current stencil operation when depth fails
  34450. * @returns a number defining stencil operation to use when depth fails
  34451. */
  34452. getStencilOperationDepthFail(): number;
  34453. /**
  34454. * Gets the current stencil operation when stencil passes
  34455. * @returns a number defining stencil operation to use when stencil passes
  34456. */
  34457. getStencilOperationPass(): number;
  34458. /**
  34459. * Sets the stencil operation to use when stencil fails
  34460. * @param operation defines the stencil operation to use when stencil fails
  34461. */
  34462. setStencilOperationFail(operation: number): void;
  34463. /**
  34464. * Sets the stencil operation to use when depth fails
  34465. * @param operation defines the stencil operation to use when depth fails
  34466. */
  34467. setStencilOperationDepthFail(operation: number): void;
  34468. /**
  34469. * Sets the stencil operation to use when stencil passes
  34470. * @param operation defines the stencil operation to use when stencil passes
  34471. */
  34472. setStencilOperationPass(operation: number): void;
  34473. /**
  34474. * Sets a boolean indicating if the dithering state is enabled or disabled
  34475. * @param value defines the dithering state
  34476. */
  34477. setDitheringState(value: boolean): void;
  34478. /**
  34479. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34480. * @param value defines the rasterizer state
  34481. */
  34482. setRasterizerState(value: boolean): void;
  34483. /**
  34484. * Gets the current depth function
  34485. * @returns a number defining the depth function
  34486. */
  34487. getDepthFunction(): Nullable<number>;
  34488. /**
  34489. * Sets the current depth function
  34490. * @param depthFunc defines the function to use
  34491. */
  34492. setDepthFunction(depthFunc: number): void;
  34493. /**
  34494. * Sets the current depth function to GREATER
  34495. */
  34496. setDepthFunctionToGreater(): void;
  34497. /**
  34498. * Sets the current depth function to GEQUAL
  34499. */
  34500. setDepthFunctionToGreaterOrEqual(): void;
  34501. /**
  34502. * Sets the current depth function to LESS
  34503. */
  34504. setDepthFunctionToLess(): void;
  34505. /**
  34506. * Sets the current depth function to LEQUAL
  34507. */
  34508. setDepthFunctionToLessOrEqual(): void;
  34509. private _cachedStencilBuffer;
  34510. private _cachedStencilFunction;
  34511. private _cachedStencilMask;
  34512. private _cachedStencilOperationPass;
  34513. private _cachedStencilOperationFail;
  34514. private _cachedStencilOperationDepthFail;
  34515. private _cachedStencilReference;
  34516. /**
  34517. * Caches the the state of the stencil buffer
  34518. */
  34519. cacheStencilState(): void;
  34520. /**
  34521. * Restores the state of the stencil buffer
  34522. */
  34523. restoreStencilState(): void;
  34524. /**
  34525. * Directly set the WebGL Viewport
  34526. * @param x defines the x coordinate of the viewport (in screen space)
  34527. * @param y defines the y coordinate of the viewport (in screen space)
  34528. * @param width defines the width of the viewport (in screen space)
  34529. * @param height defines the height of the viewport (in screen space)
  34530. * @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
  34531. */
  34532. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34533. /**
  34534. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34535. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34536. * @param y defines the y-coordinate of the corner of the clear rectangle
  34537. * @param width defines the width of the clear rectangle
  34538. * @param height defines the height of the clear rectangle
  34539. * @param clearColor defines the clear color
  34540. */
  34541. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34542. /**
  34543. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34544. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34545. * @param y defines the y-coordinate of the corner of the clear rectangle
  34546. * @param width defines the width of the clear rectangle
  34547. * @param height defines the height of the clear rectangle
  34548. */
  34549. enableScissor(x: number, y: number, width: number, height: number): void;
  34550. /**
  34551. * Disable previously set scissor test rectangle
  34552. */
  34553. disableScissor(): void;
  34554. protected _reportDrawCall(): void;
  34555. /**
  34556. * Initializes a webVR display and starts listening to display change events
  34557. * The onVRDisplayChangedObservable will be notified upon these changes
  34558. * @returns The onVRDisplayChangedObservable
  34559. */
  34560. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34561. /** @hidden */
  34562. _prepareVRComponent(): void;
  34563. /** @hidden */
  34564. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34565. /** @hidden */
  34566. _submitVRFrame(): void;
  34567. /**
  34568. * Call this function to leave webVR mode
  34569. * Will do nothing if webVR is not supported or if there is no webVR device
  34570. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34571. */
  34572. disableVR(): void;
  34573. /**
  34574. * Gets a boolean indicating that the system is in VR mode and is presenting
  34575. * @returns true if VR mode is engaged
  34576. */
  34577. isVRPresenting(): boolean;
  34578. /** @hidden */
  34579. _requestVRFrame(): void;
  34580. /** @hidden */
  34581. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34582. /**
  34583. * Gets the source code of the vertex shader associated with a specific webGL program
  34584. * @param program defines the program to use
  34585. * @returns a string containing the source code of the vertex shader associated with the program
  34586. */
  34587. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34588. /**
  34589. * Gets the source code of the fragment shader associated with a specific webGL program
  34590. * @param program defines the program to use
  34591. * @returns a string containing the source code of the fragment shader associated with the program
  34592. */
  34593. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34594. /**
  34595. * Sets a depth stencil texture from a render target to the according uniform.
  34596. * @param channel The texture channel
  34597. * @param uniform The uniform to set
  34598. * @param texture The render target texture containing the depth stencil texture to apply
  34599. */
  34600. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34601. /**
  34602. * Sets a texture to the webGL context from a postprocess
  34603. * @param channel defines the channel to use
  34604. * @param postProcess defines the source postprocess
  34605. */
  34606. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34607. /**
  34608. * Binds the output of the passed in post process to the texture channel specified
  34609. * @param channel The channel the texture should be bound to
  34610. * @param postProcess The post process which's output should be bound
  34611. */
  34612. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34613. /** @hidden */
  34614. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34615. protected _rebuildBuffers(): void;
  34616. /** @hidden */
  34617. _renderFrame(): void;
  34618. _renderLoop(): void;
  34619. /** @hidden */
  34620. _renderViews(): boolean;
  34621. /**
  34622. * Toggle full screen mode
  34623. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34624. */
  34625. switchFullscreen(requestPointerLock: boolean): void;
  34626. /**
  34627. * Enters full screen mode
  34628. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34629. */
  34630. enterFullscreen(requestPointerLock: boolean): void;
  34631. /**
  34632. * Exits full screen mode
  34633. */
  34634. exitFullscreen(): void;
  34635. /**
  34636. * Enters Pointerlock mode
  34637. */
  34638. enterPointerlock(): void;
  34639. /**
  34640. * Exits Pointerlock mode
  34641. */
  34642. exitPointerlock(): void;
  34643. /**
  34644. * Begin a new frame
  34645. */
  34646. beginFrame(): void;
  34647. /**
  34648. * Enf the current frame
  34649. */
  34650. endFrame(): void;
  34651. resize(): void;
  34652. /**
  34653. * Set the compressed texture format to use, based on the formats you have, and the formats
  34654. * supported by the hardware / browser.
  34655. *
  34656. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34657. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34658. * to API arguments needed to compressed textures. This puts the burden on the container
  34659. * generator to house the arcane code for determining these for current & future formats.
  34660. *
  34661. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34662. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34663. *
  34664. * Note: The result of this call is not taken into account when a texture is base64.
  34665. *
  34666. * @param formatsAvailable defines the list of those format families you have created
  34667. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34668. *
  34669. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34670. * @returns The extension selected.
  34671. */
  34672. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34673. /**
  34674. * Set the compressed texture extensions or file names to skip.
  34675. *
  34676. * @param skippedFiles defines the list of those texture files you want to skip
  34677. * Example: [".dds", ".env", "myfile.png"]
  34678. */
  34679. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34680. /**
  34681. * Force a specific size of the canvas
  34682. * @param width defines the new canvas' width
  34683. * @param height defines the new canvas' height
  34684. */
  34685. setSize(width: number, height: number): void;
  34686. /**
  34687. * Updates a dynamic vertex buffer.
  34688. * @param vertexBuffer the vertex buffer to update
  34689. * @param data the data used to update the vertex buffer
  34690. * @param byteOffset the byte offset of the data
  34691. * @param byteLength the byte length of the data
  34692. */
  34693. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34694. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34695. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34696. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34697. _releaseTexture(texture: InternalTexture): void;
  34698. /**
  34699. * @hidden
  34700. * Rescales a texture
  34701. * @param source input texutre
  34702. * @param destination destination texture
  34703. * @param scene scene to use to render the resize
  34704. * @param internalFormat format to use when resizing
  34705. * @param onComplete callback to be called when resize has completed
  34706. */
  34707. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34708. /**
  34709. * Gets the current framerate
  34710. * @returns a number representing the framerate
  34711. */
  34712. getFps(): number;
  34713. /**
  34714. * Gets the time spent between current and previous frame
  34715. * @returns a number representing the delta time in ms
  34716. */
  34717. getDeltaTime(): number;
  34718. private _measureFps;
  34719. /** @hidden */
  34720. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34721. /**
  34722. * Update a dynamic index buffer
  34723. * @param indexBuffer defines the target index buffer
  34724. * @param indices defines the data to update
  34725. * @param offset defines the offset in the target index buffer where update should start
  34726. */
  34727. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34728. /**
  34729. * Updates the sample count of a render target texture
  34730. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34731. * @param texture defines the texture to update
  34732. * @param samples defines the sample count to set
  34733. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34734. */
  34735. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34736. /**
  34737. * Updates a depth texture Comparison Mode and Function.
  34738. * If the comparison Function is equal to 0, the mode will be set to none.
  34739. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34740. * @param texture The texture to set the comparison function for
  34741. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34742. */
  34743. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34744. /**
  34745. * Creates a webGL buffer to use with instanciation
  34746. * @param capacity defines the size of the buffer
  34747. * @returns the webGL buffer
  34748. */
  34749. createInstancesBuffer(capacity: number): DataBuffer;
  34750. /**
  34751. * Delete a webGL buffer used with instanciation
  34752. * @param buffer defines the webGL buffer to delete
  34753. */
  34754. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34755. /** @hidden */
  34756. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34757. dispose(): void;
  34758. private _disableTouchAction;
  34759. /**
  34760. * Display the loading screen
  34761. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34762. */
  34763. displayLoadingUI(): void;
  34764. /**
  34765. * Hide the loading screen
  34766. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34767. */
  34768. hideLoadingUI(): void;
  34769. /**
  34770. * Gets the current loading screen object
  34771. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34772. */
  34773. get loadingScreen(): ILoadingScreen;
  34774. /**
  34775. * Sets the current loading screen object
  34776. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34777. */
  34778. set loadingScreen(loadingScreen: ILoadingScreen);
  34779. /**
  34780. * Sets the current loading screen text
  34781. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34782. */
  34783. set loadingUIText(text: string);
  34784. /**
  34785. * Sets the current loading screen background color
  34786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34787. */
  34788. set loadingUIBackgroundColor(color: string);
  34789. /** Pointerlock and fullscreen */
  34790. /**
  34791. * Ask the browser to promote the current element to pointerlock mode
  34792. * @param element defines the DOM element to promote
  34793. */
  34794. static _RequestPointerlock(element: HTMLElement): void;
  34795. /**
  34796. * Asks the browser to exit pointerlock mode
  34797. */
  34798. static _ExitPointerlock(): void;
  34799. /**
  34800. * Ask the browser to promote the current element to fullscreen rendering mode
  34801. * @param element defines the DOM element to promote
  34802. */
  34803. static _RequestFullscreen(element: HTMLElement): void;
  34804. /**
  34805. * Asks the browser to exit fullscreen mode
  34806. */
  34807. static _ExitFullscreen(): void;
  34808. }
  34809. }
  34810. declare module "babylonjs/Engines/engineStore" {
  34811. import { Nullable } from "babylonjs/types";
  34812. import { Engine } from "babylonjs/Engines/engine";
  34813. import { Scene } from "babylonjs/scene";
  34814. /**
  34815. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34816. * during the life time of the application.
  34817. */
  34818. export class EngineStore {
  34819. /** Gets the list of created engines */
  34820. static Instances: import("babylonjs/Engines/engine").Engine[];
  34821. /** @hidden */
  34822. static _LastCreatedScene: Nullable<Scene>;
  34823. /**
  34824. * Gets the latest created engine
  34825. */
  34826. static get LastCreatedEngine(): Nullable<Engine>;
  34827. /**
  34828. * Gets the latest created scene
  34829. */
  34830. static get LastCreatedScene(): Nullable<Scene>;
  34831. /**
  34832. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34833. * @ignorenaming
  34834. */
  34835. static UseFallbackTexture: boolean;
  34836. /**
  34837. * Texture content used if a texture cannot loaded
  34838. * @ignorenaming
  34839. */
  34840. static FallbackTexture: string;
  34841. }
  34842. }
  34843. declare module "babylonjs/Misc/promise" {
  34844. /**
  34845. * Helper class that provides a small promise polyfill
  34846. */
  34847. export class PromisePolyfill {
  34848. /**
  34849. * Static function used to check if the polyfill is required
  34850. * If this is the case then the function will inject the polyfill to window.Promise
  34851. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34852. */
  34853. static Apply(force?: boolean): void;
  34854. }
  34855. }
  34856. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34857. /**
  34858. * Interface for screenshot methods with describe argument called `size` as object with options
  34859. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34860. */
  34861. export interface IScreenshotSize {
  34862. /**
  34863. * number in pixels for canvas height
  34864. */
  34865. height?: number;
  34866. /**
  34867. * multiplier allowing render at a higher or lower resolution
  34868. * If value is defined then height and width will be ignored and taken from camera
  34869. */
  34870. precision?: number;
  34871. /**
  34872. * number in pixels for canvas width
  34873. */
  34874. width?: number;
  34875. }
  34876. }
  34877. declare module "babylonjs/Misc/tools" {
  34878. import { Nullable, float } from "babylonjs/types";
  34879. import { DomManagement } from "babylonjs/Misc/domManagement";
  34880. import { WebRequest } from "babylonjs/Misc/webRequest";
  34881. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34882. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34883. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34884. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34885. import { Camera } from "babylonjs/Cameras/camera";
  34886. import { Engine } from "babylonjs/Engines/engine";
  34887. interface IColor4Like {
  34888. r: float;
  34889. g: float;
  34890. b: float;
  34891. a: float;
  34892. }
  34893. /**
  34894. * Class containing a set of static utilities functions
  34895. */
  34896. export class Tools {
  34897. /**
  34898. * Gets or sets the base URL to use to load assets
  34899. */
  34900. static get BaseUrl(): string;
  34901. static set BaseUrl(value: string);
  34902. /**
  34903. * Enable/Disable Custom HTTP Request Headers globally.
  34904. * default = false
  34905. * @see CustomRequestHeaders
  34906. */
  34907. static UseCustomRequestHeaders: boolean;
  34908. /**
  34909. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34910. * i.e. when loading files, where the server/service expects an Authorization header
  34911. */
  34912. static CustomRequestHeaders: {
  34913. [key: string]: string;
  34914. };
  34915. /**
  34916. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34917. */
  34918. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34919. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34920. /**
  34921. * Default behaviour for cors in the application.
  34922. * It can be a string if the expected behavior is identical in the entire app.
  34923. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34924. */
  34925. static CorsBehavior: string | ((url: string | string[]) => string);
  34926. /**
  34927. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34928. * @ignorenaming
  34929. */
  34930. static get UseFallbackTexture(): boolean;
  34931. static set UseFallbackTexture(value: boolean);
  34932. /**
  34933. * Use this object to register external classes like custom textures or material
  34934. * to allow the laoders to instantiate them
  34935. */
  34936. static get RegisteredExternalClasses(): {
  34937. [key: string]: Object;
  34938. };
  34939. static set RegisteredExternalClasses(classes: {
  34940. [key: string]: Object;
  34941. });
  34942. /**
  34943. * Texture content used if a texture cannot loaded
  34944. * @ignorenaming
  34945. */
  34946. static get fallbackTexture(): string;
  34947. static set fallbackTexture(value: string);
  34948. /**
  34949. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34950. * @param u defines the coordinate on X axis
  34951. * @param v defines the coordinate on Y axis
  34952. * @param width defines the width of the source data
  34953. * @param height defines the height of the source data
  34954. * @param pixels defines the source byte array
  34955. * @param color defines the output color
  34956. */
  34957. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34958. /**
  34959. * Interpolates between a and b via alpha
  34960. * @param a The lower value (returned when alpha = 0)
  34961. * @param b The upper value (returned when alpha = 1)
  34962. * @param alpha The interpolation-factor
  34963. * @return The mixed value
  34964. */
  34965. static Mix(a: number, b: number, alpha: number): number;
  34966. /**
  34967. * Tries to instantiate a new object from a given class name
  34968. * @param className defines the class name to instantiate
  34969. * @returns the new object or null if the system was not able to do the instantiation
  34970. */
  34971. static Instantiate(className: string): any;
  34972. /**
  34973. * Provides a slice function that will work even on IE
  34974. * @param data defines the array to slice
  34975. * @param start defines the start of the data (optional)
  34976. * @param end defines the end of the data (optional)
  34977. * @returns the new sliced array
  34978. */
  34979. static Slice<T>(data: T, start?: number, end?: number): T;
  34980. /**
  34981. * Polyfill for setImmediate
  34982. * @param action defines the action to execute after the current execution block
  34983. */
  34984. static SetImmediate(action: () => void): void;
  34985. /**
  34986. * Function indicating if a number is an exponent of 2
  34987. * @param value defines the value to test
  34988. * @returns true if the value is an exponent of 2
  34989. */
  34990. static IsExponentOfTwo(value: number): boolean;
  34991. private static _tmpFloatArray;
  34992. /**
  34993. * Returns the nearest 32-bit single precision float representation of a Number
  34994. * @param value A Number. If the parameter is of a different type, it will get converted
  34995. * to a number or to NaN if it cannot be converted
  34996. * @returns number
  34997. */
  34998. static FloatRound(value: number): number;
  34999. /**
  35000. * Extracts the filename from a path
  35001. * @param path defines the path to use
  35002. * @returns the filename
  35003. */
  35004. static GetFilename(path: string): string;
  35005. /**
  35006. * Extracts the "folder" part of a path (everything before the filename).
  35007. * @param uri The URI to extract the info from
  35008. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35009. * @returns The "folder" part of the path
  35010. */
  35011. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35012. /**
  35013. * Extracts text content from a DOM element hierarchy
  35014. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35015. */
  35016. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35017. /**
  35018. * Convert an angle in radians to degrees
  35019. * @param angle defines the angle to convert
  35020. * @returns the angle in degrees
  35021. */
  35022. static ToDegrees(angle: number): number;
  35023. /**
  35024. * Convert an angle in degrees to radians
  35025. * @param angle defines the angle to convert
  35026. * @returns the angle in radians
  35027. */
  35028. static ToRadians(angle: number): number;
  35029. /**
  35030. * Returns an array if obj is not an array
  35031. * @param obj defines the object to evaluate as an array
  35032. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35033. * @returns either obj directly if obj is an array or a new array containing obj
  35034. */
  35035. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35036. /**
  35037. * Gets the pointer prefix to use
  35038. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35039. */
  35040. static GetPointerPrefix(): string;
  35041. /**
  35042. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35043. * @param url define the url we are trying
  35044. * @param element define the dom element where to configure the cors policy
  35045. */
  35046. static SetCorsBehavior(url: string | string[], element: {
  35047. crossOrigin: string | null;
  35048. }): void;
  35049. /**
  35050. * Removes unwanted characters from an url
  35051. * @param url defines the url to clean
  35052. * @returns the cleaned url
  35053. */
  35054. static CleanUrl(url: string): string;
  35055. /**
  35056. * Gets or sets a function used to pre-process url before using them to load assets
  35057. */
  35058. static get PreprocessUrl(): (url: string) => string;
  35059. static set PreprocessUrl(processor: (url: string) => string);
  35060. /**
  35061. * Loads an image as an HTMLImageElement.
  35062. * @param input url string, ArrayBuffer, or Blob to load
  35063. * @param onLoad callback called when the image successfully loads
  35064. * @param onError callback called when the image fails to load
  35065. * @param offlineProvider offline provider for caching
  35066. * @param mimeType optional mime type
  35067. * @returns the HTMLImageElement of the loaded image
  35068. */
  35069. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35070. /**
  35071. * Loads a file from a url
  35072. * @param url url string, ArrayBuffer, or Blob to load
  35073. * @param onSuccess callback called when the file successfully loads
  35074. * @param onProgress callback called while file is loading (if the server supports this mode)
  35075. * @param offlineProvider defines the offline provider for caching
  35076. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35077. * @param onError callback called when the file fails to load
  35078. * @returns a file request object
  35079. */
  35080. 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;
  35081. /**
  35082. * Loads a file from a url
  35083. * @param url the file url to load
  35084. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35085. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35086. */
  35087. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35088. /**
  35089. * Load a script (identified by an url). When the url returns, the
  35090. * content of this file is added into a new script element, attached to the DOM (body element)
  35091. * @param scriptUrl defines the url of the script to laod
  35092. * @param onSuccess defines the callback called when the script is loaded
  35093. * @param onError defines the callback to call if an error occurs
  35094. * @param scriptId defines the id of the script element
  35095. */
  35096. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35097. /**
  35098. * Load an asynchronous script (identified by an url). When the url returns, the
  35099. * content of this file is added into a new script element, attached to the DOM (body element)
  35100. * @param scriptUrl defines the url of the script to laod
  35101. * @param scriptId defines the id of the script element
  35102. * @returns a promise request object
  35103. */
  35104. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35105. /**
  35106. * Loads a file from a blob
  35107. * @param fileToLoad defines the blob to use
  35108. * @param callback defines the callback to call when data is loaded
  35109. * @param progressCallback defines the callback to call during loading process
  35110. * @returns a file request object
  35111. */
  35112. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35113. /**
  35114. * Reads a file from a File object
  35115. * @param file defines the file to load
  35116. * @param onSuccess defines the callback to call when data is loaded
  35117. * @param onProgress defines the callback to call during loading process
  35118. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35119. * @param onError defines the callback to call when an error occurs
  35120. * @returns a file request object
  35121. */
  35122. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35123. /**
  35124. * Creates a data url from a given string content
  35125. * @param content defines the content to convert
  35126. * @returns the new data url link
  35127. */
  35128. static FileAsURL(content: string): string;
  35129. /**
  35130. * Format the given number to a specific decimal format
  35131. * @param value defines the number to format
  35132. * @param decimals defines the number of decimals to use
  35133. * @returns the formatted string
  35134. */
  35135. static Format(value: number, decimals?: number): string;
  35136. /**
  35137. * Tries to copy an object by duplicating every property
  35138. * @param source defines the source object
  35139. * @param destination defines the target object
  35140. * @param doNotCopyList defines a list of properties to avoid
  35141. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35142. */
  35143. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35144. /**
  35145. * Gets a boolean indicating if the given object has no own property
  35146. * @param obj defines the object to test
  35147. * @returns true if object has no own property
  35148. */
  35149. static IsEmpty(obj: any): boolean;
  35150. /**
  35151. * Function used to register events at window level
  35152. * @param windowElement defines the Window object to use
  35153. * @param events defines the events to register
  35154. */
  35155. static RegisterTopRootEvents(windowElement: Window, events: {
  35156. name: string;
  35157. handler: Nullable<(e: FocusEvent) => any>;
  35158. }[]): void;
  35159. /**
  35160. * Function used to unregister events from window level
  35161. * @param windowElement defines the Window object to use
  35162. * @param events defines the events to unregister
  35163. */
  35164. static UnregisterTopRootEvents(windowElement: Window, events: {
  35165. name: string;
  35166. handler: Nullable<(e: FocusEvent) => any>;
  35167. }[]): void;
  35168. /**
  35169. * @ignore
  35170. */
  35171. static _ScreenshotCanvas: HTMLCanvasElement;
  35172. /**
  35173. * Dumps the current bound framebuffer
  35174. * @param width defines the rendering width
  35175. * @param height defines the rendering height
  35176. * @param engine defines the hosting engine
  35177. * @param successCallback defines the callback triggered once the data are available
  35178. * @param mimeType defines the mime type of the result
  35179. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35180. */
  35181. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35182. /**
  35183. * Converts the canvas data to blob.
  35184. * This acts as a polyfill for browsers not supporting the to blob function.
  35185. * @param canvas Defines the canvas to extract the data from
  35186. * @param successCallback Defines the callback triggered once the data are available
  35187. * @param mimeType Defines the mime type of the result
  35188. */
  35189. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35190. /**
  35191. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35192. * @param successCallback defines the callback triggered once the data are available
  35193. * @param mimeType defines the mime type of the result
  35194. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35195. */
  35196. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35197. /**
  35198. * Downloads a blob in the browser
  35199. * @param blob defines the blob to download
  35200. * @param fileName defines the name of the downloaded file
  35201. */
  35202. static Download(blob: Blob, fileName: string): void;
  35203. /**
  35204. * Captures a screenshot of the current rendering
  35205. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35206. * @param engine defines the rendering engine
  35207. * @param camera defines the source camera
  35208. * @param size This parameter can be set to a single number or to an object with the
  35209. * following (optional) properties: precision, width, height. If a single number is passed,
  35210. * it will be used for both width and height. If an object is passed, the screenshot size
  35211. * will be derived from the parameters. The precision property is a multiplier allowing
  35212. * rendering at a higher or lower resolution
  35213. * @param successCallback defines the callback receives a single parameter which contains the
  35214. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35215. * src parameter of an <img> to display it
  35216. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35217. * Check your browser for supported MIME types
  35218. */
  35219. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35220. /**
  35221. * Captures a screenshot of the current rendering
  35222. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35223. * @param engine defines the rendering engine
  35224. * @param camera defines the source camera
  35225. * @param size This parameter can be set to a single number or to an object with the
  35226. * following (optional) properties: precision, width, height. If a single number is passed,
  35227. * it will be used for both width and height. If an object is passed, the screenshot size
  35228. * will be derived from the parameters. The precision property is a multiplier allowing
  35229. * rendering at a higher or lower resolution
  35230. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35231. * Check your browser for supported MIME types
  35232. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35233. * to the src parameter of an <img> to display it
  35234. */
  35235. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35236. /**
  35237. * Generates an image screenshot from the specified camera.
  35238. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35239. * @param engine The engine to use for rendering
  35240. * @param camera The camera to use for rendering
  35241. * @param size This parameter can be set to a single number or to an object with the
  35242. * following (optional) properties: precision, width, height. If a single number is passed,
  35243. * it will be used for both width and height. If an object is passed, the screenshot size
  35244. * will be derived from the parameters. The precision property is a multiplier allowing
  35245. * rendering at a higher or lower resolution
  35246. * @param successCallback The callback receives a single parameter which contains the
  35247. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35248. * src parameter of an <img> to display it
  35249. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35250. * Check your browser for supported MIME types
  35251. * @param samples Texture samples (default: 1)
  35252. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35253. * @param fileName A name for for the downloaded file.
  35254. */
  35255. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35256. /**
  35257. * Generates an image screenshot from the specified camera.
  35258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35259. * @param engine The engine to use for rendering
  35260. * @param camera The camera to use for rendering
  35261. * @param size This parameter can be set to a single number or to an object with the
  35262. * following (optional) properties: precision, width, height. If a single number is passed,
  35263. * it will be used for both width and height. If an object is passed, the screenshot size
  35264. * will be derived from the parameters. The precision property is a multiplier allowing
  35265. * rendering at a higher or lower resolution
  35266. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35267. * Check your browser for supported MIME types
  35268. * @param samples Texture samples (default: 1)
  35269. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35270. * @param fileName A name for for the downloaded file.
  35271. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35272. * to the src parameter of an <img> to display it
  35273. */
  35274. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35275. /**
  35276. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35277. * Be aware Math.random() could cause collisions, but:
  35278. * "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"
  35279. * @returns a pseudo random id
  35280. */
  35281. static RandomId(): string;
  35282. /**
  35283. * Test if the given uri is a base64 string
  35284. * @param uri The uri to test
  35285. * @return True if the uri is a base64 string or false otherwise
  35286. */
  35287. static IsBase64(uri: string): boolean;
  35288. /**
  35289. * Decode the given base64 uri.
  35290. * @param uri The uri to decode
  35291. * @return The decoded base64 data.
  35292. */
  35293. static DecodeBase64(uri: string): ArrayBuffer;
  35294. /**
  35295. * Gets the absolute url.
  35296. * @param url the input url
  35297. * @return the absolute url
  35298. */
  35299. static GetAbsoluteUrl(url: string): string;
  35300. /**
  35301. * No log
  35302. */
  35303. static readonly NoneLogLevel: number;
  35304. /**
  35305. * Only message logs
  35306. */
  35307. static readonly MessageLogLevel: number;
  35308. /**
  35309. * Only warning logs
  35310. */
  35311. static readonly WarningLogLevel: number;
  35312. /**
  35313. * Only error logs
  35314. */
  35315. static readonly ErrorLogLevel: number;
  35316. /**
  35317. * All logs
  35318. */
  35319. static readonly AllLogLevel: number;
  35320. /**
  35321. * Gets a value indicating the number of loading errors
  35322. * @ignorenaming
  35323. */
  35324. static get errorsCount(): number;
  35325. /**
  35326. * Callback called when a new log is added
  35327. */
  35328. static OnNewCacheEntry: (entry: string) => void;
  35329. /**
  35330. * Log a message to the console
  35331. * @param message defines the message to log
  35332. */
  35333. static Log(message: string): void;
  35334. /**
  35335. * Write a warning message to the console
  35336. * @param message defines the message to log
  35337. */
  35338. static Warn(message: string): void;
  35339. /**
  35340. * Write an error message to the console
  35341. * @param message defines the message to log
  35342. */
  35343. static Error(message: string): void;
  35344. /**
  35345. * Gets current log cache (list of logs)
  35346. */
  35347. static get LogCache(): string;
  35348. /**
  35349. * Clears the log cache
  35350. */
  35351. static ClearLogCache(): void;
  35352. /**
  35353. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35354. */
  35355. static set LogLevels(level: number);
  35356. /**
  35357. * Checks if the window object exists
  35358. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35359. */
  35360. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35361. /**
  35362. * No performance log
  35363. */
  35364. static readonly PerformanceNoneLogLevel: number;
  35365. /**
  35366. * Use user marks to log performance
  35367. */
  35368. static readonly PerformanceUserMarkLogLevel: number;
  35369. /**
  35370. * Log performance to the console
  35371. */
  35372. static readonly PerformanceConsoleLogLevel: number;
  35373. private static _performance;
  35374. /**
  35375. * Sets the current performance log level
  35376. */
  35377. static set PerformanceLogLevel(level: number);
  35378. private static _StartPerformanceCounterDisabled;
  35379. private static _EndPerformanceCounterDisabled;
  35380. private static _StartUserMark;
  35381. private static _EndUserMark;
  35382. private static _StartPerformanceConsole;
  35383. private static _EndPerformanceConsole;
  35384. /**
  35385. * Starts a performance counter
  35386. */
  35387. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35388. /**
  35389. * Ends a specific performance coutner
  35390. */
  35391. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35392. /**
  35393. * Gets either window.performance.now() if supported or Date.now() else
  35394. */
  35395. static get Now(): number;
  35396. /**
  35397. * This method will return the name of the class used to create the instance of the given object.
  35398. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35399. * @param object the object to get the class name from
  35400. * @param isType defines if the object is actually a type
  35401. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35402. */
  35403. static GetClassName(object: any, isType?: boolean): string;
  35404. /**
  35405. * Gets the first element of an array satisfying a given predicate
  35406. * @param array defines the array to browse
  35407. * @param predicate defines the predicate to use
  35408. * @returns null if not found or the element
  35409. */
  35410. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35411. /**
  35412. * This method will return the name of the full name of the class, including its owning module (if any).
  35413. * 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).
  35414. * @param object the object to get the class name from
  35415. * @param isType defines if the object is actually a type
  35416. * @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.
  35417. * @ignorenaming
  35418. */
  35419. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35420. /**
  35421. * Returns a promise that resolves after the given amount of time.
  35422. * @param delay Number of milliseconds to delay
  35423. * @returns Promise that resolves after the given amount of time
  35424. */
  35425. static DelayAsync(delay: number): Promise<void>;
  35426. /**
  35427. * Utility function to detect if the current user agent is Safari
  35428. * @returns whether or not the current user agent is safari
  35429. */
  35430. static IsSafari(): boolean;
  35431. }
  35432. /**
  35433. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35434. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35435. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35436. * @param name The name of the class, case should be preserved
  35437. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35438. */
  35439. export function className(name: string, module?: string): (target: Object) => void;
  35440. /**
  35441. * An implementation of a loop for asynchronous functions.
  35442. */
  35443. export class AsyncLoop {
  35444. /**
  35445. * Defines the number of iterations for the loop
  35446. */
  35447. iterations: number;
  35448. /**
  35449. * Defines the current index of the loop.
  35450. */
  35451. index: number;
  35452. private _done;
  35453. private _fn;
  35454. private _successCallback;
  35455. /**
  35456. * Constructor.
  35457. * @param iterations the number of iterations.
  35458. * @param func the function to run each iteration
  35459. * @param successCallback the callback that will be called upon succesful execution
  35460. * @param offset starting offset.
  35461. */
  35462. constructor(
  35463. /**
  35464. * Defines the number of iterations for the loop
  35465. */
  35466. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35467. /**
  35468. * Execute the next iteration. Must be called after the last iteration was finished.
  35469. */
  35470. executeNext(): void;
  35471. /**
  35472. * Break the loop and run the success callback.
  35473. */
  35474. breakLoop(): void;
  35475. /**
  35476. * Create and run an async loop.
  35477. * @param iterations the number of iterations.
  35478. * @param fn the function to run each iteration
  35479. * @param successCallback the callback that will be called upon succesful execution
  35480. * @param offset starting offset.
  35481. * @returns the created async loop object
  35482. */
  35483. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35484. /**
  35485. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35486. * @param iterations total number of iterations
  35487. * @param syncedIterations number of synchronous iterations in each async iteration.
  35488. * @param fn the function to call each iteration.
  35489. * @param callback a success call back that will be called when iterating stops.
  35490. * @param breakFunction a break condition (optional)
  35491. * @param timeout timeout settings for the setTimeout function. default - 0.
  35492. * @returns the created async loop object
  35493. */
  35494. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35495. }
  35496. }
  35497. declare module "babylonjs/Misc/stringDictionary" {
  35498. import { Nullable } from "babylonjs/types";
  35499. /**
  35500. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35501. * The underlying implementation relies on an associative array to ensure the best performances.
  35502. * The value can be anything including 'null' but except 'undefined'
  35503. */
  35504. export class StringDictionary<T> {
  35505. /**
  35506. * This will clear this dictionary and copy the content from the 'source' one.
  35507. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35508. * @param source the dictionary to take the content from and copy to this dictionary
  35509. */
  35510. copyFrom(source: StringDictionary<T>): void;
  35511. /**
  35512. * Get a value based from its key
  35513. * @param key the given key to get the matching value from
  35514. * @return the value if found, otherwise undefined is returned
  35515. */
  35516. get(key: string): T | undefined;
  35517. /**
  35518. * Get a value from its key or add it if it doesn't exist.
  35519. * This method will ensure you that a given key/data will be present in the dictionary.
  35520. * @param key the given key to get the matching value from
  35521. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35522. * The factory will only be invoked if there's no data for the given key.
  35523. * @return the value corresponding to the key.
  35524. */
  35525. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35526. /**
  35527. * Get a value from its key if present in the dictionary otherwise add it
  35528. * @param key the key to get the value from
  35529. * @param val if there's no such key/value pair in the dictionary add it with this value
  35530. * @return the value corresponding to the key
  35531. */
  35532. getOrAdd(key: string, val: T): T;
  35533. /**
  35534. * Check if there's a given key in the dictionary
  35535. * @param key the key to check for
  35536. * @return true if the key is present, false otherwise
  35537. */
  35538. contains(key: string): boolean;
  35539. /**
  35540. * Add a new key and its corresponding value
  35541. * @param key the key to add
  35542. * @param value the value corresponding to the key
  35543. * @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
  35544. */
  35545. add(key: string, value: T): boolean;
  35546. /**
  35547. * Update a specific value associated to a key
  35548. * @param key defines the key to use
  35549. * @param value defines the value to store
  35550. * @returns true if the value was updated (or false if the key was not found)
  35551. */
  35552. set(key: string, value: T): boolean;
  35553. /**
  35554. * Get the element of the given key and remove it from the dictionary
  35555. * @param key defines the key to search
  35556. * @returns the value associated with the key or null if not found
  35557. */
  35558. getAndRemove(key: string): Nullable<T>;
  35559. /**
  35560. * Remove a key/value from the dictionary.
  35561. * @param key the key to remove
  35562. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35563. */
  35564. remove(key: string): boolean;
  35565. /**
  35566. * Clear the whole content of the dictionary
  35567. */
  35568. clear(): void;
  35569. /**
  35570. * Gets the current count
  35571. */
  35572. get count(): number;
  35573. /**
  35574. * Execute a callback on each key/val of the dictionary.
  35575. * Note that you can remove any element in this dictionary in the callback implementation
  35576. * @param callback the callback to execute on a given key/value pair
  35577. */
  35578. forEach(callback: (key: string, val: T) => void): void;
  35579. /**
  35580. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35581. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35582. * Note that you can remove any element in this dictionary in the callback implementation
  35583. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35584. * @returns the first item
  35585. */
  35586. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35587. private _count;
  35588. private _data;
  35589. }
  35590. }
  35591. declare module "babylonjs/Collisions/collisionCoordinator" {
  35592. import { Nullable } from "babylonjs/types";
  35593. import { Scene } from "babylonjs/scene";
  35594. import { Vector3 } from "babylonjs/Maths/math.vector";
  35595. import { Collider } from "babylonjs/Collisions/collider";
  35596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35597. /** @hidden */
  35598. export interface ICollisionCoordinator {
  35599. createCollider(): Collider;
  35600. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35601. init(scene: Scene): void;
  35602. }
  35603. /** @hidden */
  35604. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35605. private _scene;
  35606. private _scaledPosition;
  35607. private _scaledVelocity;
  35608. private _finalPosition;
  35609. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35610. createCollider(): Collider;
  35611. init(scene: Scene): void;
  35612. private _collideWithWorld;
  35613. }
  35614. }
  35615. declare module "babylonjs/Inputs/scene.inputManager" {
  35616. import { Nullable } from "babylonjs/types";
  35617. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35618. import { Vector2 } from "babylonjs/Maths/math.vector";
  35619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35620. import { Scene } from "babylonjs/scene";
  35621. /**
  35622. * Class used to manage all inputs for the scene.
  35623. */
  35624. export class InputManager {
  35625. /** The distance in pixel that you have to move to prevent some events */
  35626. static DragMovementThreshold: number;
  35627. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35628. static LongPressDelay: number;
  35629. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35630. static DoubleClickDelay: number;
  35631. /** If you need to check double click without raising a single click at first click, enable this flag */
  35632. static ExclusiveDoubleClickMode: boolean;
  35633. private _wheelEventName;
  35634. private _onPointerMove;
  35635. private _onPointerDown;
  35636. private _onPointerUp;
  35637. private _initClickEvent;
  35638. private _initActionManager;
  35639. private _delayedSimpleClick;
  35640. private _delayedSimpleClickTimeout;
  35641. private _previousDelayedSimpleClickTimeout;
  35642. private _meshPickProceed;
  35643. private _previousButtonPressed;
  35644. private _currentPickResult;
  35645. private _previousPickResult;
  35646. private _totalPointersPressed;
  35647. private _doubleClickOccured;
  35648. private _pointerOverMesh;
  35649. private _pickedDownMesh;
  35650. private _pickedUpMesh;
  35651. private _pointerX;
  35652. private _pointerY;
  35653. private _unTranslatedPointerX;
  35654. private _unTranslatedPointerY;
  35655. private _startingPointerPosition;
  35656. private _previousStartingPointerPosition;
  35657. private _startingPointerTime;
  35658. private _previousStartingPointerTime;
  35659. private _pointerCaptures;
  35660. private _onKeyDown;
  35661. private _onKeyUp;
  35662. private _onCanvasFocusObserver;
  35663. private _onCanvasBlurObserver;
  35664. private _scene;
  35665. /**
  35666. * Creates a new InputManager
  35667. * @param scene defines the hosting scene
  35668. */
  35669. constructor(scene: Scene);
  35670. /**
  35671. * Gets the mesh that is currently under the pointer
  35672. */
  35673. get meshUnderPointer(): Nullable<AbstractMesh>;
  35674. /**
  35675. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35676. */
  35677. get unTranslatedPointer(): Vector2;
  35678. /**
  35679. * Gets or sets the current on-screen X position of the pointer
  35680. */
  35681. get pointerX(): number;
  35682. set pointerX(value: number);
  35683. /**
  35684. * Gets or sets the current on-screen Y position of the pointer
  35685. */
  35686. get pointerY(): number;
  35687. set pointerY(value: number);
  35688. private _updatePointerPosition;
  35689. private _processPointerMove;
  35690. private _setRayOnPointerInfo;
  35691. private _checkPrePointerObservable;
  35692. /**
  35693. * Use this method to simulate a pointer move on a mesh
  35694. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35695. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35696. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35697. */
  35698. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35699. /**
  35700. * Use this method to simulate a pointer down on a mesh
  35701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35704. */
  35705. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35706. private _processPointerDown;
  35707. /** @hidden */
  35708. _isPointerSwiping(): boolean;
  35709. /**
  35710. * Use this method to simulate a pointer up on a mesh
  35711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35714. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35715. */
  35716. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35717. private _processPointerUp;
  35718. /**
  35719. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35720. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35721. * @returns true if the pointer was captured
  35722. */
  35723. isPointerCaptured(pointerId?: number): boolean;
  35724. /**
  35725. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35726. * @param attachUp defines if you want to attach events to pointerup
  35727. * @param attachDown defines if you want to attach events to pointerdown
  35728. * @param attachMove defines if you want to attach events to pointermove
  35729. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35730. */
  35731. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35732. /**
  35733. * Detaches all event handlers
  35734. */
  35735. detachControl(): void;
  35736. /**
  35737. * Force the value of meshUnderPointer
  35738. * @param mesh defines the mesh to use
  35739. */
  35740. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35741. /**
  35742. * Gets the mesh under the pointer
  35743. * @returns a Mesh or null if no mesh is under the pointer
  35744. */
  35745. getPointerOverMesh(): Nullable<AbstractMesh>;
  35746. }
  35747. }
  35748. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35749. /**
  35750. * Helper class used to generate session unique ID
  35751. */
  35752. export class UniqueIdGenerator {
  35753. private static _UniqueIdCounter;
  35754. /**
  35755. * Gets an unique (relatively to the current scene) Id
  35756. */
  35757. static get UniqueId(): number;
  35758. }
  35759. }
  35760. declare module "babylonjs/Animations/animationGroup" {
  35761. import { Animatable } from "babylonjs/Animations/animatable";
  35762. import { Animation } from "babylonjs/Animations/animation";
  35763. import { Scene, IDisposable } from "babylonjs/scene";
  35764. import { Observable } from "babylonjs/Misc/observable";
  35765. import { Nullable } from "babylonjs/types";
  35766. import "babylonjs/Animations/animatable";
  35767. /**
  35768. * This class defines the direct association between an animation and a target
  35769. */
  35770. export class TargetedAnimation {
  35771. /**
  35772. * Animation to perform
  35773. */
  35774. animation: Animation;
  35775. /**
  35776. * Target to animate
  35777. */
  35778. target: any;
  35779. /**
  35780. * Serialize the object
  35781. * @returns the JSON object representing the current entity
  35782. */
  35783. serialize(): any;
  35784. }
  35785. /**
  35786. * Use this class to create coordinated animations on multiple targets
  35787. */
  35788. export class AnimationGroup implements IDisposable {
  35789. /** The name of the animation group */
  35790. name: string;
  35791. private _scene;
  35792. private _targetedAnimations;
  35793. private _animatables;
  35794. private _from;
  35795. private _to;
  35796. private _isStarted;
  35797. private _isPaused;
  35798. private _speedRatio;
  35799. private _loopAnimation;
  35800. /**
  35801. * Gets or sets the unique id of the node
  35802. */
  35803. uniqueId: number;
  35804. /**
  35805. * This observable will notify when one animation have ended
  35806. */
  35807. onAnimationEndObservable: Observable<TargetedAnimation>;
  35808. /**
  35809. * Observer raised when one animation loops
  35810. */
  35811. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35812. /**
  35813. * Observer raised when all animations have looped
  35814. */
  35815. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35816. /**
  35817. * This observable will notify when all animations have ended.
  35818. */
  35819. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35820. /**
  35821. * This observable will notify when all animations have paused.
  35822. */
  35823. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35824. /**
  35825. * This observable will notify when all animations are playing.
  35826. */
  35827. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35828. /**
  35829. * Gets the first frame
  35830. */
  35831. get from(): number;
  35832. /**
  35833. * Gets the last frame
  35834. */
  35835. get to(): number;
  35836. /**
  35837. * Define if the animations are started
  35838. */
  35839. get isStarted(): boolean;
  35840. /**
  35841. * Gets a value indicating that the current group is playing
  35842. */
  35843. get isPlaying(): boolean;
  35844. /**
  35845. * Gets or sets the speed ratio to use for all animations
  35846. */
  35847. get speedRatio(): number;
  35848. /**
  35849. * Gets or sets the speed ratio to use for all animations
  35850. */
  35851. set speedRatio(value: number);
  35852. /**
  35853. * Gets or sets if all animations should loop or not
  35854. */
  35855. get loopAnimation(): boolean;
  35856. set loopAnimation(value: boolean);
  35857. /**
  35858. * Gets the targeted animations for this animation group
  35859. */
  35860. get targetedAnimations(): Array<TargetedAnimation>;
  35861. /**
  35862. * returning the list of animatables controlled by this animation group.
  35863. */
  35864. get animatables(): Array<Animatable>;
  35865. /**
  35866. * Instantiates a new Animation Group.
  35867. * This helps managing several animations at once.
  35868. * @see http://doc.babylonjs.com/how_to/group
  35869. * @param name Defines the name of the group
  35870. * @param scene Defines the scene the group belongs to
  35871. */
  35872. constructor(
  35873. /** The name of the animation group */
  35874. name: string, scene?: Nullable<Scene>);
  35875. /**
  35876. * Add an animation (with its target) in the group
  35877. * @param animation defines the animation we want to add
  35878. * @param target defines the target of the animation
  35879. * @returns the TargetedAnimation object
  35880. */
  35881. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35882. /**
  35883. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35884. * It can add constant keys at begin or end
  35885. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35886. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35887. * @returns the animation group
  35888. */
  35889. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35890. private _animationLoopCount;
  35891. private _animationLoopFlags;
  35892. private _processLoop;
  35893. /**
  35894. * Start all animations on given targets
  35895. * @param loop defines if animations must loop
  35896. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35897. * @param from defines the from key (optional)
  35898. * @param to defines the to key (optional)
  35899. * @returns the current animation group
  35900. */
  35901. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35902. /**
  35903. * Pause all animations
  35904. * @returns the animation group
  35905. */
  35906. pause(): AnimationGroup;
  35907. /**
  35908. * Play all animations to initial state
  35909. * This function will start() the animations if they were not started or will restart() them if they were paused
  35910. * @param loop defines if animations must loop
  35911. * @returns the animation group
  35912. */
  35913. play(loop?: boolean): AnimationGroup;
  35914. /**
  35915. * Reset all animations to initial state
  35916. * @returns the animation group
  35917. */
  35918. reset(): AnimationGroup;
  35919. /**
  35920. * Restart animations from key 0
  35921. * @returns the animation group
  35922. */
  35923. restart(): AnimationGroup;
  35924. /**
  35925. * Stop all animations
  35926. * @returns the animation group
  35927. */
  35928. stop(): AnimationGroup;
  35929. /**
  35930. * Set animation weight for all animatables
  35931. * @param weight defines the weight to use
  35932. * @return the animationGroup
  35933. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35934. */
  35935. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35936. /**
  35937. * Synchronize and normalize all animatables with a source animatable
  35938. * @param root defines the root animatable to synchronize with
  35939. * @return the animationGroup
  35940. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35941. */
  35942. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35943. /**
  35944. * Goes to a specific frame in this animation group
  35945. * @param frame the frame number to go to
  35946. * @return the animationGroup
  35947. */
  35948. goToFrame(frame: number): AnimationGroup;
  35949. /**
  35950. * Dispose all associated resources
  35951. */
  35952. dispose(): void;
  35953. private _checkAnimationGroupEnded;
  35954. /**
  35955. * Clone the current animation group and returns a copy
  35956. * @param newName defines the name of the new group
  35957. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35958. * @returns the new aniamtion group
  35959. */
  35960. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35961. /**
  35962. * Serializes the animationGroup to an object
  35963. * @returns Serialized object
  35964. */
  35965. serialize(): any;
  35966. /**
  35967. * Returns a new AnimationGroup object parsed from the source provided.
  35968. * @param parsedAnimationGroup defines the source
  35969. * @param scene defines the scene that will receive the animationGroup
  35970. * @returns a new AnimationGroup
  35971. */
  35972. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35973. /**
  35974. * Returns the string "AnimationGroup"
  35975. * @returns "AnimationGroup"
  35976. */
  35977. getClassName(): string;
  35978. /**
  35979. * Creates a detailled string about the object
  35980. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35981. * @returns a string representing the object
  35982. */
  35983. toString(fullDetails?: boolean): string;
  35984. }
  35985. }
  35986. declare module "babylonjs/scene" {
  35987. import { Nullable } from "babylonjs/types";
  35988. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35989. import { Observable } from "babylonjs/Misc/observable";
  35990. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35991. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35992. import { Geometry } from "babylonjs/Meshes/geometry";
  35993. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35994. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35996. import { Mesh } from "babylonjs/Meshes/mesh";
  35997. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35998. import { Bone } from "babylonjs/Bones/bone";
  35999. import { Skeleton } from "babylonjs/Bones/skeleton";
  36000. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36001. import { Camera } from "babylonjs/Cameras/camera";
  36002. import { AbstractScene } from "babylonjs/abstractScene";
  36003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36005. import { Material } from "babylonjs/Materials/material";
  36006. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36007. import { Effect } from "babylonjs/Materials/effect";
  36008. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36009. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36010. import { Light } from "babylonjs/Lights/light";
  36011. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36012. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36013. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36014. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36015. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36016. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36017. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36018. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36019. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36020. import { Engine } from "babylonjs/Engines/engine";
  36021. import { Node } from "babylonjs/node";
  36022. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36023. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36024. import { WebRequest } from "babylonjs/Misc/webRequest";
  36025. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36026. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36027. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36028. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36029. import { Plane } from "babylonjs/Maths/math.plane";
  36030. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36031. import { Ray } from "babylonjs/Culling/ray";
  36032. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36033. import { Animation } from "babylonjs/Animations/animation";
  36034. import { Animatable } from "babylonjs/Animations/animatable";
  36035. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36036. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36037. import { Collider } from "babylonjs/Collisions/collider";
  36038. /**
  36039. * Define an interface for all classes that will hold resources
  36040. */
  36041. export interface IDisposable {
  36042. /**
  36043. * Releases all held resources
  36044. */
  36045. dispose(): void;
  36046. }
  36047. /** Interface defining initialization parameters for Scene class */
  36048. export interface SceneOptions {
  36049. /**
  36050. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36051. * It will improve performance when the number of geometries becomes important.
  36052. */
  36053. useGeometryUniqueIdsMap?: boolean;
  36054. /**
  36055. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36056. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36057. */
  36058. useMaterialMeshMap?: boolean;
  36059. /**
  36060. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36061. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36062. */
  36063. useClonedMeshMap?: boolean;
  36064. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36065. virtual?: boolean;
  36066. }
  36067. /**
  36068. * Represents a scene to be rendered by the engine.
  36069. * @see http://doc.babylonjs.com/features/scene
  36070. */
  36071. export class Scene extends AbstractScene implements IAnimatable {
  36072. /** The fog is deactivated */
  36073. static readonly FOGMODE_NONE: number;
  36074. /** The fog density is following an exponential function */
  36075. static readonly FOGMODE_EXP: number;
  36076. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36077. static readonly FOGMODE_EXP2: number;
  36078. /** The fog density is following a linear function. */
  36079. static readonly FOGMODE_LINEAR: number;
  36080. /**
  36081. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36082. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36083. */
  36084. static MinDeltaTime: number;
  36085. /**
  36086. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36088. */
  36089. static MaxDeltaTime: number;
  36090. /**
  36091. * Factory used to create the default material.
  36092. * @param name The name of the material to create
  36093. * @param scene The scene to create the material for
  36094. * @returns The default material
  36095. */
  36096. static DefaultMaterialFactory(scene: Scene): Material;
  36097. /**
  36098. * Factory used to create the a collision coordinator.
  36099. * @returns The collision coordinator
  36100. */
  36101. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36102. /** @hidden */
  36103. _inputManager: InputManager;
  36104. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36105. cameraToUseForPointers: Nullable<Camera>;
  36106. /** @hidden */
  36107. readonly _isScene: boolean;
  36108. /**
  36109. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36110. */
  36111. autoClear: boolean;
  36112. /**
  36113. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36114. */
  36115. autoClearDepthAndStencil: boolean;
  36116. /**
  36117. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36118. */
  36119. clearColor: Color4;
  36120. /**
  36121. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36122. */
  36123. ambientColor: Color3;
  36124. /**
  36125. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36126. * It should only be one of the following (if not the default embedded one):
  36127. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36128. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36129. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36130. * The material properties need to be setup according to the type of texture in use.
  36131. */
  36132. environmentBRDFTexture: BaseTexture;
  36133. /** @hidden */
  36134. protected _environmentTexture: Nullable<BaseTexture>;
  36135. /**
  36136. * Texture used in all pbr material as the reflection texture.
  36137. * As in the majority of the scene they are the same (exception for multi room and so on),
  36138. * this is easier to reference from here than from all the materials.
  36139. */
  36140. get environmentTexture(): Nullable<BaseTexture>;
  36141. /**
  36142. * Texture used in all pbr material as the reflection texture.
  36143. * As in the majority of the scene they are the same (exception for multi room and so on),
  36144. * this is easier to set here than in all the materials.
  36145. */
  36146. set environmentTexture(value: Nullable<BaseTexture>);
  36147. /** @hidden */
  36148. protected _environmentIntensity: number;
  36149. /**
  36150. * Intensity of the environment in all pbr material.
  36151. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36152. * As in the majority of the scene they are the same (exception for multi room and so on),
  36153. * this is easier to reference from here than from all the materials.
  36154. */
  36155. get environmentIntensity(): number;
  36156. /**
  36157. * Intensity of the environment in all pbr material.
  36158. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36159. * As in the majority of the scene they are the same (exception for multi room and so on),
  36160. * this is easier to set here than in all the materials.
  36161. */
  36162. set environmentIntensity(value: number);
  36163. /** @hidden */
  36164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36165. /**
  36166. * Default image processing configuration used either in the rendering
  36167. * Forward main pass or through the imageProcessingPostProcess if present.
  36168. * As in the majority of the scene they are the same (exception for multi camera),
  36169. * this is easier to reference from here than from all the materials and post process.
  36170. *
  36171. * No setter as we it is a shared configuration, you can set the values instead.
  36172. */
  36173. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36174. private _forceWireframe;
  36175. /**
  36176. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36177. */
  36178. set forceWireframe(value: boolean);
  36179. get forceWireframe(): boolean;
  36180. private _skipFrustumClipping;
  36181. /**
  36182. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36183. */
  36184. set skipFrustumClipping(value: boolean);
  36185. get skipFrustumClipping(): boolean;
  36186. private _forcePointsCloud;
  36187. /**
  36188. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36189. */
  36190. set forcePointsCloud(value: boolean);
  36191. get forcePointsCloud(): boolean;
  36192. /**
  36193. * Gets or sets the active clipplane 1
  36194. */
  36195. clipPlane: Nullable<Plane>;
  36196. /**
  36197. * Gets or sets the active clipplane 2
  36198. */
  36199. clipPlane2: Nullable<Plane>;
  36200. /**
  36201. * Gets or sets the active clipplane 3
  36202. */
  36203. clipPlane3: Nullable<Plane>;
  36204. /**
  36205. * Gets or sets the active clipplane 4
  36206. */
  36207. clipPlane4: Nullable<Plane>;
  36208. /**
  36209. * Gets or sets the active clipplane 5
  36210. */
  36211. clipPlane5: Nullable<Plane>;
  36212. /**
  36213. * Gets or sets the active clipplane 6
  36214. */
  36215. clipPlane6: Nullable<Plane>;
  36216. /**
  36217. * Gets or sets a boolean indicating if animations are enabled
  36218. */
  36219. animationsEnabled: boolean;
  36220. private _animationPropertiesOverride;
  36221. /**
  36222. * Gets or sets the animation properties override
  36223. */
  36224. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36225. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36226. /**
  36227. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36228. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36229. */
  36230. useConstantAnimationDeltaTime: boolean;
  36231. /**
  36232. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36233. * Please note that it requires to run a ray cast through the scene on every frame
  36234. */
  36235. constantlyUpdateMeshUnderPointer: boolean;
  36236. /**
  36237. * Defines the HTML cursor to use when hovering over interactive elements
  36238. */
  36239. hoverCursor: string;
  36240. /**
  36241. * Defines the HTML default cursor to use (empty by default)
  36242. */
  36243. defaultCursor: string;
  36244. /**
  36245. * Defines whether cursors are handled by the scene.
  36246. */
  36247. doNotHandleCursors: boolean;
  36248. /**
  36249. * This is used to call preventDefault() on pointer down
  36250. * in order to block unwanted artifacts like system double clicks
  36251. */
  36252. preventDefaultOnPointerDown: boolean;
  36253. /**
  36254. * This is used to call preventDefault() on pointer up
  36255. * in order to block unwanted artifacts like system double clicks
  36256. */
  36257. preventDefaultOnPointerUp: boolean;
  36258. /**
  36259. * Gets or sets user defined metadata
  36260. */
  36261. metadata: any;
  36262. /**
  36263. * For internal use only. Please do not use.
  36264. */
  36265. reservedDataStore: any;
  36266. /**
  36267. * Gets the name of the plugin used to load this scene (null by default)
  36268. */
  36269. loadingPluginName: string;
  36270. /**
  36271. * Use this array to add regular expressions used to disable offline support for specific urls
  36272. */
  36273. disableOfflineSupportExceptionRules: RegExp[];
  36274. /**
  36275. * An event triggered when the scene is disposed.
  36276. */
  36277. onDisposeObservable: Observable<Scene>;
  36278. private _onDisposeObserver;
  36279. /** Sets a function to be executed when this scene is disposed. */
  36280. set onDispose(callback: () => void);
  36281. /**
  36282. * An event triggered before rendering the scene (right after animations and physics)
  36283. */
  36284. onBeforeRenderObservable: Observable<Scene>;
  36285. private _onBeforeRenderObserver;
  36286. /** Sets a function to be executed before rendering this scene */
  36287. set beforeRender(callback: Nullable<() => void>);
  36288. /**
  36289. * An event triggered after rendering the scene
  36290. */
  36291. onAfterRenderObservable: Observable<Scene>;
  36292. /**
  36293. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36294. */
  36295. onAfterRenderCameraObservable: Observable<Camera>;
  36296. private _onAfterRenderObserver;
  36297. /** Sets a function to be executed after rendering this scene */
  36298. set afterRender(callback: Nullable<() => void>);
  36299. /**
  36300. * An event triggered before animating the scene
  36301. */
  36302. onBeforeAnimationsObservable: Observable<Scene>;
  36303. /**
  36304. * An event triggered after animations processing
  36305. */
  36306. onAfterAnimationsObservable: Observable<Scene>;
  36307. /**
  36308. * An event triggered before draw calls are ready to be sent
  36309. */
  36310. onBeforeDrawPhaseObservable: Observable<Scene>;
  36311. /**
  36312. * An event triggered after draw calls have been sent
  36313. */
  36314. onAfterDrawPhaseObservable: Observable<Scene>;
  36315. /**
  36316. * An event triggered when the scene is ready
  36317. */
  36318. onReadyObservable: Observable<Scene>;
  36319. /**
  36320. * An event triggered before rendering a camera
  36321. */
  36322. onBeforeCameraRenderObservable: Observable<Camera>;
  36323. private _onBeforeCameraRenderObserver;
  36324. /** Sets a function to be executed before rendering a camera*/
  36325. set beforeCameraRender(callback: () => void);
  36326. /**
  36327. * An event triggered after rendering a camera
  36328. */
  36329. onAfterCameraRenderObservable: Observable<Camera>;
  36330. private _onAfterCameraRenderObserver;
  36331. /** Sets a function to be executed after rendering a camera*/
  36332. set afterCameraRender(callback: () => void);
  36333. /**
  36334. * An event triggered when active meshes evaluation is about to start
  36335. */
  36336. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36337. /**
  36338. * An event triggered when active meshes evaluation is done
  36339. */
  36340. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36341. /**
  36342. * An event triggered when particles rendering is about to start
  36343. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36344. */
  36345. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36346. /**
  36347. * An event triggered when particles rendering is done
  36348. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36349. */
  36350. onAfterParticlesRenderingObservable: Observable<Scene>;
  36351. /**
  36352. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36353. */
  36354. onDataLoadedObservable: Observable<Scene>;
  36355. /**
  36356. * An event triggered when a camera is created
  36357. */
  36358. onNewCameraAddedObservable: Observable<Camera>;
  36359. /**
  36360. * An event triggered when a camera is removed
  36361. */
  36362. onCameraRemovedObservable: Observable<Camera>;
  36363. /**
  36364. * An event triggered when a light is created
  36365. */
  36366. onNewLightAddedObservable: Observable<Light>;
  36367. /**
  36368. * An event triggered when a light is removed
  36369. */
  36370. onLightRemovedObservable: Observable<Light>;
  36371. /**
  36372. * An event triggered when a geometry is created
  36373. */
  36374. onNewGeometryAddedObservable: Observable<Geometry>;
  36375. /**
  36376. * An event triggered when a geometry is removed
  36377. */
  36378. onGeometryRemovedObservable: Observable<Geometry>;
  36379. /**
  36380. * An event triggered when a transform node is created
  36381. */
  36382. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36383. /**
  36384. * An event triggered when a transform node is removed
  36385. */
  36386. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36387. /**
  36388. * An event triggered when a mesh is created
  36389. */
  36390. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36391. /**
  36392. * An event triggered when a mesh is removed
  36393. */
  36394. onMeshRemovedObservable: Observable<AbstractMesh>;
  36395. /**
  36396. * An event triggered when a skeleton is created
  36397. */
  36398. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36399. /**
  36400. * An event triggered when a skeleton is removed
  36401. */
  36402. onSkeletonRemovedObservable: Observable<Skeleton>;
  36403. /**
  36404. * An event triggered when a material is created
  36405. */
  36406. onNewMaterialAddedObservable: Observable<Material>;
  36407. /**
  36408. * An event triggered when a material is removed
  36409. */
  36410. onMaterialRemovedObservable: Observable<Material>;
  36411. /**
  36412. * An event triggered when a texture is created
  36413. */
  36414. onNewTextureAddedObservable: Observable<BaseTexture>;
  36415. /**
  36416. * An event triggered when a texture is removed
  36417. */
  36418. onTextureRemovedObservable: Observable<BaseTexture>;
  36419. /**
  36420. * An event triggered when render targets are about to be rendered
  36421. * Can happen multiple times per frame.
  36422. */
  36423. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36424. /**
  36425. * An event triggered when render targets were rendered.
  36426. * Can happen multiple times per frame.
  36427. */
  36428. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36429. /**
  36430. * An event triggered before calculating deterministic simulation step
  36431. */
  36432. onBeforeStepObservable: Observable<Scene>;
  36433. /**
  36434. * An event triggered after calculating deterministic simulation step
  36435. */
  36436. onAfterStepObservable: Observable<Scene>;
  36437. /**
  36438. * An event triggered when the activeCamera property is updated
  36439. */
  36440. onActiveCameraChanged: Observable<Scene>;
  36441. /**
  36442. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36443. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36444. * 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)
  36445. */
  36446. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36447. /**
  36448. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36449. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36450. * 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)
  36451. */
  36452. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36453. /**
  36454. * This Observable will when a mesh has been imported into the scene.
  36455. */
  36456. onMeshImportedObservable: Observable<AbstractMesh>;
  36457. /**
  36458. * This Observable will when an animation file has been imported into the scene.
  36459. */
  36460. onAnimationFileImportedObservable: Observable<Scene>;
  36461. /**
  36462. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36463. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36464. */
  36465. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36466. /** @hidden */
  36467. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36468. /**
  36469. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36470. */
  36471. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36472. /**
  36473. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36474. */
  36475. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36476. /**
  36477. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36478. */
  36479. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36480. /** Callback called when a pointer move is detected */
  36481. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36482. /** Callback called when a pointer down is detected */
  36483. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36484. /** Callback called when a pointer up is detected */
  36485. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36486. /** Callback called when a pointer pick is detected */
  36487. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36488. /**
  36489. * 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).
  36490. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36491. */
  36492. onPrePointerObservable: Observable<PointerInfoPre>;
  36493. /**
  36494. * Observable event triggered each time an input event is received from the rendering canvas
  36495. */
  36496. onPointerObservable: Observable<PointerInfo>;
  36497. /**
  36498. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36499. */
  36500. get unTranslatedPointer(): Vector2;
  36501. /**
  36502. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36503. */
  36504. static get DragMovementThreshold(): number;
  36505. static set DragMovementThreshold(value: number);
  36506. /**
  36507. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36508. */
  36509. static get LongPressDelay(): number;
  36510. static set LongPressDelay(value: number);
  36511. /**
  36512. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36513. */
  36514. static get DoubleClickDelay(): number;
  36515. static set DoubleClickDelay(value: number);
  36516. /** If you need to check double click without raising a single click at first click, enable this flag */
  36517. static get ExclusiveDoubleClickMode(): boolean;
  36518. static set ExclusiveDoubleClickMode(value: boolean);
  36519. /** @hidden */
  36520. _mirroredCameraPosition: Nullable<Vector3>;
  36521. /**
  36522. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36523. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36524. */
  36525. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36526. /**
  36527. * Observable event triggered each time an keyboard event is received from the hosting window
  36528. */
  36529. onKeyboardObservable: Observable<KeyboardInfo>;
  36530. private _useRightHandedSystem;
  36531. /**
  36532. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36533. */
  36534. set useRightHandedSystem(value: boolean);
  36535. get useRightHandedSystem(): boolean;
  36536. private _timeAccumulator;
  36537. private _currentStepId;
  36538. private _currentInternalStep;
  36539. /**
  36540. * Sets the step Id used by deterministic lock step
  36541. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36542. * @param newStepId defines the step Id
  36543. */
  36544. setStepId(newStepId: number): void;
  36545. /**
  36546. * Gets the step Id used by deterministic lock step
  36547. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36548. * @returns the step Id
  36549. */
  36550. getStepId(): number;
  36551. /**
  36552. * Gets the internal step used by deterministic lock step
  36553. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36554. * @returns the internal step
  36555. */
  36556. getInternalStep(): number;
  36557. private _fogEnabled;
  36558. /**
  36559. * Gets or sets a boolean indicating if fog is enabled on this scene
  36560. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36561. * (Default is true)
  36562. */
  36563. set fogEnabled(value: boolean);
  36564. get fogEnabled(): boolean;
  36565. private _fogMode;
  36566. /**
  36567. * Gets or sets the fog mode to use
  36568. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36569. * | mode | value |
  36570. * | --- | --- |
  36571. * | FOGMODE_NONE | 0 |
  36572. * | FOGMODE_EXP | 1 |
  36573. * | FOGMODE_EXP2 | 2 |
  36574. * | FOGMODE_LINEAR | 3 |
  36575. */
  36576. set fogMode(value: number);
  36577. get fogMode(): number;
  36578. /**
  36579. * Gets or sets the fog color to use
  36580. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36581. * (Default is Color3(0.2, 0.2, 0.3))
  36582. */
  36583. fogColor: Color3;
  36584. /**
  36585. * Gets or sets the fog density to use
  36586. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36587. * (Default is 0.1)
  36588. */
  36589. fogDensity: number;
  36590. /**
  36591. * Gets or sets the fog start distance to use
  36592. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36593. * (Default is 0)
  36594. */
  36595. fogStart: number;
  36596. /**
  36597. * Gets or sets the fog end distance to use
  36598. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36599. * (Default is 1000)
  36600. */
  36601. fogEnd: number;
  36602. private _shadowsEnabled;
  36603. /**
  36604. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36605. */
  36606. set shadowsEnabled(value: boolean);
  36607. get shadowsEnabled(): boolean;
  36608. private _lightsEnabled;
  36609. /**
  36610. * Gets or sets a boolean indicating if lights are enabled on this scene
  36611. */
  36612. set lightsEnabled(value: boolean);
  36613. get lightsEnabled(): boolean;
  36614. /** All of the active cameras added to this scene. */
  36615. activeCameras: Camera[];
  36616. /** @hidden */
  36617. _activeCamera: Nullable<Camera>;
  36618. /** Gets or sets the current active camera */
  36619. get activeCamera(): Nullable<Camera>;
  36620. set activeCamera(value: Nullable<Camera>);
  36621. private _defaultMaterial;
  36622. /** The default material used on meshes when no material is affected */
  36623. get defaultMaterial(): Material;
  36624. /** The default material used on meshes when no material is affected */
  36625. set defaultMaterial(value: Material);
  36626. private _texturesEnabled;
  36627. /**
  36628. * Gets or sets a boolean indicating if textures are enabled on this scene
  36629. */
  36630. set texturesEnabled(value: boolean);
  36631. get texturesEnabled(): boolean;
  36632. /**
  36633. * Gets or sets a boolean indicating if particles are enabled on this scene
  36634. */
  36635. particlesEnabled: boolean;
  36636. /**
  36637. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36638. */
  36639. spritesEnabled: boolean;
  36640. private _skeletonsEnabled;
  36641. /**
  36642. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36643. */
  36644. set skeletonsEnabled(value: boolean);
  36645. get skeletonsEnabled(): boolean;
  36646. /**
  36647. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36648. */
  36649. lensFlaresEnabled: boolean;
  36650. /**
  36651. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36653. */
  36654. collisionsEnabled: boolean;
  36655. private _collisionCoordinator;
  36656. /** @hidden */
  36657. get collisionCoordinator(): ICollisionCoordinator;
  36658. /**
  36659. * Defines the gravity applied to this scene (used only for collisions)
  36660. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36661. */
  36662. gravity: Vector3;
  36663. /**
  36664. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36665. */
  36666. postProcessesEnabled: boolean;
  36667. /**
  36668. * The list of postprocesses added to the scene
  36669. */
  36670. postProcesses: PostProcess[];
  36671. /**
  36672. * Gets the current postprocess manager
  36673. */
  36674. postProcessManager: PostProcessManager;
  36675. /**
  36676. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36677. */
  36678. renderTargetsEnabled: boolean;
  36679. /**
  36680. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36681. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36682. */
  36683. dumpNextRenderTargets: boolean;
  36684. /**
  36685. * The list of user defined render targets added to the scene
  36686. */
  36687. customRenderTargets: RenderTargetTexture[];
  36688. /**
  36689. * Defines if texture loading must be delayed
  36690. * If true, textures will only be loaded when they need to be rendered
  36691. */
  36692. useDelayedTextureLoading: boolean;
  36693. /**
  36694. * Gets the list of meshes imported to the scene through SceneLoader
  36695. */
  36696. importedMeshesFiles: String[];
  36697. /**
  36698. * Gets or sets a boolean indicating if probes are enabled on this scene
  36699. */
  36700. probesEnabled: boolean;
  36701. /**
  36702. * Gets or sets the current offline provider to use to store scene data
  36703. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36704. */
  36705. offlineProvider: IOfflineProvider;
  36706. /**
  36707. * Gets or sets the action manager associated with the scene
  36708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36709. */
  36710. actionManager: AbstractActionManager;
  36711. private _meshesForIntersections;
  36712. /**
  36713. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36714. */
  36715. proceduralTexturesEnabled: boolean;
  36716. private _engine;
  36717. private _totalVertices;
  36718. /** @hidden */
  36719. _activeIndices: PerfCounter;
  36720. /** @hidden */
  36721. _activeParticles: PerfCounter;
  36722. /** @hidden */
  36723. _activeBones: PerfCounter;
  36724. private _animationRatio;
  36725. /** @hidden */
  36726. _animationTimeLast: number;
  36727. /** @hidden */
  36728. _animationTime: number;
  36729. /**
  36730. * Gets or sets a general scale for animation speed
  36731. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36732. */
  36733. animationTimeScale: number;
  36734. /** @hidden */
  36735. _cachedMaterial: Nullable<Material>;
  36736. /** @hidden */
  36737. _cachedEffect: Nullable<Effect>;
  36738. /** @hidden */
  36739. _cachedVisibility: Nullable<number>;
  36740. private _renderId;
  36741. private _frameId;
  36742. private _executeWhenReadyTimeoutId;
  36743. private _intermediateRendering;
  36744. private _viewUpdateFlag;
  36745. private _projectionUpdateFlag;
  36746. /** @hidden */
  36747. _toBeDisposed: Nullable<IDisposable>[];
  36748. private _activeRequests;
  36749. /** @hidden */
  36750. _pendingData: any[];
  36751. private _isDisposed;
  36752. /**
  36753. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36754. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36755. */
  36756. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36757. private _activeMeshes;
  36758. private _processedMaterials;
  36759. private _renderTargets;
  36760. /** @hidden */
  36761. _activeParticleSystems: SmartArray<IParticleSystem>;
  36762. private _activeSkeletons;
  36763. private _softwareSkinnedMeshes;
  36764. private _renderingManager;
  36765. /** @hidden */
  36766. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36767. private _transformMatrix;
  36768. private _sceneUbo;
  36769. /** @hidden */
  36770. _viewMatrix: Matrix;
  36771. private _projectionMatrix;
  36772. /** @hidden */
  36773. _forcedViewPosition: Nullable<Vector3>;
  36774. /** @hidden */
  36775. _frustumPlanes: Plane[];
  36776. /**
  36777. * Gets the list of frustum planes (built from the active camera)
  36778. */
  36779. get frustumPlanes(): Plane[];
  36780. /**
  36781. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36782. * This is useful if there are more lights that the maximum simulteanous authorized
  36783. */
  36784. requireLightSorting: boolean;
  36785. /** @hidden */
  36786. readonly useMaterialMeshMap: boolean;
  36787. /** @hidden */
  36788. readonly useClonedMeshMap: boolean;
  36789. private _externalData;
  36790. private _uid;
  36791. /**
  36792. * @hidden
  36793. * Backing store of defined scene components.
  36794. */
  36795. _components: ISceneComponent[];
  36796. /**
  36797. * @hidden
  36798. * Backing store of defined scene components.
  36799. */
  36800. _serializableComponents: ISceneSerializableComponent[];
  36801. /**
  36802. * List of components to register on the next registration step.
  36803. */
  36804. private _transientComponents;
  36805. /**
  36806. * Registers the transient components if needed.
  36807. */
  36808. private _registerTransientComponents;
  36809. /**
  36810. * @hidden
  36811. * Add a component to the scene.
  36812. * Note that the ccomponent could be registered on th next frame if this is called after
  36813. * the register component stage.
  36814. * @param component Defines the component to add to the scene
  36815. */
  36816. _addComponent(component: ISceneComponent): void;
  36817. /**
  36818. * @hidden
  36819. * Gets a component from the scene.
  36820. * @param name defines the name of the component to retrieve
  36821. * @returns the component or null if not present
  36822. */
  36823. _getComponent(name: string): Nullable<ISceneComponent>;
  36824. /**
  36825. * @hidden
  36826. * Defines the actions happening before camera updates.
  36827. */
  36828. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36829. /**
  36830. * @hidden
  36831. * Defines the actions happening before clear the canvas.
  36832. */
  36833. _beforeClearStage: Stage<SimpleStageAction>;
  36834. /**
  36835. * @hidden
  36836. * Defines the actions when collecting render targets for the frame.
  36837. */
  36838. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36839. /**
  36840. * @hidden
  36841. * Defines the actions happening for one camera in the frame.
  36842. */
  36843. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36844. /**
  36845. * @hidden
  36846. * Defines the actions happening during the per mesh ready checks.
  36847. */
  36848. _isReadyForMeshStage: Stage<MeshStageAction>;
  36849. /**
  36850. * @hidden
  36851. * Defines the actions happening before evaluate active mesh checks.
  36852. */
  36853. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36854. /**
  36855. * @hidden
  36856. * Defines the actions happening during the evaluate sub mesh checks.
  36857. */
  36858. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36859. /**
  36860. * @hidden
  36861. * Defines the actions happening during the active mesh stage.
  36862. */
  36863. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36864. /**
  36865. * @hidden
  36866. * Defines the actions happening during the per camera render target step.
  36867. */
  36868. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36869. /**
  36870. * @hidden
  36871. * Defines the actions happening just before the active camera is drawing.
  36872. */
  36873. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36874. /**
  36875. * @hidden
  36876. * Defines the actions happening just before a render target is drawing.
  36877. */
  36878. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36879. /**
  36880. * @hidden
  36881. * Defines the actions happening just before a rendering group is drawing.
  36882. */
  36883. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36884. /**
  36885. * @hidden
  36886. * Defines the actions happening just before a mesh is drawing.
  36887. */
  36888. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36889. /**
  36890. * @hidden
  36891. * Defines the actions happening just after a mesh has been drawn.
  36892. */
  36893. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36894. /**
  36895. * @hidden
  36896. * Defines the actions happening just after a rendering group has been drawn.
  36897. */
  36898. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36899. /**
  36900. * @hidden
  36901. * Defines the actions happening just after the active camera has been drawn.
  36902. */
  36903. _afterCameraDrawStage: Stage<CameraStageAction>;
  36904. /**
  36905. * @hidden
  36906. * Defines the actions happening just after a render target has been drawn.
  36907. */
  36908. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36909. /**
  36910. * @hidden
  36911. * Defines the actions happening just after rendering all cameras and computing intersections.
  36912. */
  36913. _afterRenderStage: Stage<SimpleStageAction>;
  36914. /**
  36915. * @hidden
  36916. * Defines the actions happening when a pointer move event happens.
  36917. */
  36918. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36919. /**
  36920. * @hidden
  36921. * Defines the actions happening when a pointer down event happens.
  36922. */
  36923. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36924. /**
  36925. * @hidden
  36926. * Defines the actions happening when a pointer up event happens.
  36927. */
  36928. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36929. /**
  36930. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36931. */
  36932. private geometriesByUniqueId;
  36933. /**
  36934. * Creates a new Scene
  36935. * @param engine defines the engine to use to render this scene
  36936. * @param options defines the scene options
  36937. */
  36938. constructor(engine: Engine, options?: SceneOptions);
  36939. /**
  36940. * Gets a string idenfifying the name of the class
  36941. * @returns "Scene" string
  36942. */
  36943. getClassName(): string;
  36944. private _defaultMeshCandidates;
  36945. /**
  36946. * @hidden
  36947. */
  36948. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36949. private _defaultSubMeshCandidates;
  36950. /**
  36951. * @hidden
  36952. */
  36953. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36954. /**
  36955. * Sets the default candidate providers for the scene.
  36956. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36957. * and getCollidingSubMeshCandidates to their default function
  36958. */
  36959. setDefaultCandidateProviders(): void;
  36960. /**
  36961. * Gets the mesh that is currently under the pointer
  36962. */
  36963. get meshUnderPointer(): Nullable<AbstractMesh>;
  36964. /**
  36965. * Gets or sets the current on-screen X position of the pointer
  36966. */
  36967. get pointerX(): number;
  36968. set pointerX(value: number);
  36969. /**
  36970. * Gets or sets the current on-screen Y position of the pointer
  36971. */
  36972. get pointerY(): number;
  36973. set pointerY(value: number);
  36974. /**
  36975. * Gets the cached material (ie. the latest rendered one)
  36976. * @returns the cached material
  36977. */
  36978. getCachedMaterial(): Nullable<Material>;
  36979. /**
  36980. * Gets the cached effect (ie. the latest rendered one)
  36981. * @returns the cached effect
  36982. */
  36983. getCachedEffect(): Nullable<Effect>;
  36984. /**
  36985. * Gets the cached visibility state (ie. the latest rendered one)
  36986. * @returns the cached visibility state
  36987. */
  36988. getCachedVisibility(): Nullable<number>;
  36989. /**
  36990. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36991. * @param material defines the current material
  36992. * @param effect defines the current effect
  36993. * @param visibility defines the current visibility state
  36994. * @returns true if one parameter is not cached
  36995. */
  36996. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36997. /**
  36998. * Gets the engine associated with the scene
  36999. * @returns an Engine
  37000. */
  37001. getEngine(): Engine;
  37002. /**
  37003. * Gets the total number of vertices rendered per frame
  37004. * @returns the total number of vertices rendered per frame
  37005. */
  37006. getTotalVertices(): number;
  37007. /**
  37008. * Gets the performance counter for total vertices
  37009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37010. */
  37011. get totalVerticesPerfCounter(): PerfCounter;
  37012. /**
  37013. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37014. * @returns the total number of active indices rendered per frame
  37015. */
  37016. getActiveIndices(): number;
  37017. /**
  37018. * Gets the performance counter for active indices
  37019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37020. */
  37021. get totalActiveIndicesPerfCounter(): PerfCounter;
  37022. /**
  37023. * Gets the total number of active particles rendered per frame
  37024. * @returns the total number of active particles rendered per frame
  37025. */
  37026. getActiveParticles(): number;
  37027. /**
  37028. * Gets the performance counter for active particles
  37029. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37030. */
  37031. get activeParticlesPerfCounter(): PerfCounter;
  37032. /**
  37033. * Gets the total number of active bones rendered per frame
  37034. * @returns the total number of active bones rendered per frame
  37035. */
  37036. getActiveBones(): number;
  37037. /**
  37038. * Gets the performance counter for active bones
  37039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37040. */
  37041. get activeBonesPerfCounter(): PerfCounter;
  37042. /**
  37043. * Gets the array of active meshes
  37044. * @returns an array of AbstractMesh
  37045. */
  37046. getActiveMeshes(): SmartArray<AbstractMesh>;
  37047. /**
  37048. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37049. * @returns a number
  37050. */
  37051. getAnimationRatio(): number;
  37052. /**
  37053. * Gets an unique Id for the current render phase
  37054. * @returns a number
  37055. */
  37056. getRenderId(): number;
  37057. /**
  37058. * Gets an unique Id for the current frame
  37059. * @returns a number
  37060. */
  37061. getFrameId(): number;
  37062. /** Call this function if you want to manually increment the render Id*/
  37063. incrementRenderId(): void;
  37064. private _createUbo;
  37065. /**
  37066. * Use this method to simulate a pointer move on a mesh
  37067. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37068. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37069. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37070. * @returns the current scene
  37071. */
  37072. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37073. /**
  37074. * Use this method to simulate a pointer down on a mesh
  37075. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37076. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37077. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37078. * @returns the current scene
  37079. */
  37080. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37081. /**
  37082. * Use this method to simulate a pointer up on a mesh
  37083. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37084. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37085. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37086. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37087. * @returns the current scene
  37088. */
  37089. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37090. /**
  37091. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37092. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37093. * @returns true if the pointer was captured
  37094. */
  37095. isPointerCaptured(pointerId?: number): boolean;
  37096. /**
  37097. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37098. * @param attachUp defines if you want to attach events to pointerup
  37099. * @param attachDown defines if you want to attach events to pointerdown
  37100. * @param attachMove defines if you want to attach events to pointermove
  37101. */
  37102. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37103. /** Detaches all event handlers*/
  37104. detachControl(): void;
  37105. /**
  37106. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37107. * Delay loaded resources are not taking in account
  37108. * @return true if all required resources are ready
  37109. */
  37110. isReady(): boolean;
  37111. /** Resets all cached information relative to material (including effect and visibility) */
  37112. resetCachedMaterial(): void;
  37113. /**
  37114. * Registers a function to be called before every frame render
  37115. * @param func defines the function to register
  37116. */
  37117. registerBeforeRender(func: () => void): void;
  37118. /**
  37119. * Unregisters a function called before every frame render
  37120. * @param func defines the function to unregister
  37121. */
  37122. unregisterBeforeRender(func: () => void): void;
  37123. /**
  37124. * Registers a function to be called after every frame render
  37125. * @param func defines the function to register
  37126. */
  37127. registerAfterRender(func: () => void): void;
  37128. /**
  37129. * Unregisters a function called after every frame render
  37130. * @param func defines the function to unregister
  37131. */
  37132. unregisterAfterRender(func: () => void): void;
  37133. private _executeOnceBeforeRender;
  37134. /**
  37135. * The provided function will run before render once and will be disposed afterwards.
  37136. * A timeout delay can be provided so that the function will be executed in N ms.
  37137. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37138. * @param func The function to be executed.
  37139. * @param timeout optional delay in ms
  37140. */
  37141. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37142. /** @hidden */
  37143. _addPendingData(data: any): void;
  37144. /** @hidden */
  37145. _removePendingData(data: any): void;
  37146. /**
  37147. * Returns the number of items waiting to be loaded
  37148. * @returns the number of items waiting to be loaded
  37149. */
  37150. getWaitingItemsCount(): number;
  37151. /**
  37152. * Returns a boolean indicating if the scene is still loading data
  37153. */
  37154. get isLoading(): boolean;
  37155. /**
  37156. * Registers a function to be executed when the scene is ready
  37157. * @param {Function} func - the function to be executed
  37158. */
  37159. executeWhenReady(func: () => void): void;
  37160. /**
  37161. * Returns a promise that resolves when the scene is ready
  37162. * @returns A promise that resolves when the scene is ready
  37163. */
  37164. whenReadyAsync(): Promise<void>;
  37165. /** @hidden */
  37166. _checkIsReady(): void;
  37167. /**
  37168. * Gets all animatable attached to the scene
  37169. */
  37170. get animatables(): Animatable[];
  37171. /**
  37172. * Resets the last animation time frame.
  37173. * Useful to override when animations start running when loading a scene for the first time.
  37174. */
  37175. resetLastAnimationTimeFrame(): void;
  37176. /**
  37177. * Gets the current view matrix
  37178. * @returns a Matrix
  37179. */
  37180. getViewMatrix(): Matrix;
  37181. /**
  37182. * Gets the current projection matrix
  37183. * @returns a Matrix
  37184. */
  37185. getProjectionMatrix(): Matrix;
  37186. /**
  37187. * Gets the current transform matrix
  37188. * @returns a Matrix made of View * Projection
  37189. */
  37190. getTransformMatrix(): Matrix;
  37191. /**
  37192. * Sets the current transform matrix
  37193. * @param viewL defines the View matrix to use
  37194. * @param projectionL defines the Projection matrix to use
  37195. * @param viewR defines the right View matrix to use (if provided)
  37196. * @param projectionR defines the right Projection matrix to use (if provided)
  37197. */
  37198. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37199. /**
  37200. * Gets the uniform buffer used to store scene data
  37201. * @returns a UniformBuffer
  37202. */
  37203. getSceneUniformBuffer(): UniformBuffer;
  37204. /**
  37205. * Gets an unique (relatively to the current scene) Id
  37206. * @returns an unique number for the scene
  37207. */
  37208. getUniqueId(): number;
  37209. /**
  37210. * Add a mesh to the list of scene's meshes
  37211. * @param newMesh defines the mesh to add
  37212. * @param recursive if all child meshes should also be added to the scene
  37213. */
  37214. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37215. /**
  37216. * Remove a mesh for the list of scene's meshes
  37217. * @param toRemove defines the mesh to remove
  37218. * @param recursive if all child meshes should also be removed from the scene
  37219. * @returns the index where the mesh was in the mesh list
  37220. */
  37221. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37222. /**
  37223. * Add a transform node to the list of scene's transform nodes
  37224. * @param newTransformNode defines the transform node to add
  37225. */
  37226. addTransformNode(newTransformNode: TransformNode): void;
  37227. /**
  37228. * Remove a transform node for the list of scene's transform nodes
  37229. * @param toRemove defines the transform node to remove
  37230. * @returns the index where the transform node was in the transform node list
  37231. */
  37232. removeTransformNode(toRemove: TransformNode): number;
  37233. /**
  37234. * Remove a skeleton for the list of scene's skeletons
  37235. * @param toRemove defines the skeleton to remove
  37236. * @returns the index where the skeleton was in the skeleton list
  37237. */
  37238. removeSkeleton(toRemove: Skeleton): number;
  37239. /**
  37240. * Remove a morph target for the list of scene's morph targets
  37241. * @param toRemove defines the morph target to remove
  37242. * @returns the index where the morph target was in the morph target list
  37243. */
  37244. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37245. /**
  37246. * Remove a light for the list of scene's lights
  37247. * @param toRemove defines the light to remove
  37248. * @returns the index where the light was in the light list
  37249. */
  37250. removeLight(toRemove: Light): number;
  37251. /**
  37252. * Remove a camera for the list of scene's cameras
  37253. * @param toRemove defines the camera to remove
  37254. * @returns the index where the camera was in the camera list
  37255. */
  37256. removeCamera(toRemove: Camera): number;
  37257. /**
  37258. * Remove a particle system for the list of scene's particle systems
  37259. * @param toRemove defines the particle system to remove
  37260. * @returns the index where the particle system was in the particle system list
  37261. */
  37262. removeParticleSystem(toRemove: IParticleSystem): number;
  37263. /**
  37264. * Remove a animation for the list of scene's animations
  37265. * @param toRemove defines the animation to remove
  37266. * @returns the index where the animation was in the animation list
  37267. */
  37268. removeAnimation(toRemove: Animation): number;
  37269. /**
  37270. * Will stop the animation of the given target
  37271. * @param target - the target
  37272. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37273. * @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)
  37274. */
  37275. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37276. /**
  37277. * Removes the given animation group from this scene.
  37278. * @param toRemove The animation group to remove
  37279. * @returns The index of the removed animation group
  37280. */
  37281. removeAnimationGroup(toRemove: AnimationGroup): number;
  37282. /**
  37283. * Removes the given multi-material from this scene.
  37284. * @param toRemove The multi-material to remove
  37285. * @returns The index of the removed multi-material
  37286. */
  37287. removeMultiMaterial(toRemove: MultiMaterial): number;
  37288. /**
  37289. * Removes the given material from this scene.
  37290. * @param toRemove The material to remove
  37291. * @returns The index of the removed material
  37292. */
  37293. removeMaterial(toRemove: Material): number;
  37294. /**
  37295. * Removes the given action manager from this scene.
  37296. * @param toRemove The action manager to remove
  37297. * @returns The index of the removed action manager
  37298. */
  37299. removeActionManager(toRemove: AbstractActionManager): number;
  37300. /**
  37301. * Removes the given texture from this scene.
  37302. * @param toRemove The texture to remove
  37303. * @returns The index of the removed texture
  37304. */
  37305. removeTexture(toRemove: BaseTexture): number;
  37306. /**
  37307. * Adds the given light to this scene
  37308. * @param newLight The light to add
  37309. */
  37310. addLight(newLight: Light): void;
  37311. /**
  37312. * Sorts the list list based on light priorities
  37313. */
  37314. sortLightsByPriority(): void;
  37315. /**
  37316. * Adds the given camera to this scene
  37317. * @param newCamera The camera to add
  37318. */
  37319. addCamera(newCamera: Camera): void;
  37320. /**
  37321. * Adds the given skeleton to this scene
  37322. * @param newSkeleton The skeleton to add
  37323. */
  37324. addSkeleton(newSkeleton: Skeleton): void;
  37325. /**
  37326. * Adds the given particle system to this scene
  37327. * @param newParticleSystem The particle system to add
  37328. */
  37329. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37330. /**
  37331. * Adds the given animation to this scene
  37332. * @param newAnimation The animation to add
  37333. */
  37334. addAnimation(newAnimation: Animation): void;
  37335. /**
  37336. * Adds the given animation group to this scene.
  37337. * @param newAnimationGroup The animation group to add
  37338. */
  37339. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37340. /**
  37341. * Adds the given multi-material to this scene
  37342. * @param newMultiMaterial The multi-material to add
  37343. */
  37344. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37345. /**
  37346. * Adds the given material to this scene
  37347. * @param newMaterial The material to add
  37348. */
  37349. addMaterial(newMaterial: Material): void;
  37350. /**
  37351. * Adds the given morph target to this scene
  37352. * @param newMorphTargetManager The morph target to add
  37353. */
  37354. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37355. /**
  37356. * Adds the given geometry to this scene
  37357. * @param newGeometry The geometry to add
  37358. */
  37359. addGeometry(newGeometry: Geometry): void;
  37360. /**
  37361. * Adds the given action manager to this scene
  37362. * @param newActionManager The action manager to add
  37363. */
  37364. addActionManager(newActionManager: AbstractActionManager): void;
  37365. /**
  37366. * Adds the given texture to this scene.
  37367. * @param newTexture The texture to add
  37368. */
  37369. addTexture(newTexture: BaseTexture): void;
  37370. /**
  37371. * Switch active camera
  37372. * @param newCamera defines the new active camera
  37373. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37374. */
  37375. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37376. /**
  37377. * sets the active camera of the scene using its ID
  37378. * @param id defines the camera's ID
  37379. * @return the new active camera or null if none found.
  37380. */
  37381. setActiveCameraByID(id: string): Nullable<Camera>;
  37382. /**
  37383. * sets the active camera of the scene using its name
  37384. * @param name defines the camera's name
  37385. * @returns the new active camera or null if none found.
  37386. */
  37387. setActiveCameraByName(name: string): Nullable<Camera>;
  37388. /**
  37389. * get an animation group using its name
  37390. * @param name defines the material's name
  37391. * @return the animation group or null if none found.
  37392. */
  37393. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37394. /**
  37395. * Get a material using its unique id
  37396. * @param uniqueId defines the material's unique id
  37397. * @return the material or null if none found.
  37398. */
  37399. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37400. /**
  37401. * get a material using its id
  37402. * @param id defines the material's ID
  37403. * @return the material or null if none found.
  37404. */
  37405. getMaterialByID(id: string): Nullable<Material>;
  37406. /**
  37407. * Gets a the last added material using a given id
  37408. * @param id defines the material's ID
  37409. * @return the last material with the given id or null if none found.
  37410. */
  37411. getLastMaterialByID(id: string): Nullable<Material>;
  37412. /**
  37413. * Gets a material using its name
  37414. * @param name defines the material's name
  37415. * @return the material or null if none found.
  37416. */
  37417. getMaterialByName(name: string): Nullable<Material>;
  37418. /**
  37419. * Get a texture using its unique id
  37420. * @param uniqueId defines the texture's unique id
  37421. * @return the texture or null if none found.
  37422. */
  37423. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37424. /**
  37425. * Gets a camera using its id
  37426. * @param id defines the id to look for
  37427. * @returns the camera or null if not found
  37428. */
  37429. getCameraByID(id: string): Nullable<Camera>;
  37430. /**
  37431. * Gets a camera using its unique id
  37432. * @param uniqueId defines the unique id to look for
  37433. * @returns the camera or null if not found
  37434. */
  37435. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37436. /**
  37437. * Gets a camera using its name
  37438. * @param name defines the camera's name
  37439. * @return the camera or null if none found.
  37440. */
  37441. getCameraByName(name: string): Nullable<Camera>;
  37442. /**
  37443. * Gets a bone using its id
  37444. * @param id defines the bone's id
  37445. * @return the bone or null if not found
  37446. */
  37447. getBoneByID(id: string): Nullable<Bone>;
  37448. /**
  37449. * Gets a bone using its id
  37450. * @param name defines the bone's name
  37451. * @return the bone or null if not found
  37452. */
  37453. getBoneByName(name: string): Nullable<Bone>;
  37454. /**
  37455. * Gets a light node using its name
  37456. * @param name defines the the light's name
  37457. * @return the light or null if none found.
  37458. */
  37459. getLightByName(name: string): Nullable<Light>;
  37460. /**
  37461. * Gets a light node using its id
  37462. * @param id defines the light's id
  37463. * @return the light or null if none found.
  37464. */
  37465. getLightByID(id: string): Nullable<Light>;
  37466. /**
  37467. * Gets a light node using its scene-generated unique ID
  37468. * @param uniqueId defines the light's unique id
  37469. * @return the light or null if none found.
  37470. */
  37471. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37472. /**
  37473. * Gets a particle system by id
  37474. * @param id defines the particle system id
  37475. * @return the corresponding system or null if none found
  37476. */
  37477. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37478. /**
  37479. * Gets a geometry using its ID
  37480. * @param id defines the geometry's id
  37481. * @return the geometry or null if none found.
  37482. */
  37483. getGeometryByID(id: string): Nullable<Geometry>;
  37484. private _getGeometryByUniqueID;
  37485. /**
  37486. * Add a new geometry to this scene
  37487. * @param geometry defines the geometry to be added to the scene.
  37488. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37489. * @return a boolean defining if the geometry was added or not
  37490. */
  37491. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37492. /**
  37493. * Removes an existing geometry
  37494. * @param geometry defines the geometry to be removed from the scene
  37495. * @return a boolean defining if the geometry was removed or not
  37496. */
  37497. removeGeometry(geometry: Geometry): boolean;
  37498. /**
  37499. * Gets the list of geometries attached to the scene
  37500. * @returns an array of Geometry
  37501. */
  37502. getGeometries(): Geometry[];
  37503. /**
  37504. * Gets the first added mesh found of a given ID
  37505. * @param id defines the id to search for
  37506. * @return the mesh found or null if not found at all
  37507. */
  37508. getMeshByID(id: string): Nullable<AbstractMesh>;
  37509. /**
  37510. * Gets a list of meshes using their id
  37511. * @param id defines the id to search for
  37512. * @returns a list of meshes
  37513. */
  37514. getMeshesByID(id: string): Array<AbstractMesh>;
  37515. /**
  37516. * Gets the first added transform node found of a given ID
  37517. * @param id defines the id to search for
  37518. * @return the found transform node or null if not found at all.
  37519. */
  37520. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37521. /**
  37522. * Gets a transform node with its auto-generated unique id
  37523. * @param uniqueId efines the unique id to search for
  37524. * @return the found transform node or null if not found at all.
  37525. */
  37526. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37527. /**
  37528. * Gets a list of transform nodes using their id
  37529. * @param id defines the id to search for
  37530. * @returns a list of transform nodes
  37531. */
  37532. getTransformNodesByID(id: string): Array<TransformNode>;
  37533. /**
  37534. * Gets a mesh with its auto-generated unique id
  37535. * @param uniqueId defines the unique id to search for
  37536. * @return the found mesh or null if not found at all.
  37537. */
  37538. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37539. /**
  37540. * Gets a the last added mesh using a given id
  37541. * @param id defines the id to search for
  37542. * @return the found mesh or null if not found at all.
  37543. */
  37544. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37545. /**
  37546. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37547. * @param id defines the id to search for
  37548. * @return the found node or null if not found at all
  37549. */
  37550. getLastEntryByID(id: string): Nullable<Node>;
  37551. /**
  37552. * Gets a node (Mesh, Camera, Light) using a given id
  37553. * @param id defines the id to search for
  37554. * @return the found node or null if not found at all
  37555. */
  37556. getNodeByID(id: string): Nullable<Node>;
  37557. /**
  37558. * Gets a node (Mesh, Camera, Light) using a given name
  37559. * @param name defines the name to search for
  37560. * @return the found node or null if not found at all.
  37561. */
  37562. getNodeByName(name: string): Nullable<Node>;
  37563. /**
  37564. * Gets a mesh using a given name
  37565. * @param name defines the name to search for
  37566. * @return the found mesh or null if not found at all.
  37567. */
  37568. getMeshByName(name: string): Nullable<AbstractMesh>;
  37569. /**
  37570. * Gets a transform node using a given name
  37571. * @param name defines the name to search for
  37572. * @return the found transform node or null if not found at all.
  37573. */
  37574. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37575. /**
  37576. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37577. * @param id defines the id to search for
  37578. * @return the found skeleton or null if not found at all.
  37579. */
  37580. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37581. /**
  37582. * Gets a skeleton using a given auto generated unique id
  37583. * @param uniqueId defines the unique id to search for
  37584. * @return the found skeleton or null if not found at all.
  37585. */
  37586. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37587. /**
  37588. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37589. * @param id defines the id to search for
  37590. * @return the found skeleton or null if not found at all.
  37591. */
  37592. getSkeletonById(id: string): Nullable<Skeleton>;
  37593. /**
  37594. * Gets a skeleton using a given name
  37595. * @param name defines the name to search for
  37596. * @return the found skeleton or null if not found at all.
  37597. */
  37598. getSkeletonByName(name: string): Nullable<Skeleton>;
  37599. /**
  37600. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37601. * @param id defines the id to search for
  37602. * @return the found morph target manager or null if not found at all.
  37603. */
  37604. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37605. /**
  37606. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37607. * @param id defines the id to search for
  37608. * @return the found morph target or null if not found at all.
  37609. */
  37610. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37611. /**
  37612. * Gets a boolean indicating if the given mesh is active
  37613. * @param mesh defines the mesh to look for
  37614. * @returns true if the mesh is in the active list
  37615. */
  37616. isActiveMesh(mesh: AbstractMesh): boolean;
  37617. /**
  37618. * Return a unique id as a string which can serve as an identifier for the scene
  37619. */
  37620. get uid(): string;
  37621. /**
  37622. * Add an externaly attached data from its key.
  37623. * This method call will fail and return false, if such key already exists.
  37624. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37625. * @param key the unique key that identifies the data
  37626. * @param data the data object to associate to the key for this Engine instance
  37627. * @return true if no such key were already present and the data was added successfully, false otherwise
  37628. */
  37629. addExternalData<T>(key: string, data: T): boolean;
  37630. /**
  37631. * Get an externaly attached data from its key
  37632. * @param key the unique key that identifies the data
  37633. * @return the associated data, if present (can be null), or undefined if not present
  37634. */
  37635. getExternalData<T>(key: string): Nullable<T>;
  37636. /**
  37637. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37638. * @param key the unique key that identifies the data
  37639. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37640. * @return the associated data, can be null if the factory returned null.
  37641. */
  37642. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37643. /**
  37644. * Remove an externaly attached data from the Engine instance
  37645. * @param key the unique key that identifies the data
  37646. * @return true if the data was successfully removed, false if it doesn't exist
  37647. */
  37648. removeExternalData(key: string): boolean;
  37649. private _evaluateSubMesh;
  37650. /**
  37651. * Clear the processed materials smart array preventing retention point in material dispose.
  37652. */
  37653. freeProcessedMaterials(): void;
  37654. private _preventFreeActiveMeshesAndRenderingGroups;
  37655. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37656. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37657. * when disposing several meshes in a row or a hierarchy of meshes.
  37658. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37659. */
  37660. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37661. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37662. /**
  37663. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37664. */
  37665. freeActiveMeshes(): void;
  37666. /**
  37667. * Clear the info related to rendering groups preventing retention points during dispose.
  37668. */
  37669. freeRenderingGroups(): void;
  37670. /** @hidden */
  37671. _isInIntermediateRendering(): boolean;
  37672. /**
  37673. * Lambda returning the list of potentially active meshes.
  37674. */
  37675. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37676. /**
  37677. * Lambda returning the list of potentially active sub meshes.
  37678. */
  37679. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37680. /**
  37681. * Lambda returning the list of potentially intersecting sub meshes.
  37682. */
  37683. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37684. /**
  37685. * Lambda returning the list of potentially colliding sub meshes.
  37686. */
  37687. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37688. private _activeMeshesFrozen;
  37689. private _skipEvaluateActiveMeshesCompletely;
  37690. /**
  37691. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37692. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37693. * @returns the current scene
  37694. */
  37695. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37696. /**
  37697. * Use this function to restart evaluating active meshes on every frame
  37698. * @returns the current scene
  37699. */
  37700. unfreezeActiveMeshes(): Scene;
  37701. private _evaluateActiveMeshes;
  37702. private _activeMesh;
  37703. /**
  37704. * Update the transform matrix to update from the current active camera
  37705. * @param force defines a boolean used to force the update even if cache is up to date
  37706. */
  37707. updateTransformMatrix(force?: boolean): void;
  37708. private _bindFrameBuffer;
  37709. /** @hidden */
  37710. _allowPostProcessClearColor: boolean;
  37711. /** @hidden */
  37712. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37713. private _processSubCameras;
  37714. private _checkIntersections;
  37715. /** @hidden */
  37716. _advancePhysicsEngineStep(step: number): void;
  37717. /**
  37718. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37719. */
  37720. getDeterministicFrameTime: () => number;
  37721. /** @hidden */
  37722. _animate(): void;
  37723. /** Execute all animations (for a frame) */
  37724. animate(): void;
  37725. /**
  37726. * Render the scene
  37727. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37728. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37729. */
  37730. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37731. /**
  37732. * Freeze all materials
  37733. * A frozen material will not be updatable but should be faster to render
  37734. */
  37735. freezeMaterials(): void;
  37736. /**
  37737. * Unfreeze all materials
  37738. * A frozen material will not be updatable but should be faster to render
  37739. */
  37740. unfreezeMaterials(): void;
  37741. /**
  37742. * Releases all held ressources
  37743. */
  37744. dispose(): void;
  37745. /**
  37746. * Gets if the scene is already disposed
  37747. */
  37748. get isDisposed(): boolean;
  37749. /**
  37750. * Call this function to reduce memory footprint of the scene.
  37751. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37752. */
  37753. clearCachedVertexData(): void;
  37754. /**
  37755. * This function will remove the local cached buffer data from texture.
  37756. * It will save memory but will prevent the texture from being rebuilt
  37757. */
  37758. cleanCachedTextureBuffer(): void;
  37759. /**
  37760. * Get the world extend vectors with an optional filter
  37761. *
  37762. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37763. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37764. */
  37765. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37766. min: Vector3;
  37767. max: Vector3;
  37768. };
  37769. /**
  37770. * Creates a ray that can be used to pick in the scene
  37771. * @param x defines the x coordinate of the origin (on-screen)
  37772. * @param y defines the y coordinate of the origin (on-screen)
  37773. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37774. * @param camera defines the camera to use for the picking
  37775. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37776. * @returns a Ray
  37777. */
  37778. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37779. /**
  37780. * Creates a ray that can be used to pick in the scene
  37781. * @param x defines the x coordinate of the origin (on-screen)
  37782. * @param y defines the y coordinate of the origin (on-screen)
  37783. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37784. * @param result defines the ray where to store the picking ray
  37785. * @param camera defines the camera to use for the picking
  37786. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37787. * @returns the current scene
  37788. */
  37789. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37790. /**
  37791. * Creates a ray that can be used to pick in the scene
  37792. * @param x defines the x coordinate of the origin (on-screen)
  37793. * @param y defines the y coordinate of the origin (on-screen)
  37794. * @param camera defines the camera to use for the picking
  37795. * @returns a Ray
  37796. */
  37797. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37798. /**
  37799. * Creates a ray that can be used to pick in the scene
  37800. * @param x defines the x coordinate of the origin (on-screen)
  37801. * @param y defines the y coordinate of the origin (on-screen)
  37802. * @param result defines the ray where to store the picking ray
  37803. * @param camera defines the camera to use for the picking
  37804. * @returns the current scene
  37805. */
  37806. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37807. /** Launch a ray to try to pick a mesh in the scene
  37808. * @param x position on screen
  37809. * @param y position on screen
  37810. * @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
  37811. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37812. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37813. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37814. * @returns a PickingInfo
  37815. */
  37816. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37817. /** Use the given ray to pick a mesh in the scene
  37818. * @param ray The ray to use to pick meshes
  37819. * @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
  37820. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37821. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37822. * @returns a PickingInfo
  37823. */
  37824. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37825. /**
  37826. * Launch a ray to try to pick a mesh in the scene
  37827. * @param x X position on screen
  37828. * @param y Y position on screen
  37829. * @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
  37830. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37831. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37832. * @returns an array of PickingInfo
  37833. */
  37834. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37835. /**
  37836. * Launch a ray to try to pick a mesh in the scene
  37837. * @param ray Ray to use
  37838. * @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
  37839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37840. * @returns an array of PickingInfo
  37841. */
  37842. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37843. /**
  37844. * Force the value of meshUnderPointer
  37845. * @param mesh defines the mesh to use
  37846. */
  37847. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37848. /**
  37849. * Gets the mesh under the pointer
  37850. * @returns a Mesh or null if no mesh is under the pointer
  37851. */
  37852. getPointerOverMesh(): Nullable<AbstractMesh>;
  37853. /** @hidden */
  37854. _rebuildGeometries(): void;
  37855. /** @hidden */
  37856. _rebuildTextures(): void;
  37857. private _getByTags;
  37858. /**
  37859. * Get a list of meshes by tags
  37860. * @param tagsQuery defines the tags query to use
  37861. * @param forEach defines a predicate used to filter results
  37862. * @returns an array of Mesh
  37863. */
  37864. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37865. /**
  37866. * Get a list of cameras by tags
  37867. * @param tagsQuery defines the tags query to use
  37868. * @param forEach defines a predicate used to filter results
  37869. * @returns an array of Camera
  37870. */
  37871. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37872. /**
  37873. * Get a list of lights by tags
  37874. * @param tagsQuery defines the tags query to use
  37875. * @param forEach defines a predicate used to filter results
  37876. * @returns an array of Light
  37877. */
  37878. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37879. /**
  37880. * Get a list of materials by tags
  37881. * @param tagsQuery defines the tags query to use
  37882. * @param forEach defines a predicate used to filter results
  37883. * @returns an array of Material
  37884. */
  37885. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37886. /**
  37887. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37888. * This allowed control for front to back rendering or reversly depending of the special needs.
  37889. *
  37890. * @param renderingGroupId The rendering group id corresponding to its index
  37891. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37892. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37893. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37894. */
  37895. 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;
  37896. /**
  37897. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37898. *
  37899. * @param renderingGroupId The rendering group id corresponding to its index
  37900. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37901. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37902. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37903. */
  37904. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37905. /**
  37906. * Gets the current auto clear configuration for one rendering group of the rendering
  37907. * manager.
  37908. * @param index the rendering group index to get the information for
  37909. * @returns The auto clear setup for the requested rendering group
  37910. */
  37911. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37912. private _blockMaterialDirtyMechanism;
  37913. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37914. get blockMaterialDirtyMechanism(): boolean;
  37915. set blockMaterialDirtyMechanism(value: boolean);
  37916. /**
  37917. * Will flag all materials as dirty to trigger new shader compilation
  37918. * @param flag defines the flag used to specify which material part must be marked as dirty
  37919. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37920. */
  37921. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37922. /** @hidden */
  37923. _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;
  37924. /** @hidden */
  37925. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37926. /** @hidden */
  37927. _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;
  37928. /** @hidden */
  37929. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37930. /** @hidden */
  37931. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37932. /** @hidden */
  37933. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37934. }
  37935. }
  37936. declare module "babylonjs/assetContainer" {
  37937. import { AbstractScene } from "babylonjs/abstractScene";
  37938. import { Scene } from "babylonjs/scene";
  37939. import { Mesh } from "babylonjs/Meshes/mesh";
  37940. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37941. import { Skeleton } from "babylonjs/Bones/skeleton";
  37942. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37943. import { Animatable } from "babylonjs/Animations/animatable";
  37944. import { Nullable } from "babylonjs/types";
  37945. import { Node } from "babylonjs/node";
  37946. /**
  37947. * Set of assets to keep when moving a scene into an asset container.
  37948. */
  37949. export class KeepAssets extends AbstractScene {
  37950. }
  37951. /**
  37952. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37953. */
  37954. export class InstantiatedEntries {
  37955. /**
  37956. * List of new root nodes (eg. nodes with no parent)
  37957. */
  37958. rootNodes: TransformNode[];
  37959. /**
  37960. * List of new skeletons
  37961. */
  37962. skeletons: Skeleton[];
  37963. /**
  37964. * List of new animation groups
  37965. */
  37966. animationGroups: AnimationGroup[];
  37967. }
  37968. /**
  37969. * Container with a set of assets that can be added or removed from a scene.
  37970. */
  37971. export class AssetContainer extends AbstractScene {
  37972. /**
  37973. * The scene the AssetContainer belongs to.
  37974. */
  37975. scene: Scene;
  37976. /**
  37977. * Instantiates an AssetContainer.
  37978. * @param scene The scene the AssetContainer belongs to.
  37979. */
  37980. constructor(scene: Scene);
  37981. /**
  37982. * Instantiate or clone all meshes and add the new ones to the scene.
  37983. * Skeletons and animation groups will all be cloned
  37984. * @param nameFunction defines an optional function used to get new names for clones
  37985. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37986. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37987. */
  37988. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37989. /**
  37990. * Adds all the assets from the container to the scene.
  37991. */
  37992. addAllToScene(): void;
  37993. /**
  37994. * Removes all the assets in the container from the scene
  37995. */
  37996. removeAllFromScene(): void;
  37997. /**
  37998. * Disposes all the assets in the container
  37999. */
  38000. dispose(): void;
  38001. private _moveAssets;
  38002. /**
  38003. * Removes all the assets contained in the scene and adds them to the container.
  38004. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38005. */
  38006. moveAllFromScene(keepAssets?: KeepAssets): void;
  38007. /**
  38008. * 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.
  38009. * @returns the root mesh
  38010. */
  38011. createRootMesh(): Mesh;
  38012. /**
  38013. * Merge animations from this asset container into a scene
  38014. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38015. * @param animatables set of animatables to retarget to a node from the scene
  38016. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38017. */
  38018. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38019. }
  38020. }
  38021. declare module "babylonjs/abstractScene" {
  38022. import { Scene } from "babylonjs/scene";
  38023. import { Nullable } from "babylonjs/types";
  38024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38025. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38026. import { Geometry } from "babylonjs/Meshes/geometry";
  38027. import { Skeleton } from "babylonjs/Bones/skeleton";
  38028. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38029. import { AssetContainer } from "babylonjs/assetContainer";
  38030. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38031. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38033. import { Material } from "babylonjs/Materials/material";
  38034. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38035. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38036. import { Camera } from "babylonjs/Cameras/camera";
  38037. import { Light } from "babylonjs/Lights/light";
  38038. import { Node } from "babylonjs/node";
  38039. import { Animation } from "babylonjs/Animations/animation";
  38040. /**
  38041. * Defines how the parser contract is defined.
  38042. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38043. */
  38044. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38045. /**
  38046. * Defines how the individual parser contract is defined.
  38047. * These parser can parse an individual asset
  38048. */
  38049. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38050. /**
  38051. * Base class of the scene acting as a container for the different elements composing a scene.
  38052. * This class is dynamically extended by the different components of the scene increasing
  38053. * flexibility and reducing coupling
  38054. */
  38055. export abstract class AbstractScene {
  38056. /**
  38057. * Stores the list of available parsers in the application.
  38058. */
  38059. private static _BabylonFileParsers;
  38060. /**
  38061. * Stores the list of available individual parsers in the application.
  38062. */
  38063. private static _IndividualBabylonFileParsers;
  38064. /**
  38065. * Adds a parser in the list of available ones
  38066. * @param name Defines the name of the parser
  38067. * @param parser Defines the parser to add
  38068. */
  38069. static AddParser(name: string, parser: BabylonFileParser): void;
  38070. /**
  38071. * Gets a general parser from the list of avaialble ones
  38072. * @param name Defines the name of the parser
  38073. * @returns the requested parser or null
  38074. */
  38075. static GetParser(name: string): Nullable<BabylonFileParser>;
  38076. /**
  38077. * Adds n individual parser in the list of available ones
  38078. * @param name Defines the name of the parser
  38079. * @param parser Defines the parser to add
  38080. */
  38081. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38082. /**
  38083. * Gets an individual parser from the list of avaialble ones
  38084. * @param name Defines the name of the parser
  38085. * @returns the requested parser or null
  38086. */
  38087. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38088. /**
  38089. * Parser json data and populate both a scene and its associated container object
  38090. * @param jsonData Defines the data to parse
  38091. * @param scene Defines the scene to parse the data for
  38092. * @param container Defines the container attached to the parsing sequence
  38093. * @param rootUrl Defines the root url of the data
  38094. */
  38095. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38096. /**
  38097. * Gets the list of root nodes (ie. nodes with no parent)
  38098. */
  38099. rootNodes: Node[];
  38100. /** All of the cameras added to this scene
  38101. * @see http://doc.babylonjs.com/babylon101/cameras
  38102. */
  38103. cameras: Camera[];
  38104. /**
  38105. * All of the lights added to this scene
  38106. * @see http://doc.babylonjs.com/babylon101/lights
  38107. */
  38108. lights: Light[];
  38109. /**
  38110. * All of the (abstract) meshes added to this scene
  38111. */
  38112. meshes: AbstractMesh[];
  38113. /**
  38114. * The list of skeletons added to the scene
  38115. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38116. */
  38117. skeletons: Skeleton[];
  38118. /**
  38119. * All of the particle systems added to this scene
  38120. * @see http://doc.babylonjs.com/babylon101/particles
  38121. */
  38122. particleSystems: IParticleSystem[];
  38123. /**
  38124. * Gets a list of Animations associated with the scene
  38125. */
  38126. animations: Animation[];
  38127. /**
  38128. * All of the animation groups added to this scene
  38129. * @see http://doc.babylonjs.com/how_to/group
  38130. */
  38131. animationGroups: AnimationGroup[];
  38132. /**
  38133. * All of the multi-materials added to this scene
  38134. * @see http://doc.babylonjs.com/how_to/multi_materials
  38135. */
  38136. multiMaterials: MultiMaterial[];
  38137. /**
  38138. * All of the materials added to this scene
  38139. * In the context of a Scene, it is not supposed to be modified manually.
  38140. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38141. * Note also that the order of the Material within the array is not significant and might change.
  38142. * @see http://doc.babylonjs.com/babylon101/materials
  38143. */
  38144. materials: Material[];
  38145. /**
  38146. * The list of morph target managers added to the scene
  38147. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38148. */
  38149. morphTargetManagers: MorphTargetManager[];
  38150. /**
  38151. * The list of geometries used in the scene.
  38152. */
  38153. geometries: Geometry[];
  38154. /**
  38155. * All of the tranform nodes added to this scene
  38156. * In the context of a Scene, it is not supposed to be modified manually.
  38157. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38158. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38159. * @see http://doc.babylonjs.com/how_to/transformnode
  38160. */
  38161. transformNodes: TransformNode[];
  38162. /**
  38163. * ActionManagers available on the scene.
  38164. */
  38165. actionManagers: AbstractActionManager[];
  38166. /**
  38167. * Textures to keep.
  38168. */
  38169. textures: BaseTexture[];
  38170. /**
  38171. * Environment texture for the scene
  38172. */
  38173. environmentTexture: Nullable<BaseTexture>;
  38174. /**
  38175. * @returns all meshes, lights, cameras, transformNodes and bones
  38176. */
  38177. getNodes(): Array<Node>;
  38178. }
  38179. }
  38180. declare module "babylonjs/Audio/sound" {
  38181. import { Observable } from "babylonjs/Misc/observable";
  38182. import { Vector3 } from "babylonjs/Maths/math.vector";
  38183. import { Nullable } from "babylonjs/types";
  38184. import { Scene } from "babylonjs/scene";
  38185. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38186. /**
  38187. * Interface used to define options for Sound class
  38188. */
  38189. export interface ISoundOptions {
  38190. /**
  38191. * Does the sound autoplay once loaded.
  38192. */
  38193. autoplay?: boolean;
  38194. /**
  38195. * Does the sound loop after it finishes playing once.
  38196. */
  38197. loop?: boolean;
  38198. /**
  38199. * Sound's volume
  38200. */
  38201. volume?: number;
  38202. /**
  38203. * Is it a spatial sound?
  38204. */
  38205. spatialSound?: boolean;
  38206. /**
  38207. * Maximum distance to hear that sound
  38208. */
  38209. maxDistance?: number;
  38210. /**
  38211. * Uses user defined attenuation function
  38212. */
  38213. useCustomAttenuation?: boolean;
  38214. /**
  38215. * Define the roll off factor of spatial sounds.
  38216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38217. */
  38218. rolloffFactor?: number;
  38219. /**
  38220. * Define the reference distance the sound should be heard perfectly.
  38221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38222. */
  38223. refDistance?: number;
  38224. /**
  38225. * Define the distance attenuation model the sound will follow.
  38226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38227. */
  38228. distanceModel?: string;
  38229. /**
  38230. * Defines the playback speed (1 by default)
  38231. */
  38232. playbackRate?: number;
  38233. /**
  38234. * Defines if the sound is from a streaming source
  38235. */
  38236. streaming?: boolean;
  38237. /**
  38238. * Defines an optional length (in seconds) inside the sound file
  38239. */
  38240. length?: number;
  38241. /**
  38242. * Defines an optional offset (in seconds) inside the sound file
  38243. */
  38244. offset?: number;
  38245. /**
  38246. * If true, URLs will not be required to state the audio file codec to use.
  38247. */
  38248. skipCodecCheck?: boolean;
  38249. }
  38250. /**
  38251. * Defines a sound that can be played in the application.
  38252. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38254. */
  38255. export class Sound {
  38256. /**
  38257. * The name of the sound in the scene.
  38258. */
  38259. name: string;
  38260. /**
  38261. * Does the sound autoplay once loaded.
  38262. */
  38263. autoplay: boolean;
  38264. /**
  38265. * Does the sound loop after it finishes playing once.
  38266. */
  38267. loop: boolean;
  38268. /**
  38269. * Does the sound use a custom attenuation curve to simulate the falloff
  38270. * happening when the source gets further away from the camera.
  38271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38272. */
  38273. useCustomAttenuation: boolean;
  38274. /**
  38275. * The sound track id this sound belongs to.
  38276. */
  38277. soundTrackId: number;
  38278. /**
  38279. * Is this sound currently played.
  38280. */
  38281. isPlaying: boolean;
  38282. /**
  38283. * Is this sound currently paused.
  38284. */
  38285. isPaused: boolean;
  38286. /**
  38287. * Does this sound enables spatial sound.
  38288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38289. */
  38290. spatialSound: boolean;
  38291. /**
  38292. * Define the reference distance the sound should be heard perfectly.
  38293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38294. */
  38295. refDistance: number;
  38296. /**
  38297. * Define the roll off factor of spatial sounds.
  38298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38299. */
  38300. rolloffFactor: number;
  38301. /**
  38302. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38304. */
  38305. maxDistance: number;
  38306. /**
  38307. * Define the distance attenuation model the sound will follow.
  38308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38309. */
  38310. distanceModel: string;
  38311. /**
  38312. * @hidden
  38313. * Back Compat
  38314. **/
  38315. onended: () => any;
  38316. /**
  38317. * Observable event when the current playing sound finishes.
  38318. */
  38319. onEndedObservable: Observable<Sound>;
  38320. private _panningModel;
  38321. private _playbackRate;
  38322. private _streaming;
  38323. private _startTime;
  38324. private _startOffset;
  38325. private _position;
  38326. /** @hidden */
  38327. _positionInEmitterSpace: boolean;
  38328. private _localDirection;
  38329. private _volume;
  38330. private _isReadyToPlay;
  38331. private _isDirectional;
  38332. private _readyToPlayCallback;
  38333. private _audioBuffer;
  38334. private _soundSource;
  38335. private _streamingSource;
  38336. private _soundPanner;
  38337. private _soundGain;
  38338. private _inputAudioNode;
  38339. private _outputAudioNode;
  38340. private _coneInnerAngle;
  38341. private _coneOuterAngle;
  38342. private _coneOuterGain;
  38343. private _scene;
  38344. private _connectedTransformNode;
  38345. private _customAttenuationFunction;
  38346. private _registerFunc;
  38347. private _isOutputConnected;
  38348. private _htmlAudioElement;
  38349. private _urlType;
  38350. private _length?;
  38351. private _offset?;
  38352. /** @hidden */
  38353. static _SceneComponentInitialization: (scene: Scene) => void;
  38354. /**
  38355. * Create a sound and attach it to a scene
  38356. * @param name Name of your sound
  38357. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38358. * @param scene defines the scene the sound belongs to
  38359. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38360. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38361. */
  38362. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38363. /**
  38364. * Release the sound and its associated resources
  38365. */
  38366. dispose(): void;
  38367. /**
  38368. * Gets if the sounds is ready to be played or not.
  38369. * @returns true if ready, otherwise false
  38370. */
  38371. isReady(): boolean;
  38372. private _soundLoaded;
  38373. /**
  38374. * Sets the data of the sound from an audiobuffer
  38375. * @param audioBuffer The audioBuffer containing the data
  38376. */
  38377. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38378. /**
  38379. * Updates the current sounds options such as maxdistance, loop...
  38380. * @param options A JSON object containing values named as the object properties
  38381. */
  38382. updateOptions(options: ISoundOptions): void;
  38383. private _createSpatialParameters;
  38384. private _updateSpatialParameters;
  38385. /**
  38386. * Switch the panning model to HRTF:
  38387. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38389. */
  38390. switchPanningModelToHRTF(): void;
  38391. /**
  38392. * Switch the panning model to Equal Power:
  38393. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38395. */
  38396. switchPanningModelToEqualPower(): void;
  38397. private _switchPanningModel;
  38398. /**
  38399. * Connect this sound to a sound track audio node like gain...
  38400. * @param soundTrackAudioNode the sound track audio node to connect to
  38401. */
  38402. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38403. /**
  38404. * Transform this sound into a directional source
  38405. * @param coneInnerAngle Size of the inner cone in degree
  38406. * @param coneOuterAngle Size of the outer cone in degree
  38407. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38408. */
  38409. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38410. /**
  38411. * Gets or sets the inner angle for the directional cone.
  38412. */
  38413. get directionalConeInnerAngle(): number;
  38414. /**
  38415. * Gets or sets the inner angle for the directional cone.
  38416. */
  38417. set directionalConeInnerAngle(value: number);
  38418. /**
  38419. * Gets or sets the outer angle for the directional cone.
  38420. */
  38421. get directionalConeOuterAngle(): number;
  38422. /**
  38423. * Gets or sets the outer angle for the directional cone.
  38424. */
  38425. set directionalConeOuterAngle(value: number);
  38426. /**
  38427. * Sets the position of the emitter if spatial sound is enabled
  38428. * @param newPosition Defines the new posisiton
  38429. */
  38430. setPosition(newPosition: Vector3): void;
  38431. /**
  38432. * Sets the local direction of the emitter if spatial sound is enabled
  38433. * @param newLocalDirection Defines the new local direction
  38434. */
  38435. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38436. private _updateDirection;
  38437. /** @hidden */
  38438. updateDistanceFromListener(): void;
  38439. /**
  38440. * Sets a new custom attenuation function for the sound.
  38441. * @param callback Defines the function used for the attenuation
  38442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38443. */
  38444. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38445. /**
  38446. * Play the sound
  38447. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38448. * @param offset (optional) Start the sound at a specific time in seconds
  38449. * @param length (optional) Sound duration (in seconds)
  38450. */
  38451. play(time?: number, offset?: number, length?: number): void;
  38452. private _onended;
  38453. /**
  38454. * Stop the sound
  38455. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38456. */
  38457. stop(time?: number): void;
  38458. /**
  38459. * Put the sound in pause
  38460. */
  38461. pause(): void;
  38462. /**
  38463. * Sets a dedicated volume for this sounds
  38464. * @param newVolume Define the new volume of the sound
  38465. * @param time Define time for gradual change to new volume
  38466. */
  38467. setVolume(newVolume: number, time?: number): void;
  38468. /**
  38469. * Set the sound play back rate
  38470. * @param newPlaybackRate Define the playback rate the sound should be played at
  38471. */
  38472. setPlaybackRate(newPlaybackRate: number): void;
  38473. /**
  38474. * Gets the volume of the sound.
  38475. * @returns the volume of the sound
  38476. */
  38477. getVolume(): number;
  38478. /**
  38479. * Attach the sound to a dedicated mesh
  38480. * @param transformNode The transform node to connect the sound with
  38481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38482. */
  38483. attachToMesh(transformNode: TransformNode): void;
  38484. /**
  38485. * Detach the sound from the previously attached mesh
  38486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38487. */
  38488. detachFromMesh(): void;
  38489. private _onRegisterAfterWorldMatrixUpdate;
  38490. /**
  38491. * Clone the current sound in the scene.
  38492. * @returns the new sound clone
  38493. */
  38494. clone(): Nullable<Sound>;
  38495. /**
  38496. * Gets the current underlying audio buffer containing the data
  38497. * @returns the audio buffer
  38498. */
  38499. getAudioBuffer(): Nullable<AudioBuffer>;
  38500. /**
  38501. * Serializes the Sound in a JSON representation
  38502. * @returns the JSON representation of the sound
  38503. */
  38504. serialize(): any;
  38505. /**
  38506. * Parse a JSON representation of a sound to innstantiate in a given scene
  38507. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38508. * @param scene Define the scene the new parsed sound should be created in
  38509. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38510. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38511. * @returns the newly parsed sound
  38512. */
  38513. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38514. }
  38515. }
  38516. declare module "babylonjs/Actions/directAudioActions" {
  38517. import { Action } from "babylonjs/Actions/action";
  38518. import { Condition } from "babylonjs/Actions/condition";
  38519. import { Sound } from "babylonjs/Audio/sound";
  38520. /**
  38521. * This defines an action helpful to play a defined sound on a triggered action.
  38522. */
  38523. export class PlaySoundAction extends Action {
  38524. private _sound;
  38525. /**
  38526. * Instantiate the action
  38527. * @param triggerOptions defines the trigger options
  38528. * @param sound defines the sound to play
  38529. * @param condition defines the trigger related conditions
  38530. */
  38531. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38532. /** @hidden */
  38533. _prepare(): void;
  38534. /**
  38535. * Execute the action and play the sound.
  38536. */
  38537. execute(): void;
  38538. /**
  38539. * Serializes the actions and its related information.
  38540. * @param parent defines the object to serialize in
  38541. * @returns the serialized object
  38542. */
  38543. serialize(parent: any): any;
  38544. }
  38545. /**
  38546. * This defines an action helpful to stop a defined sound on a triggered action.
  38547. */
  38548. export class StopSoundAction extends Action {
  38549. private _sound;
  38550. /**
  38551. * Instantiate the action
  38552. * @param triggerOptions defines the trigger options
  38553. * @param sound defines the sound to stop
  38554. * @param condition defines the trigger related conditions
  38555. */
  38556. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38557. /** @hidden */
  38558. _prepare(): void;
  38559. /**
  38560. * Execute the action and stop the sound.
  38561. */
  38562. execute(): void;
  38563. /**
  38564. * Serializes the actions and its related information.
  38565. * @param parent defines the object to serialize in
  38566. * @returns the serialized object
  38567. */
  38568. serialize(parent: any): any;
  38569. }
  38570. }
  38571. declare module "babylonjs/Actions/interpolateValueAction" {
  38572. import { Action } from "babylonjs/Actions/action";
  38573. import { Condition } from "babylonjs/Actions/condition";
  38574. import { Observable } from "babylonjs/Misc/observable";
  38575. /**
  38576. * This defines an action responsible to change the value of a property
  38577. * by interpolating between its current value and the newly set one once triggered.
  38578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38579. */
  38580. export class InterpolateValueAction extends Action {
  38581. /**
  38582. * Defines the path of the property where the value should be interpolated
  38583. */
  38584. propertyPath: string;
  38585. /**
  38586. * Defines the target value at the end of the interpolation.
  38587. */
  38588. value: any;
  38589. /**
  38590. * Defines the time it will take for the property to interpolate to the value.
  38591. */
  38592. duration: number;
  38593. /**
  38594. * Defines if the other scene animations should be stopped when the action has been triggered
  38595. */
  38596. stopOtherAnimations?: boolean;
  38597. /**
  38598. * Defines a callback raised once the interpolation animation has been done.
  38599. */
  38600. onInterpolationDone?: () => void;
  38601. /**
  38602. * Observable triggered once the interpolation animation has been done.
  38603. */
  38604. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38605. private _target;
  38606. private _effectiveTarget;
  38607. private _property;
  38608. /**
  38609. * Instantiate the action
  38610. * @param triggerOptions defines the trigger options
  38611. * @param target defines the object containing the value to interpolate
  38612. * @param propertyPath defines the path to the property in the target object
  38613. * @param value defines the target value at the end of the interpolation
  38614. * @param duration deines the time it will take for the property to interpolate to the value.
  38615. * @param condition defines the trigger related conditions
  38616. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38617. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38618. */
  38619. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38620. /** @hidden */
  38621. _prepare(): void;
  38622. /**
  38623. * Execute the action starts the value interpolation.
  38624. */
  38625. execute(): void;
  38626. /**
  38627. * Serializes the actions and its related information.
  38628. * @param parent defines the object to serialize in
  38629. * @returns the serialized object
  38630. */
  38631. serialize(parent: any): any;
  38632. }
  38633. }
  38634. declare module "babylonjs/Actions/index" {
  38635. export * from "babylonjs/Actions/abstractActionManager";
  38636. export * from "babylonjs/Actions/action";
  38637. export * from "babylonjs/Actions/actionEvent";
  38638. export * from "babylonjs/Actions/actionManager";
  38639. export * from "babylonjs/Actions/condition";
  38640. export * from "babylonjs/Actions/directActions";
  38641. export * from "babylonjs/Actions/directAudioActions";
  38642. export * from "babylonjs/Actions/interpolateValueAction";
  38643. }
  38644. declare module "babylonjs/Animations/index" {
  38645. export * from "babylonjs/Animations/animatable";
  38646. export * from "babylonjs/Animations/animation";
  38647. export * from "babylonjs/Animations/animationGroup";
  38648. export * from "babylonjs/Animations/animationPropertiesOverride";
  38649. export * from "babylonjs/Animations/easing";
  38650. export * from "babylonjs/Animations/runtimeAnimation";
  38651. export * from "babylonjs/Animations/animationEvent";
  38652. export * from "babylonjs/Animations/animationGroup";
  38653. export * from "babylonjs/Animations/animationKey";
  38654. export * from "babylonjs/Animations/animationRange";
  38655. export * from "babylonjs/Animations/animatable.interface";
  38656. }
  38657. declare module "babylonjs/Audio/soundTrack" {
  38658. import { Sound } from "babylonjs/Audio/sound";
  38659. import { Analyser } from "babylonjs/Audio/analyser";
  38660. import { Scene } from "babylonjs/scene";
  38661. /**
  38662. * Options allowed during the creation of a sound track.
  38663. */
  38664. export interface ISoundTrackOptions {
  38665. /**
  38666. * The volume the sound track should take during creation
  38667. */
  38668. volume?: number;
  38669. /**
  38670. * Define if the sound track is the main sound track of the scene
  38671. */
  38672. mainTrack?: boolean;
  38673. }
  38674. /**
  38675. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38676. * It will be also used in a future release to apply effects on a specific track.
  38677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38678. */
  38679. export class SoundTrack {
  38680. /**
  38681. * The unique identifier of the sound track in the scene.
  38682. */
  38683. id: number;
  38684. /**
  38685. * The list of sounds included in the sound track.
  38686. */
  38687. soundCollection: Array<Sound>;
  38688. private _outputAudioNode;
  38689. private _scene;
  38690. private _connectedAnalyser;
  38691. private _options;
  38692. private _isInitialized;
  38693. /**
  38694. * Creates a new sound track.
  38695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38696. * @param scene Define the scene the sound track belongs to
  38697. * @param options
  38698. */
  38699. constructor(scene: Scene, options?: ISoundTrackOptions);
  38700. private _initializeSoundTrackAudioGraph;
  38701. /**
  38702. * Release the sound track and its associated resources
  38703. */
  38704. dispose(): void;
  38705. /**
  38706. * Adds a sound to this sound track
  38707. * @param sound define the cound to add
  38708. * @ignoreNaming
  38709. */
  38710. AddSound(sound: Sound): void;
  38711. /**
  38712. * Removes a sound to this sound track
  38713. * @param sound define the cound to remove
  38714. * @ignoreNaming
  38715. */
  38716. RemoveSound(sound: Sound): void;
  38717. /**
  38718. * Set a global volume for the full sound track.
  38719. * @param newVolume Define the new volume of the sound track
  38720. */
  38721. setVolume(newVolume: number): void;
  38722. /**
  38723. * Switch the panning model to HRTF:
  38724. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38726. */
  38727. switchPanningModelToHRTF(): void;
  38728. /**
  38729. * Switch the panning model to Equal Power:
  38730. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38732. */
  38733. switchPanningModelToEqualPower(): void;
  38734. /**
  38735. * Connect the sound track to an audio analyser allowing some amazing
  38736. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38738. * @param analyser The analyser to connect to the engine
  38739. */
  38740. connectToAnalyser(analyser: Analyser): void;
  38741. }
  38742. }
  38743. declare module "babylonjs/Audio/audioSceneComponent" {
  38744. import { Sound } from "babylonjs/Audio/sound";
  38745. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38746. import { Nullable } from "babylonjs/types";
  38747. import { Vector3 } from "babylonjs/Maths/math.vector";
  38748. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38749. import { Scene } from "babylonjs/scene";
  38750. import { AbstractScene } from "babylonjs/abstractScene";
  38751. import "babylonjs/Audio/audioEngine";
  38752. module "babylonjs/abstractScene" {
  38753. interface AbstractScene {
  38754. /**
  38755. * The list of sounds used in the scene.
  38756. */
  38757. sounds: Nullable<Array<Sound>>;
  38758. }
  38759. }
  38760. module "babylonjs/scene" {
  38761. interface Scene {
  38762. /**
  38763. * @hidden
  38764. * Backing field
  38765. */
  38766. _mainSoundTrack: SoundTrack;
  38767. /**
  38768. * The main sound track played by the scene.
  38769. * It cotains your primary collection of sounds.
  38770. */
  38771. mainSoundTrack: SoundTrack;
  38772. /**
  38773. * The list of sound tracks added to the scene
  38774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38775. */
  38776. soundTracks: Nullable<Array<SoundTrack>>;
  38777. /**
  38778. * Gets a sound using a given name
  38779. * @param name defines the name to search for
  38780. * @return the found sound or null if not found at all.
  38781. */
  38782. getSoundByName(name: string): Nullable<Sound>;
  38783. /**
  38784. * Gets or sets if audio support is enabled
  38785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38786. */
  38787. audioEnabled: boolean;
  38788. /**
  38789. * Gets or sets if audio will be output to headphones
  38790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38791. */
  38792. headphone: boolean;
  38793. /**
  38794. * Gets or sets custom audio listener position provider
  38795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38796. */
  38797. audioListenerPositionProvider: Nullable<() => Vector3>;
  38798. /**
  38799. * Gets or sets a refresh rate when using 3D audio positioning
  38800. */
  38801. audioPositioningRefreshRate: number;
  38802. }
  38803. }
  38804. /**
  38805. * Defines the sound scene component responsible to manage any sounds
  38806. * in a given scene.
  38807. */
  38808. export class AudioSceneComponent implements ISceneSerializableComponent {
  38809. /**
  38810. * The component name helpfull to identify the component in the list of scene components.
  38811. */
  38812. readonly name: string;
  38813. /**
  38814. * The scene the component belongs to.
  38815. */
  38816. scene: Scene;
  38817. private _audioEnabled;
  38818. /**
  38819. * Gets whether audio is enabled or not.
  38820. * Please use related enable/disable method to switch state.
  38821. */
  38822. get audioEnabled(): boolean;
  38823. private _headphone;
  38824. /**
  38825. * Gets whether audio is outputing to headphone or not.
  38826. * Please use the according Switch methods to change output.
  38827. */
  38828. get headphone(): boolean;
  38829. /**
  38830. * Gets or sets a refresh rate when using 3D audio positioning
  38831. */
  38832. audioPositioningRefreshRate: number;
  38833. private _audioListenerPositionProvider;
  38834. /**
  38835. * Gets the current audio listener position provider
  38836. */
  38837. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38838. /**
  38839. * Sets a custom listener position for all sounds in the scene
  38840. * By default, this is the position of the first active camera
  38841. */
  38842. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38843. /**
  38844. * Creates a new instance of the component for the given scene
  38845. * @param scene Defines the scene to register the component in
  38846. */
  38847. constructor(scene: Scene);
  38848. /**
  38849. * Registers the component in a given scene
  38850. */
  38851. register(): void;
  38852. /**
  38853. * Rebuilds the elements related to this component in case of
  38854. * context lost for instance.
  38855. */
  38856. rebuild(): void;
  38857. /**
  38858. * Serializes the component data to the specified json object
  38859. * @param serializationObject The object to serialize to
  38860. */
  38861. serialize(serializationObject: any): void;
  38862. /**
  38863. * Adds all the elements from the container to the scene
  38864. * @param container the container holding the elements
  38865. */
  38866. addFromContainer(container: AbstractScene): void;
  38867. /**
  38868. * Removes all the elements in the container from the scene
  38869. * @param container contains the elements to remove
  38870. * @param dispose if the removed element should be disposed (default: false)
  38871. */
  38872. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38873. /**
  38874. * Disposes the component and the associated ressources.
  38875. */
  38876. dispose(): void;
  38877. /**
  38878. * Disables audio in the associated scene.
  38879. */
  38880. disableAudio(): void;
  38881. /**
  38882. * Enables audio in the associated scene.
  38883. */
  38884. enableAudio(): void;
  38885. /**
  38886. * Switch audio to headphone output.
  38887. */
  38888. switchAudioModeForHeadphones(): void;
  38889. /**
  38890. * Switch audio to normal speakers.
  38891. */
  38892. switchAudioModeForNormalSpeakers(): void;
  38893. private _cachedCameraDirection;
  38894. private _cachedCameraPosition;
  38895. private _lastCheck;
  38896. private _afterRender;
  38897. }
  38898. }
  38899. declare module "babylonjs/Audio/weightedsound" {
  38900. import { Sound } from "babylonjs/Audio/sound";
  38901. /**
  38902. * Wraps one or more Sound objects and selects one with random weight for playback.
  38903. */
  38904. export class WeightedSound {
  38905. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38906. loop: boolean;
  38907. private _coneInnerAngle;
  38908. private _coneOuterAngle;
  38909. private _volume;
  38910. /** A Sound is currently playing. */
  38911. isPlaying: boolean;
  38912. /** A Sound is currently paused. */
  38913. isPaused: boolean;
  38914. private _sounds;
  38915. private _weights;
  38916. private _currentIndex?;
  38917. /**
  38918. * Creates a new WeightedSound from the list of sounds given.
  38919. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38920. * @param sounds Array of Sounds that will be selected from.
  38921. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38922. */
  38923. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38924. /**
  38925. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38926. */
  38927. get directionalConeInnerAngle(): number;
  38928. /**
  38929. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38930. */
  38931. set directionalConeInnerAngle(value: number);
  38932. /**
  38933. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38934. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38935. */
  38936. get directionalConeOuterAngle(): number;
  38937. /**
  38938. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38939. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38940. */
  38941. set directionalConeOuterAngle(value: number);
  38942. /**
  38943. * Playback volume.
  38944. */
  38945. get volume(): number;
  38946. /**
  38947. * Playback volume.
  38948. */
  38949. set volume(value: number);
  38950. private _onended;
  38951. /**
  38952. * Suspend playback
  38953. */
  38954. pause(): void;
  38955. /**
  38956. * Stop playback
  38957. */
  38958. stop(): void;
  38959. /**
  38960. * Start playback.
  38961. * @param startOffset Position the clip head at a specific time in seconds.
  38962. */
  38963. play(startOffset?: number): void;
  38964. }
  38965. }
  38966. declare module "babylonjs/Audio/index" {
  38967. export * from "babylonjs/Audio/analyser";
  38968. export * from "babylonjs/Audio/audioEngine";
  38969. export * from "babylonjs/Audio/audioSceneComponent";
  38970. export * from "babylonjs/Audio/sound";
  38971. export * from "babylonjs/Audio/soundTrack";
  38972. export * from "babylonjs/Audio/weightedsound";
  38973. }
  38974. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38975. import { Behavior } from "babylonjs/Behaviors/behavior";
  38976. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38977. import { BackEase } from "babylonjs/Animations/easing";
  38978. /**
  38979. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38980. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38981. */
  38982. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38983. /**
  38984. * Gets the name of the behavior.
  38985. */
  38986. get name(): string;
  38987. /**
  38988. * The easing function used by animations
  38989. */
  38990. static EasingFunction: BackEase;
  38991. /**
  38992. * The easing mode used by animations
  38993. */
  38994. static EasingMode: number;
  38995. /**
  38996. * The duration of the animation, in milliseconds
  38997. */
  38998. transitionDuration: number;
  38999. /**
  39000. * Length of the distance animated by the transition when lower radius is reached
  39001. */
  39002. lowerRadiusTransitionRange: number;
  39003. /**
  39004. * Length of the distance animated by the transition when upper radius is reached
  39005. */
  39006. upperRadiusTransitionRange: number;
  39007. private _autoTransitionRange;
  39008. /**
  39009. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39010. */
  39011. get autoTransitionRange(): boolean;
  39012. /**
  39013. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39014. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39015. */
  39016. set autoTransitionRange(value: boolean);
  39017. private _attachedCamera;
  39018. private _onAfterCheckInputsObserver;
  39019. private _onMeshTargetChangedObserver;
  39020. /**
  39021. * Initializes the behavior.
  39022. */
  39023. init(): void;
  39024. /**
  39025. * Attaches the behavior to its arc rotate camera.
  39026. * @param camera Defines the camera to attach the behavior to
  39027. */
  39028. attach(camera: ArcRotateCamera): void;
  39029. /**
  39030. * Detaches the behavior from its current arc rotate camera.
  39031. */
  39032. detach(): void;
  39033. private _radiusIsAnimating;
  39034. private _radiusBounceTransition;
  39035. private _animatables;
  39036. private _cachedWheelPrecision;
  39037. /**
  39038. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39039. * @param radiusLimit The limit to check against.
  39040. * @return Bool to indicate if at limit.
  39041. */
  39042. private _isRadiusAtLimit;
  39043. /**
  39044. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39045. * @param radiusDelta The delta by which to animate to. Can be negative.
  39046. */
  39047. private _applyBoundRadiusAnimation;
  39048. /**
  39049. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39050. */
  39051. protected _clearAnimationLocks(): void;
  39052. /**
  39053. * Stops and removes all animations that have been applied to the camera
  39054. */
  39055. stopAllAnimations(): void;
  39056. }
  39057. }
  39058. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39059. import { Behavior } from "babylonjs/Behaviors/behavior";
  39060. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39061. import { ExponentialEase } from "babylonjs/Animations/easing";
  39062. import { Nullable } from "babylonjs/types";
  39063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39064. import { Vector3 } from "babylonjs/Maths/math.vector";
  39065. /**
  39066. * 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.
  39067. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39068. */
  39069. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39070. /**
  39071. * Gets the name of the behavior.
  39072. */
  39073. get name(): string;
  39074. private _mode;
  39075. private _radiusScale;
  39076. private _positionScale;
  39077. private _defaultElevation;
  39078. private _elevationReturnTime;
  39079. private _elevationReturnWaitTime;
  39080. private _zoomStopsAnimation;
  39081. private _framingTime;
  39082. /**
  39083. * The easing function used by animations
  39084. */
  39085. static EasingFunction: ExponentialEase;
  39086. /**
  39087. * The easing mode used by animations
  39088. */
  39089. static EasingMode: number;
  39090. /**
  39091. * Sets the current mode used by the behavior
  39092. */
  39093. set mode(mode: number);
  39094. /**
  39095. * Gets current mode used by the behavior.
  39096. */
  39097. get mode(): number;
  39098. /**
  39099. * Sets the scale applied to the radius (1 by default)
  39100. */
  39101. set radiusScale(radius: number);
  39102. /**
  39103. * Gets the scale applied to the radius
  39104. */
  39105. get radiusScale(): number;
  39106. /**
  39107. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39108. */
  39109. set positionScale(scale: number);
  39110. /**
  39111. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39112. */
  39113. get positionScale(): number;
  39114. /**
  39115. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39116. * behaviour is triggered, in radians.
  39117. */
  39118. set defaultElevation(elevation: number);
  39119. /**
  39120. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39121. * behaviour is triggered, in radians.
  39122. */
  39123. get defaultElevation(): number;
  39124. /**
  39125. * Sets the time (in milliseconds) taken to return to the default beta position.
  39126. * Negative value indicates camera should not return to default.
  39127. */
  39128. set elevationReturnTime(speed: number);
  39129. /**
  39130. * Gets the time (in milliseconds) taken to return to the default beta position.
  39131. * Negative value indicates camera should not return to default.
  39132. */
  39133. get elevationReturnTime(): number;
  39134. /**
  39135. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39136. */
  39137. set elevationReturnWaitTime(time: number);
  39138. /**
  39139. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39140. */
  39141. get elevationReturnWaitTime(): number;
  39142. /**
  39143. * Sets the flag that indicates if user zooming should stop animation.
  39144. */
  39145. set zoomStopsAnimation(flag: boolean);
  39146. /**
  39147. * Gets the flag that indicates if user zooming should stop animation.
  39148. */
  39149. get zoomStopsAnimation(): boolean;
  39150. /**
  39151. * Sets the transition time when framing the mesh, in milliseconds
  39152. */
  39153. set framingTime(time: number);
  39154. /**
  39155. * Gets the transition time when framing the mesh, in milliseconds
  39156. */
  39157. get framingTime(): number;
  39158. /**
  39159. * Define if the behavior should automatically change the configured
  39160. * camera limits and sensibilities.
  39161. */
  39162. autoCorrectCameraLimitsAndSensibility: boolean;
  39163. private _onPrePointerObservableObserver;
  39164. private _onAfterCheckInputsObserver;
  39165. private _onMeshTargetChangedObserver;
  39166. private _attachedCamera;
  39167. private _isPointerDown;
  39168. private _lastInteractionTime;
  39169. /**
  39170. * Initializes the behavior.
  39171. */
  39172. init(): void;
  39173. /**
  39174. * Attaches the behavior to its arc rotate camera.
  39175. * @param camera Defines the camera to attach the behavior to
  39176. */
  39177. attach(camera: ArcRotateCamera): void;
  39178. /**
  39179. * Detaches the behavior from its current arc rotate camera.
  39180. */
  39181. detach(): void;
  39182. private _animatables;
  39183. private _betaIsAnimating;
  39184. private _betaTransition;
  39185. private _radiusTransition;
  39186. private _vectorTransition;
  39187. /**
  39188. * Targets the given mesh and updates zoom level accordingly.
  39189. * @param mesh The mesh to target.
  39190. * @param radius Optional. If a cached radius position already exists, overrides default.
  39191. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39192. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39193. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39194. */
  39195. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39196. /**
  39197. * Targets the given mesh with its children and updates zoom level accordingly.
  39198. * @param mesh The mesh to target.
  39199. * @param radius Optional. If a cached radius position already exists, overrides default.
  39200. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39201. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39202. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39203. */
  39204. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39205. /**
  39206. * Targets the given meshes with their children and updates zoom level accordingly.
  39207. * @param meshes The mesh to target.
  39208. * @param radius Optional. If a cached radius position already exists, overrides default.
  39209. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39210. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39211. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39212. */
  39213. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39214. /**
  39215. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39216. * @param minimumWorld Determines the smaller position of the bounding box extend
  39217. * @param maximumWorld Determines the bigger position of the bounding box extend
  39218. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39219. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39220. */
  39221. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39222. /**
  39223. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39224. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39225. * frustum width.
  39226. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39227. * to fully enclose the mesh in the viewing frustum.
  39228. */
  39229. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39230. /**
  39231. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39232. * is automatically returned to its default position (expected to be above ground plane).
  39233. */
  39234. private _maintainCameraAboveGround;
  39235. /**
  39236. * Returns the frustum slope based on the canvas ratio and camera FOV
  39237. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39238. */
  39239. private _getFrustumSlope;
  39240. /**
  39241. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39242. */
  39243. private _clearAnimationLocks;
  39244. /**
  39245. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39246. */
  39247. private _applyUserInteraction;
  39248. /**
  39249. * Stops and removes all animations that have been applied to the camera
  39250. */
  39251. stopAllAnimations(): void;
  39252. /**
  39253. * Gets a value indicating if the user is moving the camera
  39254. */
  39255. get isUserIsMoving(): boolean;
  39256. /**
  39257. * The camera can move all the way towards the mesh.
  39258. */
  39259. static IgnoreBoundsSizeMode: number;
  39260. /**
  39261. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39262. */
  39263. static FitFrustumSidesMode: number;
  39264. }
  39265. }
  39266. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39267. import { Nullable } from "babylonjs/types";
  39268. import { Camera } from "babylonjs/Cameras/camera";
  39269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39270. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39271. /**
  39272. * Base class for Camera Pointer Inputs.
  39273. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39274. * for example usage.
  39275. */
  39276. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39277. /**
  39278. * Defines the camera the input is attached to.
  39279. */
  39280. abstract camera: Camera;
  39281. /**
  39282. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39283. */
  39284. protected _altKey: boolean;
  39285. protected _ctrlKey: boolean;
  39286. protected _metaKey: boolean;
  39287. protected _shiftKey: boolean;
  39288. /**
  39289. * Which mouse buttons were pressed at time of last mouse event.
  39290. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39291. */
  39292. protected _buttonsPressed: number;
  39293. /**
  39294. * Defines the buttons associated with the input to handle camera move.
  39295. */
  39296. buttons: number[];
  39297. /**
  39298. * Attach the input controls to a specific dom element to get the input from.
  39299. * @param element Defines the element the controls should be listened from
  39300. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39301. */
  39302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39303. /**
  39304. * Detach the current controls from the specified dom element.
  39305. * @param element Defines the element to stop listening the inputs from
  39306. */
  39307. detachControl(element: Nullable<HTMLElement>): void;
  39308. /**
  39309. * Gets the class name of the current input.
  39310. * @returns the class name
  39311. */
  39312. getClassName(): string;
  39313. /**
  39314. * Get the friendly name associated with the input class.
  39315. * @returns the input friendly name
  39316. */
  39317. getSimpleName(): string;
  39318. /**
  39319. * Called on pointer POINTERDOUBLETAP event.
  39320. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39321. */
  39322. protected onDoubleTap(type: string): void;
  39323. /**
  39324. * Called on pointer POINTERMOVE event if only a single touch is active.
  39325. * Override this method to provide functionality.
  39326. */
  39327. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39328. /**
  39329. * Called on pointer POINTERMOVE event if multiple touches are active.
  39330. * Override this method to provide functionality.
  39331. */
  39332. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39333. /**
  39334. * Called on JS contextmenu event.
  39335. * Override this method to provide functionality.
  39336. */
  39337. protected onContextMenu(evt: PointerEvent): void;
  39338. /**
  39339. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39340. * press.
  39341. * Override this method to provide functionality.
  39342. */
  39343. protected onButtonDown(evt: PointerEvent): void;
  39344. /**
  39345. * Called each time a new POINTERUP event occurs. Ie, for each button
  39346. * release.
  39347. * Override this method to provide functionality.
  39348. */
  39349. protected onButtonUp(evt: PointerEvent): void;
  39350. /**
  39351. * Called when window becomes inactive.
  39352. * Override this method to provide functionality.
  39353. */
  39354. protected onLostFocus(): void;
  39355. private _pointerInput;
  39356. private _observer;
  39357. private _onLostFocus;
  39358. private pointA;
  39359. private pointB;
  39360. }
  39361. }
  39362. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39363. import { Nullable } from "babylonjs/types";
  39364. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39365. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39366. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39367. /**
  39368. * Manage the pointers inputs to control an arc rotate camera.
  39369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39370. */
  39371. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39372. /**
  39373. * Defines the camera the input is attached to.
  39374. */
  39375. camera: ArcRotateCamera;
  39376. /**
  39377. * Gets the class name of the current input.
  39378. * @returns the class name
  39379. */
  39380. getClassName(): string;
  39381. /**
  39382. * Defines the buttons associated with the input to handle camera move.
  39383. */
  39384. buttons: number[];
  39385. /**
  39386. * Defines the pointer angular sensibility along the X axis or how fast is
  39387. * the camera rotating.
  39388. */
  39389. angularSensibilityX: number;
  39390. /**
  39391. * Defines the pointer angular sensibility along the Y axis or how fast is
  39392. * the camera rotating.
  39393. */
  39394. angularSensibilityY: number;
  39395. /**
  39396. * Defines the pointer pinch precision or how fast is the camera zooming.
  39397. */
  39398. pinchPrecision: number;
  39399. /**
  39400. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39401. * from 0.
  39402. * It defines the percentage of current camera.radius to use as delta when
  39403. * pinch zoom is used.
  39404. */
  39405. pinchDeltaPercentage: number;
  39406. /**
  39407. * Defines the pointer panning sensibility or how fast is the camera moving.
  39408. */
  39409. panningSensibility: number;
  39410. /**
  39411. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39412. */
  39413. multiTouchPanning: boolean;
  39414. /**
  39415. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39416. * zoom (pinch) through multitouch.
  39417. */
  39418. multiTouchPanAndZoom: boolean;
  39419. /**
  39420. * Revers pinch action direction.
  39421. */
  39422. pinchInwards: boolean;
  39423. private _isPanClick;
  39424. private _twoFingerActivityCount;
  39425. private _isPinching;
  39426. /**
  39427. * Called on pointer POINTERMOVE event if only a single touch is active.
  39428. */
  39429. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39430. /**
  39431. * Called on pointer POINTERDOUBLETAP event.
  39432. */
  39433. protected onDoubleTap(type: string): void;
  39434. /**
  39435. * Called on pointer POINTERMOVE event if multiple touches are active.
  39436. */
  39437. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39438. /**
  39439. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39440. * press.
  39441. */
  39442. protected onButtonDown(evt: PointerEvent): void;
  39443. /**
  39444. * Called each time a new POINTERUP event occurs. Ie, for each button
  39445. * release.
  39446. */
  39447. protected onButtonUp(evt: PointerEvent): void;
  39448. /**
  39449. * Called when window becomes inactive.
  39450. */
  39451. protected onLostFocus(): void;
  39452. }
  39453. }
  39454. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39455. import { Nullable } from "babylonjs/types";
  39456. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39457. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39458. /**
  39459. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39461. */
  39462. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39463. /**
  39464. * Defines the camera the input is attached to.
  39465. */
  39466. camera: ArcRotateCamera;
  39467. /**
  39468. * Defines the list of key codes associated with the up action (increase alpha)
  39469. */
  39470. keysUp: number[];
  39471. /**
  39472. * Defines the list of key codes associated with the down action (decrease alpha)
  39473. */
  39474. keysDown: number[];
  39475. /**
  39476. * Defines the list of key codes associated with the left action (increase beta)
  39477. */
  39478. keysLeft: number[];
  39479. /**
  39480. * Defines the list of key codes associated with the right action (decrease beta)
  39481. */
  39482. keysRight: number[];
  39483. /**
  39484. * Defines the list of key codes associated with the reset action.
  39485. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39486. */
  39487. keysReset: number[];
  39488. /**
  39489. * Defines the panning sensibility of the inputs.
  39490. * (How fast is the camera panning)
  39491. */
  39492. panningSensibility: number;
  39493. /**
  39494. * Defines the zooming sensibility of the inputs.
  39495. * (How fast is the camera zooming)
  39496. */
  39497. zoomingSensibility: number;
  39498. /**
  39499. * Defines whether maintaining the alt key down switch the movement mode from
  39500. * orientation to zoom.
  39501. */
  39502. useAltToZoom: boolean;
  39503. /**
  39504. * Rotation speed of the camera
  39505. */
  39506. angularSpeed: number;
  39507. private _keys;
  39508. private _ctrlPressed;
  39509. private _altPressed;
  39510. private _onCanvasBlurObserver;
  39511. private _onKeyboardObserver;
  39512. private _engine;
  39513. private _scene;
  39514. /**
  39515. * Attach the input controls to a specific dom element to get the input from.
  39516. * @param element Defines the element the controls should be listened from
  39517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39518. */
  39519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39520. /**
  39521. * Detach the current controls from the specified dom element.
  39522. * @param element Defines the element to stop listening the inputs from
  39523. */
  39524. detachControl(element: Nullable<HTMLElement>): void;
  39525. /**
  39526. * Update the current camera state depending on the inputs that have been used this frame.
  39527. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39528. */
  39529. checkInputs(): void;
  39530. /**
  39531. * Gets the class name of the current intput.
  39532. * @returns the class name
  39533. */
  39534. getClassName(): string;
  39535. /**
  39536. * Get the friendly name associated with the input class.
  39537. * @returns the input friendly name
  39538. */
  39539. getSimpleName(): string;
  39540. }
  39541. }
  39542. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39543. import { Nullable } from "babylonjs/types";
  39544. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39545. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39546. /**
  39547. * Manage the mouse wheel inputs to control an arc rotate camera.
  39548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39549. */
  39550. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39551. /**
  39552. * Defines the camera the input is attached to.
  39553. */
  39554. camera: ArcRotateCamera;
  39555. /**
  39556. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39557. */
  39558. wheelPrecision: number;
  39559. /**
  39560. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39561. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39562. */
  39563. wheelDeltaPercentage: number;
  39564. private _wheel;
  39565. private _observer;
  39566. private computeDeltaFromMouseWheelLegacyEvent;
  39567. /**
  39568. * Attach the input controls to a specific dom element to get the input from.
  39569. * @param element Defines the element the controls should be listened from
  39570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39571. */
  39572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39573. /**
  39574. * Detach the current controls from the specified dom element.
  39575. * @param element Defines the element to stop listening the inputs from
  39576. */
  39577. detachControl(element: Nullable<HTMLElement>): void;
  39578. /**
  39579. * Gets the class name of the current intput.
  39580. * @returns the class name
  39581. */
  39582. getClassName(): string;
  39583. /**
  39584. * Get the friendly name associated with the input class.
  39585. * @returns the input friendly name
  39586. */
  39587. getSimpleName(): string;
  39588. }
  39589. }
  39590. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39591. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39592. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39593. /**
  39594. * Default Inputs manager for the ArcRotateCamera.
  39595. * It groups all the default supported inputs for ease of use.
  39596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39597. */
  39598. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39599. /**
  39600. * Instantiates a new ArcRotateCameraInputsManager.
  39601. * @param camera Defines the camera the inputs belong to
  39602. */
  39603. constructor(camera: ArcRotateCamera);
  39604. /**
  39605. * Add mouse wheel input support to the input manager.
  39606. * @returns the current input manager
  39607. */
  39608. addMouseWheel(): ArcRotateCameraInputsManager;
  39609. /**
  39610. * Add pointers input support to the input manager.
  39611. * @returns the current input manager
  39612. */
  39613. addPointers(): ArcRotateCameraInputsManager;
  39614. /**
  39615. * Add keyboard input support to the input manager.
  39616. * @returns the current input manager
  39617. */
  39618. addKeyboard(): ArcRotateCameraInputsManager;
  39619. }
  39620. }
  39621. declare module "babylonjs/Cameras/arcRotateCamera" {
  39622. import { Observable } from "babylonjs/Misc/observable";
  39623. import { Nullable } from "babylonjs/types";
  39624. import { Scene } from "babylonjs/scene";
  39625. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39627. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39628. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39629. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39630. import { Camera } from "babylonjs/Cameras/camera";
  39631. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39632. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39633. import { Collider } from "babylonjs/Collisions/collider";
  39634. /**
  39635. * This represents an orbital type of camera.
  39636. *
  39637. * 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.
  39638. * 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.
  39639. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39640. */
  39641. export class ArcRotateCamera extends TargetCamera {
  39642. /**
  39643. * Defines the rotation angle of the camera along the longitudinal axis.
  39644. */
  39645. alpha: number;
  39646. /**
  39647. * Defines the rotation angle of the camera along the latitudinal axis.
  39648. */
  39649. beta: number;
  39650. /**
  39651. * Defines the radius of the camera from it s target point.
  39652. */
  39653. radius: number;
  39654. protected _target: Vector3;
  39655. protected _targetHost: Nullable<AbstractMesh>;
  39656. /**
  39657. * Defines the target point of the camera.
  39658. * The camera looks towards it form the radius distance.
  39659. */
  39660. get target(): Vector3;
  39661. set target(value: Vector3);
  39662. /**
  39663. * Define the current local position of the camera in the scene
  39664. */
  39665. get position(): Vector3;
  39666. set position(newPosition: Vector3);
  39667. protected _upVector: Vector3;
  39668. protected _upToYMatrix: Matrix;
  39669. protected _YToUpMatrix: Matrix;
  39670. /**
  39671. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39672. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39673. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39674. */
  39675. set upVector(vec: Vector3);
  39676. get upVector(): Vector3;
  39677. /**
  39678. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39679. */
  39680. setMatUp(): void;
  39681. /**
  39682. * Current inertia value on the longitudinal axis.
  39683. * The bigger this number the longer it will take for the camera to stop.
  39684. */
  39685. inertialAlphaOffset: number;
  39686. /**
  39687. * Current inertia value on the latitudinal axis.
  39688. * The bigger this number the longer it will take for the camera to stop.
  39689. */
  39690. inertialBetaOffset: number;
  39691. /**
  39692. * Current inertia value on the radius axis.
  39693. * The bigger this number the longer it will take for the camera to stop.
  39694. */
  39695. inertialRadiusOffset: number;
  39696. /**
  39697. * Minimum allowed angle on the longitudinal axis.
  39698. * This can help limiting how the Camera is able to move in the scene.
  39699. */
  39700. lowerAlphaLimit: Nullable<number>;
  39701. /**
  39702. * Maximum allowed angle on the longitudinal axis.
  39703. * This can help limiting how the Camera is able to move in the scene.
  39704. */
  39705. upperAlphaLimit: Nullable<number>;
  39706. /**
  39707. * Minimum allowed angle on the latitudinal axis.
  39708. * This can help limiting how the Camera is able to move in the scene.
  39709. */
  39710. lowerBetaLimit: number;
  39711. /**
  39712. * Maximum allowed angle on the latitudinal axis.
  39713. * This can help limiting how the Camera is able to move in the scene.
  39714. */
  39715. upperBetaLimit: number;
  39716. /**
  39717. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39718. * This can help limiting how the Camera is able to move in the scene.
  39719. */
  39720. lowerRadiusLimit: Nullable<number>;
  39721. /**
  39722. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39723. * This can help limiting how the Camera is able to move in the scene.
  39724. */
  39725. upperRadiusLimit: Nullable<number>;
  39726. /**
  39727. * Defines the current inertia value used during panning of the camera along the X axis.
  39728. */
  39729. inertialPanningX: number;
  39730. /**
  39731. * Defines the current inertia value used during panning of the camera along the Y axis.
  39732. */
  39733. inertialPanningY: number;
  39734. /**
  39735. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39736. * Basically if your fingers moves away from more than this distance you will be considered
  39737. * in pinch mode.
  39738. */
  39739. pinchToPanMaxDistance: number;
  39740. /**
  39741. * Defines the maximum distance the camera can pan.
  39742. * This could help keeping the cammera always in your scene.
  39743. */
  39744. panningDistanceLimit: Nullable<number>;
  39745. /**
  39746. * Defines the target of the camera before paning.
  39747. */
  39748. panningOriginTarget: Vector3;
  39749. /**
  39750. * Defines the value of the inertia used during panning.
  39751. * 0 would mean stop inertia and one would mean no decelleration at all.
  39752. */
  39753. panningInertia: number;
  39754. /**
  39755. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39756. */
  39757. get angularSensibilityX(): number;
  39758. set angularSensibilityX(value: number);
  39759. /**
  39760. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39761. */
  39762. get angularSensibilityY(): number;
  39763. set angularSensibilityY(value: number);
  39764. /**
  39765. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39766. */
  39767. get pinchPrecision(): number;
  39768. set pinchPrecision(value: number);
  39769. /**
  39770. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39771. * It will be used instead of pinchDeltaPrecision if different from 0.
  39772. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39773. */
  39774. get pinchDeltaPercentage(): number;
  39775. set pinchDeltaPercentage(value: number);
  39776. /**
  39777. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39778. */
  39779. get panningSensibility(): number;
  39780. set panningSensibility(value: number);
  39781. /**
  39782. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39783. */
  39784. get keysUp(): number[];
  39785. set keysUp(value: number[]);
  39786. /**
  39787. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39788. */
  39789. get keysDown(): number[];
  39790. set keysDown(value: number[]);
  39791. /**
  39792. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39793. */
  39794. get keysLeft(): number[];
  39795. set keysLeft(value: number[]);
  39796. /**
  39797. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39798. */
  39799. get keysRight(): number[];
  39800. set keysRight(value: number[]);
  39801. /**
  39802. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39803. */
  39804. get wheelPrecision(): number;
  39805. set wheelPrecision(value: number);
  39806. /**
  39807. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39808. * It will be used instead of pinchDeltaPrecision if different from 0.
  39809. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39810. */
  39811. get wheelDeltaPercentage(): number;
  39812. set wheelDeltaPercentage(value: number);
  39813. /**
  39814. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39815. */
  39816. zoomOnFactor: number;
  39817. /**
  39818. * Defines a screen offset for the camera position.
  39819. */
  39820. targetScreenOffset: Vector2;
  39821. /**
  39822. * Allows the camera to be completely reversed.
  39823. * If false the camera can not arrive upside down.
  39824. */
  39825. allowUpsideDown: boolean;
  39826. /**
  39827. * Define if double tap/click is used to restore the previously saved state of the camera.
  39828. */
  39829. useInputToRestoreState: boolean;
  39830. /** @hidden */
  39831. _viewMatrix: Matrix;
  39832. /** @hidden */
  39833. _useCtrlForPanning: boolean;
  39834. /** @hidden */
  39835. _panningMouseButton: number;
  39836. /**
  39837. * Defines the input associated to the camera.
  39838. */
  39839. inputs: ArcRotateCameraInputsManager;
  39840. /** @hidden */
  39841. _reset: () => void;
  39842. /**
  39843. * Defines the allowed panning axis.
  39844. */
  39845. panningAxis: Vector3;
  39846. protected _localDirection: Vector3;
  39847. protected _transformedDirection: Vector3;
  39848. private _bouncingBehavior;
  39849. /**
  39850. * Gets the bouncing behavior of the camera if it has been enabled.
  39851. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39852. */
  39853. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39854. /**
  39855. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39856. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39857. */
  39858. get useBouncingBehavior(): boolean;
  39859. set useBouncingBehavior(value: boolean);
  39860. private _framingBehavior;
  39861. /**
  39862. * Gets the framing behavior of the camera if it has been enabled.
  39863. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39864. */
  39865. get framingBehavior(): Nullable<FramingBehavior>;
  39866. /**
  39867. * Defines if the framing behavior of the camera is enabled on the camera.
  39868. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39869. */
  39870. get useFramingBehavior(): boolean;
  39871. set useFramingBehavior(value: boolean);
  39872. private _autoRotationBehavior;
  39873. /**
  39874. * Gets the auto rotation behavior of the camera if it has been enabled.
  39875. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39876. */
  39877. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39878. /**
  39879. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39880. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39881. */
  39882. get useAutoRotationBehavior(): boolean;
  39883. set useAutoRotationBehavior(value: boolean);
  39884. /**
  39885. * Observable triggered when the mesh target has been changed on the camera.
  39886. */
  39887. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39888. /**
  39889. * Event raised when the camera is colliding with a mesh.
  39890. */
  39891. onCollide: (collidedMesh: AbstractMesh) => void;
  39892. /**
  39893. * Defines whether the camera should check collision with the objects oh the scene.
  39894. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39895. */
  39896. checkCollisions: boolean;
  39897. /**
  39898. * Defines the collision radius of the camera.
  39899. * This simulates a sphere around the camera.
  39900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39901. */
  39902. collisionRadius: Vector3;
  39903. protected _collider: Collider;
  39904. protected _previousPosition: Vector3;
  39905. protected _collisionVelocity: Vector3;
  39906. protected _newPosition: Vector3;
  39907. protected _previousAlpha: number;
  39908. protected _previousBeta: number;
  39909. protected _previousRadius: number;
  39910. protected _collisionTriggered: boolean;
  39911. protected _targetBoundingCenter: Nullable<Vector3>;
  39912. private _computationVector;
  39913. /**
  39914. * Instantiates a new ArcRotateCamera in a given scene
  39915. * @param name Defines the name of the camera
  39916. * @param alpha Defines the camera rotation along the logitudinal axis
  39917. * @param beta Defines the camera rotation along the latitudinal axis
  39918. * @param radius Defines the camera distance from its target
  39919. * @param target Defines the camera target
  39920. * @param scene Defines the scene the camera belongs to
  39921. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39922. */
  39923. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39924. /** @hidden */
  39925. _initCache(): void;
  39926. /** @hidden */
  39927. _updateCache(ignoreParentClass?: boolean): void;
  39928. protected _getTargetPosition(): Vector3;
  39929. private _storedAlpha;
  39930. private _storedBeta;
  39931. private _storedRadius;
  39932. private _storedTarget;
  39933. private _storedTargetScreenOffset;
  39934. /**
  39935. * Stores the current state of the camera (alpha, beta, radius and target)
  39936. * @returns the camera itself
  39937. */
  39938. storeState(): Camera;
  39939. /**
  39940. * @hidden
  39941. * Restored camera state. You must call storeState() first
  39942. */
  39943. _restoreStateValues(): boolean;
  39944. /** @hidden */
  39945. _isSynchronizedViewMatrix(): boolean;
  39946. /**
  39947. * Attached controls to the current camera.
  39948. * @param element Defines the element the controls should be listened from
  39949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39950. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39951. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39952. */
  39953. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39954. /**
  39955. * Detach the current controls from the camera.
  39956. * The camera will stop reacting to inputs.
  39957. * @param element Defines the element to stop listening the inputs from
  39958. */
  39959. detachControl(element: HTMLElement): void;
  39960. /** @hidden */
  39961. _checkInputs(): void;
  39962. protected _checkLimits(): void;
  39963. /**
  39964. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39965. */
  39966. rebuildAnglesAndRadius(): void;
  39967. /**
  39968. * Use a position to define the current camera related information like alpha, beta and radius
  39969. * @param position Defines the position to set the camera at
  39970. */
  39971. setPosition(position: Vector3): void;
  39972. /**
  39973. * Defines the target the camera should look at.
  39974. * This will automatically adapt alpha beta and radius to fit within the new target.
  39975. * @param target Defines the new target as a Vector or a mesh
  39976. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39977. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39978. */
  39979. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39980. /** @hidden */
  39981. _getViewMatrix(): Matrix;
  39982. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39983. /**
  39984. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39985. * @param meshes Defines the mesh to zoom on
  39986. * @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)
  39987. */
  39988. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39989. /**
  39990. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39991. * The target will be changed but the radius
  39992. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39993. * @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)
  39994. */
  39995. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39996. min: Vector3;
  39997. max: Vector3;
  39998. distance: number;
  39999. }, doNotUpdateMaxZ?: boolean): void;
  40000. /**
  40001. * @override
  40002. * Override Camera.createRigCamera
  40003. */
  40004. createRigCamera(name: string, cameraIndex: number): Camera;
  40005. /**
  40006. * @hidden
  40007. * @override
  40008. * Override Camera._updateRigCameras
  40009. */
  40010. _updateRigCameras(): void;
  40011. /**
  40012. * Destroy the camera and release the current resources hold by it.
  40013. */
  40014. dispose(): void;
  40015. /**
  40016. * Gets the current object class name.
  40017. * @return the class name
  40018. */
  40019. getClassName(): string;
  40020. }
  40021. }
  40022. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40023. import { Behavior } from "babylonjs/Behaviors/behavior";
  40024. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40025. /**
  40026. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40028. */
  40029. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40030. /**
  40031. * Gets the name of the behavior.
  40032. */
  40033. get name(): string;
  40034. private _zoomStopsAnimation;
  40035. private _idleRotationSpeed;
  40036. private _idleRotationWaitTime;
  40037. private _idleRotationSpinupTime;
  40038. /**
  40039. * Sets the flag that indicates if user zooming should stop animation.
  40040. */
  40041. set zoomStopsAnimation(flag: boolean);
  40042. /**
  40043. * Gets the flag that indicates if user zooming should stop animation.
  40044. */
  40045. get zoomStopsAnimation(): boolean;
  40046. /**
  40047. * Sets the default speed at which the camera rotates around the model.
  40048. */
  40049. set idleRotationSpeed(speed: number);
  40050. /**
  40051. * Gets the default speed at which the camera rotates around the model.
  40052. */
  40053. get idleRotationSpeed(): number;
  40054. /**
  40055. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40056. */
  40057. set idleRotationWaitTime(time: number);
  40058. /**
  40059. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40060. */
  40061. get idleRotationWaitTime(): number;
  40062. /**
  40063. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40064. */
  40065. set idleRotationSpinupTime(time: number);
  40066. /**
  40067. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40068. */
  40069. get idleRotationSpinupTime(): number;
  40070. /**
  40071. * Gets a value indicating if the camera is currently rotating because of this behavior
  40072. */
  40073. get rotationInProgress(): boolean;
  40074. private _onPrePointerObservableObserver;
  40075. private _onAfterCheckInputsObserver;
  40076. private _attachedCamera;
  40077. private _isPointerDown;
  40078. private _lastFrameTime;
  40079. private _lastInteractionTime;
  40080. private _cameraRotationSpeed;
  40081. /**
  40082. * Initializes the behavior.
  40083. */
  40084. init(): void;
  40085. /**
  40086. * Attaches the behavior to its arc rotate camera.
  40087. * @param camera Defines the camera to attach the behavior to
  40088. */
  40089. attach(camera: ArcRotateCamera): void;
  40090. /**
  40091. * Detaches the behavior from its current arc rotate camera.
  40092. */
  40093. detach(): void;
  40094. /**
  40095. * Returns true if user is scrolling.
  40096. * @return true if user is scrolling.
  40097. */
  40098. private _userIsZooming;
  40099. private _lastFrameRadius;
  40100. private _shouldAnimationStopForInteraction;
  40101. /**
  40102. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40103. */
  40104. private _applyUserInteraction;
  40105. private _userIsMoving;
  40106. }
  40107. }
  40108. declare module "babylonjs/Behaviors/Cameras/index" {
  40109. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40110. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40111. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40112. }
  40113. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40114. import { Mesh } from "babylonjs/Meshes/mesh";
  40115. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40116. import { Behavior } from "babylonjs/Behaviors/behavior";
  40117. /**
  40118. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40119. */
  40120. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40121. private ui;
  40122. /**
  40123. * The name of the behavior
  40124. */
  40125. name: string;
  40126. /**
  40127. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40128. */
  40129. distanceAwayFromFace: number;
  40130. /**
  40131. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40132. */
  40133. distanceAwayFromBottomOfFace: number;
  40134. private _faceVectors;
  40135. private _target;
  40136. private _scene;
  40137. private _onRenderObserver;
  40138. private _tmpMatrix;
  40139. private _tmpVector;
  40140. /**
  40141. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40142. * @param ui The transform node that should be attched to the mesh
  40143. */
  40144. constructor(ui: TransformNode);
  40145. /**
  40146. * Initializes the behavior
  40147. */
  40148. init(): void;
  40149. private _closestFace;
  40150. private _zeroVector;
  40151. private _lookAtTmpMatrix;
  40152. private _lookAtToRef;
  40153. /**
  40154. * Attaches the AttachToBoxBehavior to the passed in mesh
  40155. * @param target The mesh that the specified node will be attached to
  40156. */
  40157. attach(target: Mesh): void;
  40158. /**
  40159. * Detaches the behavior from the mesh
  40160. */
  40161. detach(): void;
  40162. }
  40163. }
  40164. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40165. import { Behavior } from "babylonjs/Behaviors/behavior";
  40166. import { Mesh } from "babylonjs/Meshes/mesh";
  40167. /**
  40168. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40169. */
  40170. export class FadeInOutBehavior implements Behavior<Mesh> {
  40171. /**
  40172. * Time in milliseconds to delay before fading in (Default: 0)
  40173. */
  40174. delay: number;
  40175. /**
  40176. * Time in milliseconds for the mesh to fade in (Default: 300)
  40177. */
  40178. fadeInTime: number;
  40179. private _millisecondsPerFrame;
  40180. private _hovered;
  40181. private _hoverValue;
  40182. private _ownerNode;
  40183. /**
  40184. * Instatiates the FadeInOutBehavior
  40185. */
  40186. constructor();
  40187. /**
  40188. * The name of the behavior
  40189. */
  40190. get name(): string;
  40191. /**
  40192. * Initializes the behavior
  40193. */
  40194. init(): void;
  40195. /**
  40196. * Attaches the fade behavior on the passed in mesh
  40197. * @param ownerNode The mesh that will be faded in/out once attached
  40198. */
  40199. attach(ownerNode: Mesh): void;
  40200. /**
  40201. * Detaches the behavior from the mesh
  40202. */
  40203. detach(): void;
  40204. /**
  40205. * Triggers the mesh to begin fading in or out
  40206. * @param value if the object should fade in or out (true to fade in)
  40207. */
  40208. fadeIn(value: boolean): void;
  40209. private _update;
  40210. private _setAllVisibility;
  40211. }
  40212. }
  40213. declare module "babylonjs/Misc/pivotTools" {
  40214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40215. /**
  40216. * Class containing a set of static utilities functions for managing Pivots
  40217. * @hidden
  40218. */
  40219. export class PivotTools {
  40220. private static _PivotCached;
  40221. private static _OldPivotPoint;
  40222. private static _PivotTranslation;
  40223. private static _PivotTmpVector;
  40224. /** @hidden */
  40225. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40226. /** @hidden */
  40227. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40228. }
  40229. }
  40230. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40231. import { Scene } from "babylonjs/scene";
  40232. import { Vector4 } from "babylonjs/Maths/math.vector";
  40233. import { Mesh } from "babylonjs/Meshes/mesh";
  40234. import { Nullable } from "babylonjs/types";
  40235. import { Plane } from "babylonjs/Maths/math.plane";
  40236. /**
  40237. * Class containing static functions to help procedurally build meshes
  40238. */
  40239. export class PlaneBuilder {
  40240. /**
  40241. * Creates a plane mesh
  40242. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40243. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40244. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40248. * @param name defines the name of the mesh
  40249. * @param options defines the options used to create the mesh
  40250. * @param scene defines the hosting scene
  40251. * @returns the plane mesh
  40252. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40253. */
  40254. static CreatePlane(name: string, options: {
  40255. size?: number;
  40256. width?: number;
  40257. height?: number;
  40258. sideOrientation?: number;
  40259. frontUVs?: Vector4;
  40260. backUVs?: Vector4;
  40261. updatable?: boolean;
  40262. sourcePlane?: Plane;
  40263. }, scene?: Nullable<Scene>): Mesh;
  40264. }
  40265. }
  40266. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40267. import { Behavior } from "babylonjs/Behaviors/behavior";
  40268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40269. import { Observable } from "babylonjs/Misc/observable";
  40270. import { Vector3 } from "babylonjs/Maths/math.vector";
  40271. import { Ray } from "babylonjs/Culling/ray";
  40272. import "babylonjs/Meshes/Builders/planeBuilder";
  40273. /**
  40274. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40275. */
  40276. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40277. private static _AnyMouseID;
  40278. /**
  40279. * Abstract mesh the behavior is set on
  40280. */
  40281. attachedNode: AbstractMesh;
  40282. private _dragPlane;
  40283. private _scene;
  40284. private _pointerObserver;
  40285. private _beforeRenderObserver;
  40286. private static _planeScene;
  40287. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40288. /**
  40289. * 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)
  40290. */
  40291. maxDragAngle: number;
  40292. /**
  40293. * @hidden
  40294. */
  40295. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40296. /**
  40297. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40298. */
  40299. currentDraggingPointerID: number;
  40300. /**
  40301. * The last position where the pointer hit the drag plane in world space
  40302. */
  40303. lastDragPosition: Vector3;
  40304. /**
  40305. * If the behavior is currently in a dragging state
  40306. */
  40307. dragging: boolean;
  40308. /**
  40309. * 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)
  40310. */
  40311. dragDeltaRatio: number;
  40312. /**
  40313. * If the drag plane orientation should be updated during the dragging (Default: true)
  40314. */
  40315. updateDragPlane: boolean;
  40316. private _debugMode;
  40317. private _moving;
  40318. /**
  40319. * Fires each time the attached mesh is dragged with the pointer
  40320. * * delta between last drag position and current drag position in world space
  40321. * * dragDistance along the drag axis
  40322. * * dragPlaneNormal normal of the current drag plane used during the drag
  40323. * * dragPlanePoint in world space where the drag intersects the drag plane
  40324. */
  40325. onDragObservable: Observable<{
  40326. delta: Vector3;
  40327. dragPlanePoint: Vector3;
  40328. dragPlaneNormal: Vector3;
  40329. dragDistance: number;
  40330. pointerId: number;
  40331. }>;
  40332. /**
  40333. * Fires each time a drag begins (eg. mouse down on mesh)
  40334. */
  40335. onDragStartObservable: Observable<{
  40336. dragPlanePoint: Vector3;
  40337. pointerId: number;
  40338. }>;
  40339. /**
  40340. * Fires each time a drag ends (eg. mouse release after drag)
  40341. */
  40342. onDragEndObservable: Observable<{
  40343. dragPlanePoint: Vector3;
  40344. pointerId: number;
  40345. }>;
  40346. /**
  40347. * If the attached mesh should be moved when dragged
  40348. */
  40349. moveAttached: boolean;
  40350. /**
  40351. * If the drag behavior will react to drag events (Default: true)
  40352. */
  40353. enabled: boolean;
  40354. /**
  40355. * If pointer events should start and release the drag (Default: true)
  40356. */
  40357. startAndReleaseDragOnPointerEvents: boolean;
  40358. /**
  40359. * If camera controls should be detached during the drag
  40360. */
  40361. detachCameraControls: boolean;
  40362. /**
  40363. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40364. */
  40365. useObjectOrientationForDragging: boolean;
  40366. private _options;
  40367. /**
  40368. * Gets the options used by the behavior
  40369. */
  40370. get options(): {
  40371. dragAxis?: Vector3;
  40372. dragPlaneNormal?: Vector3;
  40373. };
  40374. /**
  40375. * Sets the options used by the behavior
  40376. */
  40377. set options(options: {
  40378. dragAxis?: Vector3;
  40379. dragPlaneNormal?: Vector3;
  40380. });
  40381. /**
  40382. * Creates a pointer drag behavior that can be attached to a mesh
  40383. * @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)
  40384. */
  40385. constructor(options?: {
  40386. dragAxis?: Vector3;
  40387. dragPlaneNormal?: Vector3;
  40388. });
  40389. /**
  40390. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40391. */
  40392. validateDrag: (targetPosition: Vector3) => boolean;
  40393. /**
  40394. * The name of the behavior
  40395. */
  40396. get name(): string;
  40397. /**
  40398. * Initializes the behavior
  40399. */
  40400. init(): void;
  40401. private _tmpVector;
  40402. private _alternatePickedPoint;
  40403. private _worldDragAxis;
  40404. private _targetPosition;
  40405. private _attachedElement;
  40406. /**
  40407. * Attaches the drag behavior the passed in mesh
  40408. * @param ownerNode The mesh that will be dragged around once attached
  40409. * @param predicate Predicate to use for pick filtering
  40410. */
  40411. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40412. /**
  40413. * Force relase the drag action by code.
  40414. */
  40415. releaseDrag(): void;
  40416. private _startDragRay;
  40417. private _lastPointerRay;
  40418. /**
  40419. * Simulates the start of a pointer drag event on the behavior
  40420. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40421. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40422. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40423. */
  40424. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40425. private _startDrag;
  40426. private _dragDelta;
  40427. private _moveDrag;
  40428. private _pickWithRayOnDragPlane;
  40429. private _pointA;
  40430. private _pointB;
  40431. private _pointC;
  40432. private _lineA;
  40433. private _lineB;
  40434. private _localAxis;
  40435. private _lookAt;
  40436. private _updateDragPlanePosition;
  40437. /**
  40438. * Detaches the behavior from the mesh
  40439. */
  40440. detach(): void;
  40441. }
  40442. }
  40443. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40444. import { Mesh } from "babylonjs/Meshes/mesh";
  40445. import { Behavior } from "babylonjs/Behaviors/behavior";
  40446. /**
  40447. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40448. */
  40449. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40450. private _dragBehaviorA;
  40451. private _dragBehaviorB;
  40452. private _startDistance;
  40453. private _initialScale;
  40454. private _targetScale;
  40455. private _ownerNode;
  40456. private _sceneRenderObserver;
  40457. /**
  40458. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40459. */
  40460. constructor();
  40461. /**
  40462. * The name of the behavior
  40463. */
  40464. get name(): string;
  40465. /**
  40466. * Initializes the behavior
  40467. */
  40468. init(): void;
  40469. private _getCurrentDistance;
  40470. /**
  40471. * Attaches the scale behavior the passed in mesh
  40472. * @param ownerNode The mesh that will be scaled around once attached
  40473. */
  40474. attach(ownerNode: Mesh): void;
  40475. /**
  40476. * Detaches the behavior from the mesh
  40477. */
  40478. detach(): void;
  40479. }
  40480. }
  40481. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40482. import { Behavior } from "babylonjs/Behaviors/behavior";
  40483. import { Mesh } from "babylonjs/Meshes/mesh";
  40484. import { Observable } from "babylonjs/Misc/observable";
  40485. /**
  40486. * 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
  40487. */
  40488. export class SixDofDragBehavior implements Behavior<Mesh> {
  40489. private static _virtualScene;
  40490. private _ownerNode;
  40491. private _sceneRenderObserver;
  40492. private _scene;
  40493. private _targetPosition;
  40494. private _virtualOriginMesh;
  40495. private _virtualDragMesh;
  40496. private _pointerObserver;
  40497. private _moving;
  40498. private _startingOrientation;
  40499. /**
  40500. * 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)
  40501. */
  40502. private zDragFactor;
  40503. /**
  40504. * If the object should rotate to face the drag origin
  40505. */
  40506. rotateDraggedObject: boolean;
  40507. /**
  40508. * If the behavior is currently in a dragging state
  40509. */
  40510. dragging: boolean;
  40511. /**
  40512. * 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)
  40513. */
  40514. dragDeltaRatio: number;
  40515. /**
  40516. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40517. */
  40518. currentDraggingPointerID: number;
  40519. /**
  40520. * If camera controls should be detached during the drag
  40521. */
  40522. detachCameraControls: boolean;
  40523. /**
  40524. * Fires each time a drag starts
  40525. */
  40526. onDragStartObservable: Observable<{}>;
  40527. /**
  40528. * Fires each time a drag ends (eg. mouse release after drag)
  40529. */
  40530. onDragEndObservable: Observable<{}>;
  40531. /**
  40532. * 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
  40533. */
  40534. constructor();
  40535. /**
  40536. * The name of the behavior
  40537. */
  40538. get name(): string;
  40539. /**
  40540. * Initializes the behavior
  40541. */
  40542. init(): void;
  40543. /**
  40544. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40545. */
  40546. private get _pointerCamera();
  40547. /**
  40548. * Attaches the scale behavior the passed in mesh
  40549. * @param ownerNode The mesh that will be scaled around once attached
  40550. */
  40551. attach(ownerNode: Mesh): void;
  40552. /**
  40553. * Detaches the behavior from the mesh
  40554. */
  40555. detach(): void;
  40556. }
  40557. }
  40558. declare module "babylonjs/Behaviors/Meshes/index" {
  40559. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40560. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40561. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40562. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40563. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40564. }
  40565. declare module "babylonjs/Behaviors/index" {
  40566. export * from "babylonjs/Behaviors/behavior";
  40567. export * from "babylonjs/Behaviors/Cameras/index";
  40568. export * from "babylonjs/Behaviors/Meshes/index";
  40569. }
  40570. declare module "babylonjs/Bones/boneIKController" {
  40571. import { Bone } from "babylonjs/Bones/bone";
  40572. import { Vector3 } from "babylonjs/Maths/math.vector";
  40573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40574. import { Nullable } from "babylonjs/types";
  40575. /**
  40576. * Class used to apply inverse kinematics to bones
  40577. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40578. */
  40579. export class BoneIKController {
  40580. private static _tmpVecs;
  40581. private static _tmpQuat;
  40582. private static _tmpMats;
  40583. /**
  40584. * Gets or sets the target mesh
  40585. */
  40586. targetMesh: AbstractMesh;
  40587. /** Gets or sets the mesh used as pole */
  40588. poleTargetMesh: AbstractMesh;
  40589. /**
  40590. * Gets or sets the bone used as pole
  40591. */
  40592. poleTargetBone: Nullable<Bone>;
  40593. /**
  40594. * Gets or sets the target position
  40595. */
  40596. targetPosition: Vector3;
  40597. /**
  40598. * Gets or sets the pole target position
  40599. */
  40600. poleTargetPosition: Vector3;
  40601. /**
  40602. * Gets or sets the pole target local offset
  40603. */
  40604. poleTargetLocalOffset: Vector3;
  40605. /**
  40606. * Gets or sets the pole angle
  40607. */
  40608. poleAngle: number;
  40609. /**
  40610. * Gets or sets the mesh associated with the controller
  40611. */
  40612. mesh: AbstractMesh;
  40613. /**
  40614. * 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)
  40615. */
  40616. slerpAmount: number;
  40617. private _bone1Quat;
  40618. private _bone1Mat;
  40619. private _bone2Ang;
  40620. private _bone1;
  40621. private _bone2;
  40622. private _bone1Length;
  40623. private _bone2Length;
  40624. private _maxAngle;
  40625. private _maxReach;
  40626. private _rightHandedSystem;
  40627. private _bendAxis;
  40628. private _slerping;
  40629. private _adjustRoll;
  40630. /**
  40631. * Gets or sets maximum allowed angle
  40632. */
  40633. get maxAngle(): number;
  40634. set maxAngle(value: number);
  40635. /**
  40636. * Creates a new BoneIKController
  40637. * @param mesh defines the mesh to control
  40638. * @param bone defines the bone to control
  40639. * @param options defines options to set up the controller
  40640. */
  40641. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40642. targetMesh?: AbstractMesh;
  40643. poleTargetMesh?: AbstractMesh;
  40644. poleTargetBone?: Bone;
  40645. poleTargetLocalOffset?: Vector3;
  40646. poleAngle?: number;
  40647. bendAxis?: Vector3;
  40648. maxAngle?: number;
  40649. slerpAmount?: number;
  40650. });
  40651. private _setMaxAngle;
  40652. /**
  40653. * Force the controller to update the bones
  40654. */
  40655. update(): void;
  40656. }
  40657. }
  40658. declare module "babylonjs/Bones/boneLookController" {
  40659. import { Vector3 } from "babylonjs/Maths/math.vector";
  40660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40661. import { Bone } from "babylonjs/Bones/bone";
  40662. import { Space } from "babylonjs/Maths/math.axis";
  40663. /**
  40664. * Class used to make a bone look toward a point in space
  40665. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40666. */
  40667. export class BoneLookController {
  40668. private static _tmpVecs;
  40669. private static _tmpQuat;
  40670. private static _tmpMats;
  40671. /**
  40672. * The target Vector3 that the bone will look at
  40673. */
  40674. target: Vector3;
  40675. /**
  40676. * The mesh that the bone is attached to
  40677. */
  40678. mesh: AbstractMesh;
  40679. /**
  40680. * The bone that will be looking to the target
  40681. */
  40682. bone: Bone;
  40683. /**
  40684. * The up axis of the coordinate system that is used when the bone is rotated
  40685. */
  40686. upAxis: Vector3;
  40687. /**
  40688. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40689. */
  40690. upAxisSpace: Space;
  40691. /**
  40692. * Used to make an adjustment to the yaw of the bone
  40693. */
  40694. adjustYaw: number;
  40695. /**
  40696. * Used to make an adjustment to the pitch of the bone
  40697. */
  40698. adjustPitch: number;
  40699. /**
  40700. * Used to make an adjustment to the roll of the bone
  40701. */
  40702. adjustRoll: number;
  40703. /**
  40704. * 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)
  40705. */
  40706. slerpAmount: number;
  40707. private _minYaw;
  40708. private _maxYaw;
  40709. private _minPitch;
  40710. private _maxPitch;
  40711. private _minYawSin;
  40712. private _minYawCos;
  40713. private _maxYawSin;
  40714. private _maxYawCos;
  40715. private _midYawConstraint;
  40716. private _minPitchTan;
  40717. private _maxPitchTan;
  40718. private _boneQuat;
  40719. private _slerping;
  40720. private _transformYawPitch;
  40721. private _transformYawPitchInv;
  40722. private _firstFrameSkipped;
  40723. private _yawRange;
  40724. private _fowardAxis;
  40725. /**
  40726. * Gets or sets the minimum yaw angle that the bone can look to
  40727. */
  40728. get minYaw(): number;
  40729. set minYaw(value: number);
  40730. /**
  40731. * Gets or sets the maximum yaw angle that the bone can look to
  40732. */
  40733. get maxYaw(): number;
  40734. set maxYaw(value: number);
  40735. /**
  40736. * Gets or sets the minimum pitch angle that the bone can look to
  40737. */
  40738. get minPitch(): number;
  40739. set minPitch(value: number);
  40740. /**
  40741. * Gets or sets the maximum pitch angle that the bone can look to
  40742. */
  40743. get maxPitch(): number;
  40744. set maxPitch(value: number);
  40745. /**
  40746. * Create a BoneLookController
  40747. * @param mesh the mesh that the bone belongs to
  40748. * @param bone the bone that will be looking to the target
  40749. * @param target the target Vector3 to look at
  40750. * @param options optional settings:
  40751. * * maxYaw: the maximum angle the bone will yaw to
  40752. * * minYaw: the minimum angle the bone will yaw to
  40753. * * maxPitch: the maximum angle the bone will pitch to
  40754. * * minPitch: the minimum angle the bone will yaw to
  40755. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40756. * * upAxis: the up axis of the coordinate system
  40757. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40758. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40759. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40760. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40761. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40762. * * adjustRoll: used to make an adjustment to the roll of the bone
  40763. **/
  40764. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40765. maxYaw?: number;
  40766. minYaw?: number;
  40767. maxPitch?: number;
  40768. minPitch?: number;
  40769. slerpAmount?: number;
  40770. upAxis?: Vector3;
  40771. upAxisSpace?: Space;
  40772. yawAxis?: Vector3;
  40773. pitchAxis?: Vector3;
  40774. adjustYaw?: number;
  40775. adjustPitch?: number;
  40776. adjustRoll?: number;
  40777. });
  40778. /**
  40779. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40780. */
  40781. update(): void;
  40782. private _getAngleDiff;
  40783. private _getAngleBetween;
  40784. private _isAngleBetween;
  40785. }
  40786. }
  40787. declare module "babylonjs/Bones/index" {
  40788. export * from "babylonjs/Bones/bone";
  40789. export * from "babylonjs/Bones/boneIKController";
  40790. export * from "babylonjs/Bones/boneLookController";
  40791. export * from "babylonjs/Bones/skeleton";
  40792. }
  40793. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40794. import { Nullable } from "babylonjs/types";
  40795. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40796. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40797. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40798. /**
  40799. * Manage the gamepad inputs to control an arc rotate camera.
  40800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40801. */
  40802. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40803. /**
  40804. * Defines the camera the input is attached to.
  40805. */
  40806. camera: ArcRotateCamera;
  40807. /**
  40808. * Defines the gamepad the input is gathering event from.
  40809. */
  40810. gamepad: Nullable<Gamepad>;
  40811. /**
  40812. * Defines the gamepad rotation sensiblity.
  40813. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40814. */
  40815. gamepadRotationSensibility: number;
  40816. /**
  40817. * Defines the gamepad move sensiblity.
  40818. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40819. */
  40820. gamepadMoveSensibility: number;
  40821. private _yAxisScale;
  40822. /**
  40823. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40824. */
  40825. get invertYAxis(): boolean;
  40826. set invertYAxis(value: boolean);
  40827. private _onGamepadConnectedObserver;
  40828. private _onGamepadDisconnectedObserver;
  40829. /**
  40830. * Attach the input controls to a specific dom element to get the input from.
  40831. * @param element Defines the element the controls should be listened from
  40832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40833. */
  40834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40835. /**
  40836. * Detach the current controls from the specified dom element.
  40837. * @param element Defines the element to stop listening the inputs from
  40838. */
  40839. detachControl(element: Nullable<HTMLElement>): void;
  40840. /**
  40841. * Update the current camera state depending on the inputs that have been used this frame.
  40842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40843. */
  40844. checkInputs(): void;
  40845. /**
  40846. * Gets the class name of the current intput.
  40847. * @returns the class name
  40848. */
  40849. getClassName(): string;
  40850. /**
  40851. * Get the friendly name associated with the input class.
  40852. * @returns the input friendly name
  40853. */
  40854. getSimpleName(): string;
  40855. }
  40856. }
  40857. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40858. import { Nullable } from "babylonjs/types";
  40859. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40861. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40862. interface ArcRotateCameraInputsManager {
  40863. /**
  40864. * Add orientation input support to the input manager.
  40865. * @returns the current input manager
  40866. */
  40867. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40868. }
  40869. }
  40870. /**
  40871. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40873. */
  40874. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40875. /**
  40876. * Defines the camera the input is attached to.
  40877. */
  40878. camera: ArcRotateCamera;
  40879. /**
  40880. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40881. */
  40882. alphaCorrection: number;
  40883. /**
  40884. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40885. */
  40886. gammaCorrection: number;
  40887. private _alpha;
  40888. private _gamma;
  40889. private _dirty;
  40890. private _deviceOrientationHandler;
  40891. /**
  40892. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40893. */
  40894. constructor();
  40895. /**
  40896. * Attach the input controls to a specific dom element to get the input from.
  40897. * @param element Defines the element the controls should be listened from
  40898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40899. */
  40900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40901. /** @hidden */
  40902. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40903. /**
  40904. * Update the current camera state depending on the inputs that have been used this frame.
  40905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40906. */
  40907. checkInputs(): void;
  40908. /**
  40909. * Detach the current controls from the specified dom element.
  40910. * @param element Defines the element to stop listening the inputs from
  40911. */
  40912. detachControl(element: Nullable<HTMLElement>): void;
  40913. /**
  40914. * Gets the class name of the current intput.
  40915. * @returns the class name
  40916. */
  40917. getClassName(): string;
  40918. /**
  40919. * Get the friendly name associated with the input class.
  40920. * @returns the input friendly name
  40921. */
  40922. getSimpleName(): string;
  40923. }
  40924. }
  40925. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40926. import { Nullable } from "babylonjs/types";
  40927. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40928. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40929. /**
  40930. * Listen to mouse events to control the camera.
  40931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40932. */
  40933. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40934. /**
  40935. * Defines the camera the input is attached to.
  40936. */
  40937. camera: FlyCamera;
  40938. /**
  40939. * Defines if touch is enabled. (Default is true.)
  40940. */
  40941. touchEnabled: boolean;
  40942. /**
  40943. * Defines the buttons associated with the input to handle camera rotation.
  40944. */
  40945. buttons: number[];
  40946. /**
  40947. * Assign buttons for Yaw control.
  40948. */
  40949. buttonsYaw: number[];
  40950. /**
  40951. * Assign buttons for Pitch control.
  40952. */
  40953. buttonsPitch: number[];
  40954. /**
  40955. * Assign buttons for Roll control.
  40956. */
  40957. buttonsRoll: number[];
  40958. /**
  40959. * Detect if any button is being pressed while mouse is moved.
  40960. * -1 = Mouse locked.
  40961. * 0 = Left button.
  40962. * 1 = Middle Button.
  40963. * 2 = Right Button.
  40964. */
  40965. activeButton: number;
  40966. /**
  40967. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40968. * Higher values reduce its sensitivity.
  40969. */
  40970. angularSensibility: number;
  40971. private _mousemoveCallback;
  40972. private _observer;
  40973. private _rollObserver;
  40974. private previousPosition;
  40975. private noPreventDefault;
  40976. private element;
  40977. /**
  40978. * Listen to mouse events to control the camera.
  40979. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40981. */
  40982. constructor(touchEnabled?: boolean);
  40983. /**
  40984. * Attach the mouse control to the HTML DOM element.
  40985. * @param element Defines the element that listens to the input events.
  40986. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40987. */
  40988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40989. /**
  40990. * Detach the current controls from the specified dom element.
  40991. * @param element Defines the element to stop listening the inputs from
  40992. */
  40993. detachControl(element: Nullable<HTMLElement>): void;
  40994. /**
  40995. * Gets the class name of the current input.
  40996. * @returns the class name.
  40997. */
  40998. getClassName(): string;
  40999. /**
  41000. * Get the friendly name associated with the input class.
  41001. * @returns the input's friendly name.
  41002. */
  41003. getSimpleName(): string;
  41004. private _pointerInput;
  41005. private _onMouseMove;
  41006. /**
  41007. * Rotate camera by mouse offset.
  41008. */
  41009. private rotateCamera;
  41010. }
  41011. }
  41012. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41013. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41014. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41015. /**
  41016. * Default Inputs manager for the FlyCamera.
  41017. * It groups all the default supported inputs for ease of use.
  41018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41019. */
  41020. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41021. /**
  41022. * Instantiates a new FlyCameraInputsManager.
  41023. * @param camera Defines the camera the inputs belong to.
  41024. */
  41025. constructor(camera: FlyCamera);
  41026. /**
  41027. * Add keyboard input support to the input manager.
  41028. * @returns the new FlyCameraKeyboardMoveInput().
  41029. */
  41030. addKeyboard(): FlyCameraInputsManager;
  41031. /**
  41032. * Add mouse input support to the input manager.
  41033. * @param touchEnabled Enable touch screen support.
  41034. * @returns the new FlyCameraMouseInput().
  41035. */
  41036. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41037. }
  41038. }
  41039. declare module "babylonjs/Cameras/flyCamera" {
  41040. import { Scene } from "babylonjs/scene";
  41041. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41043. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41044. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41045. /**
  41046. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41047. * such as in a 3D Space Shooter or a Flight Simulator.
  41048. */
  41049. export class FlyCamera extends TargetCamera {
  41050. /**
  41051. * Define the collision ellipsoid of the camera.
  41052. * This is helpful for simulating a camera body, like a player's body.
  41053. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41054. */
  41055. ellipsoid: Vector3;
  41056. /**
  41057. * Define an offset for the position of the ellipsoid around the camera.
  41058. * This can be helpful if the camera is attached away from the player's body center,
  41059. * such as at its head.
  41060. */
  41061. ellipsoidOffset: Vector3;
  41062. /**
  41063. * Enable or disable collisions of the camera with the rest of the scene objects.
  41064. */
  41065. checkCollisions: boolean;
  41066. /**
  41067. * Enable or disable gravity on the camera.
  41068. */
  41069. applyGravity: boolean;
  41070. /**
  41071. * Define the current direction the camera is moving to.
  41072. */
  41073. cameraDirection: Vector3;
  41074. /**
  41075. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41076. * This overrides and empties cameraRotation.
  41077. */
  41078. rotationQuaternion: Quaternion;
  41079. /**
  41080. * Track Roll to maintain the wanted Rolling when looking around.
  41081. */
  41082. _trackRoll: number;
  41083. /**
  41084. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41085. */
  41086. rollCorrect: number;
  41087. /**
  41088. * Mimic a banked turn, Rolling the camera when Yawing.
  41089. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41090. */
  41091. bankedTurn: boolean;
  41092. /**
  41093. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41094. */
  41095. bankedTurnLimit: number;
  41096. /**
  41097. * Value of 0 disables the banked Roll.
  41098. * Value of 1 is equal to the Yaw angle in radians.
  41099. */
  41100. bankedTurnMultiplier: number;
  41101. /**
  41102. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41103. */
  41104. inputs: FlyCameraInputsManager;
  41105. /**
  41106. * Gets the input sensibility for mouse input.
  41107. * Higher values reduce sensitivity.
  41108. */
  41109. get angularSensibility(): number;
  41110. /**
  41111. * Sets the input sensibility for a mouse input.
  41112. * Higher values reduce sensitivity.
  41113. */
  41114. set angularSensibility(value: number);
  41115. /**
  41116. * Get the keys for camera movement forward.
  41117. */
  41118. get keysForward(): number[];
  41119. /**
  41120. * Set the keys for camera movement forward.
  41121. */
  41122. set keysForward(value: number[]);
  41123. /**
  41124. * Get the keys for camera movement backward.
  41125. */
  41126. get keysBackward(): number[];
  41127. set keysBackward(value: number[]);
  41128. /**
  41129. * Get the keys for camera movement up.
  41130. */
  41131. get keysUp(): number[];
  41132. /**
  41133. * Set the keys for camera movement up.
  41134. */
  41135. set keysUp(value: number[]);
  41136. /**
  41137. * Get the keys for camera movement down.
  41138. */
  41139. get keysDown(): number[];
  41140. /**
  41141. * Set the keys for camera movement down.
  41142. */
  41143. set keysDown(value: number[]);
  41144. /**
  41145. * Get the keys for camera movement left.
  41146. */
  41147. get keysLeft(): number[];
  41148. /**
  41149. * Set the keys for camera movement left.
  41150. */
  41151. set keysLeft(value: number[]);
  41152. /**
  41153. * Set the keys for camera movement right.
  41154. */
  41155. get keysRight(): number[];
  41156. /**
  41157. * Set the keys for camera movement right.
  41158. */
  41159. set keysRight(value: number[]);
  41160. /**
  41161. * Event raised when the camera collides with a mesh in the scene.
  41162. */
  41163. onCollide: (collidedMesh: AbstractMesh) => void;
  41164. private _collider;
  41165. private _needMoveForGravity;
  41166. private _oldPosition;
  41167. private _diffPosition;
  41168. private _newPosition;
  41169. /** @hidden */
  41170. _localDirection: Vector3;
  41171. /** @hidden */
  41172. _transformedDirection: Vector3;
  41173. /**
  41174. * Instantiates a FlyCamera.
  41175. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41176. * such as in a 3D Space Shooter or a Flight Simulator.
  41177. * @param name Define the name of the camera in the scene.
  41178. * @param position Define the starting position of the camera in the scene.
  41179. * @param scene Define the scene the camera belongs to.
  41180. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41181. */
  41182. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41183. /**
  41184. * Attach a control to the HTML DOM element.
  41185. * @param element Defines the element that listens to the input events.
  41186. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41187. */
  41188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41189. /**
  41190. * Detach a control from the HTML DOM element.
  41191. * The camera will stop reacting to that input.
  41192. * @param element Defines the element that listens to the input events.
  41193. */
  41194. detachControl(element: HTMLElement): void;
  41195. private _collisionMask;
  41196. /**
  41197. * Get the mask that the camera ignores in collision events.
  41198. */
  41199. get collisionMask(): number;
  41200. /**
  41201. * Set the mask that the camera ignores in collision events.
  41202. */
  41203. set collisionMask(mask: number);
  41204. /** @hidden */
  41205. _collideWithWorld(displacement: Vector3): void;
  41206. /** @hidden */
  41207. private _onCollisionPositionChange;
  41208. /** @hidden */
  41209. _checkInputs(): void;
  41210. /** @hidden */
  41211. _decideIfNeedsToMove(): boolean;
  41212. /** @hidden */
  41213. _updatePosition(): void;
  41214. /**
  41215. * Restore the Roll to its target value at the rate specified.
  41216. * @param rate - Higher means slower restoring.
  41217. * @hidden
  41218. */
  41219. restoreRoll(rate: number): void;
  41220. /**
  41221. * Destroy the camera and release the current resources held by it.
  41222. */
  41223. dispose(): void;
  41224. /**
  41225. * Get the current object class name.
  41226. * @returns the class name.
  41227. */
  41228. getClassName(): string;
  41229. }
  41230. }
  41231. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41232. import { Nullable } from "babylonjs/types";
  41233. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41234. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41235. /**
  41236. * Listen to keyboard events to control the camera.
  41237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41238. */
  41239. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41240. /**
  41241. * Defines the camera the input is attached to.
  41242. */
  41243. camera: FlyCamera;
  41244. /**
  41245. * The list of keyboard keys used to control the forward move of the camera.
  41246. */
  41247. keysForward: number[];
  41248. /**
  41249. * The list of keyboard keys used to control the backward move of the camera.
  41250. */
  41251. keysBackward: number[];
  41252. /**
  41253. * The list of keyboard keys used to control the forward move of the camera.
  41254. */
  41255. keysUp: number[];
  41256. /**
  41257. * The list of keyboard keys used to control the backward move of the camera.
  41258. */
  41259. keysDown: number[];
  41260. /**
  41261. * The list of keyboard keys used to control the right strafe move of the camera.
  41262. */
  41263. keysRight: number[];
  41264. /**
  41265. * The list of keyboard keys used to control the left strafe move of the camera.
  41266. */
  41267. keysLeft: number[];
  41268. private _keys;
  41269. private _onCanvasBlurObserver;
  41270. private _onKeyboardObserver;
  41271. private _engine;
  41272. private _scene;
  41273. /**
  41274. * Attach the input controls to a specific dom element to get the input from.
  41275. * @param element Defines the element the controls should be listened from
  41276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41277. */
  41278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41279. /**
  41280. * Detach the current controls from the specified dom element.
  41281. * @param element Defines the element to stop listening the inputs from
  41282. */
  41283. detachControl(element: Nullable<HTMLElement>): void;
  41284. /**
  41285. * Gets the class name of the current intput.
  41286. * @returns the class name
  41287. */
  41288. getClassName(): string;
  41289. /** @hidden */
  41290. _onLostFocus(e: FocusEvent): void;
  41291. /**
  41292. * Get the friendly name associated with the input class.
  41293. * @returns the input friendly name
  41294. */
  41295. getSimpleName(): string;
  41296. /**
  41297. * Update the current camera state depending on the inputs that have been used this frame.
  41298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41299. */
  41300. checkInputs(): void;
  41301. }
  41302. }
  41303. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41304. import { Nullable } from "babylonjs/types";
  41305. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41306. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41307. /**
  41308. * Manage the mouse wheel inputs to control a follow camera.
  41309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41310. */
  41311. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41312. /**
  41313. * Defines the camera the input is attached to.
  41314. */
  41315. camera: FollowCamera;
  41316. /**
  41317. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41318. */
  41319. axisControlRadius: boolean;
  41320. /**
  41321. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41322. */
  41323. axisControlHeight: boolean;
  41324. /**
  41325. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41326. */
  41327. axisControlRotation: boolean;
  41328. /**
  41329. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41330. * relation to mouseWheel events.
  41331. */
  41332. wheelPrecision: number;
  41333. /**
  41334. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41335. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41336. */
  41337. wheelDeltaPercentage: number;
  41338. private _wheel;
  41339. private _observer;
  41340. /**
  41341. * Attach the input controls to a specific dom element to get the input from.
  41342. * @param element Defines the element the controls should be listened from
  41343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41344. */
  41345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41346. /**
  41347. * Detach the current controls from the specified dom element.
  41348. * @param element Defines the element to stop listening the inputs from
  41349. */
  41350. detachControl(element: Nullable<HTMLElement>): void;
  41351. /**
  41352. * Gets the class name of the current intput.
  41353. * @returns the class name
  41354. */
  41355. getClassName(): string;
  41356. /**
  41357. * Get the friendly name associated with the input class.
  41358. * @returns the input friendly name
  41359. */
  41360. getSimpleName(): string;
  41361. }
  41362. }
  41363. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41364. import { Nullable } from "babylonjs/types";
  41365. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41366. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41367. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41368. /**
  41369. * Manage the pointers inputs to control an follow camera.
  41370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41371. */
  41372. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41373. /**
  41374. * Defines the camera the input is attached to.
  41375. */
  41376. camera: FollowCamera;
  41377. /**
  41378. * Gets the class name of the current input.
  41379. * @returns the class name
  41380. */
  41381. getClassName(): string;
  41382. /**
  41383. * Defines the pointer angular sensibility along the X axis or how fast is
  41384. * the camera rotating.
  41385. * A negative number will reverse the axis direction.
  41386. */
  41387. angularSensibilityX: number;
  41388. /**
  41389. * Defines the pointer angular sensibility along the Y axis or how fast is
  41390. * the camera rotating.
  41391. * A negative number will reverse the axis direction.
  41392. */
  41393. angularSensibilityY: number;
  41394. /**
  41395. * Defines the pointer pinch precision or how fast is the camera zooming.
  41396. * A negative number will reverse the axis direction.
  41397. */
  41398. pinchPrecision: number;
  41399. /**
  41400. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41401. * from 0.
  41402. * It defines the percentage of current camera.radius to use as delta when
  41403. * pinch zoom is used.
  41404. */
  41405. pinchDeltaPercentage: number;
  41406. /**
  41407. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41408. */
  41409. axisXControlRadius: boolean;
  41410. /**
  41411. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41412. */
  41413. axisXControlHeight: boolean;
  41414. /**
  41415. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41416. */
  41417. axisXControlRotation: boolean;
  41418. /**
  41419. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41420. */
  41421. axisYControlRadius: boolean;
  41422. /**
  41423. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41424. */
  41425. axisYControlHeight: boolean;
  41426. /**
  41427. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41428. */
  41429. axisYControlRotation: boolean;
  41430. /**
  41431. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41432. */
  41433. axisPinchControlRadius: boolean;
  41434. /**
  41435. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41436. */
  41437. axisPinchControlHeight: boolean;
  41438. /**
  41439. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41440. */
  41441. axisPinchControlRotation: boolean;
  41442. /**
  41443. * Log error messages if basic misconfiguration has occurred.
  41444. */
  41445. warningEnable: boolean;
  41446. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41447. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41448. private _warningCounter;
  41449. private _warning;
  41450. }
  41451. }
  41452. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41453. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41454. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41455. /**
  41456. * Default Inputs manager for the FollowCamera.
  41457. * It groups all the default supported inputs for ease of use.
  41458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41459. */
  41460. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41461. /**
  41462. * Instantiates a new FollowCameraInputsManager.
  41463. * @param camera Defines the camera the inputs belong to
  41464. */
  41465. constructor(camera: FollowCamera);
  41466. /**
  41467. * Add keyboard input support to the input manager.
  41468. * @returns the current input manager
  41469. */
  41470. addKeyboard(): FollowCameraInputsManager;
  41471. /**
  41472. * Add mouse wheel input support to the input manager.
  41473. * @returns the current input manager
  41474. */
  41475. addMouseWheel(): FollowCameraInputsManager;
  41476. /**
  41477. * Add pointers input support to the input manager.
  41478. * @returns the current input manager
  41479. */
  41480. addPointers(): FollowCameraInputsManager;
  41481. /**
  41482. * Add orientation input support to the input manager.
  41483. * @returns the current input manager
  41484. */
  41485. addVRDeviceOrientation(): FollowCameraInputsManager;
  41486. }
  41487. }
  41488. declare module "babylonjs/Cameras/followCamera" {
  41489. import { Nullable } from "babylonjs/types";
  41490. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41491. import { Scene } from "babylonjs/scene";
  41492. import { Vector3 } from "babylonjs/Maths/math.vector";
  41493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41494. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41495. /**
  41496. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41497. * an arc rotate version arcFollowCamera are available.
  41498. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41499. */
  41500. export class FollowCamera extends TargetCamera {
  41501. /**
  41502. * Distance the follow camera should follow an object at
  41503. */
  41504. radius: number;
  41505. /**
  41506. * Minimum allowed distance of the camera to the axis of rotation
  41507. * (The camera can not get closer).
  41508. * This can help limiting how the Camera is able to move in the scene.
  41509. */
  41510. lowerRadiusLimit: Nullable<number>;
  41511. /**
  41512. * Maximum allowed distance of the camera to the axis of rotation
  41513. * (The camera can not get further).
  41514. * This can help limiting how the Camera is able to move in the scene.
  41515. */
  41516. upperRadiusLimit: Nullable<number>;
  41517. /**
  41518. * Define a rotation offset between the camera and the object it follows
  41519. */
  41520. rotationOffset: number;
  41521. /**
  41522. * Minimum allowed angle to camera position relative to target object.
  41523. * This can help limiting how the Camera is able to move in the scene.
  41524. */
  41525. lowerRotationOffsetLimit: Nullable<number>;
  41526. /**
  41527. * Maximum allowed angle to camera position relative to target object.
  41528. * This can help limiting how the Camera is able to move in the scene.
  41529. */
  41530. upperRotationOffsetLimit: Nullable<number>;
  41531. /**
  41532. * Define a height offset between the camera and the object it follows.
  41533. * It can help following an object from the top (like a car chaing a plane)
  41534. */
  41535. heightOffset: number;
  41536. /**
  41537. * Minimum allowed height of camera position relative to target object.
  41538. * This can help limiting how the Camera is able to move in the scene.
  41539. */
  41540. lowerHeightOffsetLimit: Nullable<number>;
  41541. /**
  41542. * Maximum allowed height of camera position relative to target object.
  41543. * This can help limiting how the Camera is able to move in the scene.
  41544. */
  41545. upperHeightOffsetLimit: Nullable<number>;
  41546. /**
  41547. * Define how fast the camera can accelerate to follow it s target.
  41548. */
  41549. cameraAcceleration: number;
  41550. /**
  41551. * Define the speed limit of the camera following an object.
  41552. */
  41553. maxCameraSpeed: number;
  41554. /**
  41555. * Define the target of the camera.
  41556. */
  41557. lockedTarget: Nullable<AbstractMesh>;
  41558. /**
  41559. * Defines the input associated with the camera.
  41560. */
  41561. inputs: FollowCameraInputsManager;
  41562. /**
  41563. * Instantiates the follow camera.
  41564. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41565. * @param name Define the name of the camera in the scene
  41566. * @param position Define the position of the camera
  41567. * @param scene Define the scene the camera belong to
  41568. * @param lockedTarget Define the target of the camera
  41569. */
  41570. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41571. private _follow;
  41572. /**
  41573. * Attached controls to the current camera.
  41574. * @param element Defines the element the controls should be listened from
  41575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41576. */
  41577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41578. /**
  41579. * Detach the current controls from the camera.
  41580. * The camera will stop reacting to inputs.
  41581. * @param element Defines the element to stop listening the inputs from
  41582. */
  41583. detachControl(element: HTMLElement): void;
  41584. /** @hidden */
  41585. _checkInputs(): void;
  41586. private _checkLimits;
  41587. /**
  41588. * Gets the camera class name.
  41589. * @returns the class name
  41590. */
  41591. getClassName(): string;
  41592. }
  41593. /**
  41594. * Arc Rotate version of the follow camera.
  41595. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41596. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41597. */
  41598. export class ArcFollowCamera extends TargetCamera {
  41599. /** The longitudinal angle of the camera */
  41600. alpha: number;
  41601. /** The latitudinal angle of the camera */
  41602. beta: number;
  41603. /** The radius of the camera from its target */
  41604. radius: number;
  41605. /** Define the camera target (the messh it should follow) */
  41606. target: Nullable<AbstractMesh>;
  41607. private _cartesianCoordinates;
  41608. /**
  41609. * Instantiates a new ArcFollowCamera
  41610. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41611. * @param name Define the name of the camera
  41612. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41613. * @param beta Define the rotation angle of the camera around the elevation axis
  41614. * @param radius Define the radius of the camera from its target point
  41615. * @param target Define the target of the camera
  41616. * @param scene Define the scene the camera belongs to
  41617. */
  41618. constructor(name: string,
  41619. /** The longitudinal angle of the camera */
  41620. alpha: number,
  41621. /** The latitudinal angle of the camera */
  41622. beta: number,
  41623. /** The radius of the camera from its target */
  41624. radius: number,
  41625. /** Define the camera target (the messh it should follow) */
  41626. target: Nullable<AbstractMesh>, scene: Scene);
  41627. private _follow;
  41628. /** @hidden */
  41629. _checkInputs(): void;
  41630. /**
  41631. * Returns the class name of the object.
  41632. * It is mostly used internally for serialization purposes.
  41633. */
  41634. getClassName(): string;
  41635. }
  41636. }
  41637. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41638. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41639. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41640. import { Nullable } from "babylonjs/types";
  41641. /**
  41642. * Manage the keyboard inputs to control the movement of a follow camera.
  41643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41644. */
  41645. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41646. /**
  41647. * Defines the camera the input is attached to.
  41648. */
  41649. camera: FollowCamera;
  41650. /**
  41651. * Defines the list of key codes associated with the up action (increase heightOffset)
  41652. */
  41653. keysHeightOffsetIncr: number[];
  41654. /**
  41655. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41656. */
  41657. keysHeightOffsetDecr: number[];
  41658. /**
  41659. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41660. */
  41661. keysHeightOffsetModifierAlt: boolean;
  41662. /**
  41663. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41664. */
  41665. keysHeightOffsetModifierCtrl: boolean;
  41666. /**
  41667. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41668. */
  41669. keysHeightOffsetModifierShift: boolean;
  41670. /**
  41671. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41672. */
  41673. keysRotationOffsetIncr: number[];
  41674. /**
  41675. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41676. */
  41677. keysRotationOffsetDecr: number[];
  41678. /**
  41679. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41680. */
  41681. keysRotationOffsetModifierAlt: boolean;
  41682. /**
  41683. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41684. */
  41685. keysRotationOffsetModifierCtrl: boolean;
  41686. /**
  41687. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41688. */
  41689. keysRotationOffsetModifierShift: boolean;
  41690. /**
  41691. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41692. */
  41693. keysRadiusIncr: number[];
  41694. /**
  41695. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41696. */
  41697. keysRadiusDecr: number[];
  41698. /**
  41699. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41700. */
  41701. keysRadiusModifierAlt: boolean;
  41702. /**
  41703. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41704. */
  41705. keysRadiusModifierCtrl: boolean;
  41706. /**
  41707. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41708. */
  41709. keysRadiusModifierShift: boolean;
  41710. /**
  41711. * Defines the rate of change of heightOffset.
  41712. */
  41713. heightSensibility: number;
  41714. /**
  41715. * Defines the rate of change of rotationOffset.
  41716. */
  41717. rotationSensibility: number;
  41718. /**
  41719. * Defines the rate of change of radius.
  41720. */
  41721. radiusSensibility: number;
  41722. private _keys;
  41723. private _ctrlPressed;
  41724. private _altPressed;
  41725. private _shiftPressed;
  41726. private _onCanvasBlurObserver;
  41727. private _onKeyboardObserver;
  41728. private _engine;
  41729. private _scene;
  41730. /**
  41731. * Attach the input controls to a specific dom element to get the input from.
  41732. * @param element Defines the element the controls should be listened from
  41733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41734. */
  41735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41736. /**
  41737. * Detach the current controls from the specified dom element.
  41738. * @param element Defines the element to stop listening the inputs from
  41739. */
  41740. detachControl(element: Nullable<HTMLElement>): void;
  41741. /**
  41742. * Update the current camera state depending on the inputs that have been used this frame.
  41743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41744. */
  41745. checkInputs(): void;
  41746. /**
  41747. * Gets the class name of the current input.
  41748. * @returns the class name
  41749. */
  41750. getClassName(): string;
  41751. /**
  41752. * Get the friendly name associated with the input class.
  41753. * @returns the input friendly name
  41754. */
  41755. getSimpleName(): string;
  41756. /**
  41757. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41758. * allow modification of the heightOffset value.
  41759. */
  41760. private _modifierHeightOffset;
  41761. /**
  41762. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41763. * allow modification of the rotationOffset value.
  41764. */
  41765. private _modifierRotationOffset;
  41766. /**
  41767. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41768. * allow modification of the radius value.
  41769. */
  41770. private _modifierRadius;
  41771. }
  41772. }
  41773. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41774. import { Nullable } from "babylonjs/types";
  41775. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41776. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41777. import { Observable } from "babylonjs/Misc/observable";
  41778. module "babylonjs/Cameras/freeCameraInputsManager" {
  41779. interface FreeCameraInputsManager {
  41780. /**
  41781. * @hidden
  41782. */
  41783. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41784. /**
  41785. * Add orientation input support to the input manager.
  41786. * @returns the current input manager
  41787. */
  41788. addDeviceOrientation(): FreeCameraInputsManager;
  41789. }
  41790. }
  41791. /**
  41792. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41793. * Screen rotation is taken into account.
  41794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41795. */
  41796. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41797. private _camera;
  41798. private _screenOrientationAngle;
  41799. private _constantTranform;
  41800. private _screenQuaternion;
  41801. private _alpha;
  41802. private _beta;
  41803. private _gamma;
  41804. /**
  41805. * Can be used to detect if a device orientation sensor is available on a device
  41806. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41807. * @returns a promise that will resolve on orientation change
  41808. */
  41809. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41810. /**
  41811. * @hidden
  41812. */
  41813. _onDeviceOrientationChangedObservable: Observable<void>;
  41814. /**
  41815. * Instantiates a new input
  41816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41817. */
  41818. constructor();
  41819. /**
  41820. * Define the camera controlled by the input.
  41821. */
  41822. get camera(): FreeCamera;
  41823. set camera(camera: FreeCamera);
  41824. /**
  41825. * Attach the input controls to a specific dom element to get the input from.
  41826. * @param element Defines the element the controls should be listened from
  41827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41828. */
  41829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41830. private _orientationChanged;
  41831. private _deviceOrientation;
  41832. /**
  41833. * Detach the current controls from the specified dom element.
  41834. * @param element Defines the element to stop listening the inputs from
  41835. */
  41836. detachControl(element: Nullable<HTMLElement>): void;
  41837. /**
  41838. * Update the current camera state depending on the inputs that have been used this frame.
  41839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41840. */
  41841. checkInputs(): void;
  41842. /**
  41843. * Gets the class name of the current intput.
  41844. * @returns the class name
  41845. */
  41846. getClassName(): string;
  41847. /**
  41848. * Get the friendly name associated with the input class.
  41849. * @returns the input friendly name
  41850. */
  41851. getSimpleName(): string;
  41852. }
  41853. }
  41854. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41855. import { Nullable } from "babylonjs/types";
  41856. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41857. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41858. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41859. /**
  41860. * Manage the gamepad inputs to control a free camera.
  41861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41862. */
  41863. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41864. /**
  41865. * Define the camera the input is attached to.
  41866. */
  41867. camera: FreeCamera;
  41868. /**
  41869. * Define the Gamepad controlling the input
  41870. */
  41871. gamepad: Nullable<Gamepad>;
  41872. /**
  41873. * Defines the gamepad rotation sensiblity.
  41874. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41875. */
  41876. gamepadAngularSensibility: number;
  41877. /**
  41878. * Defines the gamepad move sensiblity.
  41879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41880. */
  41881. gamepadMoveSensibility: number;
  41882. private _yAxisScale;
  41883. /**
  41884. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41885. */
  41886. get invertYAxis(): boolean;
  41887. set invertYAxis(value: boolean);
  41888. private _onGamepadConnectedObserver;
  41889. private _onGamepadDisconnectedObserver;
  41890. private _cameraTransform;
  41891. private _deltaTransform;
  41892. private _vector3;
  41893. private _vector2;
  41894. /**
  41895. * Attach the input controls to a specific dom element to get the input from.
  41896. * @param element Defines the element the controls should be listened from
  41897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41898. */
  41899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41900. /**
  41901. * Detach the current controls from the specified dom element.
  41902. * @param element Defines the element to stop listening the inputs from
  41903. */
  41904. detachControl(element: Nullable<HTMLElement>): void;
  41905. /**
  41906. * Update the current camera state depending on the inputs that have been used this frame.
  41907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41908. */
  41909. checkInputs(): void;
  41910. /**
  41911. * Gets the class name of the current intput.
  41912. * @returns the class name
  41913. */
  41914. getClassName(): string;
  41915. /**
  41916. * Get the friendly name associated with the input class.
  41917. * @returns the input friendly name
  41918. */
  41919. getSimpleName(): string;
  41920. }
  41921. }
  41922. declare module "babylonjs/Misc/virtualJoystick" {
  41923. import { Nullable } from "babylonjs/types";
  41924. import { Vector3 } from "babylonjs/Maths/math.vector";
  41925. /**
  41926. * Defines the potential axis of a Joystick
  41927. */
  41928. export enum JoystickAxis {
  41929. /** X axis */
  41930. X = 0,
  41931. /** Y axis */
  41932. Y = 1,
  41933. /** Z axis */
  41934. Z = 2
  41935. }
  41936. /**
  41937. * Class used to define virtual joystick (used in touch mode)
  41938. */
  41939. export class VirtualJoystick {
  41940. /**
  41941. * Gets or sets a boolean indicating that left and right values must be inverted
  41942. */
  41943. reverseLeftRight: boolean;
  41944. /**
  41945. * Gets or sets a boolean indicating that up and down values must be inverted
  41946. */
  41947. reverseUpDown: boolean;
  41948. /**
  41949. * Gets the offset value for the position (ie. the change of the position value)
  41950. */
  41951. deltaPosition: Vector3;
  41952. /**
  41953. * Gets a boolean indicating if the virtual joystick was pressed
  41954. */
  41955. pressed: boolean;
  41956. /**
  41957. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41958. */
  41959. static Canvas: Nullable<HTMLCanvasElement>;
  41960. private static _globalJoystickIndex;
  41961. private static vjCanvasContext;
  41962. private static vjCanvasWidth;
  41963. private static vjCanvasHeight;
  41964. private static halfWidth;
  41965. private _action;
  41966. private _axisTargetedByLeftAndRight;
  41967. private _axisTargetedByUpAndDown;
  41968. private _joystickSensibility;
  41969. private _inversedSensibility;
  41970. private _joystickPointerID;
  41971. private _joystickColor;
  41972. private _joystickPointerPos;
  41973. private _joystickPreviousPointerPos;
  41974. private _joystickPointerStartPos;
  41975. private _deltaJoystickVector;
  41976. private _leftJoystick;
  41977. private _touches;
  41978. private _onPointerDownHandlerRef;
  41979. private _onPointerMoveHandlerRef;
  41980. private _onPointerUpHandlerRef;
  41981. private _onResize;
  41982. /**
  41983. * Creates a new virtual joystick
  41984. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41985. */
  41986. constructor(leftJoystick?: boolean);
  41987. /**
  41988. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41989. * @param newJoystickSensibility defines the new sensibility
  41990. */
  41991. setJoystickSensibility(newJoystickSensibility: number): void;
  41992. private _onPointerDown;
  41993. private _onPointerMove;
  41994. private _onPointerUp;
  41995. /**
  41996. * Change the color of the virtual joystick
  41997. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41998. */
  41999. setJoystickColor(newColor: string): void;
  42000. /**
  42001. * Defines a callback to call when the joystick is touched
  42002. * @param action defines the callback
  42003. */
  42004. setActionOnTouch(action: () => any): void;
  42005. /**
  42006. * Defines which axis you'd like to control for left & right
  42007. * @param axis defines the axis to use
  42008. */
  42009. setAxisForLeftRight(axis: JoystickAxis): void;
  42010. /**
  42011. * Defines which axis you'd like to control for up & down
  42012. * @param axis defines the axis to use
  42013. */
  42014. setAxisForUpDown(axis: JoystickAxis): void;
  42015. private _drawVirtualJoystick;
  42016. /**
  42017. * Release internal HTML canvas
  42018. */
  42019. releaseCanvas(): void;
  42020. }
  42021. }
  42022. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42023. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42024. import { Nullable } from "babylonjs/types";
  42025. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42026. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42027. module "babylonjs/Cameras/freeCameraInputsManager" {
  42028. interface FreeCameraInputsManager {
  42029. /**
  42030. * Add virtual joystick input support to the input manager.
  42031. * @returns the current input manager
  42032. */
  42033. addVirtualJoystick(): FreeCameraInputsManager;
  42034. }
  42035. }
  42036. /**
  42037. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42039. */
  42040. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42041. /**
  42042. * Defines the camera the input is attached to.
  42043. */
  42044. camera: FreeCamera;
  42045. private _leftjoystick;
  42046. private _rightjoystick;
  42047. /**
  42048. * Gets the left stick of the virtual joystick.
  42049. * @returns The virtual Joystick
  42050. */
  42051. getLeftJoystick(): VirtualJoystick;
  42052. /**
  42053. * Gets the right stick of the virtual joystick.
  42054. * @returns The virtual Joystick
  42055. */
  42056. getRightJoystick(): VirtualJoystick;
  42057. /**
  42058. * Update the current camera state depending on the inputs that have been used this frame.
  42059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42060. */
  42061. checkInputs(): void;
  42062. /**
  42063. * Attach the input controls to a specific dom element to get the input from.
  42064. * @param element Defines the element the controls should be listened from
  42065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42066. */
  42067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42068. /**
  42069. * Detach the current controls from the specified dom element.
  42070. * @param element Defines the element to stop listening the inputs from
  42071. */
  42072. detachControl(element: Nullable<HTMLElement>): void;
  42073. /**
  42074. * Gets the class name of the current intput.
  42075. * @returns the class name
  42076. */
  42077. getClassName(): string;
  42078. /**
  42079. * Get the friendly name associated with the input class.
  42080. * @returns the input friendly name
  42081. */
  42082. getSimpleName(): string;
  42083. }
  42084. }
  42085. declare module "babylonjs/Cameras/Inputs/index" {
  42086. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42087. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42088. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42089. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42090. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42091. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42092. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42093. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42094. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42095. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42096. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42097. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42098. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42099. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42100. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42101. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42102. }
  42103. declare module "babylonjs/Cameras/touchCamera" {
  42104. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42105. import { Scene } from "babylonjs/scene";
  42106. import { Vector3 } from "babylonjs/Maths/math.vector";
  42107. /**
  42108. * This represents a FPS type of camera controlled by touch.
  42109. * This is like a universal camera minus the Gamepad controls.
  42110. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42111. */
  42112. export class TouchCamera extends FreeCamera {
  42113. /**
  42114. * Defines the touch sensibility for rotation.
  42115. * The higher the faster.
  42116. */
  42117. get touchAngularSensibility(): number;
  42118. set touchAngularSensibility(value: number);
  42119. /**
  42120. * Defines the touch sensibility for move.
  42121. * The higher the faster.
  42122. */
  42123. get touchMoveSensibility(): number;
  42124. set touchMoveSensibility(value: number);
  42125. /**
  42126. * Instantiates a new touch camera.
  42127. * This represents a FPS type of camera controlled by touch.
  42128. * This is like a universal camera minus the Gamepad controls.
  42129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42130. * @param name Define the name of the camera in the scene
  42131. * @param position Define the start position of the camera in the scene
  42132. * @param scene Define the scene the camera belongs to
  42133. */
  42134. constructor(name: string, position: Vector3, scene: Scene);
  42135. /**
  42136. * Gets the current object class name.
  42137. * @return the class name
  42138. */
  42139. getClassName(): string;
  42140. /** @hidden */
  42141. _setupInputs(): void;
  42142. }
  42143. }
  42144. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42145. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42146. import { Scene } from "babylonjs/scene";
  42147. import { Vector3 } from "babylonjs/Maths/math.vector";
  42148. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42149. import { Axis } from "babylonjs/Maths/math.axis";
  42150. /**
  42151. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42152. * being tilted forward or back and left or right.
  42153. */
  42154. export class DeviceOrientationCamera extends FreeCamera {
  42155. private _initialQuaternion;
  42156. private _quaternionCache;
  42157. private _tmpDragQuaternion;
  42158. private _disablePointerInputWhenUsingDeviceOrientation;
  42159. /**
  42160. * Creates a new device orientation camera
  42161. * @param name The name of the camera
  42162. * @param position The start position camera
  42163. * @param scene The scene the camera belongs to
  42164. */
  42165. constructor(name: string, position: Vector3, scene: Scene);
  42166. /**
  42167. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42168. */
  42169. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42170. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42171. private _dragFactor;
  42172. /**
  42173. * Enabled turning on the y axis when the orientation sensor is active
  42174. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42175. */
  42176. enableHorizontalDragging(dragFactor?: number): void;
  42177. /**
  42178. * Gets the current instance class name ("DeviceOrientationCamera").
  42179. * This helps avoiding instanceof at run time.
  42180. * @returns the class name
  42181. */
  42182. getClassName(): string;
  42183. /**
  42184. * @hidden
  42185. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42186. */
  42187. _checkInputs(): void;
  42188. /**
  42189. * Reset the camera to its default orientation on the specified axis only.
  42190. * @param axis The axis to reset
  42191. */
  42192. resetToCurrentRotation(axis?: Axis): void;
  42193. }
  42194. }
  42195. declare module "babylonjs/Gamepads/xboxGamepad" {
  42196. import { Observable } from "babylonjs/Misc/observable";
  42197. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42198. /**
  42199. * Defines supported buttons for XBox360 compatible gamepads
  42200. */
  42201. export enum Xbox360Button {
  42202. /** A */
  42203. A = 0,
  42204. /** B */
  42205. B = 1,
  42206. /** X */
  42207. X = 2,
  42208. /** Y */
  42209. Y = 3,
  42210. /** Start */
  42211. Start = 4,
  42212. /** Back */
  42213. Back = 5,
  42214. /** Left button */
  42215. LB = 6,
  42216. /** Right button */
  42217. RB = 7,
  42218. /** Left stick */
  42219. LeftStick = 8,
  42220. /** Right stick */
  42221. RightStick = 9
  42222. }
  42223. /** Defines values for XBox360 DPad */
  42224. export enum Xbox360Dpad {
  42225. /** Up */
  42226. Up = 0,
  42227. /** Down */
  42228. Down = 1,
  42229. /** Left */
  42230. Left = 2,
  42231. /** Right */
  42232. Right = 3
  42233. }
  42234. /**
  42235. * Defines a XBox360 gamepad
  42236. */
  42237. export class Xbox360Pad extends Gamepad {
  42238. private _leftTrigger;
  42239. private _rightTrigger;
  42240. private _onlefttriggerchanged;
  42241. private _onrighttriggerchanged;
  42242. private _onbuttondown;
  42243. private _onbuttonup;
  42244. private _ondpaddown;
  42245. private _ondpadup;
  42246. /** Observable raised when a button is pressed */
  42247. onButtonDownObservable: Observable<Xbox360Button>;
  42248. /** Observable raised when a button is released */
  42249. onButtonUpObservable: Observable<Xbox360Button>;
  42250. /** Observable raised when a pad is pressed */
  42251. onPadDownObservable: Observable<Xbox360Dpad>;
  42252. /** Observable raised when a pad is released */
  42253. onPadUpObservable: Observable<Xbox360Dpad>;
  42254. private _buttonA;
  42255. private _buttonB;
  42256. private _buttonX;
  42257. private _buttonY;
  42258. private _buttonBack;
  42259. private _buttonStart;
  42260. private _buttonLB;
  42261. private _buttonRB;
  42262. private _buttonLeftStick;
  42263. private _buttonRightStick;
  42264. private _dPadUp;
  42265. private _dPadDown;
  42266. private _dPadLeft;
  42267. private _dPadRight;
  42268. private _isXboxOnePad;
  42269. /**
  42270. * Creates a new XBox360 gamepad object
  42271. * @param id defines the id of this gamepad
  42272. * @param index defines its index
  42273. * @param gamepad defines the internal HTML gamepad object
  42274. * @param xboxOne defines if it is a XBox One gamepad
  42275. */
  42276. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42277. /**
  42278. * Defines the callback to call when left trigger is pressed
  42279. * @param callback defines the callback to use
  42280. */
  42281. onlefttriggerchanged(callback: (value: number) => void): void;
  42282. /**
  42283. * Defines the callback to call when right trigger is pressed
  42284. * @param callback defines the callback to use
  42285. */
  42286. onrighttriggerchanged(callback: (value: number) => void): void;
  42287. /**
  42288. * Gets the left trigger value
  42289. */
  42290. get leftTrigger(): number;
  42291. /**
  42292. * Sets the left trigger value
  42293. */
  42294. set leftTrigger(newValue: number);
  42295. /**
  42296. * Gets the right trigger value
  42297. */
  42298. get rightTrigger(): number;
  42299. /**
  42300. * Sets the right trigger value
  42301. */
  42302. set rightTrigger(newValue: number);
  42303. /**
  42304. * Defines the callback to call when a button is pressed
  42305. * @param callback defines the callback to use
  42306. */
  42307. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42308. /**
  42309. * Defines the callback to call when a button is released
  42310. * @param callback defines the callback to use
  42311. */
  42312. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42313. /**
  42314. * Defines the callback to call when a pad is pressed
  42315. * @param callback defines the callback to use
  42316. */
  42317. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42318. /**
  42319. * Defines the callback to call when a pad is released
  42320. * @param callback defines the callback to use
  42321. */
  42322. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42323. private _setButtonValue;
  42324. private _setDPadValue;
  42325. /**
  42326. * Gets the value of the `A` button
  42327. */
  42328. get buttonA(): number;
  42329. /**
  42330. * Sets the value of the `A` button
  42331. */
  42332. set buttonA(value: number);
  42333. /**
  42334. * Gets the value of the `B` button
  42335. */
  42336. get buttonB(): number;
  42337. /**
  42338. * Sets the value of the `B` button
  42339. */
  42340. set buttonB(value: number);
  42341. /**
  42342. * Gets the value of the `X` button
  42343. */
  42344. get buttonX(): number;
  42345. /**
  42346. * Sets the value of the `X` button
  42347. */
  42348. set buttonX(value: number);
  42349. /**
  42350. * Gets the value of the `Y` button
  42351. */
  42352. get buttonY(): number;
  42353. /**
  42354. * Sets the value of the `Y` button
  42355. */
  42356. set buttonY(value: number);
  42357. /**
  42358. * Gets the value of the `Start` button
  42359. */
  42360. get buttonStart(): number;
  42361. /**
  42362. * Sets the value of the `Start` button
  42363. */
  42364. set buttonStart(value: number);
  42365. /**
  42366. * Gets the value of the `Back` button
  42367. */
  42368. get buttonBack(): number;
  42369. /**
  42370. * Sets the value of the `Back` button
  42371. */
  42372. set buttonBack(value: number);
  42373. /**
  42374. * Gets the value of the `Left` button
  42375. */
  42376. get buttonLB(): number;
  42377. /**
  42378. * Sets the value of the `Left` button
  42379. */
  42380. set buttonLB(value: number);
  42381. /**
  42382. * Gets the value of the `Right` button
  42383. */
  42384. get buttonRB(): number;
  42385. /**
  42386. * Sets the value of the `Right` button
  42387. */
  42388. set buttonRB(value: number);
  42389. /**
  42390. * Gets the value of the Left joystick
  42391. */
  42392. get buttonLeftStick(): number;
  42393. /**
  42394. * Sets the value of the Left joystick
  42395. */
  42396. set buttonLeftStick(value: number);
  42397. /**
  42398. * Gets the value of the Right joystick
  42399. */
  42400. get buttonRightStick(): number;
  42401. /**
  42402. * Sets the value of the Right joystick
  42403. */
  42404. set buttonRightStick(value: number);
  42405. /**
  42406. * Gets the value of D-pad up
  42407. */
  42408. get dPadUp(): number;
  42409. /**
  42410. * Sets the value of D-pad up
  42411. */
  42412. set dPadUp(value: number);
  42413. /**
  42414. * Gets the value of D-pad down
  42415. */
  42416. get dPadDown(): number;
  42417. /**
  42418. * Sets the value of D-pad down
  42419. */
  42420. set dPadDown(value: number);
  42421. /**
  42422. * Gets the value of D-pad left
  42423. */
  42424. get dPadLeft(): number;
  42425. /**
  42426. * Sets the value of D-pad left
  42427. */
  42428. set dPadLeft(value: number);
  42429. /**
  42430. * Gets the value of D-pad right
  42431. */
  42432. get dPadRight(): number;
  42433. /**
  42434. * Sets the value of D-pad right
  42435. */
  42436. set dPadRight(value: number);
  42437. /**
  42438. * Force the gamepad to synchronize with device values
  42439. */
  42440. update(): void;
  42441. /**
  42442. * Disposes the gamepad
  42443. */
  42444. dispose(): void;
  42445. }
  42446. }
  42447. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42448. import { Observable } from "babylonjs/Misc/observable";
  42449. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42450. /**
  42451. * Defines supported buttons for DualShock compatible gamepads
  42452. */
  42453. export enum DualShockButton {
  42454. /** Cross */
  42455. Cross = 0,
  42456. /** Circle */
  42457. Circle = 1,
  42458. /** Square */
  42459. Square = 2,
  42460. /** Triangle */
  42461. Triangle = 3,
  42462. /** Options */
  42463. Options = 4,
  42464. /** Share */
  42465. Share = 5,
  42466. /** L1 */
  42467. L1 = 6,
  42468. /** R1 */
  42469. R1 = 7,
  42470. /** Left stick */
  42471. LeftStick = 8,
  42472. /** Right stick */
  42473. RightStick = 9
  42474. }
  42475. /** Defines values for DualShock DPad */
  42476. export enum DualShockDpad {
  42477. /** Up */
  42478. Up = 0,
  42479. /** Down */
  42480. Down = 1,
  42481. /** Left */
  42482. Left = 2,
  42483. /** Right */
  42484. Right = 3
  42485. }
  42486. /**
  42487. * Defines a DualShock gamepad
  42488. */
  42489. export class DualShockPad extends Gamepad {
  42490. private _leftTrigger;
  42491. private _rightTrigger;
  42492. private _onlefttriggerchanged;
  42493. private _onrighttriggerchanged;
  42494. private _onbuttondown;
  42495. private _onbuttonup;
  42496. private _ondpaddown;
  42497. private _ondpadup;
  42498. /** Observable raised when a button is pressed */
  42499. onButtonDownObservable: Observable<DualShockButton>;
  42500. /** Observable raised when a button is released */
  42501. onButtonUpObservable: Observable<DualShockButton>;
  42502. /** Observable raised when a pad is pressed */
  42503. onPadDownObservable: Observable<DualShockDpad>;
  42504. /** Observable raised when a pad is released */
  42505. onPadUpObservable: Observable<DualShockDpad>;
  42506. private _buttonCross;
  42507. private _buttonCircle;
  42508. private _buttonSquare;
  42509. private _buttonTriangle;
  42510. private _buttonShare;
  42511. private _buttonOptions;
  42512. private _buttonL1;
  42513. private _buttonR1;
  42514. private _buttonLeftStick;
  42515. private _buttonRightStick;
  42516. private _dPadUp;
  42517. private _dPadDown;
  42518. private _dPadLeft;
  42519. private _dPadRight;
  42520. /**
  42521. * Creates a new DualShock gamepad object
  42522. * @param id defines the id of this gamepad
  42523. * @param index defines its index
  42524. * @param gamepad defines the internal HTML gamepad object
  42525. */
  42526. constructor(id: string, index: number, gamepad: any);
  42527. /**
  42528. * Defines the callback to call when left trigger is pressed
  42529. * @param callback defines the callback to use
  42530. */
  42531. onlefttriggerchanged(callback: (value: number) => void): void;
  42532. /**
  42533. * Defines the callback to call when right trigger is pressed
  42534. * @param callback defines the callback to use
  42535. */
  42536. onrighttriggerchanged(callback: (value: number) => void): void;
  42537. /**
  42538. * Gets the left trigger value
  42539. */
  42540. get leftTrigger(): number;
  42541. /**
  42542. * Sets the left trigger value
  42543. */
  42544. set leftTrigger(newValue: number);
  42545. /**
  42546. * Gets the right trigger value
  42547. */
  42548. get rightTrigger(): number;
  42549. /**
  42550. * Sets the right trigger value
  42551. */
  42552. set rightTrigger(newValue: number);
  42553. /**
  42554. * Defines the callback to call when a button is pressed
  42555. * @param callback defines the callback to use
  42556. */
  42557. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42558. /**
  42559. * Defines the callback to call when a button is released
  42560. * @param callback defines the callback to use
  42561. */
  42562. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42563. /**
  42564. * Defines the callback to call when a pad is pressed
  42565. * @param callback defines the callback to use
  42566. */
  42567. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42568. /**
  42569. * Defines the callback to call when a pad is released
  42570. * @param callback defines the callback to use
  42571. */
  42572. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42573. private _setButtonValue;
  42574. private _setDPadValue;
  42575. /**
  42576. * Gets the value of the `Cross` button
  42577. */
  42578. get buttonCross(): number;
  42579. /**
  42580. * Sets the value of the `Cross` button
  42581. */
  42582. set buttonCross(value: number);
  42583. /**
  42584. * Gets the value of the `Circle` button
  42585. */
  42586. get buttonCircle(): number;
  42587. /**
  42588. * Sets the value of the `Circle` button
  42589. */
  42590. set buttonCircle(value: number);
  42591. /**
  42592. * Gets the value of the `Square` button
  42593. */
  42594. get buttonSquare(): number;
  42595. /**
  42596. * Sets the value of the `Square` button
  42597. */
  42598. set buttonSquare(value: number);
  42599. /**
  42600. * Gets the value of the `Triangle` button
  42601. */
  42602. get buttonTriangle(): number;
  42603. /**
  42604. * Sets the value of the `Triangle` button
  42605. */
  42606. set buttonTriangle(value: number);
  42607. /**
  42608. * Gets the value of the `Options` button
  42609. */
  42610. get buttonOptions(): number;
  42611. /**
  42612. * Sets the value of the `Options` button
  42613. */
  42614. set buttonOptions(value: number);
  42615. /**
  42616. * Gets the value of the `Share` button
  42617. */
  42618. get buttonShare(): number;
  42619. /**
  42620. * Sets the value of the `Share` button
  42621. */
  42622. set buttonShare(value: number);
  42623. /**
  42624. * Gets the value of the `L1` button
  42625. */
  42626. get buttonL1(): number;
  42627. /**
  42628. * Sets the value of the `L1` button
  42629. */
  42630. set buttonL1(value: number);
  42631. /**
  42632. * Gets the value of the `R1` button
  42633. */
  42634. get buttonR1(): number;
  42635. /**
  42636. * Sets the value of the `R1` button
  42637. */
  42638. set buttonR1(value: number);
  42639. /**
  42640. * Gets the value of the Left joystick
  42641. */
  42642. get buttonLeftStick(): number;
  42643. /**
  42644. * Sets the value of the Left joystick
  42645. */
  42646. set buttonLeftStick(value: number);
  42647. /**
  42648. * Gets the value of the Right joystick
  42649. */
  42650. get buttonRightStick(): number;
  42651. /**
  42652. * Sets the value of the Right joystick
  42653. */
  42654. set buttonRightStick(value: number);
  42655. /**
  42656. * Gets the value of D-pad up
  42657. */
  42658. get dPadUp(): number;
  42659. /**
  42660. * Sets the value of D-pad up
  42661. */
  42662. set dPadUp(value: number);
  42663. /**
  42664. * Gets the value of D-pad down
  42665. */
  42666. get dPadDown(): number;
  42667. /**
  42668. * Sets the value of D-pad down
  42669. */
  42670. set dPadDown(value: number);
  42671. /**
  42672. * Gets the value of D-pad left
  42673. */
  42674. get dPadLeft(): number;
  42675. /**
  42676. * Sets the value of D-pad left
  42677. */
  42678. set dPadLeft(value: number);
  42679. /**
  42680. * Gets the value of D-pad right
  42681. */
  42682. get dPadRight(): number;
  42683. /**
  42684. * Sets the value of D-pad right
  42685. */
  42686. set dPadRight(value: number);
  42687. /**
  42688. * Force the gamepad to synchronize with device values
  42689. */
  42690. update(): void;
  42691. /**
  42692. * Disposes the gamepad
  42693. */
  42694. dispose(): void;
  42695. }
  42696. }
  42697. declare module "babylonjs/Gamepads/gamepadManager" {
  42698. import { Observable } from "babylonjs/Misc/observable";
  42699. import { Nullable } from "babylonjs/types";
  42700. import { Scene } from "babylonjs/scene";
  42701. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42702. /**
  42703. * Manager for handling gamepads
  42704. */
  42705. export class GamepadManager {
  42706. private _scene?;
  42707. private _babylonGamepads;
  42708. private _oneGamepadConnected;
  42709. /** @hidden */
  42710. _isMonitoring: boolean;
  42711. private _gamepadEventSupported;
  42712. private _gamepadSupport?;
  42713. /**
  42714. * observable to be triggered when the gamepad controller has been connected
  42715. */
  42716. onGamepadConnectedObservable: Observable<Gamepad>;
  42717. /**
  42718. * observable to be triggered when the gamepad controller has been disconnected
  42719. */
  42720. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42721. private _onGamepadConnectedEvent;
  42722. private _onGamepadDisconnectedEvent;
  42723. /**
  42724. * Initializes the gamepad manager
  42725. * @param _scene BabylonJS scene
  42726. */
  42727. constructor(_scene?: Scene | undefined);
  42728. /**
  42729. * The gamepads in the game pad manager
  42730. */
  42731. get gamepads(): Gamepad[];
  42732. /**
  42733. * Get the gamepad controllers based on type
  42734. * @param type The type of gamepad controller
  42735. * @returns Nullable gamepad
  42736. */
  42737. getGamepadByType(type?: number): Nullable<Gamepad>;
  42738. /**
  42739. * Disposes the gamepad manager
  42740. */
  42741. dispose(): void;
  42742. private _addNewGamepad;
  42743. private _startMonitoringGamepads;
  42744. private _stopMonitoringGamepads;
  42745. /** @hidden */
  42746. _checkGamepadsStatus(): void;
  42747. private _updateGamepadObjects;
  42748. }
  42749. }
  42750. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42751. import { Nullable } from "babylonjs/types";
  42752. import { Scene } from "babylonjs/scene";
  42753. import { ISceneComponent } from "babylonjs/sceneComponent";
  42754. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42755. module "babylonjs/scene" {
  42756. interface Scene {
  42757. /** @hidden */
  42758. _gamepadManager: Nullable<GamepadManager>;
  42759. /**
  42760. * Gets the gamepad manager associated with the scene
  42761. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42762. */
  42763. gamepadManager: GamepadManager;
  42764. }
  42765. }
  42766. module "babylonjs/Cameras/freeCameraInputsManager" {
  42767. /**
  42768. * Interface representing a free camera inputs manager
  42769. */
  42770. interface FreeCameraInputsManager {
  42771. /**
  42772. * Adds gamepad input support to the FreeCameraInputsManager.
  42773. * @returns the FreeCameraInputsManager
  42774. */
  42775. addGamepad(): FreeCameraInputsManager;
  42776. }
  42777. }
  42778. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42779. /**
  42780. * Interface representing an arc rotate camera inputs manager
  42781. */
  42782. interface ArcRotateCameraInputsManager {
  42783. /**
  42784. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42785. * @returns the camera inputs manager
  42786. */
  42787. addGamepad(): ArcRotateCameraInputsManager;
  42788. }
  42789. }
  42790. /**
  42791. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42792. */
  42793. export class GamepadSystemSceneComponent implements ISceneComponent {
  42794. /**
  42795. * The component name helpfull to identify the component in the list of scene components.
  42796. */
  42797. readonly name: string;
  42798. /**
  42799. * The scene the component belongs to.
  42800. */
  42801. scene: Scene;
  42802. /**
  42803. * Creates a new instance of the component for the given scene
  42804. * @param scene Defines the scene to register the component in
  42805. */
  42806. constructor(scene: Scene);
  42807. /**
  42808. * Registers the component in a given scene
  42809. */
  42810. register(): void;
  42811. /**
  42812. * Rebuilds the elements related to this component in case of
  42813. * context lost for instance.
  42814. */
  42815. rebuild(): void;
  42816. /**
  42817. * Disposes the component and the associated ressources
  42818. */
  42819. dispose(): void;
  42820. private _beforeCameraUpdate;
  42821. }
  42822. }
  42823. declare module "babylonjs/Cameras/universalCamera" {
  42824. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42825. import { Scene } from "babylonjs/scene";
  42826. import { Vector3 } from "babylonjs/Maths/math.vector";
  42827. import "babylonjs/Gamepads/gamepadSceneComponent";
  42828. /**
  42829. * 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,
  42830. * which still works and will still be found in many Playgrounds.
  42831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42832. */
  42833. export class UniversalCamera extends TouchCamera {
  42834. /**
  42835. * Defines the gamepad rotation sensiblity.
  42836. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42837. */
  42838. get gamepadAngularSensibility(): number;
  42839. set gamepadAngularSensibility(value: number);
  42840. /**
  42841. * Defines the gamepad move sensiblity.
  42842. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42843. */
  42844. get gamepadMoveSensibility(): number;
  42845. set gamepadMoveSensibility(value: number);
  42846. /**
  42847. * 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,
  42848. * which still works and will still be found in many Playgrounds.
  42849. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42850. * @param name Define the name of the camera in the scene
  42851. * @param position Define the start position of the camera in the scene
  42852. * @param scene Define the scene the camera belongs to
  42853. */
  42854. constructor(name: string, position: Vector3, scene: Scene);
  42855. /**
  42856. * Gets the current object class name.
  42857. * @return the class name
  42858. */
  42859. getClassName(): string;
  42860. }
  42861. }
  42862. declare module "babylonjs/Cameras/gamepadCamera" {
  42863. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42864. import { Scene } from "babylonjs/scene";
  42865. import { Vector3 } from "babylonjs/Maths/math.vector";
  42866. /**
  42867. * This represents a FPS type of camera. This is only here for back compat purpose.
  42868. * Please use the UniversalCamera instead as both are identical.
  42869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42870. */
  42871. export class GamepadCamera extends UniversalCamera {
  42872. /**
  42873. * Instantiates a new Gamepad Camera
  42874. * This represents a FPS type of camera. This is only here for back compat purpose.
  42875. * Please use the UniversalCamera instead as both are identical.
  42876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42877. * @param name Define the name of the camera in the scene
  42878. * @param position Define the start position of the camera in the scene
  42879. * @param scene Define the scene the camera belongs to
  42880. */
  42881. constructor(name: string, position: Vector3, scene: Scene);
  42882. /**
  42883. * Gets the current object class name.
  42884. * @return the class name
  42885. */
  42886. getClassName(): string;
  42887. }
  42888. }
  42889. declare module "babylonjs/Shaders/pass.fragment" {
  42890. /** @hidden */
  42891. export var passPixelShader: {
  42892. name: string;
  42893. shader: string;
  42894. };
  42895. }
  42896. declare module "babylonjs/Shaders/passCube.fragment" {
  42897. /** @hidden */
  42898. export var passCubePixelShader: {
  42899. name: string;
  42900. shader: string;
  42901. };
  42902. }
  42903. declare module "babylonjs/PostProcesses/passPostProcess" {
  42904. import { Nullable } from "babylonjs/types";
  42905. import { Camera } from "babylonjs/Cameras/camera";
  42906. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42907. import { Engine } from "babylonjs/Engines/engine";
  42908. import "babylonjs/Shaders/pass.fragment";
  42909. import "babylonjs/Shaders/passCube.fragment";
  42910. /**
  42911. * PassPostProcess which produces an output the same as it's input
  42912. */
  42913. export class PassPostProcess extends PostProcess {
  42914. /**
  42915. * Creates the PassPostProcess
  42916. * @param name The name of the effect.
  42917. * @param options The required width/height ratio to downsize to before computing the render pass.
  42918. * @param camera The camera to apply the render pass to.
  42919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42920. * @param engine The engine which the post process will be applied. (default: current engine)
  42921. * @param reusable If the post process can be reused on the same frame. (default: false)
  42922. * @param textureType The type of texture to be used when performing the post processing.
  42923. * @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)
  42924. */
  42925. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42926. }
  42927. /**
  42928. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42929. */
  42930. export class PassCubePostProcess extends PostProcess {
  42931. private _face;
  42932. /**
  42933. * Gets or sets the cube face to display.
  42934. * * 0 is +X
  42935. * * 1 is -X
  42936. * * 2 is +Y
  42937. * * 3 is -Y
  42938. * * 4 is +Z
  42939. * * 5 is -Z
  42940. */
  42941. get face(): number;
  42942. set face(value: number);
  42943. /**
  42944. * Creates the PassCubePostProcess
  42945. * @param name The name of the effect.
  42946. * @param options The required width/height ratio to downsize to before computing the render pass.
  42947. * @param camera The camera to apply the render pass to.
  42948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42949. * @param engine The engine which the post process will be applied. (default: current engine)
  42950. * @param reusable If the post process can be reused on the same frame. (default: false)
  42951. * @param textureType The type of texture to be used when performing the post processing.
  42952. * @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)
  42953. */
  42954. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42955. }
  42956. }
  42957. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42958. /** @hidden */
  42959. export var anaglyphPixelShader: {
  42960. name: string;
  42961. shader: string;
  42962. };
  42963. }
  42964. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42965. import { Engine } from "babylonjs/Engines/engine";
  42966. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42967. import { Camera } from "babylonjs/Cameras/camera";
  42968. import "babylonjs/Shaders/anaglyph.fragment";
  42969. /**
  42970. * Postprocess used to generate anaglyphic rendering
  42971. */
  42972. export class AnaglyphPostProcess extends PostProcess {
  42973. private _passedProcess;
  42974. /**
  42975. * Creates a new AnaglyphPostProcess
  42976. * @param name defines postprocess name
  42977. * @param options defines creation options or target ratio scale
  42978. * @param rigCameras defines cameras using this postprocess
  42979. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42980. * @param engine defines hosting engine
  42981. * @param reusable defines if the postprocess will be reused multiple times per frame
  42982. */
  42983. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42984. }
  42985. }
  42986. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42987. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42988. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42989. import { Scene } from "babylonjs/scene";
  42990. import { Vector3 } from "babylonjs/Maths/math.vector";
  42991. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42992. /**
  42993. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42994. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42995. */
  42996. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42997. /**
  42998. * Creates a new AnaglyphArcRotateCamera
  42999. * @param name defines camera name
  43000. * @param alpha defines alpha angle (in radians)
  43001. * @param beta defines beta angle (in radians)
  43002. * @param radius defines radius
  43003. * @param target defines camera target
  43004. * @param interaxialDistance defines distance between each color axis
  43005. * @param scene defines the hosting scene
  43006. */
  43007. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43008. /**
  43009. * Gets camera class name
  43010. * @returns AnaglyphArcRotateCamera
  43011. */
  43012. getClassName(): string;
  43013. }
  43014. }
  43015. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43016. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43017. import { Scene } from "babylonjs/scene";
  43018. import { Vector3 } from "babylonjs/Maths/math.vector";
  43019. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43020. /**
  43021. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43022. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43023. */
  43024. export class AnaglyphFreeCamera extends FreeCamera {
  43025. /**
  43026. * Creates a new AnaglyphFreeCamera
  43027. * @param name defines camera name
  43028. * @param position defines initial position
  43029. * @param interaxialDistance defines distance between each color axis
  43030. * @param scene defines the hosting scene
  43031. */
  43032. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43033. /**
  43034. * Gets camera class name
  43035. * @returns AnaglyphFreeCamera
  43036. */
  43037. getClassName(): string;
  43038. }
  43039. }
  43040. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43041. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43042. import { Scene } from "babylonjs/scene";
  43043. import { Vector3 } from "babylonjs/Maths/math.vector";
  43044. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43045. /**
  43046. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43047. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43048. */
  43049. export class AnaglyphGamepadCamera extends GamepadCamera {
  43050. /**
  43051. * Creates a new AnaglyphGamepadCamera
  43052. * @param name defines camera name
  43053. * @param position defines initial position
  43054. * @param interaxialDistance defines distance between each color axis
  43055. * @param scene defines the hosting scene
  43056. */
  43057. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43058. /**
  43059. * Gets camera class name
  43060. * @returns AnaglyphGamepadCamera
  43061. */
  43062. getClassName(): string;
  43063. }
  43064. }
  43065. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43066. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43067. import { Scene } from "babylonjs/scene";
  43068. import { Vector3 } from "babylonjs/Maths/math.vector";
  43069. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43070. /**
  43071. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43072. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43073. */
  43074. export class AnaglyphUniversalCamera extends UniversalCamera {
  43075. /**
  43076. * Creates a new AnaglyphUniversalCamera
  43077. * @param name defines camera name
  43078. * @param position defines initial position
  43079. * @param interaxialDistance defines distance between each color axis
  43080. * @param scene defines the hosting scene
  43081. */
  43082. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43083. /**
  43084. * Gets camera class name
  43085. * @returns AnaglyphUniversalCamera
  43086. */
  43087. getClassName(): string;
  43088. }
  43089. }
  43090. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43091. /** @hidden */
  43092. export var stereoscopicInterlacePixelShader: {
  43093. name: string;
  43094. shader: string;
  43095. };
  43096. }
  43097. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43098. import { Camera } from "babylonjs/Cameras/camera";
  43099. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43100. import { Engine } from "babylonjs/Engines/engine";
  43101. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43102. /**
  43103. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43104. */
  43105. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43106. private _stepSize;
  43107. private _passedProcess;
  43108. /**
  43109. * Initializes a StereoscopicInterlacePostProcessI
  43110. * @param name The name of the effect.
  43111. * @param rigCameras The rig cameras to be appled to the post process
  43112. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43113. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43115. * @param engine The engine which the post process will be applied. (default: current engine)
  43116. * @param reusable If the post process can be reused on the same frame. (default: false)
  43117. */
  43118. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43119. }
  43120. /**
  43121. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43122. */
  43123. export class StereoscopicInterlacePostProcess extends PostProcess {
  43124. private _stepSize;
  43125. private _passedProcess;
  43126. /**
  43127. * Initializes a StereoscopicInterlacePostProcess
  43128. * @param name The name of the effect.
  43129. * @param rigCameras The rig cameras to be appled to the post process
  43130. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43132. * @param engine The engine which the post process will be applied. (default: current engine)
  43133. * @param reusable If the post process can be reused on the same frame. (default: false)
  43134. */
  43135. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43136. }
  43137. }
  43138. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43139. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43140. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43141. import { Scene } from "babylonjs/scene";
  43142. import { Vector3 } from "babylonjs/Maths/math.vector";
  43143. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43144. /**
  43145. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43146. * @see http://doc.babylonjs.com/features/cameras
  43147. */
  43148. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43149. /**
  43150. * Creates a new StereoscopicArcRotateCamera
  43151. * @param name defines camera name
  43152. * @param alpha defines alpha angle (in radians)
  43153. * @param beta defines beta angle (in radians)
  43154. * @param radius defines radius
  43155. * @param target defines camera target
  43156. * @param interaxialDistance defines distance between each color axis
  43157. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43158. * @param scene defines the hosting scene
  43159. */
  43160. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43161. /**
  43162. * Gets camera class name
  43163. * @returns StereoscopicArcRotateCamera
  43164. */
  43165. getClassName(): string;
  43166. }
  43167. }
  43168. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43169. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43170. import { Scene } from "babylonjs/scene";
  43171. import { Vector3 } from "babylonjs/Maths/math.vector";
  43172. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43173. /**
  43174. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43175. * @see http://doc.babylonjs.com/features/cameras
  43176. */
  43177. export class StereoscopicFreeCamera extends FreeCamera {
  43178. /**
  43179. * Creates a new StereoscopicFreeCamera
  43180. * @param name defines camera name
  43181. * @param position defines initial position
  43182. * @param interaxialDistance defines distance between each color axis
  43183. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43184. * @param scene defines the hosting scene
  43185. */
  43186. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43187. /**
  43188. * Gets camera class name
  43189. * @returns StereoscopicFreeCamera
  43190. */
  43191. getClassName(): string;
  43192. }
  43193. }
  43194. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43195. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43196. import { Scene } from "babylonjs/scene";
  43197. import { Vector3 } from "babylonjs/Maths/math.vector";
  43198. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43199. /**
  43200. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43201. * @see http://doc.babylonjs.com/features/cameras
  43202. */
  43203. export class StereoscopicGamepadCamera extends GamepadCamera {
  43204. /**
  43205. * Creates a new StereoscopicGamepadCamera
  43206. * @param name defines camera name
  43207. * @param position defines initial position
  43208. * @param interaxialDistance defines distance between each color axis
  43209. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43210. * @param scene defines the hosting scene
  43211. */
  43212. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43213. /**
  43214. * Gets camera class name
  43215. * @returns StereoscopicGamepadCamera
  43216. */
  43217. getClassName(): string;
  43218. }
  43219. }
  43220. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43221. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43222. import { Scene } from "babylonjs/scene";
  43223. import { Vector3 } from "babylonjs/Maths/math.vector";
  43224. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43225. /**
  43226. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43227. * @see http://doc.babylonjs.com/features/cameras
  43228. */
  43229. export class StereoscopicUniversalCamera extends UniversalCamera {
  43230. /**
  43231. * Creates a new StereoscopicUniversalCamera
  43232. * @param name defines camera name
  43233. * @param position defines initial position
  43234. * @param interaxialDistance defines distance between each color axis
  43235. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43236. * @param scene defines the hosting scene
  43237. */
  43238. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43239. /**
  43240. * Gets camera class name
  43241. * @returns StereoscopicUniversalCamera
  43242. */
  43243. getClassName(): string;
  43244. }
  43245. }
  43246. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43247. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43248. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43249. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43250. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43251. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43252. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43253. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43254. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43255. }
  43256. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43257. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43258. import { Scene } from "babylonjs/scene";
  43259. import { Vector3 } from "babylonjs/Maths/math.vector";
  43260. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43261. /**
  43262. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43263. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43264. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43265. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43266. */
  43267. export class VirtualJoysticksCamera extends FreeCamera {
  43268. /**
  43269. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43270. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43271. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43272. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43273. * @param name Define the name of the camera in the scene
  43274. * @param position Define the start position of the camera in the scene
  43275. * @param scene Define the scene the camera belongs to
  43276. */
  43277. constructor(name: string, position: Vector3, scene: Scene);
  43278. /**
  43279. * Gets the current object class name.
  43280. * @return the class name
  43281. */
  43282. getClassName(): string;
  43283. }
  43284. }
  43285. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43286. import { Matrix } from "babylonjs/Maths/math.vector";
  43287. /**
  43288. * This represents all the required metrics to create a VR camera.
  43289. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43290. */
  43291. export class VRCameraMetrics {
  43292. /**
  43293. * Define the horizontal resolution off the screen.
  43294. */
  43295. hResolution: number;
  43296. /**
  43297. * Define the vertical resolution off the screen.
  43298. */
  43299. vResolution: number;
  43300. /**
  43301. * Define the horizontal screen size.
  43302. */
  43303. hScreenSize: number;
  43304. /**
  43305. * Define the vertical screen size.
  43306. */
  43307. vScreenSize: number;
  43308. /**
  43309. * Define the vertical screen center position.
  43310. */
  43311. vScreenCenter: number;
  43312. /**
  43313. * Define the distance of the eyes to the screen.
  43314. */
  43315. eyeToScreenDistance: number;
  43316. /**
  43317. * Define the distance between both lenses
  43318. */
  43319. lensSeparationDistance: number;
  43320. /**
  43321. * Define the distance between both viewer's eyes.
  43322. */
  43323. interpupillaryDistance: number;
  43324. /**
  43325. * Define the distortion factor of the VR postprocess.
  43326. * Please, touch with care.
  43327. */
  43328. distortionK: number[];
  43329. /**
  43330. * Define the chromatic aberration correction factors for the VR post process.
  43331. */
  43332. chromaAbCorrection: number[];
  43333. /**
  43334. * Define the scale factor of the post process.
  43335. * The smaller the better but the slower.
  43336. */
  43337. postProcessScaleFactor: number;
  43338. /**
  43339. * Define an offset for the lens center.
  43340. */
  43341. lensCenterOffset: number;
  43342. /**
  43343. * Define if the current vr camera should compensate the distortion of the lense or not.
  43344. */
  43345. compensateDistortion: boolean;
  43346. /**
  43347. * Defines if multiview should be enabled when rendering (Default: false)
  43348. */
  43349. multiviewEnabled: boolean;
  43350. /**
  43351. * Gets the rendering aspect ratio based on the provided resolutions.
  43352. */
  43353. get aspectRatio(): number;
  43354. /**
  43355. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43356. */
  43357. get aspectRatioFov(): number;
  43358. /**
  43359. * @hidden
  43360. */
  43361. get leftHMatrix(): Matrix;
  43362. /**
  43363. * @hidden
  43364. */
  43365. get rightHMatrix(): Matrix;
  43366. /**
  43367. * @hidden
  43368. */
  43369. get leftPreViewMatrix(): Matrix;
  43370. /**
  43371. * @hidden
  43372. */
  43373. get rightPreViewMatrix(): Matrix;
  43374. /**
  43375. * Get the default VRMetrics based on the most generic setup.
  43376. * @returns the default vr metrics
  43377. */
  43378. static GetDefault(): VRCameraMetrics;
  43379. }
  43380. }
  43381. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43382. /** @hidden */
  43383. export var vrDistortionCorrectionPixelShader: {
  43384. name: string;
  43385. shader: string;
  43386. };
  43387. }
  43388. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43389. import { Camera } from "babylonjs/Cameras/camera";
  43390. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43391. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43392. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43393. /**
  43394. * VRDistortionCorrectionPostProcess used for mobile VR
  43395. */
  43396. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43397. private _isRightEye;
  43398. private _distortionFactors;
  43399. private _postProcessScaleFactor;
  43400. private _lensCenterOffset;
  43401. private _scaleIn;
  43402. private _scaleFactor;
  43403. private _lensCenter;
  43404. /**
  43405. * Initializes the VRDistortionCorrectionPostProcess
  43406. * @param name The name of the effect.
  43407. * @param camera The camera to apply the render pass to.
  43408. * @param isRightEye If this is for the right eye distortion
  43409. * @param vrMetrics All the required metrics for the VR camera
  43410. */
  43411. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43412. }
  43413. }
  43414. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43415. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43416. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43417. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43418. import { Scene } from "babylonjs/scene";
  43419. import { Vector3 } from "babylonjs/Maths/math.vector";
  43420. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43421. import "babylonjs/Cameras/RigModes/vrRigMode";
  43422. /**
  43423. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43424. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43425. */
  43426. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43427. /**
  43428. * Creates a new VRDeviceOrientationArcRotateCamera
  43429. * @param name defines camera name
  43430. * @param alpha defines the camera rotation along the logitudinal axis
  43431. * @param beta defines the camera rotation along the latitudinal axis
  43432. * @param radius defines the camera distance from its target
  43433. * @param target defines the camera target
  43434. * @param scene defines the scene the camera belongs to
  43435. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43436. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43437. */
  43438. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43439. /**
  43440. * Gets camera class name
  43441. * @returns VRDeviceOrientationArcRotateCamera
  43442. */
  43443. getClassName(): string;
  43444. }
  43445. }
  43446. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43447. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43448. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43449. import { Scene } from "babylonjs/scene";
  43450. import { Vector3 } from "babylonjs/Maths/math.vector";
  43451. import "babylonjs/Cameras/RigModes/vrRigMode";
  43452. /**
  43453. * Camera used to simulate VR rendering (based on FreeCamera)
  43454. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43455. */
  43456. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43457. /**
  43458. * Creates a new VRDeviceOrientationFreeCamera
  43459. * @param name defines camera name
  43460. * @param position defines the start position of the camera
  43461. * @param scene defines the scene the camera belongs to
  43462. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43463. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43464. */
  43465. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43466. /**
  43467. * Gets camera class name
  43468. * @returns VRDeviceOrientationFreeCamera
  43469. */
  43470. getClassName(): string;
  43471. }
  43472. }
  43473. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43474. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43475. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43476. import { Scene } from "babylonjs/scene";
  43477. import { Vector3 } from "babylonjs/Maths/math.vector";
  43478. import "babylonjs/Gamepads/gamepadSceneComponent";
  43479. /**
  43480. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43481. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43482. */
  43483. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43484. /**
  43485. * Creates a new VRDeviceOrientationGamepadCamera
  43486. * @param name defines camera name
  43487. * @param position defines the start position of the camera
  43488. * @param scene defines the scene the camera belongs to
  43489. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43490. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43491. */
  43492. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43493. /**
  43494. * Gets camera class name
  43495. * @returns VRDeviceOrientationGamepadCamera
  43496. */
  43497. getClassName(): string;
  43498. }
  43499. }
  43500. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43501. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43503. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43504. /** @hidden */
  43505. export var imageProcessingPixelShader: {
  43506. name: string;
  43507. shader: string;
  43508. };
  43509. }
  43510. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43511. import { Nullable } from "babylonjs/types";
  43512. import { Color4 } from "babylonjs/Maths/math.color";
  43513. import { Camera } from "babylonjs/Cameras/camera";
  43514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43515. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43516. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43517. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43518. import { Engine } from "babylonjs/Engines/engine";
  43519. import "babylonjs/Shaders/imageProcessing.fragment";
  43520. import "babylonjs/Shaders/postprocess.vertex";
  43521. /**
  43522. * ImageProcessingPostProcess
  43523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43524. */
  43525. export class ImageProcessingPostProcess extends PostProcess {
  43526. /**
  43527. * Default configuration related to image processing available in the PBR Material.
  43528. */
  43529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43530. /**
  43531. * Gets the image processing configuration used either in this material.
  43532. */
  43533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43534. /**
  43535. * Sets the Default image processing configuration used either in the this material.
  43536. *
  43537. * If sets to null, the scene one is in use.
  43538. */
  43539. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43540. /**
  43541. * Keep track of the image processing observer to allow dispose and replace.
  43542. */
  43543. private _imageProcessingObserver;
  43544. /**
  43545. * Attaches a new image processing configuration to the PBR Material.
  43546. * @param configuration
  43547. */
  43548. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43549. /**
  43550. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43551. */
  43552. get colorCurves(): Nullable<ColorCurves>;
  43553. /**
  43554. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43555. */
  43556. set colorCurves(value: Nullable<ColorCurves>);
  43557. /**
  43558. * Gets wether the color curves effect is enabled.
  43559. */
  43560. get colorCurvesEnabled(): boolean;
  43561. /**
  43562. * Sets wether the color curves effect is enabled.
  43563. */
  43564. set colorCurvesEnabled(value: boolean);
  43565. /**
  43566. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43567. */
  43568. get colorGradingTexture(): Nullable<BaseTexture>;
  43569. /**
  43570. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43571. */
  43572. set colorGradingTexture(value: Nullable<BaseTexture>);
  43573. /**
  43574. * Gets wether the color grading effect is enabled.
  43575. */
  43576. get colorGradingEnabled(): boolean;
  43577. /**
  43578. * Gets wether the color grading effect is enabled.
  43579. */
  43580. set colorGradingEnabled(value: boolean);
  43581. /**
  43582. * Gets exposure used in the effect.
  43583. */
  43584. get exposure(): number;
  43585. /**
  43586. * Sets exposure used in the effect.
  43587. */
  43588. set exposure(value: number);
  43589. /**
  43590. * Gets wether tonemapping is enabled or not.
  43591. */
  43592. get toneMappingEnabled(): boolean;
  43593. /**
  43594. * Sets wether tonemapping is enabled or not
  43595. */
  43596. set toneMappingEnabled(value: boolean);
  43597. /**
  43598. * Gets the type of tone mapping effect.
  43599. */
  43600. get toneMappingType(): number;
  43601. /**
  43602. * Sets the type of tone mapping effect.
  43603. */
  43604. set toneMappingType(value: number);
  43605. /**
  43606. * Gets contrast used in the effect.
  43607. */
  43608. get contrast(): number;
  43609. /**
  43610. * Sets contrast used in the effect.
  43611. */
  43612. set contrast(value: number);
  43613. /**
  43614. * Gets Vignette stretch size.
  43615. */
  43616. get vignetteStretch(): number;
  43617. /**
  43618. * Sets Vignette stretch size.
  43619. */
  43620. set vignetteStretch(value: number);
  43621. /**
  43622. * Gets Vignette centre X Offset.
  43623. */
  43624. get vignetteCentreX(): number;
  43625. /**
  43626. * Sets Vignette centre X Offset.
  43627. */
  43628. set vignetteCentreX(value: number);
  43629. /**
  43630. * Gets Vignette centre Y Offset.
  43631. */
  43632. get vignetteCentreY(): number;
  43633. /**
  43634. * Sets Vignette centre Y Offset.
  43635. */
  43636. set vignetteCentreY(value: number);
  43637. /**
  43638. * Gets Vignette weight or intensity of the vignette effect.
  43639. */
  43640. get vignetteWeight(): number;
  43641. /**
  43642. * Sets Vignette weight or intensity of the vignette effect.
  43643. */
  43644. set vignetteWeight(value: number);
  43645. /**
  43646. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43647. * if vignetteEnabled is set to true.
  43648. */
  43649. get vignetteColor(): Color4;
  43650. /**
  43651. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43652. * if vignetteEnabled is set to true.
  43653. */
  43654. set vignetteColor(value: Color4);
  43655. /**
  43656. * Gets Camera field of view used by the Vignette effect.
  43657. */
  43658. get vignetteCameraFov(): number;
  43659. /**
  43660. * Sets Camera field of view used by the Vignette effect.
  43661. */
  43662. set vignetteCameraFov(value: number);
  43663. /**
  43664. * Gets the vignette blend mode allowing different kind of effect.
  43665. */
  43666. get vignetteBlendMode(): number;
  43667. /**
  43668. * Sets the vignette blend mode allowing different kind of effect.
  43669. */
  43670. set vignetteBlendMode(value: number);
  43671. /**
  43672. * Gets wether the vignette effect is enabled.
  43673. */
  43674. get vignetteEnabled(): boolean;
  43675. /**
  43676. * Sets wether the vignette effect is enabled.
  43677. */
  43678. set vignetteEnabled(value: boolean);
  43679. private _fromLinearSpace;
  43680. /**
  43681. * Gets wether the input of the processing is in Gamma or Linear Space.
  43682. */
  43683. get fromLinearSpace(): boolean;
  43684. /**
  43685. * Sets wether the input of the processing is in Gamma or Linear Space.
  43686. */
  43687. set fromLinearSpace(value: boolean);
  43688. /**
  43689. * Defines cache preventing GC.
  43690. */
  43691. private _defines;
  43692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43693. /**
  43694. * "ImageProcessingPostProcess"
  43695. * @returns "ImageProcessingPostProcess"
  43696. */
  43697. getClassName(): string;
  43698. protected _updateParameters(): void;
  43699. dispose(camera?: Camera): void;
  43700. }
  43701. }
  43702. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43703. import { Scene } from "babylonjs/scene";
  43704. import { Color3 } from "babylonjs/Maths/math.color";
  43705. import { Mesh } from "babylonjs/Meshes/mesh";
  43706. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43707. import { Nullable } from "babylonjs/types";
  43708. /**
  43709. * Class containing static functions to help procedurally build meshes
  43710. */
  43711. export class GroundBuilder {
  43712. /**
  43713. * Creates a ground mesh
  43714. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43715. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43717. * @param name defines the name of the mesh
  43718. * @param options defines the options used to create the mesh
  43719. * @param scene defines the hosting scene
  43720. * @returns the ground mesh
  43721. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43722. */
  43723. static CreateGround(name: string, options: {
  43724. width?: number;
  43725. height?: number;
  43726. subdivisions?: number;
  43727. subdivisionsX?: number;
  43728. subdivisionsY?: number;
  43729. updatable?: boolean;
  43730. }, scene: any): Mesh;
  43731. /**
  43732. * Creates a tiled ground mesh
  43733. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43734. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43735. * * 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
  43736. * * 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
  43737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43738. * @param name defines the name of the mesh
  43739. * @param options defines the options used to create the mesh
  43740. * @param scene defines the hosting scene
  43741. * @returns the tiled ground mesh
  43742. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43743. */
  43744. static CreateTiledGround(name: string, options: {
  43745. xmin: number;
  43746. zmin: number;
  43747. xmax: number;
  43748. zmax: number;
  43749. subdivisions?: {
  43750. w: number;
  43751. h: number;
  43752. };
  43753. precision?: {
  43754. w: number;
  43755. h: number;
  43756. };
  43757. updatable?: boolean;
  43758. }, scene?: Nullable<Scene>): Mesh;
  43759. /**
  43760. * Creates a ground mesh from a height map
  43761. * * The parameter `url` sets the URL of the height map image resource.
  43762. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43763. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43764. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43765. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43766. * * 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.
  43767. * * 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).
  43768. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43770. * @param name defines the name of the mesh
  43771. * @param url defines the url to the height map
  43772. * @param options defines the options used to create the mesh
  43773. * @param scene defines the hosting scene
  43774. * @returns the ground mesh
  43775. * @see https://doc.babylonjs.com/babylon101/height_map
  43776. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43777. */
  43778. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43779. width?: number;
  43780. height?: number;
  43781. subdivisions?: number;
  43782. minHeight?: number;
  43783. maxHeight?: number;
  43784. colorFilter?: Color3;
  43785. alphaFilter?: number;
  43786. updatable?: boolean;
  43787. onReady?: (mesh: GroundMesh) => void;
  43788. }, scene?: Nullable<Scene>): GroundMesh;
  43789. }
  43790. }
  43791. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43792. import { Vector4 } from "babylonjs/Maths/math.vector";
  43793. import { Mesh } from "babylonjs/Meshes/mesh";
  43794. /**
  43795. * Class containing static functions to help procedurally build meshes
  43796. */
  43797. export class TorusBuilder {
  43798. /**
  43799. * Creates a torus mesh
  43800. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43801. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43802. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43806. * @param name defines the name of the mesh
  43807. * @param options defines the options used to create the mesh
  43808. * @param scene defines the hosting scene
  43809. * @returns the torus mesh
  43810. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43811. */
  43812. static CreateTorus(name: string, options: {
  43813. diameter?: number;
  43814. thickness?: number;
  43815. tessellation?: number;
  43816. updatable?: boolean;
  43817. sideOrientation?: number;
  43818. frontUVs?: Vector4;
  43819. backUVs?: Vector4;
  43820. }, scene: any): Mesh;
  43821. }
  43822. }
  43823. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43824. import { Vector4 } from "babylonjs/Maths/math.vector";
  43825. import { Color4 } from "babylonjs/Maths/math.color";
  43826. import { Mesh } from "babylonjs/Meshes/mesh";
  43827. /**
  43828. * Class containing static functions to help procedurally build meshes
  43829. */
  43830. export class CylinderBuilder {
  43831. /**
  43832. * Creates a cylinder or a cone mesh
  43833. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43834. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43835. * * 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.
  43836. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43837. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43838. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43839. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43840. * * 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).
  43841. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43842. * * 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).
  43843. * * 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
  43844. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43845. * * 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
  43846. * * 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.
  43847. * * If `enclose` is false, a ring surface is one element.
  43848. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43849. * * 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
  43850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43853. * @param name defines the name of the mesh
  43854. * @param options defines the options used to create the mesh
  43855. * @param scene defines the hosting scene
  43856. * @returns the cylinder mesh
  43857. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43858. */
  43859. static CreateCylinder(name: string, options: {
  43860. height?: number;
  43861. diameterTop?: number;
  43862. diameterBottom?: number;
  43863. diameter?: number;
  43864. tessellation?: number;
  43865. subdivisions?: number;
  43866. arc?: number;
  43867. faceColors?: Color4[];
  43868. faceUV?: Vector4[];
  43869. updatable?: boolean;
  43870. hasRings?: boolean;
  43871. enclose?: boolean;
  43872. cap?: number;
  43873. sideOrientation?: number;
  43874. frontUVs?: Vector4;
  43875. backUVs?: Vector4;
  43876. }, scene: any): Mesh;
  43877. }
  43878. }
  43879. declare module "babylonjs/XR/webXRTypes" {
  43880. import { Nullable } from "babylonjs/types";
  43881. import { IDisposable } from "babylonjs/scene";
  43882. /**
  43883. * States of the webXR experience
  43884. */
  43885. export enum WebXRState {
  43886. /**
  43887. * Transitioning to being in XR mode
  43888. */
  43889. ENTERING_XR = 0,
  43890. /**
  43891. * Transitioning to non XR mode
  43892. */
  43893. EXITING_XR = 1,
  43894. /**
  43895. * In XR mode and presenting
  43896. */
  43897. IN_XR = 2,
  43898. /**
  43899. * Not entered XR mode
  43900. */
  43901. NOT_IN_XR = 3
  43902. }
  43903. /**
  43904. * Abstraction of the XR render target
  43905. */
  43906. export interface WebXRRenderTarget extends IDisposable {
  43907. /**
  43908. * xrpresent context of the canvas which can be used to display/mirror xr content
  43909. */
  43910. canvasContext: WebGLRenderingContext;
  43911. /**
  43912. * xr layer for the canvas
  43913. */
  43914. xrLayer: Nullable<XRWebGLLayer>;
  43915. /**
  43916. * Initializes the xr layer for the session
  43917. * @param xrSession xr session
  43918. * @returns a promise that will resolve once the XR Layer has been created
  43919. */
  43920. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43921. }
  43922. }
  43923. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  43924. import { Nullable } from "babylonjs/types";
  43925. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  43926. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  43927. /**
  43928. * COnfiguration object for WebXR output canvas
  43929. */
  43930. export class WebXRManagedOutputCanvasOptions {
  43931. /**
  43932. * Options for this XR Layer output
  43933. */
  43934. canvasOptions?: XRWebGLLayerOptions;
  43935. /**
  43936. * CSS styling for a newly created canvas (if not provided)
  43937. */
  43938. newCanvasCssStyle?: string;
  43939. /**
  43940. * An optional canvas in case you wish to create it yourself and provide it here.
  43941. * If not provided, a new canvas will be created
  43942. */
  43943. canvasElement?: HTMLCanvasElement;
  43944. /**
  43945. * Get the default values of the configuration object
  43946. * @returns default values of this configuration object
  43947. */
  43948. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43949. }
  43950. /**
  43951. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43952. */
  43953. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43954. private _options;
  43955. private _engine;
  43956. private _canvas;
  43957. /**
  43958. * Rendering context of the canvas which can be used to display/mirror xr content
  43959. */
  43960. canvasContext: WebGLRenderingContext;
  43961. /**
  43962. * xr layer for the canvas
  43963. */
  43964. xrLayer: Nullable<XRWebGLLayer>;
  43965. /**
  43966. * Initializes the xr layer for the session
  43967. * @param xrSession xr session
  43968. * @returns a promise that will resolve once the XR Layer has been created
  43969. */
  43970. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43971. /**
  43972. * Initializes the canvas to be added/removed upon entering/exiting xr
  43973. * @param _xrSessionManager The XR Session manager
  43974. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43975. */
  43976. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43977. /**
  43978. * Disposes of the object
  43979. */
  43980. dispose(): void;
  43981. private _setManagedOutputCanvas;
  43982. private _addCanvas;
  43983. private _removeCanvas;
  43984. }
  43985. }
  43986. declare module "babylonjs/XR/webXRSessionManager" {
  43987. import { Observable } from "babylonjs/Misc/observable";
  43988. import { Nullable } from "babylonjs/types";
  43989. import { IDisposable, Scene } from "babylonjs/scene";
  43990. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43991. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  43992. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  43993. /**
  43994. * Manages an XRSession to work with Babylon's engine
  43995. * @see https://doc.babylonjs.com/how_to/webxr
  43996. */
  43997. export class WebXRSessionManager implements IDisposable {
  43998. /** The scene which the session should be created for */
  43999. scene: Scene;
  44000. /**
  44001. * Fires every time a new xrFrame arrives which can be used to update the camera
  44002. */
  44003. onXRFrameObservable: Observable<XRFrame>;
  44004. /**
  44005. * Fires when the xr session is ended either by the device or manually done
  44006. */
  44007. onXRSessionEnded: Observable<any>;
  44008. /**
  44009. * Fires when the xr session is ended either by the device or manually done
  44010. */
  44011. onXRSessionInit: Observable<XRSession>;
  44012. /**
  44013. * Fires when the reference space changed
  44014. */
  44015. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44016. /**
  44017. * Underlying xr session
  44018. */
  44019. session: XRSession;
  44020. /**
  44021. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44022. * or get the offset the player is currently at.
  44023. */
  44024. viewerReferenceSpace: XRReferenceSpace;
  44025. private _referenceSpace;
  44026. /**
  44027. * The current reference space used in this session. This reference space can constantly change!
  44028. * It is mainly used to offset the camera's position.
  44029. */
  44030. get referenceSpace(): XRReferenceSpace;
  44031. /**
  44032. * Set a new reference space and triggers the observable
  44033. */
  44034. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44035. /**
  44036. * The base reference space from which the session started. good if you want to reset your
  44037. * reference space
  44038. */
  44039. baseReferenceSpace: XRReferenceSpace;
  44040. /**
  44041. * Used just in case of a failure to initialize an immersive session.
  44042. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44043. */
  44044. defaultHeightCompensation: number;
  44045. /**
  44046. * Current XR frame
  44047. */
  44048. currentFrame: Nullable<XRFrame>;
  44049. /** WebXR timestamp updated every frame */
  44050. currentTimestamp: number;
  44051. private _xrNavigator;
  44052. private baseLayer;
  44053. private _rttProvider;
  44054. private _sessionEnded;
  44055. /**
  44056. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44057. * @param scene The scene which the session should be created for
  44058. */
  44059. constructor(
  44060. /** The scene which the session should be created for */
  44061. scene: Scene);
  44062. /**
  44063. * Initializes the manager
  44064. * After initialization enterXR can be called to start an XR session
  44065. * @returns Promise which resolves after it is initialized
  44066. */
  44067. initializeAsync(): Promise<void>;
  44068. /**
  44069. * Initializes an xr session
  44070. * @param xrSessionMode mode to initialize
  44071. * @param xrSessionInit defines optional and required values to pass to the session builder
  44072. * @returns a promise which will resolve once the session has been initialized
  44073. */
  44074. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44075. /**
  44076. * Sets the reference space on the xr session
  44077. * @param referenceSpaceType space to set
  44078. * @returns a promise that will resolve once the reference space has been set
  44079. */
  44080. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44081. /**
  44082. * Resets the reference space to the one started the session
  44083. */
  44084. resetReferenceSpace(): void;
  44085. /**
  44086. * Updates the render state of the session
  44087. * @param state state to set
  44088. * @returns a promise that resolves once the render state has been updated
  44089. */
  44090. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44091. /**
  44092. * Starts rendering to the xr layer
  44093. */
  44094. runXRRenderLoop(): void;
  44095. /**
  44096. * Gets the correct render target texture to be rendered this frame for this eye
  44097. * @param eye the eye for which to get the render target
  44098. * @returns the render target for the specified eye
  44099. */
  44100. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44101. /**
  44102. * Stops the xrSession and restores the renderloop
  44103. * @returns Promise which resolves after it exits XR
  44104. */
  44105. exitXRAsync(): Promise<void>;
  44106. /**
  44107. * Checks if a session would be supported for the creation options specified
  44108. * @param sessionMode session mode to check if supported eg. immersive-vr
  44109. * @returns A Promise that resolves to true if supported and false if not
  44110. */
  44111. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44112. /**
  44113. * Creates a WebXRRenderTarget object for the XR session
  44114. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44115. * @param options optional options to provide when creating a new render target
  44116. * @returns a WebXR render target to which the session can render
  44117. */
  44118. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44119. /**
  44120. * @hidden
  44121. * Converts the render layer of xrSession to a render target
  44122. * @param session session to create render target for
  44123. * @param scene scene the new render target should be created for
  44124. * @param baseLayer the webgl layer to create the render target for
  44125. */
  44126. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44127. /**
  44128. * Disposes of the session manager
  44129. */
  44130. dispose(): void;
  44131. /**
  44132. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44133. * @param sessionMode defines the session to test
  44134. * @returns a promise with boolean as final value
  44135. */
  44136. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44137. }
  44138. }
  44139. declare module "babylonjs/XR/webXRCamera" {
  44140. import { Scene } from "babylonjs/scene";
  44141. import { Camera } from "babylonjs/Cameras/camera";
  44142. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44143. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44144. /**
  44145. * WebXR Camera which holds the views for the xrSession
  44146. * @see https://doc.babylonjs.com/how_to/webxr
  44147. */
  44148. export class WebXRCamera extends FreeCamera {
  44149. private _xrSessionManager;
  44150. /**
  44151. * Should position compensation execute on first frame.
  44152. * This is used when copying the position from a native (non XR) camera
  44153. */
  44154. compensateOnFirstFrame: boolean;
  44155. private _firstFrame;
  44156. private _referencedPosition;
  44157. private _referenceQuaternion;
  44158. private _xrInvPositionCache;
  44159. private _xrInvQuaternionCache;
  44160. private _realWorldHeight;
  44161. /**
  44162. * Prevent the camera from calculating the real-world height
  44163. * If you are not using the user's height disable this for better performance
  44164. */
  44165. disableRealWorldHeightCalculation: boolean;
  44166. /**
  44167. * Return the user's height, unrelated to the current ground.
  44168. */
  44169. get realWorldHeight(): number;
  44170. /**
  44171. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44172. * @param name the name of the camera
  44173. * @param scene the scene to add the camera to
  44174. */
  44175. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44176. private _updateNumberOfRigCameras;
  44177. /**
  44178. * Sets this camera's transformation based on a non-vr camera
  44179. * @param otherCamera the non-vr camera to copy the transformation from
  44180. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44181. */
  44182. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44183. /** @hidden */
  44184. _updateForDualEyeDebugging(): void;
  44185. private _updateReferenceSpace;
  44186. private _updateReferenceSpaceOffset;
  44187. private _updateFromXRSession;
  44188. }
  44189. }
  44190. declare module "babylonjs/XR/webXRFeaturesManager" {
  44191. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44192. import { IDisposable } from "babylonjs/scene";
  44193. /**
  44194. * Defining the interface required for a (webxr) feature
  44195. */
  44196. export interface IWebXRFeature extends IDisposable {
  44197. /**
  44198. * Is this feature attached
  44199. */
  44200. attached: boolean;
  44201. /**
  44202. * Should auto-attach be disabled?
  44203. */
  44204. disableAutoAttach: boolean;
  44205. /**
  44206. * Attach the feature to the session
  44207. * Will usually be called by the features manager
  44208. *
  44209. * @param force should attachment be forced (even when already attached)
  44210. * @returns true if successful.
  44211. */
  44212. attach(force?: boolean): boolean;
  44213. /**
  44214. * Detach the feature from the session
  44215. * Will usually be called by the features manager
  44216. *
  44217. * @returns true if successful.
  44218. */
  44219. detach(): boolean;
  44220. }
  44221. /**
  44222. * A list of the currently available features without referencing them
  44223. */
  44224. export class WebXRFeatureName {
  44225. /**
  44226. * The name of the hit test feature
  44227. */
  44228. static HIT_TEST: string;
  44229. /**
  44230. * The name of the anchor system feature
  44231. */
  44232. static ANCHOR_SYSTEM: string;
  44233. /**
  44234. * The name of the background remover feature
  44235. */
  44236. static BACKGROUND_REMOVER: string;
  44237. /**
  44238. * The name of the pointer selection feature
  44239. */
  44240. static POINTER_SELECTION: string;
  44241. /**
  44242. * The name of the teleportation feature
  44243. */
  44244. static TELEPORTATION: string;
  44245. /**
  44246. * The name of the plane detection feature
  44247. */
  44248. static PLANE_DETECTION: string;
  44249. /**
  44250. * physics impostors for xr controllers feature
  44251. */
  44252. static PHYSICS_CONTROLLERS: string;
  44253. }
  44254. /**
  44255. * Defining the constructor of a feature. Used to register the modules.
  44256. */
  44257. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44258. /**
  44259. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44260. * It is mainly used in AR sessions.
  44261. *
  44262. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44263. */
  44264. export class WebXRFeaturesManager implements IDisposable {
  44265. private _xrSessionManager;
  44266. private static readonly _AvailableFeatures;
  44267. /**
  44268. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44269. * Mainly used internally.
  44270. *
  44271. * @param featureName the name of the feature to register
  44272. * @param constructorFunction the function used to construct the module
  44273. * @param version the (babylon) version of the module
  44274. * @param stable is that a stable version of this module
  44275. */
  44276. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44277. /**
  44278. * Returns a constructor of a specific feature.
  44279. *
  44280. * @param featureName the name of the feature to construct
  44281. * @param version the version of the feature to load
  44282. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44283. * @param options optional options provided to the module.
  44284. * @returns a function that, when called, will return a new instance of this feature
  44285. */
  44286. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44287. /**
  44288. * Return the latest unstable version of this feature
  44289. * @param featureName the name of the feature to search
  44290. * @returns the version number. if not found will return -1
  44291. */
  44292. static GetLatestVersionOfFeature(featureName: string): number;
  44293. /**
  44294. * Return the latest stable version of this feature
  44295. * @param featureName the name of the feature to search
  44296. * @returns the version number. if not found will return -1
  44297. */
  44298. static GetStableVersionOfFeature(featureName: string): number;
  44299. /**
  44300. * Can be used to return the list of features currently registered
  44301. *
  44302. * @returns an Array of available features
  44303. */
  44304. static GetAvailableFeatures(): string[];
  44305. /**
  44306. * Gets the versions available for a specific feature
  44307. * @param featureName the name of the feature
  44308. * @returns an array with the available versions
  44309. */
  44310. static GetAvailableVersions(featureName: string): string[];
  44311. private _features;
  44312. /**
  44313. * constructs a new features manages.
  44314. *
  44315. * @param _xrSessionManager an instance of WebXRSessionManager
  44316. */
  44317. constructor(_xrSessionManager: WebXRSessionManager);
  44318. /**
  44319. * 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.
  44320. * 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.
  44321. *
  44322. * @param featureName the name of the feature to load or the class of the feature
  44323. * @param version optional version to load. if not provided the latest version will be enabled
  44324. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44325. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44326. * @returns a new constructed feature or throws an error if feature not found.
  44327. */
  44328. enableFeature(featureName: string | {
  44329. Name: string;
  44330. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44331. /**
  44332. * Used to disable an already-enabled feature
  44333. * The feature will be disposed and will be recreated once enabled.
  44334. * @param featureName the feature to disable
  44335. * @returns true if disable was successful
  44336. */
  44337. disableFeature(featureName: string | {
  44338. Name: string;
  44339. }): boolean;
  44340. /**
  44341. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44342. * Can be used during a session to start a feature
  44343. * @param featureName the name of feature to attach
  44344. */
  44345. attachFeature(featureName: string): void;
  44346. /**
  44347. * Can be used inside a session or when the session ends to detach a specific feature
  44348. * @param featureName the name of the feature to detach
  44349. */
  44350. detachFeature(featureName: string): void;
  44351. /**
  44352. * Get the list of enabled features
  44353. * @returns an array of enabled features
  44354. */
  44355. getEnabledFeatures(): string[];
  44356. /**
  44357. * get the implementation of an enabled feature.
  44358. * @param featureName the name of the feature to load
  44359. * @returns the feature class, if found
  44360. */
  44361. getEnabledFeature(featureName: string): IWebXRFeature;
  44362. /**
  44363. * dispose this features manager
  44364. */
  44365. dispose(): void;
  44366. }
  44367. }
  44368. declare module "babylonjs/XR/webXRExperienceHelper" {
  44369. import { Observable } from "babylonjs/Misc/observable";
  44370. import { IDisposable, Scene } from "babylonjs/scene";
  44371. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44372. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44373. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44374. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44375. /**
  44376. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44377. * @see https://doc.babylonjs.com/how_to/webxr
  44378. */
  44379. export class WebXRExperienceHelper implements IDisposable {
  44380. private scene;
  44381. /**
  44382. * Camera used to render xr content
  44383. */
  44384. camera: WebXRCamera;
  44385. /**
  44386. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44387. */
  44388. state: WebXRState;
  44389. private _setState;
  44390. /**
  44391. * Fires when the state of the experience helper has changed
  44392. */
  44393. onStateChangedObservable: Observable<WebXRState>;
  44394. /**
  44395. * Observers registered here will be triggered after the camera's initial transformation is set
  44396. * This can be used to set a different ground level or an extra rotation.
  44397. *
  44398. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44399. * to the position set after this observable is done executing.
  44400. */
  44401. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44402. /** Session manager used to keep track of xr session */
  44403. sessionManager: WebXRSessionManager;
  44404. /** A features manager for this xr session */
  44405. featuresManager: WebXRFeaturesManager;
  44406. private _nonVRCamera;
  44407. private _originalSceneAutoClear;
  44408. private _supported;
  44409. /**
  44410. * Creates the experience helper
  44411. * @param scene the scene to attach the experience helper to
  44412. * @returns a promise for the experience helper
  44413. */
  44414. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44415. /**
  44416. * Creates a WebXRExperienceHelper
  44417. * @param scene The scene the helper should be created in
  44418. */
  44419. private constructor();
  44420. /**
  44421. * Exits XR mode and returns the scene to its original state
  44422. * @returns promise that resolves after xr mode has exited
  44423. */
  44424. exitXRAsync(): Promise<void>;
  44425. /**
  44426. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44427. * @param sessionMode options for the XR session
  44428. * @param referenceSpaceType frame of reference of the XR session
  44429. * @param renderTarget the output canvas that will be used to enter XR mode
  44430. * @returns promise that resolves after xr mode has entered
  44431. */
  44432. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44433. /**
  44434. * Disposes of the experience helper
  44435. */
  44436. dispose(): void;
  44437. private _nonXRToXRCamera;
  44438. }
  44439. }
  44440. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44441. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractController";
  44442. import { Observable } from "babylonjs/Misc/observable";
  44443. import { IDisposable } from "babylonjs/scene";
  44444. /**
  44445. * X-Y values for axes in WebXR
  44446. */
  44447. export interface IWebXRMotionControllerAxesValue {
  44448. /**
  44449. * The value of the x axis
  44450. */
  44451. x: number;
  44452. /**
  44453. * The value of the y-axis
  44454. */
  44455. y: number;
  44456. }
  44457. /**
  44458. * changed / previous values for the values of this component
  44459. */
  44460. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44461. /**
  44462. * current (this frame) value
  44463. */
  44464. current: T;
  44465. /**
  44466. * previous (last change) value
  44467. */
  44468. previous: T;
  44469. }
  44470. /**
  44471. * Represents changes in the component between current frame and last values recorded
  44472. */
  44473. export interface IWebXRMotionControllerComponentChanges {
  44474. /**
  44475. * will be populated with previous and current values if touched changed
  44476. */
  44477. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44478. /**
  44479. * will be populated with previous and current values if pressed changed
  44480. */
  44481. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44482. /**
  44483. * will be populated with previous and current values if value changed
  44484. */
  44485. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44486. /**
  44487. * will be populated with previous and current values if axes changed
  44488. */
  44489. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44490. }
  44491. /**
  44492. * This class represents a single component (for example button or thumbstick) of a motion controller
  44493. */
  44494. export class WebXRControllerComponent implements IDisposable {
  44495. /**
  44496. * the id of this component
  44497. */
  44498. id: string;
  44499. /**
  44500. * the type of the component
  44501. */
  44502. type: MotionControllerComponentType;
  44503. private _buttonIndex;
  44504. private _axesIndices;
  44505. /**
  44506. * Thumbstick component type
  44507. */
  44508. static THUMBSTICK: MotionControllerComponentType;
  44509. /**
  44510. * Touchpad component type
  44511. */
  44512. static TOUCHPAD: MotionControllerComponentType;
  44513. /**
  44514. * trigger component type
  44515. */
  44516. static TRIGGER: MotionControllerComponentType;
  44517. /**
  44518. * squeeze component type
  44519. */
  44520. static SQUEEZE: MotionControllerComponentType;
  44521. /**
  44522. * button component type
  44523. */
  44524. static BUTTON: MotionControllerComponentType;
  44525. /**
  44526. * Observers registered here will be triggered when the state of a button changes
  44527. * State change is either pressed / touched / value
  44528. */
  44529. onButtonStateChanged: Observable<WebXRControllerComponent>;
  44530. /**
  44531. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44532. * the axes data changes
  44533. */
  44534. onAxisValueChanged: Observable<{
  44535. x: number;
  44536. y: number;
  44537. }>;
  44538. private _currentValue;
  44539. private _touched;
  44540. private _pressed;
  44541. private _axes;
  44542. private _changes;
  44543. private _hasChanges;
  44544. /**
  44545. * Return whether or not the component changed the last frame
  44546. */
  44547. get hasChanges(): boolean;
  44548. /**
  44549. * Creates a new component for a motion controller.
  44550. * It is created by the motion controller itself
  44551. *
  44552. * @param id the id of this component
  44553. * @param type the type of the component
  44554. * @param _buttonIndex index in the buttons array of the gamepad
  44555. * @param _axesIndices indices of the values in the axes array of the gamepad
  44556. */
  44557. constructor(
  44558. /**
  44559. * the id of this component
  44560. */
  44561. id: string,
  44562. /**
  44563. * the type of the component
  44564. */
  44565. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44566. /**
  44567. * Get the current value of this component
  44568. */
  44569. get value(): number;
  44570. /**
  44571. * is the button currently pressed
  44572. */
  44573. get pressed(): boolean;
  44574. /**
  44575. * is the button currently touched
  44576. */
  44577. get touched(): boolean;
  44578. /**
  44579. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44580. */
  44581. get axes(): IWebXRMotionControllerAxesValue;
  44582. /**
  44583. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44584. */
  44585. get changes(): IWebXRMotionControllerComponentChanges;
  44586. /**
  44587. * Is this component a button (hence - pressable)
  44588. * @returns true if can be pressed
  44589. */
  44590. isButton(): boolean;
  44591. /**
  44592. * Are there axes correlating to this component
  44593. * @return true is axes data is available
  44594. */
  44595. isAxes(): boolean;
  44596. /**
  44597. * update this component using the gamepad object it is in. Called on every frame
  44598. * @param nativeController the native gamepad controller object
  44599. */
  44600. update(nativeController: IMinimalMotionControllerObject): void;
  44601. /**
  44602. * Dispose this component
  44603. */
  44604. dispose(): void;
  44605. }
  44606. }
  44607. declare module "babylonjs/Loading/sceneLoader" {
  44608. import { Observable } from "babylonjs/Misc/observable";
  44609. import { Nullable } from "babylonjs/types";
  44610. import { Scene } from "babylonjs/scene";
  44611. import { Engine } from "babylonjs/Engines/engine";
  44612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44613. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44614. import { AssetContainer } from "babylonjs/assetContainer";
  44615. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44616. import { Skeleton } from "babylonjs/Bones/skeleton";
  44617. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44618. import { WebRequest } from "babylonjs/Misc/webRequest";
  44619. /**
  44620. * Class used to represent data loading progression
  44621. */
  44622. export class SceneLoaderProgressEvent {
  44623. /** defines if data length to load can be evaluated */
  44624. readonly lengthComputable: boolean;
  44625. /** defines the loaded data length */
  44626. readonly loaded: number;
  44627. /** defines the data length to load */
  44628. readonly total: number;
  44629. /**
  44630. * Create a new progress event
  44631. * @param lengthComputable defines if data length to load can be evaluated
  44632. * @param loaded defines the loaded data length
  44633. * @param total defines the data length to load
  44634. */
  44635. constructor(
  44636. /** defines if data length to load can be evaluated */
  44637. lengthComputable: boolean,
  44638. /** defines the loaded data length */
  44639. loaded: number,
  44640. /** defines the data length to load */
  44641. total: number);
  44642. /**
  44643. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44644. * @param event defines the source event
  44645. * @returns a new SceneLoaderProgressEvent
  44646. */
  44647. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44648. }
  44649. /**
  44650. * Interface used by SceneLoader plugins to define supported file extensions
  44651. */
  44652. export interface ISceneLoaderPluginExtensions {
  44653. /**
  44654. * Defines the list of supported extensions
  44655. */
  44656. [extension: string]: {
  44657. isBinary: boolean;
  44658. };
  44659. }
  44660. /**
  44661. * Interface used by SceneLoader plugin factory
  44662. */
  44663. export interface ISceneLoaderPluginFactory {
  44664. /**
  44665. * Defines the name of the factory
  44666. */
  44667. name: string;
  44668. /**
  44669. * Function called to create a new plugin
  44670. * @return the new plugin
  44671. */
  44672. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44673. /**
  44674. * The callback that returns true if the data can be directly loaded.
  44675. * @param data string containing the file data
  44676. * @returns if the data can be loaded directly
  44677. */
  44678. canDirectLoad?(data: string): boolean;
  44679. }
  44680. /**
  44681. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44682. */
  44683. export interface ISceneLoaderPluginBase {
  44684. /**
  44685. * The friendly name of this plugin.
  44686. */
  44687. name: string;
  44688. /**
  44689. * The file extensions supported by this plugin.
  44690. */
  44691. extensions: string | ISceneLoaderPluginExtensions;
  44692. /**
  44693. * The callback called when loading from a url.
  44694. * @param scene scene loading this url
  44695. * @param url url to load
  44696. * @param onSuccess callback called when the file successfully loads
  44697. * @param onProgress callback called while file is loading (if the server supports this mode)
  44698. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44699. * @param onError callback called when the file fails to load
  44700. * @returns a file request object
  44701. */
  44702. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44703. /**
  44704. * The callback called when loading from a file object.
  44705. * @param scene scene loading this file
  44706. * @param file defines the file to load
  44707. * @param onSuccess defines the callback to call when data is loaded
  44708. * @param onProgress defines the callback to call during loading process
  44709. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44710. * @param onError defines the callback to call when an error occurs
  44711. * @returns a file request object
  44712. */
  44713. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44714. /**
  44715. * The callback that returns true if the data can be directly loaded.
  44716. * @param data string containing the file data
  44717. * @returns if the data can be loaded directly
  44718. */
  44719. canDirectLoad?(data: string): boolean;
  44720. /**
  44721. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44722. * @param scene scene loading this data
  44723. * @param data string containing the data
  44724. * @returns data to pass to the plugin
  44725. */
  44726. directLoad?(scene: Scene, data: string): any;
  44727. /**
  44728. * The callback that allows custom handling of the root url based on the response url.
  44729. * @param rootUrl the original root url
  44730. * @param responseURL the response url if available
  44731. * @returns the new root url
  44732. */
  44733. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44734. }
  44735. /**
  44736. * Interface used to define a SceneLoader plugin
  44737. */
  44738. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44739. /**
  44740. * Import meshes into a scene.
  44741. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44742. * @param scene The scene to import into
  44743. * @param data The data to import
  44744. * @param rootUrl The root url for scene and resources
  44745. * @param meshes The meshes array to import into
  44746. * @param particleSystems The particle systems array to import into
  44747. * @param skeletons The skeletons array to import into
  44748. * @param onError The callback when import fails
  44749. * @returns True if successful or false otherwise
  44750. */
  44751. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44752. /**
  44753. * Load into a scene.
  44754. * @param scene The scene to load into
  44755. * @param data The data to import
  44756. * @param rootUrl The root url for scene and resources
  44757. * @param onError The callback when import fails
  44758. * @returns True if successful or false otherwise
  44759. */
  44760. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44761. /**
  44762. * Load into an asset container.
  44763. * @param scene The scene to load into
  44764. * @param data The data to import
  44765. * @param rootUrl The root url for scene and resources
  44766. * @param onError The callback when import fails
  44767. * @returns The loaded asset container
  44768. */
  44769. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44770. }
  44771. /**
  44772. * Interface used to define an async SceneLoader plugin
  44773. */
  44774. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44775. /**
  44776. * Import meshes into a scene.
  44777. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44778. * @param scene The scene to import into
  44779. * @param data The data to import
  44780. * @param rootUrl The root url for scene and resources
  44781. * @param onProgress The callback when the load progresses
  44782. * @param fileName Defines the name of the file to load
  44783. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44784. */
  44785. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44786. meshes: AbstractMesh[];
  44787. particleSystems: IParticleSystem[];
  44788. skeletons: Skeleton[];
  44789. animationGroups: AnimationGroup[];
  44790. }>;
  44791. /**
  44792. * Load into a scene.
  44793. * @param scene The scene to load into
  44794. * @param data The data to import
  44795. * @param rootUrl The root url for scene and resources
  44796. * @param onProgress The callback when the load progresses
  44797. * @param fileName Defines the name of the file to load
  44798. * @returns Nothing
  44799. */
  44800. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44801. /**
  44802. * Load into an asset container.
  44803. * @param scene The scene to load into
  44804. * @param data The data to import
  44805. * @param rootUrl The root url for scene and resources
  44806. * @param onProgress The callback when the load progresses
  44807. * @param fileName Defines the name of the file to load
  44808. * @returns The loaded asset container
  44809. */
  44810. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44811. }
  44812. /**
  44813. * Mode that determines how to handle old animation groups before loading new ones.
  44814. */
  44815. export enum SceneLoaderAnimationGroupLoadingMode {
  44816. /**
  44817. * Reset all old animations to initial state then dispose them.
  44818. */
  44819. Clean = 0,
  44820. /**
  44821. * Stop all old animations.
  44822. */
  44823. Stop = 1,
  44824. /**
  44825. * Restart old animations from first frame.
  44826. */
  44827. Sync = 2,
  44828. /**
  44829. * Old animations remains untouched.
  44830. */
  44831. NoSync = 3
  44832. }
  44833. /**
  44834. * Class used to load scene from various file formats using registered plugins
  44835. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44836. */
  44837. export class SceneLoader {
  44838. /**
  44839. * No logging while loading
  44840. */
  44841. static readonly NO_LOGGING: number;
  44842. /**
  44843. * Minimal logging while loading
  44844. */
  44845. static readonly MINIMAL_LOGGING: number;
  44846. /**
  44847. * Summary logging while loading
  44848. */
  44849. static readonly SUMMARY_LOGGING: number;
  44850. /**
  44851. * Detailled logging while loading
  44852. */
  44853. static readonly DETAILED_LOGGING: number;
  44854. /**
  44855. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44856. */
  44857. static get ForceFullSceneLoadingForIncremental(): boolean;
  44858. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44859. /**
  44860. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44861. */
  44862. static get ShowLoadingScreen(): boolean;
  44863. static set ShowLoadingScreen(value: boolean);
  44864. /**
  44865. * Defines the current logging level (while loading the scene)
  44866. * @ignorenaming
  44867. */
  44868. static get loggingLevel(): number;
  44869. static set loggingLevel(value: number);
  44870. /**
  44871. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44872. */
  44873. static get CleanBoneMatrixWeights(): boolean;
  44874. static set CleanBoneMatrixWeights(value: boolean);
  44875. /**
  44876. * Event raised when a plugin is used to load a scene
  44877. */
  44878. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44879. private static _registeredPlugins;
  44880. private static _getDefaultPlugin;
  44881. private static _getPluginForExtension;
  44882. private static _getPluginForDirectLoad;
  44883. private static _getPluginForFilename;
  44884. private static _getDirectLoad;
  44885. private static _loadData;
  44886. private static _getFileInfo;
  44887. /**
  44888. * Gets a plugin that can load the given extension
  44889. * @param extension defines the extension to load
  44890. * @returns a plugin or null if none works
  44891. */
  44892. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44893. /**
  44894. * Gets a boolean indicating that the given extension can be loaded
  44895. * @param extension defines the extension to load
  44896. * @returns true if the extension is supported
  44897. */
  44898. static IsPluginForExtensionAvailable(extension: string): boolean;
  44899. /**
  44900. * Adds a new plugin to the list of registered plugins
  44901. * @param plugin defines the plugin to add
  44902. */
  44903. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44904. /**
  44905. * Import meshes into a scene
  44906. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44907. * @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)
  44908. * @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)
  44909. * @param scene the instance of BABYLON.Scene to append to
  44910. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44911. * @param onProgress a callback with a progress event for each file being loaded
  44912. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44913. * @param pluginExtension the extension used to determine the plugin
  44914. * @returns The loaded plugin
  44915. */
  44916. 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>;
  44917. /**
  44918. * Import meshes into a scene
  44919. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44920. * @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)
  44921. * @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)
  44922. * @param scene the instance of BABYLON.Scene to append to
  44923. * @param onProgress a callback with a progress event for each file being loaded
  44924. * @param pluginExtension the extension used to determine the plugin
  44925. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44926. */
  44927. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44928. meshes: AbstractMesh[];
  44929. particleSystems: IParticleSystem[];
  44930. skeletons: Skeleton[];
  44931. animationGroups: AnimationGroup[];
  44932. }>;
  44933. /**
  44934. * Load a scene
  44935. * @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)
  44936. * @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)
  44937. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44938. * @param onSuccess a callback with the scene when import succeeds
  44939. * @param onProgress a callback with a progress event for each file being loaded
  44940. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44941. * @param pluginExtension the extension used to determine the plugin
  44942. * @returns The loaded plugin
  44943. */
  44944. 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>;
  44945. /**
  44946. * Load a scene
  44947. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  44948. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  44949. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44950. * @param onProgress a callback with a progress event for each file being loaded
  44951. * @param pluginExtension the extension used to determine the plugin
  44952. * @returns The loaded scene
  44953. */
  44954. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44955. /**
  44956. * Append a scene
  44957. * @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)
  44958. * @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)
  44959. * @param scene is the instance of BABYLON.Scene to append to
  44960. * @param onSuccess a callback with the scene when import succeeds
  44961. * @param onProgress a callback with a progress event for each file being loaded
  44962. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44963. * @param pluginExtension the extension used to determine the plugin
  44964. * @returns The loaded plugin
  44965. */
  44966. 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>;
  44967. /**
  44968. * Append a scene
  44969. * @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)
  44970. * @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)
  44971. * @param scene is the instance of BABYLON.Scene to append to
  44972. * @param onProgress a callback with a progress event for each file being loaded
  44973. * @param pluginExtension the extension used to determine the plugin
  44974. * @returns The given scene
  44975. */
  44976. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44977. /**
  44978. * Load a scene into an asset container
  44979. * @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)
  44980. * @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)
  44981. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44982. * @param onSuccess a callback with the scene when import succeeds
  44983. * @param onProgress a callback with a progress event for each file being loaded
  44984. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44985. * @param pluginExtension the extension used to determine the plugin
  44986. * @returns The loaded plugin
  44987. */
  44988. 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>;
  44989. /**
  44990. * Load a scene into an asset container
  44991. * @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)
  44992. * @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)
  44993. * @param scene is the instance of Scene to append to
  44994. * @param onProgress a callback with a progress event for each file being loaded
  44995. * @param pluginExtension the extension used to determine the plugin
  44996. * @returns The loaded asset container
  44997. */
  44998. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44999. /**
  45000. * Import animations from a file into a scene
  45001. * @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)
  45002. * @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)
  45003. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45004. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45005. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45006. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45007. * @param onSuccess a callback with the scene when import succeeds
  45008. * @param onProgress a callback with a progress event for each file being loaded
  45009. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45010. */
  45011. 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;
  45012. /**
  45013. * Import animations from a file into a scene
  45014. * @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)
  45015. * @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)
  45016. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45017. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45018. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45019. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45020. * @param onSuccess a callback with the scene when import succeeds
  45021. * @param onProgress a callback with a progress event for each file being loaded
  45022. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45023. * @returns the updated scene with imported animations
  45024. */
  45025. 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>;
  45026. }
  45027. }
  45028. declare module "babylonjs/XR/motionController/webXRAbstractController" {
  45029. import { IDisposable, Scene } from "babylonjs/scene";
  45030. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45031. import { Observable } from "babylonjs/Misc/observable";
  45032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45033. import { Nullable } from "babylonjs/types";
  45034. /**
  45035. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45036. */
  45037. export type MotionControllerHandness = "none" | "left" | "right";
  45038. /**
  45039. * The type of components available in motion controllers.
  45040. * This is not the name of the component.
  45041. */
  45042. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45043. /**
  45044. * The state of a controller component
  45045. */
  45046. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45047. /**
  45048. * The schema of motion controller layout.
  45049. * No object will be initialized using this interface
  45050. * This is used just to define the profile.
  45051. */
  45052. export interface IMotionControllerLayout {
  45053. /**
  45054. * Defines the main button component id
  45055. */
  45056. selectComponentId: string;
  45057. /**
  45058. * Available components (unsorted)
  45059. */
  45060. components: {
  45061. /**
  45062. * A map of component Ids
  45063. */
  45064. [componentId: string]: {
  45065. /**
  45066. * The type of input the component outputs
  45067. */
  45068. type: MotionControllerComponentType;
  45069. /**
  45070. * The indices of this component in the gamepad object
  45071. */
  45072. gamepadIndices: {
  45073. /**
  45074. * Index of button
  45075. */
  45076. button?: number;
  45077. /**
  45078. * If available, index of x-axis
  45079. */
  45080. xAxis?: number;
  45081. /**
  45082. * If available, index of y-axis
  45083. */
  45084. yAxis?: number;
  45085. };
  45086. /**
  45087. * The mesh's root node name
  45088. */
  45089. rootNodeName: string;
  45090. /**
  45091. * Animation definitions for this model
  45092. */
  45093. visualResponses: {
  45094. [stateKey: string]: {
  45095. /**
  45096. * What property will be animated
  45097. */
  45098. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45099. /**
  45100. * What states influence this visual reponse
  45101. */
  45102. states: MotionControllerComponentStateType[];
  45103. /**
  45104. * Type of animation - movement or visibility
  45105. */
  45106. valueNodeProperty: "transform" | "visibility";
  45107. /**
  45108. * Base node name to move. Its position will be calculated according to the min and max nodes
  45109. */
  45110. valueNodeName?: string;
  45111. /**
  45112. * Minimum movement node
  45113. */
  45114. minNodeName?: string;
  45115. /**
  45116. * Max movement node
  45117. */
  45118. maxNodeName?: string;
  45119. };
  45120. };
  45121. /**
  45122. * If touch enabled, what is the name of node to display user feedback
  45123. */
  45124. touchPointNodeName?: string;
  45125. };
  45126. };
  45127. /**
  45128. * Is it xr standard mapping or not
  45129. */
  45130. gamepadMapping: "" | "xr-standard";
  45131. /**
  45132. * Base root node of this entire model
  45133. */
  45134. rootNodeName: string;
  45135. /**
  45136. * Path to load the assets. Usually relative to the base path
  45137. */
  45138. assetPath: string;
  45139. }
  45140. /**
  45141. * A definition for the layout map in the input profile
  45142. */
  45143. export interface IMotionControllerLayoutMap {
  45144. /**
  45145. * Layouts with handness type as a key
  45146. */
  45147. [handness: string]: IMotionControllerLayout;
  45148. }
  45149. /**
  45150. * The XR Input profile schema
  45151. * Profiles can be found here:
  45152. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45153. */
  45154. export interface IMotionControllerProfile {
  45155. /**
  45156. * The id of this profile
  45157. * correlates to the profile(s) in the xrInput.profiles array
  45158. */
  45159. profileId: string;
  45160. /**
  45161. * fallback profiles for this profileId
  45162. */
  45163. fallbackProfileIds: string[];
  45164. /**
  45165. * The layout map, with handness as key
  45166. */
  45167. layouts: IMotionControllerLayoutMap;
  45168. }
  45169. /**
  45170. * A helper-interface for the 3 meshes needed for controller button animation
  45171. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45172. */
  45173. export interface IMotionControllerButtonMeshMap {
  45174. /**
  45175. * The mesh that will be changed when value changes
  45176. */
  45177. valueMesh: AbstractMesh;
  45178. /**
  45179. * the mesh that defines the pressed value mesh position.
  45180. * This is used to find the max-position of this button
  45181. */
  45182. pressedMesh: AbstractMesh;
  45183. /**
  45184. * the mesh that defines the unpressed value mesh position.
  45185. * This is used to find the min (or initial) position of this button
  45186. */
  45187. unpressedMesh: AbstractMesh;
  45188. }
  45189. /**
  45190. * A helper-interface for the 3 meshes needed for controller axis animation.
  45191. * This will be expanded when touchpad animations are fully supported
  45192. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45193. */
  45194. export interface IMotionControllerMeshMap {
  45195. /**
  45196. * The mesh that will be changed when axis value changes
  45197. */
  45198. valueMesh: AbstractMesh;
  45199. /**
  45200. * the mesh that defines the minimum value mesh position.
  45201. */
  45202. minMesh?: AbstractMesh;
  45203. /**
  45204. * the mesh that defines the maximum value mesh position.
  45205. */
  45206. maxMesh?: AbstractMesh;
  45207. }
  45208. /**
  45209. * The elements needed for change-detection of the gamepad objects in motion controllers
  45210. */
  45211. export interface IMinimalMotionControllerObject {
  45212. /**
  45213. * An array of available buttons
  45214. */
  45215. buttons: Array<{
  45216. /**
  45217. * Value of the button/trigger
  45218. */
  45219. value: number;
  45220. /**
  45221. * If the button/trigger is currently touched
  45222. */
  45223. touched: boolean;
  45224. /**
  45225. * If the button/trigger is currently pressed
  45226. */
  45227. pressed: boolean;
  45228. }>;
  45229. /**
  45230. * Available axes of this controller
  45231. */
  45232. axes: number[];
  45233. }
  45234. /**
  45235. * An Abstract Motion controller
  45236. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45237. * Each component has an observable to check for changes in value and state
  45238. */
  45239. export abstract class WebXRAbstractMotionController implements IDisposable {
  45240. protected scene: Scene;
  45241. protected layout: IMotionControllerLayout;
  45242. /**
  45243. * The gamepad object correlating to this controller
  45244. */
  45245. gamepadObject: IMinimalMotionControllerObject;
  45246. /**
  45247. * handness (left/right/none) of this controller
  45248. */
  45249. handness: MotionControllerHandness;
  45250. /**
  45251. * The profile id of this motion controller
  45252. */
  45253. abstract profileId: string;
  45254. /**
  45255. * A map of components (WebXRControllerComponent) in this motion controller
  45256. * Components have a ComponentType and can also have both button and axis definitions
  45257. */
  45258. readonly components: {
  45259. [id: string]: WebXRControllerComponent;
  45260. };
  45261. /**
  45262. * Observers registered here will be triggered when the model of this controller is done loading
  45263. */
  45264. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45265. /**
  45266. * The root mesh of the model. It is null if the model was not yet initialized
  45267. */
  45268. rootMesh: Nullable<AbstractMesh>;
  45269. /**
  45270. * Disable the model's animation. Can be set at any time.
  45271. */
  45272. disableAnimation: boolean;
  45273. private _modelReady;
  45274. /**
  45275. * constructs a new abstract motion controller
  45276. * @param scene the scene to which the model of the controller will be added
  45277. * @param layout The profile layout to load
  45278. * @param gamepadObject The gamepad object correlating to this controller
  45279. * @param handness handness (left/right/none) of this controller
  45280. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45281. */
  45282. constructor(scene: Scene, layout: IMotionControllerLayout,
  45283. /**
  45284. * The gamepad object correlating to this controller
  45285. */
  45286. gamepadObject: IMinimalMotionControllerObject,
  45287. /**
  45288. * handness (left/right/none) of this controller
  45289. */
  45290. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45291. private _initComponent;
  45292. /**
  45293. * Update this model using the current XRFrame
  45294. * @param xrFrame the current xr frame to use and update the model
  45295. */
  45296. updateFromXRFrame(xrFrame: XRFrame): void;
  45297. /**
  45298. * Get the list of components available in this motion controller
  45299. * @returns an array of strings correlating to available components
  45300. */
  45301. getComponentIds(): string[];
  45302. /**
  45303. * Get the main (Select) component of this controller as defined in the layout
  45304. * @returns the main component of this controller
  45305. */
  45306. getMainComponent(): WebXRControllerComponent;
  45307. /**
  45308. * get a component based an its component id as defined in layout.components
  45309. * @param id the id of the component
  45310. * @returns the component correlates to the id or undefined if not found
  45311. */
  45312. getComponent(id: string): WebXRControllerComponent;
  45313. /**
  45314. * Get the first component of specific type
  45315. * @param type type of component to find
  45316. * @return a controller component or null if not found
  45317. */
  45318. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45319. /**
  45320. * Returns all components of specific type
  45321. * @param type the type to search for
  45322. * @return an array of components with this type
  45323. */
  45324. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45325. /**
  45326. * Loads the model correlating to this controller
  45327. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45328. * @returns A promise fulfilled with the result of the model loading
  45329. */
  45330. loadModel(): Promise<boolean>;
  45331. /**
  45332. * Update the model itself with the current frame data
  45333. * @param xrFrame the frame to use for updating the model mesh
  45334. */
  45335. protected updateModel(xrFrame: XRFrame): void;
  45336. /**
  45337. * Moves the axis on the controller mesh based on its current state
  45338. * @param axis the index of the axis
  45339. * @param axisValue the value of the axis which determines the meshes new position
  45340. * @hidden
  45341. */
  45342. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45343. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45344. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45345. private _getGenericFilenameAndPath;
  45346. private _getGenericParentMesh;
  45347. /**
  45348. * Get the filename and path for this controller's model
  45349. * @returns a map of filename and path
  45350. */
  45351. protected abstract _getFilenameAndPath(): {
  45352. filename: string;
  45353. path: string;
  45354. };
  45355. /**
  45356. * This function will be called after the model was successfully loaded and can be used
  45357. * for mesh transformations before it is available for the user
  45358. * @param meshes the loaded meshes
  45359. */
  45360. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45361. /**
  45362. * Set the root mesh for this controller. Important for the WebXR controller class
  45363. * @param meshes the loaded meshes
  45364. */
  45365. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45366. /**
  45367. * A function executed each frame that updates the mesh (if needed)
  45368. * @param xrFrame the current xrFrame
  45369. */
  45370. protected abstract _updateModel(xrFrame: XRFrame): void;
  45371. /**
  45372. * This function is called before the mesh is loaded. It checks for loading constraints.
  45373. * For example, this function can check if the GLB loader is available
  45374. * If this function returns false, the generic controller will be loaded instead
  45375. * @returns Is the client ready to load the mesh
  45376. */
  45377. protected abstract _getModelLoadingConstraints(): boolean;
  45378. /**
  45379. * Dispose this controller, the model mesh and all its components
  45380. */
  45381. dispose(): void;
  45382. }
  45383. }
  45384. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45385. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractController";
  45386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45387. import { Scene } from "babylonjs/scene";
  45388. /**
  45389. * A generic trigger-only motion controller for WebXR
  45390. */
  45391. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45392. /**
  45393. * Static version of the profile id of this controller
  45394. */
  45395. static ProfileId: string;
  45396. profileId: string;
  45397. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45398. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45399. protected _updateModel(): void;
  45400. protected _getFilenameAndPath(): {
  45401. filename: string;
  45402. path: string;
  45403. };
  45404. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45405. protected _getModelLoadingConstraints(): boolean;
  45406. }
  45407. }
  45408. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45409. import { Vector4 } from "babylonjs/Maths/math.vector";
  45410. import { Mesh } from "babylonjs/Meshes/mesh";
  45411. import { Scene } from "babylonjs/scene";
  45412. import { Nullable } from "babylonjs/types";
  45413. /**
  45414. * Class containing static functions to help procedurally build meshes
  45415. */
  45416. export class SphereBuilder {
  45417. /**
  45418. * Creates a sphere mesh
  45419. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45420. * * 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`)
  45421. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45422. * * 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
  45423. * * 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)
  45424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45427. * @param name defines the name of the mesh
  45428. * @param options defines the options used to create the mesh
  45429. * @param scene defines the hosting scene
  45430. * @returns the sphere mesh
  45431. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45432. */
  45433. static CreateSphere(name: string, options: {
  45434. segments?: number;
  45435. diameter?: number;
  45436. diameterX?: number;
  45437. diameterY?: number;
  45438. diameterZ?: number;
  45439. arc?: number;
  45440. slice?: number;
  45441. sideOrientation?: number;
  45442. frontUVs?: Vector4;
  45443. backUVs?: Vector4;
  45444. updatable?: boolean;
  45445. }, scene?: Nullable<Scene>): Mesh;
  45446. }
  45447. }
  45448. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45450. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractController";
  45451. import { Scene } from "babylonjs/scene";
  45452. /**
  45453. * A profiled motion controller has its profile loaded from an online repository.
  45454. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45455. */
  45456. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45457. private _repositoryUrl;
  45458. /**
  45459. * The profile ID of this controller. Will be populated when the controller initializes.
  45460. */
  45461. profileId: string;
  45462. private _buttonMeshMapping;
  45463. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45464. protected _getFilenameAndPath(): {
  45465. filename: string;
  45466. path: string;
  45467. };
  45468. private _touchDots;
  45469. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45470. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45471. protected _updateModel(_xrFrame: XRFrame): void;
  45472. protected _getModelLoadingConstraints(): boolean;
  45473. dispose(): void;
  45474. }
  45475. }
  45476. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45477. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractController";
  45478. import { Scene } from "babylonjs/scene";
  45479. /**
  45480. * A construction function type to create a new controller based on an xrInput object
  45481. */
  45482. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45483. /**
  45484. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45485. *
  45486. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45487. * it should be replaced with auto-loaded controllers.
  45488. *
  45489. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45490. */
  45491. export class WebXRMotionControllerManager {
  45492. /**
  45493. * The base URL of the online controller repository. Can be changed at any time.
  45494. */
  45495. static BaseRepositoryUrl: string;
  45496. /**
  45497. * Use the online repository, or use only locally-defined controllers
  45498. */
  45499. static UseOnlineRepository: boolean;
  45500. /**
  45501. * Which repository gets priority - local or online
  45502. */
  45503. static PrioritizeOnlineRepository: boolean;
  45504. private static _AvailableControllers;
  45505. private static _Fallbacks;
  45506. /**
  45507. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45508. *
  45509. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45510. *
  45511. * @param type the profile type to register
  45512. * @param constructFunction the function to be called when loading this profile
  45513. */
  45514. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45515. /**
  45516. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45517. * The order of search:
  45518. *
  45519. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45520. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45521. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45522. * 4) return the generic trigger controller if none were found
  45523. *
  45524. * @param xrInput the xrInput to which a new controller is initialized
  45525. * @param scene the scene to which the model will be added
  45526. * @param forceProfile force a certain profile for this controller
  45527. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45528. */
  45529. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45530. private static _LoadProfilesFromAvailableControllers;
  45531. private static _ProfilesList;
  45532. private static _ProfileLoadingPromises;
  45533. private static _LoadProfileFromRepository;
  45534. /**
  45535. * Clear the cache used for profile loading and reload when requested again
  45536. */
  45537. static ClearProfilesCache(): void;
  45538. /**
  45539. * Will update the list of profiles available in the repository
  45540. * @return a promise that resolves to a map of profiles available online
  45541. */
  45542. static UpdateProfilesList(): Promise<{
  45543. [profile: string]: string;
  45544. }>;
  45545. /**
  45546. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45547. * @param profileId the profile to which a fallback needs to be found
  45548. * @return an array with corresponding fallback profiles
  45549. */
  45550. static FindFallbackWithProfileId(profileId: string): string[];
  45551. /**
  45552. * Register a fallback to a specific profile.
  45553. * @param profileId the profileId that will receive the fallbacks
  45554. * @param fallbacks A list of fallback profiles
  45555. */
  45556. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45557. /**
  45558. * Register the default fallbacks.
  45559. * This function is called automatically when this file is imported.
  45560. */
  45561. static DefaultFallbacks(): void;
  45562. }
  45563. }
  45564. declare module "babylonjs/XR/webXRController" {
  45565. import { Observable } from "babylonjs/Misc/observable";
  45566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45567. import { Ray } from "babylonjs/Culling/ray";
  45568. import { Scene } from "babylonjs/scene";
  45569. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractController";
  45570. /**
  45571. * Configuration options for the WebXR controller creation
  45572. */
  45573. export interface IWebXRControllerOptions {
  45574. /**
  45575. * Force a specific controller type for this controller.
  45576. * This can be used when creating your own profile or when testing different controllers
  45577. */
  45578. forceControllerProfile?: string;
  45579. /**
  45580. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45581. */
  45582. doNotLoadControllerMesh?: boolean;
  45583. /**
  45584. * Should the controller mesh be animated when a user interacts with it
  45585. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45586. */
  45587. disableMotionControllerAnimation?: boolean;
  45588. }
  45589. /**
  45590. * Represents an XR controller
  45591. */
  45592. export class WebXRController {
  45593. private _scene;
  45594. /** The underlying input source for the controller */
  45595. inputSource: XRInputSource;
  45596. private _options;
  45597. /**
  45598. * 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
  45599. */
  45600. grip?: AbstractMesh;
  45601. /**
  45602. * Pointer which can be used to select objects or attach a visible laser to
  45603. */
  45604. pointer: AbstractMesh;
  45605. /**
  45606. * If available, this is the gamepad object related to this controller.
  45607. * Using this object it is possible to get click events and trackpad changes of the
  45608. * webxr controller that is currently being used.
  45609. */
  45610. motionController?: WebXRAbstractMotionController;
  45611. /**
  45612. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45613. */
  45614. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45615. /**
  45616. * Will be triggered when the mesh associated with the motion controller is done loading.
  45617. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45618. * A shortened version of controller -> motion controller -> on mesh loaded.
  45619. */
  45620. onMeshLoadedObservable: Observable<AbstractMesh>;
  45621. /**
  45622. * Event that fires when the controller is removed/disposed.
  45623. * The object provided as event data is this controller, after associated assets were disposed.
  45624. * uniqueId is still available.
  45625. */
  45626. onDisposeObservable: Observable<WebXRController>;
  45627. private _tmpQuaternion;
  45628. private _tmpVector;
  45629. private _uniqueId;
  45630. /**
  45631. * Creates the controller
  45632. * @see https://doc.babylonjs.com/how_to/webxr
  45633. * @param _scene the scene which the controller should be associated to
  45634. * @param inputSource the underlying input source for the controller
  45635. * @param _options options for this controller creation
  45636. */
  45637. constructor(_scene: Scene,
  45638. /** The underlying input source for the controller */
  45639. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45640. /**
  45641. * Get this controllers unique id
  45642. */
  45643. get uniqueId(): string;
  45644. /**
  45645. * Updates the controller pose based on the given XRFrame
  45646. * @param xrFrame xr frame to update the pose with
  45647. * @param referenceSpace reference space to use
  45648. */
  45649. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45650. /**
  45651. * Gets a world space ray coming from the controller
  45652. * @param result the resulting ray
  45653. */
  45654. getWorldPointerRayToRef(result: Ray): void;
  45655. /**
  45656. * Disposes of the object
  45657. */
  45658. dispose(): void;
  45659. }
  45660. }
  45661. declare module "babylonjs/XR/webXRInput" {
  45662. import { Observable } from "babylonjs/Misc/observable";
  45663. import { IDisposable } from "babylonjs/scene";
  45664. import { WebXRController } from "babylonjs/XR/webXRController";
  45665. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45666. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45667. /**
  45668. * The schema for initialization options of the XR Input class
  45669. */
  45670. export interface IWebXRInputOptions {
  45671. /**
  45672. * If set to true no model will be automatically loaded
  45673. */
  45674. doNotLoadControllerMeshes?: boolean;
  45675. /**
  45676. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45677. * If not found, the xr input profile data will be used.
  45678. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45679. */
  45680. forceInputProfile?: string;
  45681. /**
  45682. * Do not send a request to the controlle repository to load the profile.
  45683. *
  45684. * Instead, use the controllers available in babylon itself.
  45685. */
  45686. disableOnlineControllerRepository?: boolean;
  45687. /**
  45688. * A custom URL for the controllers repository
  45689. */
  45690. customControllersRepositoryURL?: string;
  45691. /**
  45692. * Should the controller model's components not move according to the user input
  45693. */
  45694. disableControllerAnimation?: boolean;
  45695. }
  45696. /**
  45697. * XR input used to track XR inputs such as controllers/rays
  45698. */
  45699. export class WebXRInput implements IDisposable {
  45700. /**
  45701. * the xr session manager for this session
  45702. */
  45703. xrSessionManager: WebXRSessionManager;
  45704. /**
  45705. * the WebXR camera for this session. Mainly used for teleportation
  45706. */
  45707. xrCamera: WebXRCamera;
  45708. private readonly options;
  45709. /**
  45710. * XR controllers being tracked
  45711. */
  45712. controllers: Array<WebXRController>;
  45713. private _frameObserver;
  45714. private _sessionEndedObserver;
  45715. private _sessionInitObserver;
  45716. /**
  45717. * Event when a controller has been connected/added
  45718. */
  45719. onControllerAddedObservable: Observable<WebXRController>;
  45720. /**
  45721. * Event when a controller has been removed/disconnected
  45722. */
  45723. onControllerRemovedObservable: Observable<WebXRController>;
  45724. /**
  45725. * Initializes the WebXRInput
  45726. * @param xrSessionManager the xr session manager for this session
  45727. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45728. * @param options = initialization options for this xr input
  45729. */
  45730. constructor(
  45731. /**
  45732. * the xr session manager for this session
  45733. */
  45734. xrSessionManager: WebXRSessionManager,
  45735. /**
  45736. * the WebXR camera for this session. Mainly used for teleportation
  45737. */
  45738. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45739. private _onInputSourcesChange;
  45740. private _addAndRemoveControllers;
  45741. /**
  45742. * Disposes of the object
  45743. */
  45744. dispose(): void;
  45745. }
  45746. }
  45747. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45748. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45749. import { Observable, EventState } from "babylonjs/Misc/observable";
  45750. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45751. /**
  45752. * This is the base class for all WebXR features.
  45753. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45754. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45755. */
  45756. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45757. protected _xrSessionManager: WebXRSessionManager;
  45758. /**
  45759. * Construct a new (abstract) webxr feature
  45760. * @param _xrSessionManager the xr session manager for this feature
  45761. */
  45762. constructor(_xrSessionManager: WebXRSessionManager);
  45763. private _attached;
  45764. private _removeOnDetach;
  45765. /**
  45766. * Is this feature attached
  45767. */
  45768. get attached(): boolean;
  45769. /**
  45770. * Should auto-attach be disabled?
  45771. */
  45772. disableAutoAttach: boolean;
  45773. /**
  45774. * attach this feature
  45775. *
  45776. * @param force should attachment be forced (even when already attached)
  45777. * @returns true if successful, false is failed or already attached
  45778. */
  45779. attach(force?: boolean): boolean;
  45780. /**
  45781. * detach this feature.
  45782. *
  45783. * @returns true if successful, false if failed or already detached
  45784. */
  45785. detach(): boolean;
  45786. /**
  45787. * Dispose this feature and all of the resources attached
  45788. */
  45789. dispose(): void;
  45790. /**
  45791. * Code in this function will be executed on each xrFrame received from the browser.
  45792. * This function will not execute after the feature is detached.
  45793. * @param _xrFrame the current frame
  45794. */
  45795. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45796. /**
  45797. * This is used to register callbacks that will automatically be removed when detach is called.
  45798. * @param observable the observable to which the observer will be attached
  45799. * @param callback the callback to register
  45800. */
  45801. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45802. }
  45803. }
  45804. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45805. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45806. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45807. import { WebXRController } from "babylonjs/XR/webXRController";
  45808. import { Nullable } from "babylonjs/types";
  45809. import { Color3 } from "babylonjs/Maths/math.color";
  45810. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45811. /**
  45812. * Options interface for the pointer selection module
  45813. */
  45814. export interface IWebXRControllerPointerSelectionOptions {
  45815. /**
  45816. * the xr input to use with this pointer selection
  45817. */
  45818. xrInput: WebXRInput;
  45819. /**
  45820. * Different button type to use instead of the main component
  45821. */
  45822. overrideButtonId?: string;
  45823. /**
  45824. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  45825. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45826. * 3000 means 3 seconds between pointing at something and selecting it
  45827. */
  45828. timeToSelect?: number;
  45829. /**
  45830. * 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)
  45831. * If not disabled, the last picked point will be used to execute a pointer up event
  45832. * If disabled, pointer up event will be triggered right after the pointer down event.
  45833. * Used in screen and gaze target ray mode only
  45834. */
  45835. disablePointerUpOnTouchOut: boolean;
  45836. /**
  45837. * For gaze mode (time to select instead of press)
  45838. */
  45839. forceGazeMode: boolean;
  45840. /**
  45841. * 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
  45842. * to start a new countdown to the pointer down event.
  45843. * Defaults to 1.
  45844. */
  45845. gazeModePointerMovedFactor?: number;
  45846. }
  45847. /**
  45848. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45849. */
  45850. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45851. private readonly _options;
  45852. /**
  45853. * The module's name
  45854. */
  45855. static readonly Name: string;
  45856. /**
  45857. * The (Babylon) version of this module.
  45858. * This is an integer representing the implementation version.
  45859. * This number does not correspond to the webxr specs version
  45860. */
  45861. static readonly Version: number;
  45862. /**
  45863. * This color will be set to the laser pointer when selection is triggered
  45864. */
  45865. laserPointerPickedColor: Color3;
  45866. /**
  45867. * This color will be applied to the selection ring when selection is triggered
  45868. */
  45869. selectionMeshPickedColor: Color3;
  45870. /**
  45871. * default color of the selection ring
  45872. */
  45873. selectionMeshDefaultColor: Color3;
  45874. /**
  45875. * Default color of the laser pointer
  45876. */
  45877. lasterPointerDefaultColor: Color3;
  45878. /**
  45879. * Should the laser pointer be displayed
  45880. */
  45881. displayLaserPointer: boolean;
  45882. /**
  45883. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45884. */
  45885. displaySelectionMesh: boolean;
  45886. /**
  45887. * Disable lighting on the laser pointer (so it will always be visible)
  45888. */
  45889. disablePointerLighting: boolean;
  45890. /**
  45891. * Disable lighting on the selection mesh (so it will always be visible)
  45892. */
  45893. disableSelectionMeshLighting: boolean;
  45894. private static _idCounter;
  45895. private _tmpRay;
  45896. private _controllers;
  45897. private _scene;
  45898. /**
  45899. * constructs a new background remover module
  45900. * @param _xrSessionManager the session manager for this module
  45901. * @param _options read-only options to be used in this module
  45902. */
  45903. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45904. /**
  45905. * attach this feature
  45906. * Will usually be called by the features manager
  45907. *
  45908. * @returns true if successful.
  45909. */
  45910. attach(): boolean;
  45911. /**
  45912. * detach this feature.
  45913. * Will usually be called by the features manager
  45914. *
  45915. * @returns true if successful.
  45916. */
  45917. detach(): boolean;
  45918. /**
  45919. * Get the xr controller that correlates to the pointer id in the pointer event
  45920. *
  45921. * @param id the pointer id to search for
  45922. * @returns the controller that correlates to this id or null if not found
  45923. */
  45924. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  45925. protected _onXRFrame(_xrFrame: XRFrame): void;
  45926. private _attachController;
  45927. private _attachScreenRayMode;
  45928. private _attachGazeMode;
  45929. private _tmpVectorForPickCompare;
  45930. private _pickingMoved;
  45931. private _attachTrackedPointerRayMode;
  45932. private _detachController;
  45933. private _generateNewMeshPair;
  45934. private _convertNormalToDirectionOfRay;
  45935. private _updatePointerDistance;
  45936. }
  45937. }
  45938. declare module "babylonjs/XR/webXREnterExitUI" {
  45939. import { Nullable } from "babylonjs/types";
  45940. import { Observable } from "babylonjs/Misc/observable";
  45941. import { IDisposable, Scene } from "babylonjs/scene";
  45942. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  45943. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  45944. /**
  45945. * Button which can be used to enter a different mode of XR
  45946. */
  45947. export class WebXREnterExitUIButton {
  45948. /** button element */
  45949. element: HTMLElement;
  45950. /** XR initialization options for the button */
  45951. sessionMode: XRSessionMode;
  45952. /** Reference space type */
  45953. referenceSpaceType: XRReferenceSpaceType;
  45954. /**
  45955. * Creates a WebXREnterExitUIButton
  45956. * @param element button element
  45957. * @param sessionMode XR initialization session mode
  45958. * @param referenceSpaceType the type of reference space to be used
  45959. */
  45960. constructor(
  45961. /** button element */
  45962. element: HTMLElement,
  45963. /** XR initialization options for the button */
  45964. sessionMode: XRSessionMode,
  45965. /** Reference space type */
  45966. referenceSpaceType: XRReferenceSpaceType);
  45967. /**
  45968. * Overwritable function which can be used to update the button's visuals when the state changes
  45969. * @param activeButton the current active button in the UI
  45970. */
  45971. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45972. }
  45973. /**
  45974. * Options to create the webXR UI
  45975. */
  45976. export class WebXREnterExitUIOptions {
  45977. /**
  45978. * Context to enter xr with
  45979. */
  45980. renderTarget?: Nullable<WebXRRenderTarget>;
  45981. /**
  45982. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45983. */
  45984. customButtons?: Array<WebXREnterExitUIButton>;
  45985. /**
  45986. * A session mode to use when creating the default button.
  45987. * Default is immersive-vr
  45988. */
  45989. sessionMode?: XRSessionMode;
  45990. /**
  45991. * A reference space type to use when creating the default button.
  45992. * Default is local-floor
  45993. */
  45994. referenceSpaceType?: XRReferenceSpaceType;
  45995. }
  45996. /**
  45997. * UI to allow the user to enter/exit XR mode
  45998. */
  45999. export class WebXREnterExitUI implements IDisposable {
  46000. private scene;
  46001. /** version of the options passed to this UI */
  46002. options: WebXREnterExitUIOptions;
  46003. private _overlay;
  46004. private _buttons;
  46005. private _activeButton;
  46006. /**
  46007. * Fired every time the active button is changed.
  46008. *
  46009. * When xr is entered via a button that launches xr that button will be the callback parameter
  46010. *
  46011. * When exiting xr the callback parameter will be null)
  46012. */
  46013. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46014. /**
  46015. * Creates UI to allow the user to enter/exit XR mode
  46016. * @param scene the scene to add the ui to
  46017. * @param helper the xr experience helper to enter/exit xr with
  46018. * @param options options to configure the UI
  46019. * @returns the created ui
  46020. */
  46021. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46022. /**
  46023. *
  46024. * @param scene babylon scene object to use
  46025. * @param options (read-only) version of the options passed to this UI
  46026. */
  46027. private constructor();
  46028. private _updateButtons;
  46029. /**
  46030. * Disposes of the object
  46031. */
  46032. dispose(): void;
  46033. }
  46034. }
  46035. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46036. import { Vector3 } from "babylonjs/Maths/math.vector";
  46037. import { Color4 } from "babylonjs/Maths/math.color";
  46038. import { Nullable } from "babylonjs/types";
  46039. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46040. import { Scene } from "babylonjs/scene";
  46041. /**
  46042. * Class containing static functions to help procedurally build meshes
  46043. */
  46044. export class LinesBuilder {
  46045. /**
  46046. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46047. * * 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
  46048. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46049. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46050. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46051. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46053. * * 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
  46054. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46057. * @param name defines the name of the new line system
  46058. * @param options defines the options used to create the line system
  46059. * @param scene defines the hosting scene
  46060. * @returns a new line system mesh
  46061. */
  46062. static CreateLineSystem(name: string, options: {
  46063. lines: Vector3[][];
  46064. updatable?: boolean;
  46065. instance?: Nullable<LinesMesh>;
  46066. colors?: Nullable<Color4[][]>;
  46067. useVertexAlpha?: boolean;
  46068. }, scene: Nullable<Scene>): LinesMesh;
  46069. /**
  46070. * Creates a line mesh
  46071. * 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
  46072. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46073. * * The parameter `points` is an array successive Vector3
  46074. * * 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
  46075. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46076. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46077. * * When updating an instance, remember that only point positions can change, not the number of points
  46078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46080. * @param name defines the name of the new line system
  46081. * @param options defines the options used to create the line system
  46082. * @param scene defines the hosting scene
  46083. * @returns a new line mesh
  46084. */
  46085. static CreateLines(name: string, options: {
  46086. points: Vector3[];
  46087. updatable?: boolean;
  46088. instance?: Nullable<LinesMesh>;
  46089. colors?: Color4[];
  46090. useVertexAlpha?: boolean;
  46091. }, scene?: Nullable<Scene>): LinesMesh;
  46092. /**
  46093. * Creates a dashed line mesh
  46094. * * 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
  46095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46096. * * The parameter `points` is an array successive Vector3
  46097. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46098. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46099. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46100. * * 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
  46101. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46102. * * When updating an instance, remember that only point positions can change, not the number of points
  46103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46104. * @param name defines the name of the mesh
  46105. * @param options defines the options used to create the mesh
  46106. * @param scene defines the hosting scene
  46107. * @returns the dashed line mesh
  46108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46109. */
  46110. static CreateDashedLines(name: string, options: {
  46111. points: Vector3[];
  46112. dashSize?: number;
  46113. gapSize?: number;
  46114. dashNb?: number;
  46115. updatable?: boolean;
  46116. instance?: LinesMesh;
  46117. useVertexAlpha?: boolean;
  46118. }, scene?: Nullable<Scene>): LinesMesh;
  46119. }
  46120. }
  46121. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46122. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46123. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46124. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46126. import { Material } from "babylonjs/Materials/material";
  46127. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46128. /**
  46129. * The options container for the teleportation module
  46130. */
  46131. export interface IWebXRTeleportationOptions {
  46132. /**
  46133. * Babylon XR Input class for controller
  46134. */
  46135. xrInput: WebXRInput;
  46136. /**
  46137. * A list of meshes to use as floor meshes.
  46138. * Meshes can be added and removed after initializing the feature using the
  46139. * addFloorMesh and removeFloorMesh functions
  46140. * If empty, rotation will still work
  46141. */
  46142. floorMeshes?: AbstractMesh[];
  46143. /**
  46144. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46145. * If you want to support rotation, make sure your mesh has a direction indicator.
  46146. *
  46147. * When left untouched, the default mesh will be initialized.
  46148. */
  46149. teleportationTargetMesh?: AbstractMesh;
  46150. /**
  46151. * Values to configure the default target mesh
  46152. */
  46153. defaultTargetMeshOptions?: {
  46154. /**
  46155. * Fill color of the teleportation area
  46156. */
  46157. teleportationFillColor?: string;
  46158. /**
  46159. * Border color for the teleportation area
  46160. */
  46161. teleportationBorderColor?: string;
  46162. /**
  46163. * Disable the mesh's animation sequence
  46164. */
  46165. disableAnimation?: boolean;
  46166. /**
  46167. * Disable lighting on the material or the ring and arrow
  46168. */
  46169. disableLighting?: boolean;
  46170. /**
  46171. * Override the default material of the torus and arrow
  46172. */
  46173. torusArrowMaterial?: Material;
  46174. };
  46175. /**
  46176. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46177. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46178. */
  46179. useMainComponentOnly?: boolean;
  46180. /**
  46181. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46182. */
  46183. timeToTeleport?: number;
  46184. }
  46185. /**
  46186. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46187. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  46188. * the input of the attached controllers.
  46189. */
  46190. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46191. private _options;
  46192. /**
  46193. * The module's name
  46194. */
  46195. static readonly Name: string;
  46196. /**
  46197. * The (Babylon) version of this module.
  46198. * This is an integer representing the implementation version.
  46199. * This number does not correspond to the webxr specs version
  46200. */
  46201. static readonly Version: number;
  46202. /**
  46203. * Is rotation enabled when moving forward?
  46204. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46205. */
  46206. rotationEnabled: boolean;
  46207. /**
  46208. * Should the module support parabolic ray on top of direct ray
  46209. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46210. * Very helpful when moving between floors / different heights
  46211. */
  46212. parabolicRayEnabled: boolean;
  46213. /**
  46214. * The distance from the user to the inspection point in the direction of the controller
  46215. * A higher number will allow the user to move further
  46216. * defaults to 5 (meters, in xr units)
  46217. */
  46218. parabolicCheckRadius: number;
  46219. /**
  46220. * How much rotation should be applied when rotating right and left
  46221. */
  46222. rotationAngle: number;
  46223. /**
  46224. * Is movement backwards enabled
  46225. */
  46226. backwardsMovementEnabled: boolean;
  46227. /**
  46228. * Distance to travel when moving backwards
  46229. */
  46230. backwardsTeleportationDistance: number;
  46231. /**
  46232. * Add a new mesh to the floor meshes array
  46233. * @param mesh the mesh to use as floor mesh
  46234. */
  46235. addFloorMesh(mesh: AbstractMesh): void;
  46236. /**
  46237. * Remove a mesh from the floor meshes array
  46238. * @param mesh the mesh to remove
  46239. */
  46240. removeFloorMesh(mesh: AbstractMesh): void;
  46241. /**
  46242. * Remove a mesh from the floor meshes array using its name
  46243. * @param name the mesh name to remove
  46244. */
  46245. removeFloorMeshByName(name: string): void;
  46246. private _tmpRay;
  46247. private _tmpVector;
  46248. private _floorMeshes;
  46249. private _controllers;
  46250. /**
  46251. * constructs a new anchor system
  46252. * @param _xrSessionManager an instance of WebXRSessionManager
  46253. * @param _options configuration object for this feature
  46254. */
  46255. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46256. private _selectionFeature;
  46257. /**
  46258. * This function sets a selection feature that will be disabled when
  46259. * the forward ray is shown and will be reattached when hidden.
  46260. * This is used to remove the selection rays when moving.
  46261. * @param selectionFeature the feature to disable when forward movement is enabled
  46262. */
  46263. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46264. attach(): boolean;
  46265. detach(): boolean;
  46266. dispose(): void;
  46267. protected _onXRFrame(_xrFrame: XRFrame): void;
  46268. private _currentTeleportationControllerId;
  46269. private _attachController;
  46270. private _teleportForward;
  46271. private _detachController;
  46272. private createDefaultTargetMesh;
  46273. private setTargetMeshVisibility;
  46274. private setTargetMeshPosition;
  46275. private _quadraticBezierCurve;
  46276. private _showParabolicPath;
  46277. }
  46278. }
  46279. declare module "babylonjs/XR/webXRDefaultExperience" {
  46280. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46281. import { Scene } from "babylonjs/scene";
  46282. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46283. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46284. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46285. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46287. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46288. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46289. /**
  46290. * Options for the default xr helper
  46291. */
  46292. export class WebXRDefaultExperienceOptions {
  46293. /**
  46294. * Floor meshes that will be used for teleporting
  46295. */
  46296. floorMeshes?: Array<AbstractMesh>;
  46297. /**
  46298. * Enable or disable default UI to enter XR
  46299. */
  46300. disableDefaultUI?: boolean;
  46301. /**
  46302. * optional configuration for the output canvas
  46303. */
  46304. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46305. /**
  46306. * optional UI options. This can be used among other to change session mode and reference space type
  46307. */
  46308. uiOptions?: WebXREnterExitUIOptions;
  46309. /**
  46310. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46311. */
  46312. inputOptions?: IWebXRInputOptions;
  46313. /**
  46314. * Should teleportation not initialize. defaults to false.
  46315. */
  46316. disableTeleportation?: boolean;
  46317. /**
  46318. * If set to true, the first frame will not be used to reset position
  46319. * The first frame is mainly used when copying transformation from the old camera
  46320. * Mainly used in AR
  46321. */
  46322. ignoreNativeCameraTransformation?: boolean;
  46323. /**
  46324. * When loading teleportation and pointer select, use stable versions instead of latest.
  46325. */
  46326. useStablePlugins?: boolean;
  46327. }
  46328. /**
  46329. * Default experience which provides a similar setup to the previous webVRExperience
  46330. */
  46331. export class WebXRDefaultExperience {
  46332. /**
  46333. * Base experience
  46334. */
  46335. baseExperience: WebXRExperienceHelper;
  46336. /**
  46337. * Input experience extension
  46338. */
  46339. input: WebXRInput;
  46340. /**
  46341. * Enables laser pointer and selection
  46342. */
  46343. pointerSelection: WebXRControllerPointerSelection;
  46344. /**
  46345. * Enables teleportation
  46346. */
  46347. teleportation: WebXRMotionControllerTeleportation;
  46348. /**
  46349. * Enables ui for entering/exiting xr
  46350. */
  46351. enterExitUI: WebXREnterExitUI;
  46352. /**
  46353. * Default target xr should render to
  46354. */
  46355. renderTarget: WebXRRenderTarget;
  46356. /**
  46357. * Creates the default xr experience
  46358. * @param scene scene
  46359. * @param options options for basic configuration
  46360. * @returns resulting WebXRDefaultExperience
  46361. */
  46362. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46363. private constructor();
  46364. /**
  46365. * DIsposes of the experience helper
  46366. */
  46367. dispose(): void;
  46368. }
  46369. }
  46370. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46371. import { Observable } from "babylonjs/Misc/observable";
  46372. import { Nullable } from "babylonjs/types";
  46373. import { Camera } from "babylonjs/Cameras/camera";
  46374. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46375. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46376. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46377. import { Scene } from "babylonjs/scene";
  46378. import { Vector3 } from "babylonjs/Maths/math.vector";
  46379. import { Color3 } from "babylonjs/Maths/math.color";
  46380. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46382. import { Mesh } from "babylonjs/Meshes/mesh";
  46383. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46384. import { EasingFunction } from "babylonjs/Animations/easing";
  46385. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46386. import "babylonjs/Meshes/Builders/groundBuilder";
  46387. import "babylonjs/Meshes/Builders/torusBuilder";
  46388. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46389. import "babylonjs/Gamepads/gamepadSceneComponent";
  46390. import "babylonjs/Animations/animatable";
  46391. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46392. /**
  46393. * Options to modify the vr teleportation behavior.
  46394. */
  46395. export interface VRTeleportationOptions {
  46396. /**
  46397. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46398. */
  46399. floorMeshName?: string;
  46400. /**
  46401. * A list of meshes to be used as the teleportation floor. (default: empty)
  46402. */
  46403. floorMeshes?: Mesh[];
  46404. /**
  46405. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46406. */
  46407. teleportationMode?: number;
  46408. /**
  46409. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46410. */
  46411. teleportationTime?: number;
  46412. /**
  46413. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46414. */
  46415. teleportationSpeed?: number;
  46416. /**
  46417. * The easing function used in the animation or null for Linear. (default CircleEase)
  46418. */
  46419. easingFunction?: EasingFunction;
  46420. }
  46421. /**
  46422. * Options to modify the vr experience helper's behavior.
  46423. */
  46424. export interface VRExperienceHelperOptions extends WebVROptions {
  46425. /**
  46426. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46427. */
  46428. createDeviceOrientationCamera?: boolean;
  46429. /**
  46430. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46431. */
  46432. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46433. /**
  46434. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46435. */
  46436. laserToggle?: boolean;
  46437. /**
  46438. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46439. */
  46440. floorMeshes?: Mesh[];
  46441. /**
  46442. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46443. */
  46444. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46445. /**
  46446. * Defines if WebXR should be used instead of WebVR (if available)
  46447. */
  46448. useXR?: boolean;
  46449. }
  46450. /**
  46451. * Event containing information after VR has been entered
  46452. */
  46453. export class OnAfterEnteringVRObservableEvent {
  46454. /**
  46455. * If entering vr was successful
  46456. */
  46457. success: boolean;
  46458. }
  46459. /**
  46460. * Helps to quickly add VR support to an existing scene.
  46461. * See http://doc.babylonjs.com/how_to/webvr_helper
  46462. */
  46463. export class VRExperienceHelper {
  46464. /** Options to modify the vr experience helper's behavior. */
  46465. webVROptions: VRExperienceHelperOptions;
  46466. private _scene;
  46467. private _position;
  46468. private _btnVR;
  46469. private _btnVRDisplayed;
  46470. private _webVRsupported;
  46471. private _webVRready;
  46472. private _webVRrequesting;
  46473. private _webVRpresenting;
  46474. private _hasEnteredVR;
  46475. private _fullscreenVRpresenting;
  46476. private _inputElement;
  46477. private _webVRCamera;
  46478. private _vrDeviceOrientationCamera;
  46479. private _deviceOrientationCamera;
  46480. private _existingCamera;
  46481. private _onKeyDown;
  46482. private _onVrDisplayPresentChange;
  46483. private _onVRDisplayChanged;
  46484. private _onVRRequestPresentStart;
  46485. private _onVRRequestPresentComplete;
  46486. /**
  46487. * 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)
  46488. */
  46489. enableGazeEvenWhenNoPointerLock: boolean;
  46490. /**
  46491. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46492. */
  46493. exitVROnDoubleTap: boolean;
  46494. /**
  46495. * Observable raised right before entering VR.
  46496. */
  46497. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46498. /**
  46499. * Observable raised when entering VR has completed.
  46500. */
  46501. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46502. /**
  46503. * Observable raised when exiting VR.
  46504. */
  46505. onExitingVRObservable: Observable<VRExperienceHelper>;
  46506. /**
  46507. * Observable raised when controller mesh is loaded.
  46508. */
  46509. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46510. /** Return this.onEnteringVRObservable
  46511. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46512. */
  46513. get onEnteringVR(): Observable<VRExperienceHelper>;
  46514. /** Return this.onExitingVRObservable
  46515. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46516. */
  46517. get onExitingVR(): Observable<VRExperienceHelper>;
  46518. /** Return this.onControllerMeshLoadedObservable
  46519. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46520. */
  46521. get onControllerMeshLoaded(): Observable<WebVRController>;
  46522. private _rayLength;
  46523. private _useCustomVRButton;
  46524. private _teleportationRequested;
  46525. private _teleportActive;
  46526. private _floorMeshName;
  46527. private _floorMeshesCollection;
  46528. private _teleportationMode;
  46529. private _teleportationTime;
  46530. private _teleportationSpeed;
  46531. private _teleportationEasing;
  46532. private _rotationAllowed;
  46533. private _teleportBackwardsVector;
  46534. private _teleportationTarget;
  46535. private _isDefaultTeleportationTarget;
  46536. private _postProcessMove;
  46537. private _teleportationFillColor;
  46538. private _teleportationBorderColor;
  46539. private _rotationAngle;
  46540. private _haloCenter;
  46541. private _cameraGazer;
  46542. private _padSensibilityUp;
  46543. private _padSensibilityDown;
  46544. private _leftController;
  46545. private _rightController;
  46546. private _gazeColor;
  46547. private _laserColor;
  46548. private _pickedLaserColor;
  46549. private _pickedGazeColor;
  46550. /**
  46551. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46552. */
  46553. onNewMeshSelected: Observable<AbstractMesh>;
  46554. /**
  46555. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46556. * This observable will provide the mesh and the controller used to select the mesh
  46557. */
  46558. onMeshSelectedWithController: Observable<{
  46559. mesh: AbstractMesh;
  46560. controller: WebVRController;
  46561. }>;
  46562. /**
  46563. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46564. */
  46565. onNewMeshPicked: Observable<PickingInfo>;
  46566. private _circleEase;
  46567. /**
  46568. * Observable raised before camera teleportation
  46569. */
  46570. onBeforeCameraTeleport: Observable<Vector3>;
  46571. /**
  46572. * Observable raised after camera teleportation
  46573. */
  46574. onAfterCameraTeleport: Observable<Vector3>;
  46575. /**
  46576. * Observable raised when current selected mesh gets unselected
  46577. */
  46578. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46579. private _raySelectionPredicate;
  46580. /**
  46581. * To be optionaly changed by user to define custom ray selection
  46582. */
  46583. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46584. /**
  46585. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46586. */
  46587. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46588. /**
  46589. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46590. */
  46591. teleportationEnabled: boolean;
  46592. private _defaultHeight;
  46593. private _teleportationInitialized;
  46594. private _interactionsEnabled;
  46595. private _interactionsRequested;
  46596. private _displayGaze;
  46597. private _displayLaserPointer;
  46598. /**
  46599. * The mesh used to display where the user is going to teleport.
  46600. */
  46601. get teleportationTarget(): Mesh;
  46602. /**
  46603. * Sets the mesh to be used to display where the user is going to teleport.
  46604. */
  46605. set teleportationTarget(value: Mesh);
  46606. /**
  46607. * 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
  46608. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46609. * See http://doc.babylonjs.com/resources/baking_transformations
  46610. */
  46611. get gazeTrackerMesh(): Mesh;
  46612. set gazeTrackerMesh(value: Mesh);
  46613. /**
  46614. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46615. */
  46616. updateGazeTrackerScale: boolean;
  46617. /**
  46618. * If the gaze trackers color should be updated when selecting meshes
  46619. */
  46620. updateGazeTrackerColor: boolean;
  46621. /**
  46622. * If the controller laser color should be updated when selecting meshes
  46623. */
  46624. updateControllerLaserColor: boolean;
  46625. /**
  46626. * The gaze tracking mesh corresponding to the left controller
  46627. */
  46628. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46629. /**
  46630. * The gaze tracking mesh corresponding to the right controller
  46631. */
  46632. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46633. /**
  46634. * If the ray of the gaze should be displayed.
  46635. */
  46636. get displayGaze(): boolean;
  46637. /**
  46638. * Sets if the ray of the gaze should be displayed.
  46639. */
  46640. set displayGaze(value: boolean);
  46641. /**
  46642. * If the ray of the LaserPointer should be displayed.
  46643. */
  46644. get displayLaserPointer(): boolean;
  46645. /**
  46646. * Sets if the ray of the LaserPointer should be displayed.
  46647. */
  46648. set displayLaserPointer(value: boolean);
  46649. /**
  46650. * The deviceOrientationCamera used as the camera when not in VR.
  46651. */
  46652. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46653. /**
  46654. * Based on the current WebVR support, returns the current VR camera used.
  46655. */
  46656. get currentVRCamera(): Nullable<Camera>;
  46657. /**
  46658. * The webVRCamera which is used when in VR.
  46659. */
  46660. get webVRCamera(): WebVRFreeCamera;
  46661. /**
  46662. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46663. */
  46664. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46665. /**
  46666. * The html button that is used to trigger entering into VR.
  46667. */
  46668. get vrButton(): Nullable<HTMLButtonElement>;
  46669. private get _teleportationRequestInitiated();
  46670. /**
  46671. * Defines whether or not Pointer lock should be requested when switching to
  46672. * full screen.
  46673. */
  46674. requestPointerLockOnFullScreen: boolean;
  46675. /**
  46676. * If asking to force XR, this will be populated with the default xr experience
  46677. */
  46678. xr: WebXRDefaultExperience;
  46679. /**
  46680. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46681. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46682. */
  46683. xrTestDone: boolean;
  46684. /**
  46685. * Instantiates a VRExperienceHelper.
  46686. * Helps to quickly add VR support to an existing scene.
  46687. * @param scene The scene the VRExperienceHelper belongs to.
  46688. * @param webVROptions Options to modify the vr experience helper's behavior.
  46689. */
  46690. constructor(scene: Scene,
  46691. /** Options to modify the vr experience helper's behavior. */
  46692. webVROptions?: VRExperienceHelperOptions);
  46693. private completeVRInit;
  46694. private _onDefaultMeshLoaded;
  46695. private _onResize;
  46696. private _onFullscreenChange;
  46697. /**
  46698. * Gets a value indicating if we are currently in VR mode.
  46699. */
  46700. get isInVRMode(): boolean;
  46701. private onVrDisplayPresentChange;
  46702. private onVRDisplayChanged;
  46703. private moveButtonToBottomRight;
  46704. private displayVRButton;
  46705. private updateButtonVisibility;
  46706. private _cachedAngularSensibility;
  46707. /**
  46708. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46709. * Otherwise, will use the fullscreen API.
  46710. */
  46711. enterVR(): void;
  46712. /**
  46713. * Attempt to exit VR, or fullscreen.
  46714. */
  46715. exitVR(): void;
  46716. /**
  46717. * The position of the vr experience helper.
  46718. */
  46719. get position(): Vector3;
  46720. /**
  46721. * Sets the position of the vr experience helper.
  46722. */
  46723. set position(value: Vector3);
  46724. /**
  46725. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46726. */
  46727. enableInteractions(): void;
  46728. private get _noControllerIsActive();
  46729. private beforeRender;
  46730. private _isTeleportationFloor;
  46731. /**
  46732. * Adds a floor mesh to be used for teleportation.
  46733. * @param floorMesh the mesh to be used for teleportation.
  46734. */
  46735. addFloorMesh(floorMesh: Mesh): void;
  46736. /**
  46737. * Removes a floor mesh from being used for teleportation.
  46738. * @param floorMesh the mesh to be removed.
  46739. */
  46740. removeFloorMesh(floorMesh: Mesh): void;
  46741. /**
  46742. * Enables interactions and teleportation using the VR controllers and gaze.
  46743. * @param vrTeleportationOptions options to modify teleportation behavior.
  46744. */
  46745. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46746. private _onNewGamepadConnected;
  46747. private _tryEnableInteractionOnController;
  46748. private _onNewGamepadDisconnected;
  46749. private _enableInteractionOnController;
  46750. private _checkTeleportWithRay;
  46751. private _checkRotate;
  46752. private _checkTeleportBackwards;
  46753. private _enableTeleportationOnController;
  46754. private _createTeleportationCircles;
  46755. private _displayTeleportationTarget;
  46756. private _hideTeleportationTarget;
  46757. private _rotateCamera;
  46758. private _moveTeleportationSelectorTo;
  46759. private _workingVector;
  46760. private _workingQuaternion;
  46761. private _workingMatrix;
  46762. /**
  46763. * Time Constant Teleportation Mode
  46764. */
  46765. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46766. /**
  46767. * Speed Constant Teleportation Mode
  46768. */
  46769. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46770. /**
  46771. * Teleports the users feet to the desired location
  46772. * @param location The location where the user's feet should be placed
  46773. */
  46774. teleportCamera(location: Vector3): void;
  46775. private _convertNormalToDirectionOfRay;
  46776. private _castRayAndSelectObject;
  46777. private _notifySelectedMeshUnselected;
  46778. /**
  46779. * Permanently set new colors for the laser pointer
  46780. * @param color the new laser color
  46781. * @param pickedColor the new laser color when picked mesh detected
  46782. */
  46783. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46784. /**
  46785. * Set lighting enabled / disabled on the laser pointer of both controllers
  46786. * @param enabled should the lighting be enabled on the laser pointer
  46787. */
  46788. setLaserLightingState(enabled?: boolean): void;
  46789. /**
  46790. * Permanently set new colors for the gaze pointer
  46791. * @param color the new gaze color
  46792. * @param pickedColor the new gaze color when picked mesh detected
  46793. */
  46794. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46795. /**
  46796. * Sets the color of the laser ray from the vr controllers.
  46797. * @param color new color for the ray.
  46798. */
  46799. changeLaserColor(color: Color3): void;
  46800. /**
  46801. * Sets the color of the ray from the vr headsets gaze.
  46802. * @param color new color for the ray.
  46803. */
  46804. changeGazeColor(color: Color3): void;
  46805. /**
  46806. * Exits VR and disposes of the vr experience helper
  46807. */
  46808. dispose(): void;
  46809. /**
  46810. * Gets the name of the VRExperienceHelper class
  46811. * @returns "VRExperienceHelper"
  46812. */
  46813. getClassName(): string;
  46814. }
  46815. }
  46816. declare module "babylonjs/Cameras/VR/index" {
  46817. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  46818. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  46819. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46820. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  46821. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  46822. export * from "babylonjs/Cameras/VR/webVRCamera";
  46823. }
  46824. declare module "babylonjs/Cameras/RigModes/index" {
  46825. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46826. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46827. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46828. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46829. }
  46830. declare module "babylonjs/Cameras/index" {
  46831. export * from "babylonjs/Cameras/Inputs/index";
  46832. export * from "babylonjs/Cameras/cameraInputsManager";
  46833. export * from "babylonjs/Cameras/camera";
  46834. export * from "babylonjs/Cameras/targetCamera";
  46835. export * from "babylonjs/Cameras/freeCamera";
  46836. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46837. export * from "babylonjs/Cameras/touchCamera";
  46838. export * from "babylonjs/Cameras/arcRotateCamera";
  46839. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46840. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46841. export * from "babylonjs/Cameras/flyCamera";
  46842. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46843. export * from "babylonjs/Cameras/followCamera";
  46844. export * from "babylonjs/Cameras/followCameraInputsManager";
  46845. export * from "babylonjs/Cameras/gamepadCamera";
  46846. export * from "babylonjs/Cameras/Stereoscopic/index";
  46847. export * from "babylonjs/Cameras/universalCamera";
  46848. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46849. export * from "babylonjs/Cameras/VR/index";
  46850. export * from "babylonjs/Cameras/RigModes/index";
  46851. }
  46852. declare module "babylonjs/Collisions/index" {
  46853. export * from "babylonjs/Collisions/collider";
  46854. export * from "babylonjs/Collisions/collisionCoordinator";
  46855. export * from "babylonjs/Collisions/pickingInfo";
  46856. export * from "babylonjs/Collisions/intersectionInfo";
  46857. export * from "babylonjs/Collisions/meshCollisionData";
  46858. }
  46859. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46860. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46861. import { Vector3 } from "babylonjs/Maths/math.vector";
  46862. import { Ray } from "babylonjs/Culling/ray";
  46863. import { Plane } from "babylonjs/Maths/math.plane";
  46864. /**
  46865. * Contains an array of blocks representing the octree
  46866. */
  46867. export interface IOctreeContainer<T> {
  46868. /**
  46869. * Blocks within the octree
  46870. */
  46871. blocks: Array<OctreeBlock<T>>;
  46872. }
  46873. /**
  46874. * Class used to store a cell in an octree
  46875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46876. */
  46877. export class OctreeBlock<T> {
  46878. /**
  46879. * Gets the content of the current block
  46880. */
  46881. entries: T[];
  46882. /**
  46883. * Gets the list of block children
  46884. */
  46885. blocks: Array<OctreeBlock<T>>;
  46886. private _depth;
  46887. private _maxDepth;
  46888. private _capacity;
  46889. private _minPoint;
  46890. private _maxPoint;
  46891. private _boundingVectors;
  46892. private _creationFunc;
  46893. /**
  46894. * Creates a new block
  46895. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46896. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46897. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46898. * @param depth defines the current depth of this block in the octree
  46899. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46900. * @param creationFunc defines a callback to call when an element is added to the block
  46901. */
  46902. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46903. /**
  46904. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46905. */
  46906. get capacity(): number;
  46907. /**
  46908. * Gets the minimum vector (in world space) of the block's bounding box
  46909. */
  46910. get minPoint(): Vector3;
  46911. /**
  46912. * Gets the maximum vector (in world space) of the block's bounding box
  46913. */
  46914. get maxPoint(): Vector3;
  46915. /**
  46916. * Add a new element to this block
  46917. * @param entry defines the element to add
  46918. */
  46919. addEntry(entry: T): void;
  46920. /**
  46921. * Remove an element from this block
  46922. * @param entry defines the element to remove
  46923. */
  46924. removeEntry(entry: T): void;
  46925. /**
  46926. * Add an array of elements to this block
  46927. * @param entries defines the array of elements to add
  46928. */
  46929. addEntries(entries: T[]): void;
  46930. /**
  46931. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46932. * @param frustumPlanes defines the frustum planes to test
  46933. * @param selection defines the array to store current content if selection is positive
  46934. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46935. */
  46936. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46937. /**
  46938. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46939. * @param sphereCenter defines the bounding sphere center
  46940. * @param sphereRadius defines the bounding sphere radius
  46941. * @param selection defines the array to store current content if selection is positive
  46942. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46943. */
  46944. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46945. /**
  46946. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46947. * @param ray defines the ray to test with
  46948. * @param selection defines the array to store current content if selection is positive
  46949. */
  46950. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46951. /**
  46952. * Subdivide the content into child blocks (this block will then be empty)
  46953. */
  46954. createInnerBlocks(): void;
  46955. /**
  46956. * @hidden
  46957. */
  46958. 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;
  46959. }
  46960. }
  46961. declare module "babylonjs/Culling/Octrees/octree" {
  46962. import { SmartArray } from "babylonjs/Misc/smartArray";
  46963. import { Vector3 } from "babylonjs/Maths/math.vector";
  46964. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46966. import { Ray } from "babylonjs/Culling/ray";
  46967. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46968. import { Plane } from "babylonjs/Maths/math.plane";
  46969. /**
  46970. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46971. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46972. */
  46973. export class Octree<T> {
  46974. /** 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.) */
  46975. maxDepth: number;
  46976. /**
  46977. * Blocks within the octree containing objects
  46978. */
  46979. blocks: Array<OctreeBlock<T>>;
  46980. /**
  46981. * Content stored in the octree
  46982. */
  46983. dynamicContent: T[];
  46984. private _maxBlockCapacity;
  46985. private _selectionContent;
  46986. private _creationFunc;
  46987. /**
  46988. * Creates a octree
  46989. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46990. * @param creationFunc function to be used to instatiate the octree
  46991. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46992. * @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.)
  46993. */
  46994. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46995. /** 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.) */
  46996. maxDepth?: number);
  46997. /**
  46998. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46999. * @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);
  47000. * @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);
  47001. * @param entries meshes to be added to the octree blocks
  47002. */
  47003. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47004. /**
  47005. * Adds a mesh to the octree
  47006. * @param entry Mesh to add to the octree
  47007. */
  47008. addMesh(entry: T): void;
  47009. /**
  47010. * Remove an element from the octree
  47011. * @param entry defines the element to remove
  47012. */
  47013. removeMesh(entry: T): void;
  47014. /**
  47015. * Selects an array of meshes within the frustum
  47016. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47017. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47018. * @returns array of meshes within the frustum
  47019. */
  47020. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47021. /**
  47022. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47023. * @param sphereCenter defines the bounding sphere center
  47024. * @param sphereRadius defines the bounding sphere radius
  47025. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47026. * @returns an array of objects that intersect the sphere
  47027. */
  47028. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47029. /**
  47030. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47031. * @param ray defines the ray to test with
  47032. * @returns array of intersected objects
  47033. */
  47034. intersectsRay(ray: Ray): SmartArray<T>;
  47035. /**
  47036. * Adds a mesh into the octree block if it intersects the block
  47037. */
  47038. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47039. /**
  47040. * Adds a submesh into the octree block if it intersects the block
  47041. */
  47042. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47043. }
  47044. }
  47045. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47046. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47047. import { Scene } from "babylonjs/scene";
  47048. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47050. import { Ray } from "babylonjs/Culling/ray";
  47051. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47052. import { Collider } from "babylonjs/Collisions/collider";
  47053. module "babylonjs/scene" {
  47054. interface Scene {
  47055. /**
  47056. * @hidden
  47057. * Backing Filed
  47058. */
  47059. _selectionOctree: Octree<AbstractMesh>;
  47060. /**
  47061. * Gets the octree used to boost mesh selection (picking)
  47062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47063. */
  47064. selectionOctree: Octree<AbstractMesh>;
  47065. /**
  47066. * Creates or updates the octree used to boost selection (picking)
  47067. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47068. * @param maxCapacity defines the maximum capacity per leaf
  47069. * @param maxDepth defines the maximum depth of the octree
  47070. * @returns an octree of AbstractMesh
  47071. */
  47072. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47073. }
  47074. }
  47075. module "babylonjs/Meshes/abstractMesh" {
  47076. interface AbstractMesh {
  47077. /**
  47078. * @hidden
  47079. * Backing Field
  47080. */
  47081. _submeshesOctree: Octree<SubMesh>;
  47082. /**
  47083. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47084. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47085. * @param maxCapacity defines the maximum size of each block (64 by default)
  47086. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47087. * @returns the new octree
  47088. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47090. */
  47091. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47092. }
  47093. }
  47094. /**
  47095. * Defines the octree scene component responsible to manage any octrees
  47096. * in a given scene.
  47097. */
  47098. export class OctreeSceneComponent {
  47099. /**
  47100. * The component name help to identify the component in the list of scene components.
  47101. */
  47102. readonly name: string;
  47103. /**
  47104. * The scene the component belongs to.
  47105. */
  47106. scene: Scene;
  47107. /**
  47108. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47109. */
  47110. readonly checksIsEnabled: boolean;
  47111. /**
  47112. * Creates a new instance of the component for the given scene
  47113. * @param scene Defines the scene to register the component in
  47114. */
  47115. constructor(scene: Scene);
  47116. /**
  47117. * Registers the component in a given scene
  47118. */
  47119. register(): void;
  47120. /**
  47121. * Return the list of active meshes
  47122. * @returns the list of active meshes
  47123. */
  47124. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47125. /**
  47126. * Return the list of active sub meshes
  47127. * @param mesh The mesh to get the candidates sub meshes from
  47128. * @returns the list of active sub meshes
  47129. */
  47130. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47131. private _tempRay;
  47132. /**
  47133. * Return the list of sub meshes intersecting with a given local ray
  47134. * @param mesh defines the mesh to find the submesh for
  47135. * @param localRay defines the ray in local space
  47136. * @returns the list of intersecting sub meshes
  47137. */
  47138. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47139. /**
  47140. * Return the list of sub meshes colliding with a collider
  47141. * @param mesh defines the mesh to find the submesh for
  47142. * @param collider defines the collider to evaluate the collision against
  47143. * @returns the list of colliding sub meshes
  47144. */
  47145. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47146. /**
  47147. * Rebuilds the elements related to this component in case of
  47148. * context lost for instance.
  47149. */
  47150. rebuild(): void;
  47151. /**
  47152. * Disposes the component and the associated ressources.
  47153. */
  47154. dispose(): void;
  47155. }
  47156. }
  47157. declare module "babylonjs/Culling/Octrees/index" {
  47158. export * from "babylonjs/Culling/Octrees/octree";
  47159. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47160. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47161. }
  47162. declare module "babylonjs/Culling/index" {
  47163. export * from "babylonjs/Culling/boundingBox";
  47164. export * from "babylonjs/Culling/boundingInfo";
  47165. export * from "babylonjs/Culling/boundingSphere";
  47166. export * from "babylonjs/Culling/Octrees/index";
  47167. export * from "babylonjs/Culling/ray";
  47168. }
  47169. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  47170. import { IDisposable, Scene } from "babylonjs/scene";
  47171. import { Nullable } from "babylonjs/types";
  47172. import { Observable } from "babylonjs/Misc/observable";
  47173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47174. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  47175. import { Camera } from "babylonjs/Cameras/camera";
  47176. /**
  47177. * Renders a layer on top of an existing scene
  47178. */
  47179. export class UtilityLayerRenderer implements IDisposable {
  47180. /** the original scene that will be rendered on top of */
  47181. originalScene: Scene;
  47182. private _pointerCaptures;
  47183. private _lastPointerEvents;
  47184. private static _DefaultUtilityLayer;
  47185. private static _DefaultKeepDepthUtilityLayer;
  47186. private _sharedGizmoLight;
  47187. private _renderCamera;
  47188. /**
  47189. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47190. * @returns the camera that is used when rendering the utility layer
  47191. */
  47192. getRenderCamera(): Camera;
  47193. /**
  47194. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47195. * @param cam the camera that should be used when rendering the utility layer
  47196. */
  47197. setRenderCamera(cam: Nullable<Camera>): void;
  47198. /**
  47199. * @hidden
  47200. * Light which used by gizmos to get light shading
  47201. */
  47202. _getSharedGizmoLight(): HemisphericLight;
  47203. /**
  47204. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47205. */
  47206. pickUtilitySceneFirst: boolean;
  47207. /**
  47208. * 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)
  47209. */
  47210. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47211. /**
  47212. * 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)
  47213. */
  47214. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47215. /**
  47216. * The scene that is rendered on top of the original scene
  47217. */
  47218. utilityLayerScene: Scene;
  47219. /**
  47220. * If the utility layer should automatically be rendered on top of existing scene
  47221. */
  47222. shouldRender: boolean;
  47223. /**
  47224. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47225. */
  47226. onlyCheckPointerDownEvents: boolean;
  47227. /**
  47228. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47229. */
  47230. processAllEvents: boolean;
  47231. /**
  47232. * Observable raised when the pointer move from the utility layer scene to the main scene
  47233. */
  47234. onPointerOutObservable: Observable<number>;
  47235. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47236. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47237. private _afterRenderObserver;
  47238. private _sceneDisposeObserver;
  47239. private _originalPointerObserver;
  47240. /**
  47241. * Instantiates a UtilityLayerRenderer
  47242. * @param originalScene the original scene that will be rendered on top of
  47243. * @param handleEvents boolean indicating if the utility layer should handle events
  47244. */
  47245. constructor(
  47246. /** the original scene that will be rendered on top of */
  47247. originalScene: Scene, handleEvents?: boolean);
  47248. private _notifyObservers;
  47249. /**
  47250. * Renders the utility layers scene on top of the original scene
  47251. */
  47252. render(): void;
  47253. /**
  47254. * Disposes of the renderer
  47255. */
  47256. dispose(): void;
  47257. private _updateCamera;
  47258. }
  47259. }
  47260. declare module "babylonjs/Gizmos/gizmo" {
  47261. import { Nullable } from "babylonjs/types";
  47262. import { IDisposable } from "babylonjs/scene";
  47263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47264. import { Mesh } from "babylonjs/Meshes/mesh";
  47265. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47266. /**
  47267. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47268. */
  47269. export class Gizmo implements IDisposable {
  47270. /** The utility layer the gizmo will be added to */
  47271. gizmoLayer: UtilityLayerRenderer;
  47272. /**
  47273. * The root mesh of the gizmo
  47274. */
  47275. _rootMesh: Mesh;
  47276. private _attachedMesh;
  47277. /**
  47278. * Ratio for the scale of the gizmo (Default: 1)
  47279. */
  47280. scaleRatio: number;
  47281. /**
  47282. * If a custom mesh has been set (Default: false)
  47283. */
  47284. protected _customMeshSet: boolean;
  47285. /**
  47286. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47287. * * When set, interactions will be enabled
  47288. */
  47289. get attachedMesh(): Nullable<AbstractMesh>;
  47290. set attachedMesh(value: Nullable<AbstractMesh>);
  47291. /**
  47292. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47293. * @param mesh The mesh to replace the default mesh of the gizmo
  47294. */
  47295. setCustomMesh(mesh: Mesh): void;
  47296. /**
  47297. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47298. */
  47299. updateGizmoRotationToMatchAttachedMesh: boolean;
  47300. /**
  47301. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47302. */
  47303. updateGizmoPositionToMatchAttachedMesh: boolean;
  47304. /**
  47305. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47306. */
  47307. updateScale: boolean;
  47308. protected _interactionsEnabled: boolean;
  47309. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47310. private _beforeRenderObserver;
  47311. private _tempVector;
  47312. /**
  47313. * Creates a gizmo
  47314. * @param gizmoLayer The utility layer the gizmo will be added to
  47315. */
  47316. constructor(
  47317. /** The utility layer the gizmo will be added to */
  47318. gizmoLayer?: UtilityLayerRenderer);
  47319. /**
  47320. * Updates the gizmo to match the attached mesh's position/rotation
  47321. */
  47322. protected _update(): void;
  47323. /**
  47324. * Disposes of the gizmo
  47325. */
  47326. dispose(): void;
  47327. }
  47328. }
  47329. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47330. import { Observable } from "babylonjs/Misc/observable";
  47331. import { Nullable } from "babylonjs/types";
  47332. import { Vector3 } from "babylonjs/Maths/math.vector";
  47333. import { Color3 } from "babylonjs/Maths/math.color";
  47334. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47336. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47337. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47338. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47339. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47340. import { Scene } from "babylonjs/scene";
  47341. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47342. /**
  47343. * Single plane drag gizmo
  47344. */
  47345. export class PlaneDragGizmo extends Gizmo {
  47346. /**
  47347. * Drag behavior responsible for the gizmos dragging interactions
  47348. */
  47349. dragBehavior: PointerDragBehavior;
  47350. private _pointerObserver;
  47351. /**
  47352. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47353. */
  47354. snapDistance: number;
  47355. /**
  47356. * Event that fires each time the gizmo snaps to a new location.
  47357. * * snapDistance is the the change in distance
  47358. */
  47359. onSnapObservable: Observable<{
  47360. snapDistance: number;
  47361. }>;
  47362. private _plane;
  47363. private _coloredMaterial;
  47364. private _hoverMaterial;
  47365. private _isEnabled;
  47366. private _parent;
  47367. /** @hidden */
  47368. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47369. /** @hidden */
  47370. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47371. /**
  47372. * Creates a PlaneDragGizmo
  47373. * @param gizmoLayer The utility layer the gizmo will be added to
  47374. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47375. * @param color The color of the gizmo
  47376. */
  47377. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47378. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47379. /**
  47380. * If the gizmo is enabled
  47381. */
  47382. set isEnabled(value: boolean);
  47383. get isEnabled(): boolean;
  47384. /**
  47385. * Disposes of the gizmo
  47386. */
  47387. dispose(): void;
  47388. }
  47389. }
  47390. declare module "babylonjs/Gizmos/positionGizmo" {
  47391. import { Observable } from "babylonjs/Misc/observable";
  47392. import { Nullable } from "babylonjs/types";
  47393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47394. import { Mesh } from "babylonjs/Meshes/mesh";
  47395. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47396. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47397. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47398. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47399. /**
  47400. * Gizmo that enables dragging a mesh along 3 axis
  47401. */
  47402. export class PositionGizmo extends Gizmo {
  47403. /**
  47404. * Internal gizmo used for interactions on the x axis
  47405. */
  47406. xGizmo: AxisDragGizmo;
  47407. /**
  47408. * Internal gizmo used for interactions on the y axis
  47409. */
  47410. yGizmo: AxisDragGizmo;
  47411. /**
  47412. * Internal gizmo used for interactions on the z axis
  47413. */
  47414. zGizmo: AxisDragGizmo;
  47415. /**
  47416. * Internal gizmo used for interactions on the yz plane
  47417. */
  47418. xPlaneGizmo: PlaneDragGizmo;
  47419. /**
  47420. * Internal gizmo used for interactions on the xz plane
  47421. */
  47422. yPlaneGizmo: PlaneDragGizmo;
  47423. /**
  47424. * Internal gizmo used for interactions on the xy plane
  47425. */
  47426. zPlaneGizmo: PlaneDragGizmo;
  47427. /**
  47428. * private variables
  47429. */
  47430. private _meshAttached;
  47431. private _updateGizmoRotationToMatchAttachedMesh;
  47432. private _snapDistance;
  47433. private _scaleRatio;
  47434. /** Fires an event when any of it's sub gizmos are dragged */
  47435. onDragStartObservable: Observable<unknown>;
  47436. /** Fires an event when any of it's sub gizmos are released from dragging */
  47437. onDragEndObservable: Observable<unknown>;
  47438. /**
  47439. * If set to true, planar drag is enabled
  47440. */
  47441. private _planarGizmoEnabled;
  47442. get attachedMesh(): Nullable<AbstractMesh>;
  47443. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47444. /**
  47445. * Creates a PositionGizmo
  47446. * @param gizmoLayer The utility layer the gizmo will be added to
  47447. */
  47448. constructor(gizmoLayer?: UtilityLayerRenderer);
  47449. /**
  47450. * If the planar drag gizmo is enabled
  47451. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47452. */
  47453. set planarGizmoEnabled(value: boolean);
  47454. get planarGizmoEnabled(): boolean;
  47455. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47456. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47457. /**
  47458. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47459. */
  47460. set snapDistance(value: number);
  47461. get snapDistance(): number;
  47462. /**
  47463. * Ratio for the scale of the gizmo (Default: 1)
  47464. */
  47465. set scaleRatio(value: number);
  47466. get scaleRatio(): number;
  47467. /**
  47468. * Disposes of the gizmo
  47469. */
  47470. dispose(): void;
  47471. /**
  47472. * CustomMeshes are not supported by this gizmo
  47473. * @param mesh The mesh to replace the default mesh of the gizmo
  47474. */
  47475. setCustomMesh(mesh: Mesh): void;
  47476. }
  47477. }
  47478. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47479. import { Observable } from "babylonjs/Misc/observable";
  47480. import { Nullable } from "babylonjs/types";
  47481. import { Vector3 } from "babylonjs/Maths/math.vector";
  47482. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47484. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47485. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47486. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47487. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47488. import { Scene } from "babylonjs/scene";
  47489. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47490. import { Color3 } from "babylonjs/Maths/math.color";
  47491. /**
  47492. * Single axis drag gizmo
  47493. */
  47494. export class AxisDragGizmo extends Gizmo {
  47495. /**
  47496. * Drag behavior responsible for the gizmos dragging interactions
  47497. */
  47498. dragBehavior: PointerDragBehavior;
  47499. private _pointerObserver;
  47500. /**
  47501. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47502. */
  47503. snapDistance: number;
  47504. /**
  47505. * Event that fires each time the gizmo snaps to a new location.
  47506. * * snapDistance is the the change in distance
  47507. */
  47508. onSnapObservable: Observable<{
  47509. snapDistance: number;
  47510. }>;
  47511. private _isEnabled;
  47512. private _parent;
  47513. private _arrow;
  47514. private _coloredMaterial;
  47515. private _hoverMaterial;
  47516. /** @hidden */
  47517. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47518. /** @hidden */
  47519. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47520. /**
  47521. * Creates an AxisDragGizmo
  47522. * @param gizmoLayer The utility layer the gizmo will be added to
  47523. * @param dragAxis The axis which the gizmo will be able to drag on
  47524. * @param color The color of the gizmo
  47525. */
  47526. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47527. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47528. /**
  47529. * If the gizmo is enabled
  47530. */
  47531. set isEnabled(value: boolean);
  47532. get isEnabled(): boolean;
  47533. /**
  47534. * Disposes of the gizmo
  47535. */
  47536. dispose(): void;
  47537. }
  47538. }
  47539. declare module "babylonjs/Debug/axesViewer" {
  47540. import { Vector3 } from "babylonjs/Maths/math.vector";
  47541. import { Nullable } from "babylonjs/types";
  47542. import { Scene } from "babylonjs/scene";
  47543. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47544. /**
  47545. * The Axes viewer will show 3 axes in a specific point in space
  47546. */
  47547. export class AxesViewer {
  47548. private _xAxis;
  47549. private _yAxis;
  47550. private _zAxis;
  47551. private _scaleLinesFactor;
  47552. private _instanced;
  47553. /**
  47554. * Gets the hosting scene
  47555. */
  47556. scene: Scene;
  47557. /**
  47558. * Gets or sets a number used to scale line length
  47559. */
  47560. scaleLines: number;
  47561. /** Gets the node hierarchy used to render x-axis */
  47562. get xAxis(): TransformNode;
  47563. /** Gets the node hierarchy used to render y-axis */
  47564. get yAxis(): TransformNode;
  47565. /** Gets the node hierarchy used to render z-axis */
  47566. get zAxis(): TransformNode;
  47567. /**
  47568. * Creates a new AxesViewer
  47569. * @param scene defines the hosting scene
  47570. * @param scaleLines defines a number used to scale line length (1 by default)
  47571. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47572. * @param xAxis defines the node hierarchy used to render the x-axis
  47573. * @param yAxis defines the node hierarchy used to render the y-axis
  47574. * @param zAxis defines the node hierarchy used to render the z-axis
  47575. */
  47576. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47577. /**
  47578. * Force the viewer to update
  47579. * @param position defines the position of the viewer
  47580. * @param xaxis defines the x axis of the viewer
  47581. * @param yaxis defines the y axis of the viewer
  47582. * @param zaxis defines the z axis of the viewer
  47583. */
  47584. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47585. /**
  47586. * Creates an instance of this axes viewer.
  47587. * @returns a new axes viewer with instanced meshes
  47588. */
  47589. createInstance(): AxesViewer;
  47590. /** Releases resources */
  47591. dispose(): void;
  47592. private static _SetRenderingGroupId;
  47593. }
  47594. }
  47595. declare module "babylonjs/Debug/boneAxesViewer" {
  47596. import { Nullable } from "babylonjs/types";
  47597. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47598. import { Vector3 } from "babylonjs/Maths/math.vector";
  47599. import { Mesh } from "babylonjs/Meshes/mesh";
  47600. import { Bone } from "babylonjs/Bones/bone";
  47601. import { Scene } from "babylonjs/scene";
  47602. /**
  47603. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47604. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47605. */
  47606. export class BoneAxesViewer extends AxesViewer {
  47607. /**
  47608. * Gets or sets the target mesh where to display the axes viewer
  47609. */
  47610. mesh: Nullable<Mesh>;
  47611. /**
  47612. * Gets or sets the target bone where to display the axes viewer
  47613. */
  47614. bone: Nullable<Bone>;
  47615. /** Gets current position */
  47616. pos: Vector3;
  47617. /** Gets direction of X axis */
  47618. xaxis: Vector3;
  47619. /** Gets direction of Y axis */
  47620. yaxis: Vector3;
  47621. /** Gets direction of Z axis */
  47622. zaxis: Vector3;
  47623. /**
  47624. * Creates a new BoneAxesViewer
  47625. * @param scene defines the hosting scene
  47626. * @param bone defines the target bone
  47627. * @param mesh defines the target mesh
  47628. * @param scaleLines defines a scaling factor for line length (1 by default)
  47629. */
  47630. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47631. /**
  47632. * Force the viewer to update
  47633. */
  47634. update(): void;
  47635. /** Releases resources */
  47636. dispose(): void;
  47637. }
  47638. }
  47639. declare module "babylonjs/Debug/debugLayer" {
  47640. import { Scene } from "babylonjs/scene";
  47641. /**
  47642. * Interface used to define scene explorer extensibility option
  47643. */
  47644. export interface IExplorerExtensibilityOption {
  47645. /**
  47646. * Define the option label
  47647. */
  47648. label: string;
  47649. /**
  47650. * Defines the action to execute on click
  47651. */
  47652. action: (entity: any) => void;
  47653. }
  47654. /**
  47655. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47656. */
  47657. export interface IExplorerExtensibilityGroup {
  47658. /**
  47659. * Defines a predicate to test if a given type mut be extended
  47660. */
  47661. predicate: (entity: any) => boolean;
  47662. /**
  47663. * Gets the list of options added to a type
  47664. */
  47665. entries: IExplorerExtensibilityOption[];
  47666. }
  47667. /**
  47668. * Interface used to define the options to use to create the Inspector
  47669. */
  47670. export interface IInspectorOptions {
  47671. /**
  47672. * Display in overlay mode (default: false)
  47673. */
  47674. overlay?: boolean;
  47675. /**
  47676. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47677. */
  47678. globalRoot?: HTMLElement;
  47679. /**
  47680. * Display the Scene explorer
  47681. */
  47682. showExplorer?: boolean;
  47683. /**
  47684. * Display the property inspector
  47685. */
  47686. showInspector?: boolean;
  47687. /**
  47688. * Display in embed mode (both panes on the right)
  47689. */
  47690. embedMode?: boolean;
  47691. /**
  47692. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47693. */
  47694. handleResize?: boolean;
  47695. /**
  47696. * Allow the panes to popup (default: true)
  47697. */
  47698. enablePopup?: boolean;
  47699. /**
  47700. * Allow the panes to be closed by users (default: true)
  47701. */
  47702. enableClose?: boolean;
  47703. /**
  47704. * Optional list of extensibility entries
  47705. */
  47706. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47707. /**
  47708. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47709. */
  47710. inspectorURL?: string;
  47711. /**
  47712. * Optional initial tab (default to DebugLayerTab.Properties)
  47713. */
  47714. initialTab?: DebugLayerTab;
  47715. }
  47716. module "babylonjs/scene" {
  47717. interface Scene {
  47718. /**
  47719. * @hidden
  47720. * Backing field
  47721. */
  47722. _debugLayer: DebugLayer;
  47723. /**
  47724. * Gets the debug layer (aka Inspector) associated with the scene
  47725. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47726. */
  47727. debugLayer: DebugLayer;
  47728. }
  47729. }
  47730. /**
  47731. * Enum of inspector action tab
  47732. */
  47733. export enum DebugLayerTab {
  47734. /**
  47735. * Properties tag (default)
  47736. */
  47737. Properties = 0,
  47738. /**
  47739. * Debug tab
  47740. */
  47741. Debug = 1,
  47742. /**
  47743. * Statistics tab
  47744. */
  47745. Statistics = 2,
  47746. /**
  47747. * Tools tab
  47748. */
  47749. Tools = 3,
  47750. /**
  47751. * Settings tab
  47752. */
  47753. Settings = 4
  47754. }
  47755. /**
  47756. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47757. * what is happening in your scene
  47758. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47759. */
  47760. export class DebugLayer {
  47761. /**
  47762. * Define the url to get the inspector script from.
  47763. * By default it uses the babylonjs CDN.
  47764. * @ignoreNaming
  47765. */
  47766. static InspectorURL: string;
  47767. private _scene;
  47768. private BJSINSPECTOR;
  47769. private _onPropertyChangedObservable?;
  47770. /**
  47771. * Observable triggered when a property is changed through the inspector.
  47772. */
  47773. get onPropertyChangedObservable(): any;
  47774. /**
  47775. * Instantiates a new debug layer.
  47776. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47777. * what is happening in your scene
  47778. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47779. * @param scene Defines the scene to inspect
  47780. */
  47781. constructor(scene: Scene);
  47782. /** Creates the inspector window. */
  47783. private _createInspector;
  47784. /**
  47785. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47786. * @param entity defines the entity to select
  47787. * @param lineContainerTitle defines the specific block to highlight
  47788. */
  47789. select(entity: any, lineContainerTitle?: string): void;
  47790. /** Get the inspector from bundle or global */
  47791. private _getGlobalInspector;
  47792. /**
  47793. * Get if the inspector is visible or not.
  47794. * @returns true if visible otherwise, false
  47795. */
  47796. isVisible(): boolean;
  47797. /**
  47798. * Hide the inspector and close its window.
  47799. */
  47800. hide(): void;
  47801. /**
  47802. * Launch the debugLayer.
  47803. * @param config Define the configuration of the inspector
  47804. * @return a promise fulfilled when the debug layer is visible
  47805. */
  47806. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47807. }
  47808. }
  47809. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47810. import { Nullable } from "babylonjs/types";
  47811. import { Scene } from "babylonjs/scene";
  47812. import { Vector4 } from "babylonjs/Maths/math.vector";
  47813. import { Color4 } from "babylonjs/Maths/math.color";
  47814. import { Mesh } from "babylonjs/Meshes/mesh";
  47815. /**
  47816. * Class containing static functions to help procedurally build meshes
  47817. */
  47818. export class BoxBuilder {
  47819. /**
  47820. * Creates a box mesh
  47821. * * The parameter `size` sets the size (float) of each box side (default 1)
  47822. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47823. * * 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)
  47824. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47828. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47829. * @param name defines the name of the mesh
  47830. * @param options defines the options used to create the mesh
  47831. * @param scene defines the hosting scene
  47832. * @returns the box mesh
  47833. */
  47834. static CreateBox(name: string, options: {
  47835. size?: number;
  47836. width?: number;
  47837. height?: number;
  47838. depth?: number;
  47839. faceUV?: Vector4[];
  47840. faceColors?: Color4[];
  47841. sideOrientation?: number;
  47842. frontUVs?: Vector4;
  47843. backUVs?: Vector4;
  47844. wrap?: boolean;
  47845. topBaseAt?: number;
  47846. bottomBaseAt?: number;
  47847. updatable?: boolean;
  47848. }, scene?: Nullable<Scene>): Mesh;
  47849. }
  47850. }
  47851. declare module "babylonjs/Debug/physicsViewer" {
  47852. import { Nullable } from "babylonjs/types";
  47853. import { Scene } from "babylonjs/scene";
  47854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47855. import { Mesh } from "babylonjs/Meshes/mesh";
  47856. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47857. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47858. /**
  47859. * Used to show the physics impostor around the specific mesh
  47860. */
  47861. export class PhysicsViewer {
  47862. /** @hidden */
  47863. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47864. /** @hidden */
  47865. protected _meshes: Array<Nullable<AbstractMesh>>;
  47866. /** @hidden */
  47867. protected _scene: Nullable<Scene>;
  47868. /** @hidden */
  47869. protected _numMeshes: number;
  47870. /** @hidden */
  47871. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47872. private _renderFunction;
  47873. private _utilityLayer;
  47874. private _debugBoxMesh;
  47875. private _debugSphereMesh;
  47876. private _debugCylinderMesh;
  47877. private _debugMaterial;
  47878. private _debugMeshMeshes;
  47879. /**
  47880. * Creates a new PhysicsViewer
  47881. * @param scene defines the hosting scene
  47882. */
  47883. constructor(scene: Scene);
  47884. /** @hidden */
  47885. protected _updateDebugMeshes(): void;
  47886. /**
  47887. * Renders a specified physic impostor
  47888. * @param impostor defines the impostor to render
  47889. * @param targetMesh defines the mesh represented by the impostor
  47890. * @returns the new debug mesh used to render the impostor
  47891. */
  47892. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47893. /**
  47894. * Hides a specified physic impostor
  47895. * @param impostor defines the impostor to hide
  47896. */
  47897. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47898. private _getDebugMaterial;
  47899. private _getDebugBoxMesh;
  47900. private _getDebugSphereMesh;
  47901. private _getDebugCylinderMesh;
  47902. private _getDebugMeshMesh;
  47903. private _getDebugMesh;
  47904. /** Releases all resources */
  47905. dispose(): void;
  47906. }
  47907. }
  47908. declare module "babylonjs/Debug/rayHelper" {
  47909. import { Nullable } from "babylonjs/types";
  47910. import { Ray } from "babylonjs/Culling/ray";
  47911. import { Vector3 } from "babylonjs/Maths/math.vector";
  47912. import { Color3 } from "babylonjs/Maths/math.color";
  47913. import { Scene } from "babylonjs/scene";
  47914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47915. import "babylonjs/Meshes/Builders/linesBuilder";
  47916. /**
  47917. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47918. * in order to better appreciate the issue one might have.
  47919. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47920. */
  47921. export class RayHelper {
  47922. /**
  47923. * Defines the ray we are currently tryin to visualize.
  47924. */
  47925. ray: Nullable<Ray>;
  47926. private _renderPoints;
  47927. private _renderLine;
  47928. private _renderFunction;
  47929. private _scene;
  47930. private _updateToMeshFunction;
  47931. private _attachedToMesh;
  47932. private _meshSpaceDirection;
  47933. private _meshSpaceOrigin;
  47934. /**
  47935. * Helper function to create a colored helper in a scene in one line.
  47936. * @param ray Defines the ray we are currently tryin to visualize
  47937. * @param scene Defines the scene the ray is used in
  47938. * @param color Defines the color we want to see the ray in
  47939. * @returns The newly created ray helper.
  47940. */
  47941. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47942. /**
  47943. * Instantiate a new ray helper.
  47944. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47945. * in order to better appreciate the issue one might have.
  47946. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47947. * @param ray Defines the ray we are currently tryin to visualize
  47948. */
  47949. constructor(ray: Ray);
  47950. /**
  47951. * Shows the ray we are willing to debug.
  47952. * @param scene Defines the scene the ray needs to be rendered in
  47953. * @param color Defines the color the ray needs to be rendered in
  47954. */
  47955. show(scene: Scene, color?: Color3): void;
  47956. /**
  47957. * Hides the ray we are debugging.
  47958. */
  47959. hide(): void;
  47960. private _render;
  47961. /**
  47962. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47963. * @param mesh Defines the mesh we want the helper attached to
  47964. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47965. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47966. * @param length Defines the length of the ray
  47967. */
  47968. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47969. /**
  47970. * Detach the ray helper from the mesh it has previously been attached to.
  47971. */
  47972. detachFromMesh(): void;
  47973. private _updateToMesh;
  47974. /**
  47975. * Dispose the helper and release its associated resources.
  47976. */
  47977. dispose(): void;
  47978. }
  47979. }
  47980. declare module "babylonjs/Debug/skeletonViewer" {
  47981. import { Color3 } from "babylonjs/Maths/math.color";
  47982. import { Scene } from "babylonjs/scene";
  47983. import { Nullable } from "babylonjs/types";
  47984. import { Skeleton } from "babylonjs/Bones/skeleton";
  47985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47986. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47987. /**
  47988. * Class used to render a debug view of a given skeleton
  47989. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47990. */
  47991. export class SkeletonViewer {
  47992. /** defines the skeleton to render */
  47993. skeleton: Skeleton;
  47994. /** defines the mesh attached to the skeleton */
  47995. mesh: AbstractMesh;
  47996. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47997. autoUpdateBonesMatrices: boolean;
  47998. /** defines the rendering group id to use with the viewer */
  47999. renderingGroupId: number;
  48000. /** Gets or sets the color used to render the skeleton */
  48001. color: Color3;
  48002. private _scene;
  48003. private _debugLines;
  48004. private _debugMesh;
  48005. private _isEnabled;
  48006. private _renderFunction;
  48007. private _utilityLayer;
  48008. /**
  48009. * Returns the mesh used to render the bones
  48010. */
  48011. get debugMesh(): Nullable<LinesMesh>;
  48012. /**
  48013. * Creates a new SkeletonViewer
  48014. * @param skeleton defines the skeleton to render
  48015. * @param mesh defines the mesh attached to the skeleton
  48016. * @param scene defines the hosting scene
  48017. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48018. * @param renderingGroupId defines the rendering group id to use with the viewer
  48019. */
  48020. constructor(
  48021. /** defines the skeleton to render */
  48022. skeleton: Skeleton,
  48023. /** defines the mesh attached to the skeleton */
  48024. mesh: AbstractMesh, scene: Scene,
  48025. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48026. autoUpdateBonesMatrices?: boolean,
  48027. /** defines the rendering group id to use with the viewer */
  48028. renderingGroupId?: number);
  48029. /** Gets or sets a boolean indicating if the viewer is enabled */
  48030. set isEnabled(value: boolean);
  48031. get isEnabled(): boolean;
  48032. private _getBonePosition;
  48033. private _getLinesForBonesWithLength;
  48034. private _getLinesForBonesNoLength;
  48035. /** Update the viewer to sync with current skeleton state */
  48036. update(): void;
  48037. /** Release associated resources */
  48038. dispose(): void;
  48039. }
  48040. }
  48041. declare module "babylonjs/Debug/index" {
  48042. export * from "babylonjs/Debug/axesViewer";
  48043. export * from "babylonjs/Debug/boneAxesViewer";
  48044. export * from "babylonjs/Debug/debugLayer";
  48045. export * from "babylonjs/Debug/physicsViewer";
  48046. export * from "babylonjs/Debug/rayHelper";
  48047. export * from "babylonjs/Debug/skeletonViewer";
  48048. }
  48049. declare module "babylonjs/Engines/nullEngine" {
  48050. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48051. import { Scene } from "babylonjs/scene";
  48052. import { Engine } from "babylonjs/Engines/engine";
  48053. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48054. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48055. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48056. import { Effect } from "babylonjs/Materials/effect";
  48057. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48058. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48059. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48060. /**
  48061. * Options to create the null engine
  48062. */
  48063. export class NullEngineOptions {
  48064. /**
  48065. * Render width (Default: 512)
  48066. */
  48067. renderWidth: number;
  48068. /**
  48069. * Render height (Default: 256)
  48070. */
  48071. renderHeight: number;
  48072. /**
  48073. * Texture size (Default: 512)
  48074. */
  48075. textureSize: number;
  48076. /**
  48077. * If delta time between frames should be constant
  48078. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48079. */
  48080. deterministicLockstep: boolean;
  48081. /**
  48082. * Maximum about of steps between frames (Default: 4)
  48083. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48084. */
  48085. lockstepMaxSteps: number;
  48086. }
  48087. /**
  48088. * The null engine class provides support for headless version of babylon.js.
  48089. * This can be used in server side scenario or for testing purposes
  48090. */
  48091. export class NullEngine extends Engine {
  48092. private _options;
  48093. /**
  48094. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48095. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48096. * @returns true if engine is in deterministic lock step mode
  48097. */
  48098. isDeterministicLockStep(): boolean;
  48099. /**
  48100. * Gets the max steps when engine is running in deterministic lock step
  48101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48102. * @returns the max steps
  48103. */
  48104. getLockstepMaxSteps(): number;
  48105. /**
  48106. * Gets the current hardware scaling level.
  48107. * By default the hardware scaling level is computed from the window device ratio.
  48108. * 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.
  48109. * @returns a number indicating the current hardware scaling level
  48110. */
  48111. getHardwareScalingLevel(): number;
  48112. constructor(options?: NullEngineOptions);
  48113. /**
  48114. * Creates a vertex buffer
  48115. * @param vertices the data for the vertex buffer
  48116. * @returns the new WebGL static buffer
  48117. */
  48118. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48119. /**
  48120. * Creates a new index buffer
  48121. * @param indices defines the content of the index buffer
  48122. * @param updatable defines if the index buffer must be updatable
  48123. * @returns a new webGL buffer
  48124. */
  48125. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48126. /**
  48127. * Clear the current render buffer or the current render target (if any is set up)
  48128. * @param color defines the color to use
  48129. * @param backBuffer defines if the back buffer must be cleared
  48130. * @param depth defines if the depth buffer must be cleared
  48131. * @param stencil defines if the stencil buffer must be cleared
  48132. */
  48133. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48134. /**
  48135. * Gets the current render width
  48136. * @param useScreen defines if screen size must be used (or the current render target if any)
  48137. * @returns a number defining the current render width
  48138. */
  48139. getRenderWidth(useScreen?: boolean): number;
  48140. /**
  48141. * Gets the current render height
  48142. * @param useScreen defines if screen size must be used (or the current render target if any)
  48143. * @returns a number defining the current render height
  48144. */
  48145. getRenderHeight(useScreen?: boolean): number;
  48146. /**
  48147. * Set the WebGL's viewport
  48148. * @param viewport defines the viewport element to be used
  48149. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48150. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48151. */
  48152. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48153. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48154. /**
  48155. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48156. * @param pipelineContext defines the pipeline context to use
  48157. * @param uniformsNames defines the list of uniform names
  48158. * @returns an array of webGL uniform locations
  48159. */
  48160. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48161. /**
  48162. * Gets the lsit of active attributes for a given webGL program
  48163. * @param pipelineContext defines the pipeline context to use
  48164. * @param attributesNames defines the list of attribute names to get
  48165. * @returns an array of indices indicating the offset of each attribute
  48166. */
  48167. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48168. /**
  48169. * Binds an effect to the webGL context
  48170. * @param effect defines the effect to bind
  48171. */
  48172. bindSamplers(effect: Effect): void;
  48173. /**
  48174. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48175. * @param effect defines the effect to activate
  48176. */
  48177. enableEffect(effect: Effect): void;
  48178. /**
  48179. * Set various states to the webGL context
  48180. * @param culling defines backface culling state
  48181. * @param zOffset defines the value to apply to zOffset (0 by default)
  48182. * @param force defines if states must be applied even if cache is up to date
  48183. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48184. */
  48185. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48186. /**
  48187. * Set the value of an uniform to an array of int32
  48188. * @param uniform defines the webGL uniform location where to store the value
  48189. * @param array defines the array of int32 to store
  48190. */
  48191. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48192. /**
  48193. * Set the value of an uniform to an array of int32 (stored as vec2)
  48194. * @param uniform defines the webGL uniform location where to store the value
  48195. * @param array defines the array of int32 to store
  48196. */
  48197. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48198. /**
  48199. * Set the value of an uniform to an array of int32 (stored as vec3)
  48200. * @param uniform defines the webGL uniform location where to store the value
  48201. * @param array defines the array of int32 to store
  48202. */
  48203. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48204. /**
  48205. * Set the value of an uniform to an array of int32 (stored as vec4)
  48206. * @param uniform defines the webGL uniform location where to store the value
  48207. * @param array defines the array of int32 to store
  48208. */
  48209. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48210. /**
  48211. * Set the value of an uniform to an array of float32
  48212. * @param uniform defines the webGL uniform location where to store the value
  48213. * @param array defines the array of float32 to store
  48214. */
  48215. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48216. /**
  48217. * Set the value of an uniform to an array of float32 (stored as vec2)
  48218. * @param uniform defines the webGL uniform location where to store the value
  48219. * @param array defines the array of float32 to store
  48220. */
  48221. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48222. /**
  48223. * Set the value of an uniform to an array of float32 (stored as vec3)
  48224. * @param uniform defines the webGL uniform location where to store the value
  48225. * @param array defines the array of float32 to store
  48226. */
  48227. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48228. /**
  48229. * Set the value of an uniform to an array of float32 (stored as vec4)
  48230. * @param uniform defines the webGL uniform location where to store the value
  48231. * @param array defines the array of float32 to store
  48232. */
  48233. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48234. /**
  48235. * Set the value of an uniform to an array of number
  48236. * @param uniform defines the webGL uniform location where to store the value
  48237. * @param array defines the array of number to store
  48238. */
  48239. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48240. /**
  48241. * Set the value of an uniform to an array of number (stored as vec2)
  48242. * @param uniform defines the webGL uniform location where to store the value
  48243. * @param array defines the array of number to store
  48244. */
  48245. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48246. /**
  48247. * Set the value of an uniform to an array of number (stored as vec3)
  48248. * @param uniform defines the webGL uniform location where to store the value
  48249. * @param array defines the array of number to store
  48250. */
  48251. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48252. /**
  48253. * Set the value of an uniform to an array of number (stored as vec4)
  48254. * @param uniform defines the webGL uniform location where to store the value
  48255. * @param array defines the array of number to store
  48256. */
  48257. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48258. /**
  48259. * Set the value of an uniform to an array of float32 (stored as matrices)
  48260. * @param uniform defines the webGL uniform location where to store the value
  48261. * @param matrices defines the array of float32 to store
  48262. */
  48263. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48264. /**
  48265. * Set the value of an uniform to a matrix (3x3)
  48266. * @param uniform defines the webGL uniform location where to store the value
  48267. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48268. */
  48269. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48270. /**
  48271. * Set the value of an uniform to a matrix (2x2)
  48272. * @param uniform defines the webGL uniform location where to store the value
  48273. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48274. */
  48275. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48276. /**
  48277. * Set the value of an uniform to a number (float)
  48278. * @param uniform defines the webGL uniform location where to store the value
  48279. * @param value defines the float number to store
  48280. */
  48281. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48282. /**
  48283. * Set the value of an uniform to a vec2
  48284. * @param uniform defines the webGL uniform location where to store the value
  48285. * @param x defines the 1st component of the value
  48286. * @param y defines the 2nd component of the value
  48287. */
  48288. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48289. /**
  48290. * Set the value of an uniform to a vec3
  48291. * @param uniform defines the webGL uniform location where to store the value
  48292. * @param x defines the 1st component of the value
  48293. * @param y defines the 2nd component of the value
  48294. * @param z defines the 3rd component of the value
  48295. */
  48296. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48297. /**
  48298. * Set the value of an uniform to a boolean
  48299. * @param uniform defines the webGL uniform location where to store the value
  48300. * @param bool defines the boolean to store
  48301. */
  48302. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48303. /**
  48304. * Set the value of an uniform to a vec4
  48305. * @param uniform defines the webGL uniform location where to store the value
  48306. * @param x defines the 1st component of the value
  48307. * @param y defines the 2nd component of the value
  48308. * @param z defines the 3rd component of the value
  48309. * @param w defines the 4th component of the value
  48310. */
  48311. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48312. /**
  48313. * Sets the current alpha mode
  48314. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48315. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48316. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48317. */
  48318. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48319. /**
  48320. * Bind webGl buffers directly to the webGL context
  48321. * @param vertexBuffers defines the vertex buffer to bind
  48322. * @param indexBuffer defines the index buffer to bind
  48323. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48324. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48325. * @param effect defines the effect associated with the vertex buffer
  48326. */
  48327. bindBuffers(vertexBuffers: {
  48328. [key: string]: VertexBuffer;
  48329. }, indexBuffer: DataBuffer, effect: Effect): void;
  48330. /**
  48331. * Force the entire cache to be cleared
  48332. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48333. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48334. */
  48335. wipeCaches(bruteForce?: boolean): void;
  48336. /**
  48337. * Send a draw order
  48338. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48339. * @param indexStart defines the starting index
  48340. * @param indexCount defines the number of index to draw
  48341. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48342. */
  48343. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48344. /**
  48345. * Draw a list of indexed primitives
  48346. * @param fillMode defines the primitive to use
  48347. * @param indexStart defines the starting index
  48348. * @param indexCount defines the number of index to draw
  48349. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48350. */
  48351. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48352. /**
  48353. * Draw a list of unindexed primitives
  48354. * @param fillMode defines the primitive to use
  48355. * @param verticesStart defines the index of first vertex to draw
  48356. * @param verticesCount defines the count of vertices to draw
  48357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48358. */
  48359. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48360. /** @hidden */
  48361. _createTexture(): WebGLTexture;
  48362. /** @hidden */
  48363. _releaseTexture(texture: InternalTexture): void;
  48364. /**
  48365. * Usually called from Texture.ts.
  48366. * Passed information to create a WebGLTexture
  48367. * @param urlArg defines a value which contains one of the following:
  48368. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48369. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48370. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48371. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48372. * @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)
  48373. * @param scene needed for loading to the correct scene
  48374. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48375. * @param onLoad optional callback to be called upon successful completion
  48376. * @param onError optional callback to be called upon failure
  48377. * @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
  48378. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48379. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48380. * @param forcedExtension defines the extension to use to pick the right loader
  48381. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48382. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48383. */
  48384. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  48385. /**
  48386. * Creates a new render target texture
  48387. * @param size defines the size of the texture
  48388. * @param options defines the options used to create the texture
  48389. * @returns a new render target texture stored in an InternalTexture
  48390. */
  48391. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48392. /**
  48393. * Update the sampling mode of a given texture
  48394. * @param samplingMode defines the required sampling mode
  48395. * @param texture defines the texture to update
  48396. */
  48397. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48398. /**
  48399. * Binds the frame buffer to the specified texture.
  48400. * @param texture The texture to render to or null for the default canvas
  48401. * @param faceIndex The face of the texture to render to in case of cube texture
  48402. * @param requiredWidth The width of the target to render to
  48403. * @param requiredHeight The height of the target to render to
  48404. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48405. * @param lodLevel defines le lod level to bind to the frame buffer
  48406. */
  48407. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48408. /**
  48409. * Unbind the current render target texture from the webGL context
  48410. * @param texture defines the render target texture to unbind
  48411. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48412. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48413. */
  48414. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48415. /**
  48416. * Creates a dynamic vertex buffer
  48417. * @param vertices the data for the dynamic vertex buffer
  48418. * @returns the new WebGL dynamic buffer
  48419. */
  48420. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48421. /**
  48422. * Update the content of a dynamic texture
  48423. * @param texture defines the texture to update
  48424. * @param canvas defines the canvas containing the source
  48425. * @param invertY defines if data must be stored with Y axis inverted
  48426. * @param premulAlpha defines if alpha is stored as premultiplied
  48427. * @param format defines the format of the data
  48428. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48429. */
  48430. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48431. /**
  48432. * Gets a boolean indicating if all created effects are ready
  48433. * @returns true if all effects are ready
  48434. */
  48435. areAllEffectsReady(): boolean;
  48436. /**
  48437. * @hidden
  48438. * Get the current error code of the webGL context
  48439. * @returns the error code
  48440. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48441. */
  48442. getError(): number;
  48443. /** @hidden */
  48444. _getUnpackAlignement(): number;
  48445. /** @hidden */
  48446. _unpackFlipY(value: boolean): void;
  48447. /**
  48448. * Update a dynamic index buffer
  48449. * @param indexBuffer defines the target index buffer
  48450. * @param indices defines the data to update
  48451. * @param offset defines the offset in the target index buffer where update should start
  48452. */
  48453. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48454. /**
  48455. * Updates a dynamic vertex buffer.
  48456. * @param vertexBuffer the vertex buffer to update
  48457. * @param vertices the data used to update the vertex buffer
  48458. * @param byteOffset the byte offset of the data (optional)
  48459. * @param byteLength the byte length of the data (optional)
  48460. */
  48461. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48462. /** @hidden */
  48463. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48464. /** @hidden */
  48465. _bindTexture(channel: number, texture: InternalTexture): void;
  48466. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48467. /**
  48468. * 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
  48469. */
  48470. releaseEffects(): void;
  48471. displayLoadingUI(): void;
  48472. hideLoadingUI(): void;
  48473. /** @hidden */
  48474. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48475. /** @hidden */
  48476. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48477. /** @hidden */
  48478. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48479. /** @hidden */
  48480. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48481. }
  48482. }
  48483. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48484. import { Nullable, int } from "babylonjs/types";
  48485. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48486. /** @hidden */
  48487. export class _OcclusionDataStorage {
  48488. /** @hidden */
  48489. occlusionInternalRetryCounter: number;
  48490. /** @hidden */
  48491. isOcclusionQueryInProgress: boolean;
  48492. /** @hidden */
  48493. isOccluded: boolean;
  48494. /** @hidden */
  48495. occlusionRetryCount: number;
  48496. /** @hidden */
  48497. occlusionType: number;
  48498. /** @hidden */
  48499. occlusionQueryAlgorithmType: number;
  48500. }
  48501. module "babylonjs/Engines/engine" {
  48502. interface Engine {
  48503. /**
  48504. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48505. * @return the new query
  48506. */
  48507. createQuery(): WebGLQuery;
  48508. /**
  48509. * Delete and release a webGL query
  48510. * @param query defines the query to delete
  48511. * @return the current engine
  48512. */
  48513. deleteQuery(query: WebGLQuery): Engine;
  48514. /**
  48515. * Check if a given query has resolved and got its value
  48516. * @param query defines the query to check
  48517. * @returns true if the query got its value
  48518. */
  48519. isQueryResultAvailable(query: WebGLQuery): boolean;
  48520. /**
  48521. * Gets the value of a given query
  48522. * @param query defines the query to check
  48523. * @returns the value of the query
  48524. */
  48525. getQueryResult(query: WebGLQuery): number;
  48526. /**
  48527. * Initiates an occlusion query
  48528. * @param algorithmType defines the algorithm to use
  48529. * @param query defines the query to use
  48530. * @returns the current engine
  48531. * @see http://doc.babylonjs.com/features/occlusionquery
  48532. */
  48533. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48534. /**
  48535. * Ends an occlusion query
  48536. * @see http://doc.babylonjs.com/features/occlusionquery
  48537. * @param algorithmType defines the algorithm to use
  48538. * @returns the current engine
  48539. */
  48540. endOcclusionQuery(algorithmType: number): Engine;
  48541. /**
  48542. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48543. * Please note that only one query can be issued at a time
  48544. * @returns a time token used to track the time span
  48545. */
  48546. startTimeQuery(): Nullable<_TimeToken>;
  48547. /**
  48548. * Ends a time query
  48549. * @param token defines the token used to measure the time span
  48550. * @returns the time spent (in ns)
  48551. */
  48552. endTimeQuery(token: _TimeToken): int;
  48553. /** @hidden */
  48554. _currentNonTimestampToken: Nullable<_TimeToken>;
  48555. /** @hidden */
  48556. _createTimeQuery(): WebGLQuery;
  48557. /** @hidden */
  48558. _deleteTimeQuery(query: WebGLQuery): void;
  48559. /** @hidden */
  48560. _getGlAlgorithmType(algorithmType: number): number;
  48561. /** @hidden */
  48562. _getTimeQueryResult(query: WebGLQuery): any;
  48563. /** @hidden */
  48564. _getTimeQueryAvailability(query: WebGLQuery): any;
  48565. }
  48566. }
  48567. module "babylonjs/Meshes/abstractMesh" {
  48568. interface AbstractMesh {
  48569. /**
  48570. * Backing filed
  48571. * @hidden
  48572. */
  48573. __occlusionDataStorage: _OcclusionDataStorage;
  48574. /**
  48575. * Access property
  48576. * @hidden
  48577. */
  48578. _occlusionDataStorage: _OcclusionDataStorage;
  48579. /**
  48580. * 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.
  48581. * The default value is -1 which means don't break the query and wait till the result
  48582. * @see http://doc.babylonjs.com/features/occlusionquery
  48583. */
  48584. occlusionRetryCount: number;
  48585. /**
  48586. * 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:
  48587. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48588. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48589. * * 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.
  48590. * @see http://doc.babylonjs.com/features/occlusionquery
  48591. */
  48592. occlusionType: number;
  48593. /**
  48594. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48595. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48596. * * 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.
  48597. * @see http://doc.babylonjs.com/features/occlusionquery
  48598. */
  48599. occlusionQueryAlgorithmType: number;
  48600. /**
  48601. * 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
  48602. * @see http://doc.babylonjs.com/features/occlusionquery
  48603. */
  48604. isOccluded: boolean;
  48605. /**
  48606. * Flag to check the progress status of the query
  48607. * @see http://doc.babylonjs.com/features/occlusionquery
  48608. */
  48609. isOcclusionQueryInProgress: boolean;
  48610. }
  48611. }
  48612. }
  48613. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48614. import { Nullable } from "babylonjs/types";
  48615. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48616. /** @hidden */
  48617. export var _forceTransformFeedbackToBundle: boolean;
  48618. module "babylonjs/Engines/engine" {
  48619. interface Engine {
  48620. /**
  48621. * Creates a webGL transform feedback object
  48622. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48623. * @returns the webGL transform feedback object
  48624. */
  48625. createTransformFeedback(): WebGLTransformFeedback;
  48626. /**
  48627. * Delete a webGL transform feedback object
  48628. * @param value defines the webGL transform feedback object to delete
  48629. */
  48630. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48631. /**
  48632. * Bind a webGL transform feedback object to the webgl context
  48633. * @param value defines the webGL transform feedback object to bind
  48634. */
  48635. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48636. /**
  48637. * Begins a transform feedback operation
  48638. * @param usePoints defines if points or triangles must be used
  48639. */
  48640. beginTransformFeedback(usePoints: boolean): void;
  48641. /**
  48642. * Ends a transform feedback operation
  48643. */
  48644. endTransformFeedback(): void;
  48645. /**
  48646. * Specify the varyings to use with transform feedback
  48647. * @param program defines the associated webGL program
  48648. * @param value defines the list of strings representing the varying names
  48649. */
  48650. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48651. /**
  48652. * Bind a webGL buffer for a transform feedback operation
  48653. * @param value defines the webGL buffer to bind
  48654. */
  48655. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48656. }
  48657. }
  48658. }
  48659. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48660. import { Scene } from "babylonjs/scene";
  48661. import { Engine } from "babylonjs/Engines/engine";
  48662. import { Texture } from "babylonjs/Materials/Textures/texture";
  48663. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48664. import "babylonjs/Engines/Extensions/engine.multiRender";
  48665. /**
  48666. * Creation options of the multi render target texture.
  48667. */
  48668. export interface IMultiRenderTargetOptions {
  48669. /**
  48670. * Define if the texture needs to create mip maps after render.
  48671. */
  48672. generateMipMaps?: boolean;
  48673. /**
  48674. * Define the types of all the draw buffers we want to create
  48675. */
  48676. types?: number[];
  48677. /**
  48678. * Define the sampling modes of all the draw buffers we want to create
  48679. */
  48680. samplingModes?: number[];
  48681. /**
  48682. * Define if a depth buffer is required
  48683. */
  48684. generateDepthBuffer?: boolean;
  48685. /**
  48686. * Define if a stencil buffer is required
  48687. */
  48688. generateStencilBuffer?: boolean;
  48689. /**
  48690. * Define if a depth texture is required instead of a depth buffer
  48691. */
  48692. generateDepthTexture?: boolean;
  48693. /**
  48694. * Define the number of desired draw buffers
  48695. */
  48696. textureCount?: number;
  48697. /**
  48698. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48699. */
  48700. doNotChangeAspectRatio?: boolean;
  48701. /**
  48702. * Define the default type of the buffers we are creating
  48703. */
  48704. defaultType?: number;
  48705. }
  48706. /**
  48707. * A multi render target, like a render target provides the ability to render to a texture.
  48708. * Unlike the render target, it can render to several draw buffers in one draw.
  48709. * This is specially interesting in deferred rendering or for any effects requiring more than
  48710. * just one color from a single pass.
  48711. */
  48712. export class MultiRenderTarget extends RenderTargetTexture {
  48713. private _internalTextures;
  48714. private _textures;
  48715. private _multiRenderTargetOptions;
  48716. /**
  48717. * Get if draw buffers are currently supported by the used hardware and browser.
  48718. */
  48719. get isSupported(): boolean;
  48720. /**
  48721. * Get the list of textures generated by the multi render target.
  48722. */
  48723. get textures(): Texture[];
  48724. /**
  48725. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48726. */
  48727. get depthTexture(): Texture;
  48728. /**
  48729. * Set the wrapping mode on U of all the textures we are rendering to.
  48730. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48731. */
  48732. set wrapU(wrap: number);
  48733. /**
  48734. * Set the wrapping mode on V of all the textures we are rendering to.
  48735. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48736. */
  48737. set wrapV(wrap: number);
  48738. /**
  48739. * Instantiate a new multi render target texture.
  48740. * A multi render target, like a render target provides the ability to render to a texture.
  48741. * Unlike the render target, it can render to several draw buffers in one draw.
  48742. * This is specially interesting in deferred rendering or for any effects requiring more than
  48743. * just one color from a single pass.
  48744. * @param name Define the name of the texture
  48745. * @param size Define the size of the buffers to render to
  48746. * @param count Define the number of target we are rendering into
  48747. * @param scene Define the scene the texture belongs to
  48748. * @param options Define the options used to create the multi render target
  48749. */
  48750. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48751. /** @hidden */
  48752. _rebuild(): void;
  48753. private _createInternalTextures;
  48754. private _createTextures;
  48755. /**
  48756. * Define the number of samples used if MSAA is enabled.
  48757. */
  48758. get samples(): number;
  48759. set samples(value: number);
  48760. /**
  48761. * Resize all the textures in the multi render target.
  48762. * Be carrefull as it will recreate all the data in the new texture.
  48763. * @param size Define the new size
  48764. */
  48765. resize(size: any): void;
  48766. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48767. /**
  48768. * Dispose the render targets and their associated resources
  48769. */
  48770. dispose(): void;
  48771. /**
  48772. * Release all the underlying texture used as draw buffers.
  48773. */
  48774. releaseInternalTextures(): void;
  48775. }
  48776. }
  48777. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48778. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48779. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48780. import { Nullable } from "babylonjs/types";
  48781. module "babylonjs/Engines/thinEngine" {
  48782. interface ThinEngine {
  48783. /**
  48784. * Unbind a list of render target textures from the webGL context
  48785. * This is used only when drawBuffer extension or webGL2 are active
  48786. * @param textures defines the render target textures to unbind
  48787. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48788. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48789. */
  48790. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48791. /**
  48792. * Create a multi render target texture
  48793. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48794. * @param size defines the size of the texture
  48795. * @param options defines the creation options
  48796. * @returns the cube texture as an InternalTexture
  48797. */
  48798. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48799. /**
  48800. * Update the sample count for a given multiple render target texture
  48801. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48802. * @param textures defines the textures to update
  48803. * @param samples defines the sample count to set
  48804. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48805. */
  48806. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48807. }
  48808. }
  48809. }
  48810. declare module "babylonjs/Engines/Extensions/engine.views" {
  48811. import { Camera } from "babylonjs/Cameras/camera";
  48812. import { Nullable } from "babylonjs/types";
  48813. /**
  48814. * Class used to define an additional view for the engine
  48815. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48816. */
  48817. export class EngineView {
  48818. /** Defines the canvas where to render the view */
  48819. target: HTMLCanvasElement;
  48820. /** Defines an optional camera used to render the view (will use active camera else) */
  48821. camera?: Camera;
  48822. }
  48823. module "babylonjs/Engines/engine" {
  48824. interface Engine {
  48825. /**
  48826. * Gets or sets the HTML element to use for attaching events
  48827. */
  48828. inputElement: Nullable<HTMLElement>;
  48829. /**
  48830. * Gets the current engine view
  48831. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48832. */
  48833. activeView: Nullable<EngineView>;
  48834. /** Gets or sets the list of views */
  48835. views: EngineView[];
  48836. /**
  48837. * Register a new child canvas
  48838. * @param canvas defines the canvas to register
  48839. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48840. * @returns the associated view
  48841. */
  48842. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48843. /**
  48844. * Remove a registered child canvas
  48845. * @param canvas defines the canvas to remove
  48846. * @returns the current engine
  48847. */
  48848. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48849. }
  48850. }
  48851. }
  48852. declare module "babylonjs/Engines/Extensions/index" {
  48853. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48854. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48855. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48856. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48857. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48858. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48859. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48860. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48861. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48862. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48863. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48864. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48865. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48866. export * from "babylonjs/Engines/Extensions/engine.views";
  48867. }
  48868. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48869. import { Nullable } from "babylonjs/types";
  48870. /**
  48871. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48872. */
  48873. export interface CubeMapInfo {
  48874. /**
  48875. * The pixel array for the front face.
  48876. * This is stored in format, left to right, up to down format.
  48877. */
  48878. front: Nullable<ArrayBufferView>;
  48879. /**
  48880. * The pixel array for the back face.
  48881. * This is stored in format, left to right, up to down format.
  48882. */
  48883. back: Nullable<ArrayBufferView>;
  48884. /**
  48885. * The pixel array for the left face.
  48886. * This is stored in format, left to right, up to down format.
  48887. */
  48888. left: Nullable<ArrayBufferView>;
  48889. /**
  48890. * The pixel array for the right face.
  48891. * This is stored in format, left to right, up to down format.
  48892. */
  48893. right: Nullable<ArrayBufferView>;
  48894. /**
  48895. * The pixel array for the up face.
  48896. * This is stored in format, left to right, up to down format.
  48897. */
  48898. up: Nullable<ArrayBufferView>;
  48899. /**
  48900. * The pixel array for the down face.
  48901. * This is stored in format, left to right, up to down format.
  48902. */
  48903. down: Nullable<ArrayBufferView>;
  48904. /**
  48905. * The size of the cubemap stored.
  48906. *
  48907. * Each faces will be size * size pixels.
  48908. */
  48909. size: number;
  48910. /**
  48911. * The format of the texture.
  48912. *
  48913. * RGBA, RGB.
  48914. */
  48915. format: number;
  48916. /**
  48917. * The type of the texture data.
  48918. *
  48919. * UNSIGNED_INT, FLOAT.
  48920. */
  48921. type: number;
  48922. /**
  48923. * Specifies whether the texture is in gamma space.
  48924. */
  48925. gammaSpace: boolean;
  48926. }
  48927. /**
  48928. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48929. */
  48930. export class PanoramaToCubeMapTools {
  48931. private static FACE_FRONT;
  48932. private static FACE_BACK;
  48933. private static FACE_RIGHT;
  48934. private static FACE_LEFT;
  48935. private static FACE_DOWN;
  48936. private static FACE_UP;
  48937. /**
  48938. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48939. *
  48940. * @param float32Array The source data.
  48941. * @param inputWidth The width of the input panorama.
  48942. * @param inputHeight The height of the input panorama.
  48943. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48944. * @return The cubemap data
  48945. */
  48946. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48947. private static CreateCubemapTexture;
  48948. private static CalcProjectionSpherical;
  48949. }
  48950. }
  48951. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48952. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48954. import { Nullable } from "babylonjs/types";
  48955. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48956. /**
  48957. * Helper class dealing with the extraction of spherical polynomial dataArray
  48958. * from a cube map.
  48959. */
  48960. export class CubeMapToSphericalPolynomialTools {
  48961. private static FileFaces;
  48962. /**
  48963. * Converts a texture to the according Spherical Polynomial data.
  48964. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48965. *
  48966. * @param texture The texture to extract the information from.
  48967. * @return The Spherical Polynomial data.
  48968. */
  48969. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48970. /**
  48971. * Converts a cubemap to the according Spherical Polynomial data.
  48972. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48973. *
  48974. * @param cubeInfo The Cube map to extract the information from.
  48975. * @return The Spherical Polynomial data.
  48976. */
  48977. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48978. }
  48979. }
  48980. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48981. import { Nullable } from "babylonjs/types";
  48982. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48983. module "babylonjs/Materials/Textures/baseTexture" {
  48984. interface BaseTexture {
  48985. /**
  48986. * Get the polynomial representation of the texture data.
  48987. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48988. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48989. */
  48990. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48991. }
  48992. }
  48993. }
  48994. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48995. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48996. /** @hidden */
  48997. export var rgbdEncodePixelShader: {
  48998. name: string;
  48999. shader: string;
  49000. };
  49001. }
  49002. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49003. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49004. /** @hidden */
  49005. export var rgbdDecodePixelShader: {
  49006. name: string;
  49007. shader: string;
  49008. };
  49009. }
  49010. declare module "babylonjs/Misc/environmentTextureTools" {
  49011. import { Nullable } from "babylonjs/types";
  49012. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49013. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49014. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49015. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49016. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49017. import "babylonjs/Shaders/rgbdEncode.fragment";
  49018. import "babylonjs/Shaders/rgbdDecode.fragment";
  49019. /**
  49020. * Raw texture data and descriptor sufficient for WebGL texture upload
  49021. */
  49022. export interface EnvironmentTextureInfo {
  49023. /**
  49024. * Version of the environment map
  49025. */
  49026. version: number;
  49027. /**
  49028. * Width of image
  49029. */
  49030. width: number;
  49031. /**
  49032. * Irradiance information stored in the file.
  49033. */
  49034. irradiance: any;
  49035. /**
  49036. * Specular information stored in the file.
  49037. */
  49038. specular: any;
  49039. }
  49040. /**
  49041. * Defines One Image in the file. It requires only the position in the file
  49042. * as well as the length.
  49043. */
  49044. interface BufferImageData {
  49045. /**
  49046. * Length of the image data.
  49047. */
  49048. length: number;
  49049. /**
  49050. * Position of the data from the null terminator delimiting the end of the JSON.
  49051. */
  49052. position: number;
  49053. }
  49054. /**
  49055. * Defines the specular data enclosed in the file.
  49056. * This corresponds to the version 1 of the data.
  49057. */
  49058. export interface EnvironmentTextureSpecularInfoV1 {
  49059. /**
  49060. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49061. */
  49062. specularDataPosition?: number;
  49063. /**
  49064. * This contains all the images data needed to reconstruct the cubemap.
  49065. */
  49066. mipmaps: Array<BufferImageData>;
  49067. /**
  49068. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49069. */
  49070. lodGenerationScale: number;
  49071. }
  49072. /**
  49073. * Sets of helpers addressing the serialization and deserialization of environment texture
  49074. * stored in a BabylonJS env file.
  49075. * Those files are usually stored as .env files.
  49076. */
  49077. export class EnvironmentTextureTools {
  49078. /**
  49079. * Magic number identifying the env file.
  49080. */
  49081. private static _MagicBytes;
  49082. /**
  49083. * Gets the environment info from an env file.
  49084. * @param data The array buffer containing the .env bytes.
  49085. * @returns the environment file info (the json header) if successfully parsed.
  49086. */
  49087. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49088. /**
  49089. * Creates an environment texture from a loaded cube texture.
  49090. * @param texture defines the cube texture to convert in env file
  49091. * @return a promise containing the environment data if succesfull.
  49092. */
  49093. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49094. /**
  49095. * Creates a JSON representation of the spherical data.
  49096. * @param texture defines the texture containing the polynomials
  49097. * @return the JSON representation of the spherical info
  49098. */
  49099. private static _CreateEnvTextureIrradiance;
  49100. /**
  49101. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49102. * @param data the image data
  49103. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49104. * @return the views described by info providing access to the underlying buffer
  49105. */
  49106. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49107. /**
  49108. * Uploads the texture info contained in the env file to the GPU.
  49109. * @param texture defines the internal texture to upload to
  49110. * @param data defines the data to load
  49111. * @param info defines the texture info retrieved through the GetEnvInfo method
  49112. * @returns a promise
  49113. */
  49114. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49115. private static _OnImageReadyAsync;
  49116. /**
  49117. * Uploads the levels of image data to the GPU.
  49118. * @param texture defines the internal texture to upload to
  49119. * @param imageData defines the array buffer views of image data [mipmap][face]
  49120. * @returns a promise
  49121. */
  49122. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49123. /**
  49124. * Uploads spherical polynomials information to the texture.
  49125. * @param texture defines the texture we are trying to upload the information to
  49126. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49127. */
  49128. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49129. /** @hidden */
  49130. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49131. }
  49132. }
  49133. declare module "babylonjs/Maths/math.vertexFormat" {
  49134. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49135. /**
  49136. * Contains position and normal vectors for a vertex
  49137. */
  49138. export class PositionNormalVertex {
  49139. /** the position of the vertex (defaut: 0,0,0) */
  49140. position: Vector3;
  49141. /** the normal of the vertex (defaut: 0,1,0) */
  49142. normal: Vector3;
  49143. /**
  49144. * Creates a PositionNormalVertex
  49145. * @param position the position of the vertex (defaut: 0,0,0)
  49146. * @param normal the normal of the vertex (defaut: 0,1,0)
  49147. */
  49148. constructor(
  49149. /** the position of the vertex (defaut: 0,0,0) */
  49150. position?: Vector3,
  49151. /** the normal of the vertex (defaut: 0,1,0) */
  49152. normal?: Vector3);
  49153. /**
  49154. * Clones the PositionNormalVertex
  49155. * @returns the cloned PositionNormalVertex
  49156. */
  49157. clone(): PositionNormalVertex;
  49158. }
  49159. /**
  49160. * Contains position, normal and uv vectors for a vertex
  49161. */
  49162. export class PositionNormalTextureVertex {
  49163. /** the position of the vertex (defaut: 0,0,0) */
  49164. position: Vector3;
  49165. /** the normal of the vertex (defaut: 0,1,0) */
  49166. normal: Vector3;
  49167. /** the uv of the vertex (default: 0,0) */
  49168. uv: Vector2;
  49169. /**
  49170. * Creates a PositionNormalTextureVertex
  49171. * @param position the position of the vertex (defaut: 0,0,0)
  49172. * @param normal the normal of the vertex (defaut: 0,1,0)
  49173. * @param uv the uv of the vertex (default: 0,0)
  49174. */
  49175. constructor(
  49176. /** the position of the vertex (defaut: 0,0,0) */
  49177. position?: Vector3,
  49178. /** the normal of the vertex (defaut: 0,1,0) */
  49179. normal?: Vector3,
  49180. /** the uv of the vertex (default: 0,0) */
  49181. uv?: Vector2);
  49182. /**
  49183. * Clones the PositionNormalTextureVertex
  49184. * @returns the cloned PositionNormalTextureVertex
  49185. */
  49186. clone(): PositionNormalTextureVertex;
  49187. }
  49188. }
  49189. declare module "babylonjs/Maths/math" {
  49190. export * from "babylonjs/Maths/math.axis";
  49191. export * from "babylonjs/Maths/math.color";
  49192. export * from "babylonjs/Maths/math.constants";
  49193. export * from "babylonjs/Maths/math.frustum";
  49194. export * from "babylonjs/Maths/math.path";
  49195. export * from "babylonjs/Maths/math.plane";
  49196. export * from "babylonjs/Maths/math.size";
  49197. export * from "babylonjs/Maths/math.vector";
  49198. export * from "babylonjs/Maths/math.vertexFormat";
  49199. export * from "babylonjs/Maths/math.viewport";
  49200. }
  49201. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49202. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49203. /** @hidden */
  49204. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49205. private _genericAttributeLocation;
  49206. private _varyingLocationCount;
  49207. private _varyingLocationMap;
  49208. private _replacements;
  49209. private _textureCount;
  49210. private _uniforms;
  49211. lineProcessor(line: string): string;
  49212. attributeProcessor(attribute: string): string;
  49213. varyingProcessor(varying: string, isFragment: boolean): string;
  49214. uniformProcessor(uniform: string): string;
  49215. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49216. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49217. }
  49218. }
  49219. declare module "babylonjs/Engines/nativeEngine" {
  49220. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49221. import { Engine } from "babylonjs/Engines/engine";
  49222. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49223. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49225. import { Effect } from "babylonjs/Materials/effect";
  49226. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49227. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49228. import { IColor4Like } from "babylonjs/Maths/math.like";
  49229. import { Scene } from "babylonjs/scene";
  49230. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49231. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49232. /**
  49233. * Container for accessors for natively-stored mesh data buffers.
  49234. */
  49235. class NativeDataBuffer extends DataBuffer {
  49236. /**
  49237. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49238. */
  49239. nativeIndexBuffer?: any;
  49240. /**
  49241. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49242. */
  49243. nativeVertexBuffer?: any;
  49244. }
  49245. /** @hidden */
  49246. class NativeTexture extends InternalTexture {
  49247. getInternalTexture(): InternalTexture;
  49248. getViewCount(): number;
  49249. }
  49250. /** @hidden */
  49251. export class NativeEngine extends Engine {
  49252. private readonly _native;
  49253. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49254. private readonly INVALID_HANDLE;
  49255. getHardwareScalingLevel(): number;
  49256. constructor();
  49257. /**
  49258. * Can be used to override the current requestAnimationFrame requester.
  49259. * @hidden
  49260. */
  49261. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49262. /**
  49263. * Override default engine behavior.
  49264. * @param color
  49265. * @param backBuffer
  49266. * @param depth
  49267. * @param stencil
  49268. */
  49269. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49270. /**
  49271. * Gets host document
  49272. * @returns the host document object
  49273. */
  49274. getHostDocument(): Nullable<Document>;
  49275. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49276. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49277. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49278. recordVertexArrayObject(vertexBuffers: {
  49279. [key: string]: VertexBuffer;
  49280. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49281. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49282. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49283. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49284. /**
  49285. * Draw a list of indexed primitives
  49286. * @param fillMode defines the primitive to use
  49287. * @param indexStart defines the starting index
  49288. * @param indexCount defines the number of index to draw
  49289. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49290. */
  49291. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49292. /**
  49293. * Draw a list of unindexed primitives
  49294. * @param fillMode defines the primitive to use
  49295. * @param verticesStart defines the index of first vertex to draw
  49296. * @param verticesCount defines the count of vertices to draw
  49297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49298. */
  49299. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49300. createPipelineContext(): IPipelineContext;
  49301. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49302. /** @hidden */
  49303. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49304. /** @hidden */
  49305. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49306. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49307. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49308. protected _setProgram(program: WebGLProgram): void;
  49309. _releaseEffect(effect: Effect): void;
  49310. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49311. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49312. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49313. bindSamplers(effect: Effect): void;
  49314. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49315. getRenderWidth(useScreen?: boolean): number;
  49316. getRenderHeight(useScreen?: boolean): number;
  49317. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49318. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49319. /**
  49320. * Set the z offset to apply to current rendering
  49321. * @param value defines the offset to apply
  49322. */
  49323. setZOffset(value: number): void;
  49324. /**
  49325. * Gets the current value of the zOffset
  49326. * @returns the current zOffset state
  49327. */
  49328. getZOffset(): number;
  49329. /**
  49330. * Enable or disable depth buffering
  49331. * @param enable defines the state to set
  49332. */
  49333. setDepthBuffer(enable: boolean): void;
  49334. /**
  49335. * Gets a boolean indicating if depth writing is enabled
  49336. * @returns the current depth writing state
  49337. */
  49338. getDepthWrite(): boolean;
  49339. /**
  49340. * Enable or disable depth writing
  49341. * @param enable defines the state to set
  49342. */
  49343. setDepthWrite(enable: boolean): void;
  49344. /**
  49345. * Enable or disable color writing
  49346. * @param enable defines the state to set
  49347. */
  49348. setColorWrite(enable: boolean): void;
  49349. /**
  49350. * Gets a boolean indicating if color writing is enabled
  49351. * @returns the current color writing state
  49352. */
  49353. getColorWrite(): boolean;
  49354. /**
  49355. * Sets alpha constants used by some alpha blending modes
  49356. * @param r defines the red component
  49357. * @param g defines the green component
  49358. * @param b defines the blue component
  49359. * @param a defines the alpha component
  49360. */
  49361. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49362. /**
  49363. * Sets the current alpha mode
  49364. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49365. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49366. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49367. */
  49368. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49369. /**
  49370. * Gets the current alpha mode
  49371. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49372. * @returns the current alpha mode
  49373. */
  49374. getAlphaMode(): number;
  49375. setInt(uniform: WebGLUniformLocation, int: number): void;
  49376. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49377. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49378. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49379. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49380. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49381. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49382. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49383. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49384. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49385. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49386. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49387. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49388. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49389. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49390. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49391. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49392. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49393. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49394. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49395. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49396. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49397. wipeCaches(bruteForce?: boolean): void;
  49398. _createTexture(): WebGLTexture;
  49399. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49400. /**
  49401. * Usually called from BABYLON.Texture.ts.
  49402. * Passed information to create a WebGLTexture
  49403. * @param urlArg defines a value which contains one of the following:
  49404. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49405. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49406. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49407. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49408. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49409. * @param scene needed for loading to the correct scene
  49410. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49411. * @param onLoad optional callback to be called upon successful completion
  49412. * @param onError optional callback to be called upon failure
  49413. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49414. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49415. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49416. * @param forcedExtension defines the extension to use to pick the right loader
  49417. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49418. */
  49419. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  49420. /**
  49421. * Creates a cube texture
  49422. * @param rootUrl defines the url where the files to load is located
  49423. * @param scene defines the current scene
  49424. * @param files defines the list of files to load (1 per face)
  49425. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49426. * @param onLoad defines an optional callback raised when the texture is loaded
  49427. * @param onError defines an optional callback raised if there is an issue to load the texture
  49428. * @param format defines the format of the data
  49429. * @param forcedExtension defines the extension to use to pick the right loader
  49430. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49431. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49432. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49433. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49434. * @returns the cube texture as an InternalTexture
  49435. */
  49436. 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;
  49437. private _getSamplingFilter;
  49438. private static _GetNativeTextureFormat;
  49439. createRenderTargetTexture(size: number | {
  49440. width: number;
  49441. height: number;
  49442. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49443. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49444. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49445. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49446. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49447. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49448. /**
  49449. * Updates a dynamic vertex buffer.
  49450. * @param vertexBuffer the vertex buffer to update
  49451. * @param data the data used to update the vertex buffer
  49452. * @param byteOffset the byte offset of the data (optional)
  49453. * @param byteLength the byte length of the data (optional)
  49454. */
  49455. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49456. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49457. private _updateAnisotropicLevel;
  49458. private _getAddressMode;
  49459. /** @hidden */
  49460. _bindTexture(channel: number, texture: InternalTexture): void;
  49461. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49462. releaseEffects(): void;
  49463. /** @hidden */
  49464. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49465. /** @hidden */
  49466. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49467. /** @hidden */
  49468. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49469. /** @hidden */
  49470. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49471. }
  49472. }
  49473. declare module "babylonjs/Engines/index" {
  49474. export * from "babylonjs/Engines/constants";
  49475. export * from "babylonjs/Engines/engineCapabilities";
  49476. export * from "babylonjs/Engines/instancingAttributeInfo";
  49477. export * from "babylonjs/Engines/thinEngine";
  49478. export * from "babylonjs/Engines/engine";
  49479. export * from "babylonjs/Engines/engineStore";
  49480. export * from "babylonjs/Engines/nullEngine";
  49481. export * from "babylonjs/Engines/Extensions/index";
  49482. export * from "babylonjs/Engines/IPipelineContext";
  49483. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49484. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49485. export * from "babylonjs/Engines/nativeEngine";
  49486. }
  49487. declare module "babylonjs/Events/clipboardEvents" {
  49488. /**
  49489. * Gather the list of clipboard event types as constants.
  49490. */
  49491. export class ClipboardEventTypes {
  49492. /**
  49493. * The clipboard event is fired when a copy command is active (pressed).
  49494. */
  49495. static readonly COPY: number;
  49496. /**
  49497. * The clipboard event is fired when a cut command is active (pressed).
  49498. */
  49499. static readonly CUT: number;
  49500. /**
  49501. * The clipboard event is fired when a paste command is active (pressed).
  49502. */
  49503. static readonly PASTE: number;
  49504. }
  49505. /**
  49506. * This class is used to store clipboard related info for the onClipboardObservable event.
  49507. */
  49508. export class ClipboardInfo {
  49509. /**
  49510. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49511. */
  49512. type: number;
  49513. /**
  49514. * Defines the related dom event
  49515. */
  49516. event: ClipboardEvent;
  49517. /**
  49518. *Creates an instance of ClipboardInfo.
  49519. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49520. * @param event Defines the related dom event
  49521. */
  49522. constructor(
  49523. /**
  49524. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49525. */
  49526. type: number,
  49527. /**
  49528. * Defines the related dom event
  49529. */
  49530. event: ClipboardEvent);
  49531. /**
  49532. * Get the clipboard event's type from the keycode.
  49533. * @param keyCode Defines the keyCode for the current keyboard event.
  49534. * @return {number}
  49535. */
  49536. static GetTypeFromCharacter(keyCode: number): number;
  49537. }
  49538. }
  49539. declare module "babylonjs/Events/index" {
  49540. export * from "babylonjs/Events/keyboardEvents";
  49541. export * from "babylonjs/Events/pointerEvents";
  49542. export * from "babylonjs/Events/clipboardEvents";
  49543. }
  49544. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49545. import { Scene } from "babylonjs/scene";
  49546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49547. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49548. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49549. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49550. /**
  49551. * Google Daydream controller
  49552. */
  49553. export class DaydreamController extends WebVRController {
  49554. /**
  49555. * Base Url for the controller model.
  49556. */
  49557. static MODEL_BASE_URL: string;
  49558. /**
  49559. * File name for the controller model.
  49560. */
  49561. static MODEL_FILENAME: string;
  49562. /**
  49563. * Gamepad Id prefix used to identify Daydream Controller.
  49564. */
  49565. static readonly GAMEPAD_ID_PREFIX: string;
  49566. /**
  49567. * Creates a new DaydreamController from a gamepad
  49568. * @param vrGamepad the gamepad that the controller should be created from
  49569. */
  49570. constructor(vrGamepad: any);
  49571. /**
  49572. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49573. * @param scene scene in which to add meshes
  49574. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49575. */
  49576. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49577. /**
  49578. * Called once for each button that changed state since the last frame
  49579. * @param buttonIdx Which button index changed
  49580. * @param state New state of the button
  49581. * @param changes Which properties on the state changed since last frame
  49582. */
  49583. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49584. }
  49585. }
  49586. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49587. import { Scene } from "babylonjs/scene";
  49588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49589. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49590. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49591. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49592. /**
  49593. * Gear VR Controller
  49594. */
  49595. export class GearVRController extends WebVRController {
  49596. /**
  49597. * Base Url for the controller model.
  49598. */
  49599. static MODEL_BASE_URL: string;
  49600. /**
  49601. * File name for the controller model.
  49602. */
  49603. static MODEL_FILENAME: string;
  49604. /**
  49605. * Gamepad Id prefix used to identify this controller.
  49606. */
  49607. static readonly GAMEPAD_ID_PREFIX: string;
  49608. private readonly _buttonIndexToObservableNameMap;
  49609. /**
  49610. * Creates a new GearVRController from a gamepad
  49611. * @param vrGamepad the gamepad that the controller should be created from
  49612. */
  49613. constructor(vrGamepad: any);
  49614. /**
  49615. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49616. * @param scene scene in which to add meshes
  49617. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49618. */
  49619. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49620. /**
  49621. * Called once for each button that changed state since the last frame
  49622. * @param buttonIdx Which button index changed
  49623. * @param state New state of the button
  49624. * @param changes Which properties on the state changed since last frame
  49625. */
  49626. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49627. }
  49628. }
  49629. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49630. import { Scene } from "babylonjs/scene";
  49631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49632. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49633. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49634. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49635. /**
  49636. * Generic Controller
  49637. */
  49638. export class GenericController extends WebVRController {
  49639. /**
  49640. * Base Url for the controller model.
  49641. */
  49642. static readonly MODEL_BASE_URL: string;
  49643. /**
  49644. * File name for the controller model.
  49645. */
  49646. static readonly MODEL_FILENAME: string;
  49647. /**
  49648. * Creates a new GenericController from a gamepad
  49649. * @param vrGamepad the gamepad that the controller should be created from
  49650. */
  49651. constructor(vrGamepad: any);
  49652. /**
  49653. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49654. * @param scene scene in which to add meshes
  49655. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49656. */
  49657. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49658. /**
  49659. * Called once for each button that changed state since the last frame
  49660. * @param buttonIdx Which button index changed
  49661. * @param state New state of the button
  49662. * @param changes Which properties on the state changed since last frame
  49663. */
  49664. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49665. }
  49666. }
  49667. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49668. import { Observable } from "babylonjs/Misc/observable";
  49669. import { Scene } from "babylonjs/scene";
  49670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49671. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49672. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49673. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49674. /**
  49675. * Oculus Touch Controller
  49676. */
  49677. export class OculusTouchController extends WebVRController {
  49678. /**
  49679. * Base Url for the controller model.
  49680. */
  49681. static MODEL_BASE_URL: string;
  49682. /**
  49683. * File name for the left controller model.
  49684. */
  49685. static MODEL_LEFT_FILENAME: string;
  49686. /**
  49687. * File name for the right controller model.
  49688. */
  49689. static MODEL_RIGHT_FILENAME: string;
  49690. /**
  49691. * Base Url for the Quest controller model.
  49692. */
  49693. static QUEST_MODEL_BASE_URL: string;
  49694. /**
  49695. * @hidden
  49696. * If the controllers are running on a device that needs the updated Quest controller models
  49697. */
  49698. static _IsQuest: boolean;
  49699. /**
  49700. * Fired when the secondary trigger on this controller is modified
  49701. */
  49702. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49703. /**
  49704. * Fired when the thumb rest on this controller is modified
  49705. */
  49706. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49707. /**
  49708. * Creates a new OculusTouchController from a gamepad
  49709. * @param vrGamepad the gamepad that the controller should be created from
  49710. */
  49711. constructor(vrGamepad: any);
  49712. /**
  49713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49714. * @param scene scene in which to add meshes
  49715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49716. */
  49717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49718. /**
  49719. * Fired when the A button on this controller is modified
  49720. */
  49721. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49722. /**
  49723. * Fired when the B button on this controller is modified
  49724. */
  49725. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49726. /**
  49727. * Fired when the X button on this controller is modified
  49728. */
  49729. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49730. /**
  49731. * Fired when the Y button on this controller is modified
  49732. */
  49733. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49734. /**
  49735. * Called once for each button that changed state since the last frame
  49736. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49737. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49738. * 2) secondary trigger (same)
  49739. * 3) A (right) X (left), touch, pressed = value
  49740. * 4) B / Y
  49741. * 5) thumb rest
  49742. * @param buttonIdx Which button index changed
  49743. * @param state New state of the button
  49744. * @param changes Which properties on the state changed since last frame
  49745. */
  49746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49747. }
  49748. }
  49749. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49750. import { Scene } from "babylonjs/scene";
  49751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49752. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49753. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49754. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49755. import { Observable } from "babylonjs/Misc/observable";
  49756. /**
  49757. * Vive Controller
  49758. */
  49759. export class ViveController extends WebVRController {
  49760. /**
  49761. * Base Url for the controller model.
  49762. */
  49763. static MODEL_BASE_URL: string;
  49764. /**
  49765. * File name for the controller model.
  49766. */
  49767. static MODEL_FILENAME: string;
  49768. /**
  49769. * Creates a new ViveController from a gamepad
  49770. * @param vrGamepad the gamepad that the controller should be created from
  49771. */
  49772. constructor(vrGamepad: any);
  49773. /**
  49774. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49775. * @param scene scene in which to add meshes
  49776. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49777. */
  49778. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49779. /**
  49780. * Fired when the left button on this controller is modified
  49781. */
  49782. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49783. /**
  49784. * Fired when the right button on this controller is modified
  49785. */
  49786. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49787. /**
  49788. * Fired when the menu button on this controller is modified
  49789. */
  49790. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49791. /**
  49792. * Called once for each button that changed state since the last frame
  49793. * Vive mapping:
  49794. * 0: touchpad
  49795. * 1: trigger
  49796. * 2: left AND right buttons
  49797. * 3: menu button
  49798. * @param buttonIdx Which button index changed
  49799. * @param state New state of the button
  49800. * @param changes Which properties on the state changed since last frame
  49801. */
  49802. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49803. }
  49804. }
  49805. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49806. import { Observable } from "babylonjs/Misc/observable";
  49807. import { Scene } from "babylonjs/scene";
  49808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49809. import { Ray } from "babylonjs/Culling/ray";
  49810. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49811. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49812. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49813. /**
  49814. * Defines the WindowsMotionController object that the state of the windows motion controller
  49815. */
  49816. export class WindowsMotionController extends WebVRController {
  49817. /**
  49818. * The base url used to load the left and right controller models
  49819. */
  49820. static MODEL_BASE_URL: string;
  49821. /**
  49822. * The name of the left controller model file
  49823. */
  49824. static MODEL_LEFT_FILENAME: string;
  49825. /**
  49826. * The name of the right controller model file
  49827. */
  49828. static MODEL_RIGHT_FILENAME: string;
  49829. /**
  49830. * The controller name prefix for this controller type
  49831. */
  49832. static readonly GAMEPAD_ID_PREFIX: string;
  49833. /**
  49834. * The controller id pattern for this controller type
  49835. */
  49836. private static readonly GAMEPAD_ID_PATTERN;
  49837. private _loadedMeshInfo;
  49838. protected readonly _mapping: {
  49839. buttons: string[];
  49840. buttonMeshNames: {
  49841. 'trigger': string;
  49842. 'menu': string;
  49843. 'grip': string;
  49844. 'thumbstick': string;
  49845. 'trackpad': string;
  49846. };
  49847. buttonObservableNames: {
  49848. 'trigger': string;
  49849. 'menu': string;
  49850. 'grip': string;
  49851. 'thumbstick': string;
  49852. 'trackpad': string;
  49853. };
  49854. axisMeshNames: string[];
  49855. pointingPoseMeshName: string;
  49856. };
  49857. /**
  49858. * Fired when the trackpad on this controller is clicked
  49859. */
  49860. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49861. /**
  49862. * Fired when the trackpad on this controller is modified
  49863. */
  49864. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49865. /**
  49866. * The current x and y values of this controller's trackpad
  49867. */
  49868. trackpad: StickValues;
  49869. /**
  49870. * Creates a new WindowsMotionController from a gamepad
  49871. * @param vrGamepad the gamepad that the controller should be created from
  49872. */
  49873. constructor(vrGamepad: any);
  49874. /**
  49875. * Fired when the trigger on this controller is modified
  49876. */
  49877. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49878. /**
  49879. * Fired when the menu button on this controller is modified
  49880. */
  49881. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49882. /**
  49883. * Fired when the grip button on this controller is modified
  49884. */
  49885. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49886. /**
  49887. * Fired when the thumbstick button on this controller is modified
  49888. */
  49889. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49890. /**
  49891. * Fired when the touchpad button on this controller is modified
  49892. */
  49893. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49894. /**
  49895. * Fired when the touchpad values on this controller are modified
  49896. */
  49897. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  49898. protected _updateTrackpad(): void;
  49899. /**
  49900. * Called once per frame by the engine.
  49901. */
  49902. update(): void;
  49903. /**
  49904. * Called once for each button that changed state since the last frame
  49905. * @param buttonIdx Which button index changed
  49906. * @param state New state of the button
  49907. * @param changes Which properties on the state changed since last frame
  49908. */
  49909. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49910. /**
  49911. * Moves the buttons on the controller mesh based on their current state
  49912. * @param buttonName the name of the button to move
  49913. * @param buttonValue the value of the button which determines the buttons new position
  49914. */
  49915. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  49916. /**
  49917. * Moves the axis on the controller mesh based on its current state
  49918. * @param axis the index of the axis
  49919. * @param axisValue the value of the axis which determines the meshes new position
  49920. * @hidden
  49921. */
  49922. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  49923. /**
  49924. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49925. * @param scene scene in which to add meshes
  49926. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49927. */
  49928. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  49929. /**
  49930. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  49931. * can be transformed by button presses and axes values, based on this._mapping.
  49932. *
  49933. * @param scene scene in which the meshes exist
  49934. * @param meshes list of meshes that make up the controller model to process
  49935. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  49936. */
  49937. private processModel;
  49938. private createMeshInfo;
  49939. /**
  49940. * Gets the ray of the controller in the direction the controller is pointing
  49941. * @param length the length the resulting ray should be
  49942. * @returns a ray in the direction the controller is pointing
  49943. */
  49944. getForwardRay(length?: number): Ray;
  49945. /**
  49946. * Disposes of the controller
  49947. */
  49948. dispose(): void;
  49949. }
  49950. /**
  49951. * This class represents a new windows motion controller in XR.
  49952. */
  49953. export class XRWindowsMotionController extends WindowsMotionController {
  49954. /**
  49955. * Changing the original WIndowsMotionController mapping to fir the new mapping
  49956. */
  49957. protected readonly _mapping: {
  49958. buttons: string[];
  49959. buttonMeshNames: {
  49960. 'trigger': string;
  49961. 'menu': string;
  49962. 'grip': string;
  49963. 'thumbstick': string;
  49964. 'trackpad': string;
  49965. };
  49966. buttonObservableNames: {
  49967. 'trigger': string;
  49968. 'menu': string;
  49969. 'grip': string;
  49970. 'thumbstick': string;
  49971. 'trackpad': string;
  49972. };
  49973. axisMeshNames: string[];
  49974. pointingPoseMeshName: string;
  49975. };
  49976. /**
  49977. * Construct a new XR-Based windows motion controller
  49978. *
  49979. * @param gamepadInfo the gamepad object from the browser
  49980. */
  49981. constructor(gamepadInfo: any);
  49982. /**
  49983. * holds the thumbstick values (X,Y)
  49984. */
  49985. thumbstickValues: StickValues;
  49986. /**
  49987. * Fired when the thumbstick on this controller is clicked
  49988. */
  49989. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  49990. /**
  49991. * Fired when the thumbstick on this controller is modified
  49992. */
  49993. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49994. /**
  49995. * Fired when the touchpad button on this controller is modified
  49996. */
  49997. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49998. /**
  49999. * Fired when the touchpad values on this controller are modified
  50000. */
  50001. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50002. /**
  50003. * Fired when the thumbstick button on this controller is modified
  50004. * here to prevent breaking changes
  50005. */
  50006. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50007. /**
  50008. * updating the thumbstick(!) and not the trackpad.
  50009. * This is named this way due to the difference between WebVR and XR and to avoid
  50010. * changing the parent class.
  50011. */
  50012. protected _updateTrackpad(): void;
  50013. /**
  50014. * Disposes the class with joy
  50015. */
  50016. dispose(): void;
  50017. }
  50018. }
  50019. declare module "babylonjs/Gamepads/Controllers/index" {
  50020. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50021. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50022. export * from "babylonjs/Gamepads/Controllers/genericController";
  50023. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50024. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50025. export * from "babylonjs/Gamepads/Controllers/viveController";
  50026. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50027. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50028. }
  50029. declare module "babylonjs/Gamepads/index" {
  50030. export * from "babylonjs/Gamepads/Controllers/index";
  50031. export * from "babylonjs/Gamepads/gamepad";
  50032. export * from "babylonjs/Gamepads/gamepadManager";
  50033. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50034. export * from "babylonjs/Gamepads/xboxGamepad";
  50035. export * from "babylonjs/Gamepads/dualShockGamepad";
  50036. }
  50037. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50038. import { Scene } from "babylonjs/scene";
  50039. import { Vector4 } from "babylonjs/Maths/math.vector";
  50040. import { Color4 } from "babylonjs/Maths/math.color";
  50041. import { Mesh } from "babylonjs/Meshes/mesh";
  50042. import { Nullable } from "babylonjs/types";
  50043. /**
  50044. * Class containing static functions to help procedurally build meshes
  50045. */
  50046. export class PolyhedronBuilder {
  50047. /**
  50048. * Creates a polyhedron mesh
  50049. * * 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
  50050. * * The parameter `size` (positive float, default 1) sets the polygon size
  50051. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50052. * * 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`
  50053. * * 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
  50054. * * 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)`)
  50055. * * 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
  50056. * * 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
  50057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50060. * @param name defines the name of the mesh
  50061. * @param options defines the options used to create the mesh
  50062. * @param scene defines the hosting scene
  50063. * @returns the polyhedron mesh
  50064. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50065. */
  50066. static CreatePolyhedron(name: string, options: {
  50067. type?: number;
  50068. size?: number;
  50069. sizeX?: number;
  50070. sizeY?: number;
  50071. sizeZ?: number;
  50072. custom?: any;
  50073. faceUV?: Vector4[];
  50074. faceColors?: Color4[];
  50075. flat?: boolean;
  50076. updatable?: boolean;
  50077. sideOrientation?: number;
  50078. frontUVs?: Vector4;
  50079. backUVs?: Vector4;
  50080. }, scene?: Nullable<Scene>): Mesh;
  50081. }
  50082. }
  50083. declare module "babylonjs/Gizmos/scaleGizmo" {
  50084. import { Observable } from "babylonjs/Misc/observable";
  50085. import { Nullable } from "babylonjs/types";
  50086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50087. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50088. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50089. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50090. /**
  50091. * Gizmo that enables scaling a mesh along 3 axis
  50092. */
  50093. export class ScaleGizmo extends Gizmo {
  50094. /**
  50095. * Internal gizmo used for interactions on the x axis
  50096. */
  50097. xGizmo: AxisScaleGizmo;
  50098. /**
  50099. * Internal gizmo used for interactions on the y axis
  50100. */
  50101. yGizmo: AxisScaleGizmo;
  50102. /**
  50103. * Internal gizmo used for interactions on the z axis
  50104. */
  50105. zGizmo: AxisScaleGizmo;
  50106. /**
  50107. * Internal gizmo used to scale all axis equally
  50108. */
  50109. uniformScaleGizmo: AxisScaleGizmo;
  50110. private _meshAttached;
  50111. private _updateGizmoRotationToMatchAttachedMesh;
  50112. private _snapDistance;
  50113. private _scaleRatio;
  50114. private _uniformScalingMesh;
  50115. private _octahedron;
  50116. private _sensitivity;
  50117. /** Fires an event when any of it's sub gizmos are dragged */
  50118. onDragStartObservable: Observable<unknown>;
  50119. /** Fires an event when any of it's sub gizmos are released from dragging */
  50120. onDragEndObservable: Observable<unknown>;
  50121. get attachedMesh(): Nullable<AbstractMesh>;
  50122. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50123. /**
  50124. * Creates a ScaleGizmo
  50125. * @param gizmoLayer The utility layer the gizmo will be added to
  50126. */
  50127. constructor(gizmoLayer?: UtilityLayerRenderer);
  50128. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50129. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50130. /**
  50131. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50132. */
  50133. set snapDistance(value: number);
  50134. get snapDistance(): number;
  50135. /**
  50136. * Ratio for the scale of the gizmo (Default: 1)
  50137. */
  50138. set scaleRatio(value: number);
  50139. get scaleRatio(): number;
  50140. /**
  50141. * Sensitivity factor for dragging (Default: 1)
  50142. */
  50143. set sensitivity(value: number);
  50144. get sensitivity(): number;
  50145. /**
  50146. * Disposes of the gizmo
  50147. */
  50148. dispose(): void;
  50149. }
  50150. }
  50151. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50152. import { Observable } from "babylonjs/Misc/observable";
  50153. import { Nullable } from "babylonjs/types";
  50154. import { Vector3 } from "babylonjs/Maths/math.vector";
  50155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50156. import { Mesh } from "babylonjs/Meshes/mesh";
  50157. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50158. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50159. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50160. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50161. import { Color3 } from "babylonjs/Maths/math.color";
  50162. /**
  50163. * Single axis scale gizmo
  50164. */
  50165. export class AxisScaleGizmo extends Gizmo {
  50166. /**
  50167. * Drag behavior responsible for the gizmos dragging interactions
  50168. */
  50169. dragBehavior: PointerDragBehavior;
  50170. private _pointerObserver;
  50171. /**
  50172. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50173. */
  50174. snapDistance: number;
  50175. /**
  50176. * Event that fires each time the gizmo snaps to a new location.
  50177. * * snapDistance is the the change in distance
  50178. */
  50179. onSnapObservable: Observable<{
  50180. snapDistance: number;
  50181. }>;
  50182. /**
  50183. * If the scaling operation should be done on all axis (default: false)
  50184. */
  50185. uniformScaling: boolean;
  50186. /**
  50187. * Custom sensitivity value for the drag strength
  50188. */
  50189. sensitivity: number;
  50190. private _isEnabled;
  50191. private _parent;
  50192. private _arrow;
  50193. private _coloredMaterial;
  50194. private _hoverMaterial;
  50195. /**
  50196. * Creates an AxisScaleGizmo
  50197. * @param gizmoLayer The utility layer the gizmo will be added to
  50198. * @param dragAxis The axis which the gizmo will be able to scale on
  50199. * @param color The color of the gizmo
  50200. */
  50201. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50202. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50203. /**
  50204. * If the gizmo is enabled
  50205. */
  50206. set isEnabled(value: boolean);
  50207. get isEnabled(): boolean;
  50208. /**
  50209. * Disposes of the gizmo
  50210. */
  50211. dispose(): void;
  50212. /**
  50213. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50214. * @param mesh The mesh to replace the default mesh of the gizmo
  50215. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50216. */
  50217. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50218. }
  50219. }
  50220. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50221. import { Observable } from "babylonjs/Misc/observable";
  50222. import { Nullable } from "babylonjs/types";
  50223. import { Vector3 } from "babylonjs/Maths/math.vector";
  50224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50225. import { Mesh } from "babylonjs/Meshes/mesh";
  50226. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50227. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50228. import { Color3 } from "babylonjs/Maths/math.color";
  50229. import "babylonjs/Meshes/Builders/boxBuilder";
  50230. /**
  50231. * Bounding box gizmo
  50232. */
  50233. export class BoundingBoxGizmo extends Gizmo {
  50234. private _lineBoundingBox;
  50235. private _rotateSpheresParent;
  50236. private _scaleBoxesParent;
  50237. private _boundingDimensions;
  50238. private _renderObserver;
  50239. private _pointerObserver;
  50240. private _scaleDragSpeed;
  50241. private _tmpQuaternion;
  50242. private _tmpVector;
  50243. private _tmpRotationMatrix;
  50244. /**
  50245. * 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)
  50246. */
  50247. ignoreChildren: boolean;
  50248. /**
  50249. * 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)
  50250. */
  50251. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50252. /**
  50253. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50254. */
  50255. rotationSphereSize: number;
  50256. /**
  50257. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50258. */
  50259. scaleBoxSize: number;
  50260. /**
  50261. * 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)
  50262. */
  50263. fixedDragMeshScreenSize: boolean;
  50264. /**
  50265. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50266. */
  50267. fixedDragMeshScreenSizeDistanceFactor: number;
  50268. /**
  50269. * Fired when a rotation sphere or scale box is dragged
  50270. */
  50271. onDragStartObservable: Observable<{}>;
  50272. /**
  50273. * Fired when a scale box is dragged
  50274. */
  50275. onScaleBoxDragObservable: Observable<{}>;
  50276. /**
  50277. * Fired when a scale box drag is ended
  50278. */
  50279. onScaleBoxDragEndObservable: Observable<{}>;
  50280. /**
  50281. * Fired when a rotation sphere is dragged
  50282. */
  50283. onRotationSphereDragObservable: Observable<{}>;
  50284. /**
  50285. * Fired when a rotation sphere drag is ended
  50286. */
  50287. onRotationSphereDragEndObservable: Observable<{}>;
  50288. /**
  50289. * 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)
  50290. */
  50291. scalePivot: Nullable<Vector3>;
  50292. /**
  50293. * Mesh used as a pivot to rotate the attached mesh
  50294. */
  50295. private _anchorMesh;
  50296. private _existingMeshScale;
  50297. private _dragMesh;
  50298. private pointerDragBehavior;
  50299. private coloredMaterial;
  50300. private hoverColoredMaterial;
  50301. /**
  50302. * Sets the color of the bounding box gizmo
  50303. * @param color the color to set
  50304. */
  50305. setColor(color: Color3): void;
  50306. /**
  50307. * Creates an BoundingBoxGizmo
  50308. * @param gizmoLayer The utility layer the gizmo will be added to
  50309. * @param color The color of the gizmo
  50310. */
  50311. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50312. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50313. private _selectNode;
  50314. /**
  50315. * Updates the bounding box information for the Gizmo
  50316. */
  50317. updateBoundingBox(): void;
  50318. private _updateRotationSpheres;
  50319. private _updateScaleBoxes;
  50320. /**
  50321. * Enables rotation on the specified axis and disables rotation on the others
  50322. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50323. */
  50324. setEnabledRotationAxis(axis: string): void;
  50325. /**
  50326. * Enables/disables scaling
  50327. * @param enable if scaling should be enabled
  50328. */
  50329. setEnabledScaling(enable: boolean): void;
  50330. private _updateDummy;
  50331. /**
  50332. * Enables a pointer drag behavior on the bounding box of the gizmo
  50333. */
  50334. enableDragBehavior(): void;
  50335. /**
  50336. * Disposes of the gizmo
  50337. */
  50338. dispose(): void;
  50339. /**
  50340. * 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)
  50341. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50342. * @returns the bounding box mesh with the passed in mesh as a child
  50343. */
  50344. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50345. /**
  50346. * CustomMeshes are not supported by this gizmo
  50347. * @param mesh The mesh to replace the default mesh of the gizmo
  50348. */
  50349. setCustomMesh(mesh: Mesh): void;
  50350. }
  50351. }
  50352. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50353. import { Observable } from "babylonjs/Misc/observable";
  50354. import { Nullable } from "babylonjs/types";
  50355. import { Vector3 } from "babylonjs/Maths/math.vector";
  50356. import { Color3 } from "babylonjs/Maths/math.color";
  50357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50358. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50359. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50360. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50361. import "babylonjs/Meshes/Builders/linesBuilder";
  50362. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50363. /**
  50364. * Single plane rotation gizmo
  50365. */
  50366. export class PlaneRotationGizmo extends Gizmo {
  50367. /**
  50368. * Drag behavior responsible for the gizmos dragging interactions
  50369. */
  50370. dragBehavior: PointerDragBehavior;
  50371. private _pointerObserver;
  50372. /**
  50373. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50374. */
  50375. snapDistance: number;
  50376. /**
  50377. * Event that fires each time the gizmo snaps to a new location.
  50378. * * snapDistance is the the change in distance
  50379. */
  50380. onSnapObservable: Observable<{
  50381. snapDistance: number;
  50382. }>;
  50383. private _isEnabled;
  50384. private _parent;
  50385. /**
  50386. * Creates a PlaneRotationGizmo
  50387. * @param gizmoLayer The utility layer the gizmo will be added to
  50388. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50389. * @param color The color of the gizmo
  50390. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50391. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50392. */
  50393. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50394. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50395. /**
  50396. * If the gizmo is enabled
  50397. */
  50398. set isEnabled(value: boolean);
  50399. get isEnabled(): boolean;
  50400. /**
  50401. * Disposes of the gizmo
  50402. */
  50403. dispose(): void;
  50404. }
  50405. }
  50406. declare module "babylonjs/Gizmos/rotationGizmo" {
  50407. import { Observable } from "babylonjs/Misc/observable";
  50408. import { Nullable } from "babylonjs/types";
  50409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50410. import { Mesh } from "babylonjs/Meshes/mesh";
  50411. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50412. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50413. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50414. /**
  50415. * Gizmo that enables rotating a mesh along 3 axis
  50416. */
  50417. export class RotationGizmo extends Gizmo {
  50418. /**
  50419. * Internal gizmo used for interactions on the x axis
  50420. */
  50421. xGizmo: PlaneRotationGizmo;
  50422. /**
  50423. * Internal gizmo used for interactions on the y axis
  50424. */
  50425. yGizmo: PlaneRotationGizmo;
  50426. /**
  50427. * Internal gizmo used for interactions on the z axis
  50428. */
  50429. zGizmo: PlaneRotationGizmo;
  50430. /** Fires an event when any of it's sub gizmos are dragged */
  50431. onDragStartObservable: Observable<unknown>;
  50432. /** Fires an event when any of it's sub gizmos are released from dragging */
  50433. onDragEndObservable: Observable<unknown>;
  50434. private _meshAttached;
  50435. get attachedMesh(): Nullable<AbstractMesh>;
  50436. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50437. /**
  50438. * Creates a RotationGizmo
  50439. * @param gizmoLayer The utility layer the gizmo will be added to
  50440. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50441. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50442. */
  50443. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50444. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50445. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50446. /**
  50447. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50448. */
  50449. set snapDistance(value: number);
  50450. get snapDistance(): number;
  50451. /**
  50452. * Ratio for the scale of the gizmo (Default: 1)
  50453. */
  50454. set scaleRatio(value: number);
  50455. get scaleRatio(): number;
  50456. /**
  50457. * Disposes of the gizmo
  50458. */
  50459. dispose(): void;
  50460. /**
  50461. * CustomMeshes are not supported by this gizmo
  50462. * @param mesh The mesh to replace the default mesh of the gizmo
  50463. */
  50464. setCustomMesh(mesh: Mesh): void;
  50465. }
  50466. }
  50467. declare module "babylonjs/Gizmos/gizmoManager" {
  50468. import { Observable } from "babylonjs/Misc/observable";
  50469. import { Nullable } from "babylonjs/types";
  50470. import { Scene, IDisposable } from "babylonjs/scene";
  50471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50472. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50473. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50474. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50475. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50476. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50477. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50478. /**
  50479. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50480. */
  50481. export class GizmoManager implements IDisposable {
  50482. private scene;
  50483. /**
  50484. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50485. */
  50486. gizmos: {
  50487. positionGizmo: Nullable<PositionGizmo>;
  50488. rotationGizmo: Nullable<RotationGizmo>;
  50489. scaleGizmo: Nullable<ScaleGizmo>;
  50490. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50491. };
  50492. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50493. clearGizmoOnEmptyPointerEvent: boolean;
  50494. /** Fires an event when the manager is attached to a mesh */
  50495. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50496. private _gizmosEnabled;
  50497. private _pointerObserver;
  50498. private _attachedMesh;
  50499. private _boundingBoxColor;
  50500. private _defaultUtilityLayer;
  50501. private _defaultKeepDepthUtilityLayer;
  50502. /**
  50503. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50504. */
  50505. boundingBoxDragBehavior: SixDofDragBehavior;
  50506. /**
  50507. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50508. */
  50509. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50510. /**
  50511. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50512. */
  50513. usePointerToAttachGizmos: boolean;
  50514. /**
  50515. * Utility layer that the bounding box gizmo belongs to
  50516. */
  50517. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50518. /**
  50519. * Utility layer that all gizmos besides bounding box belong to
  50520. */
  50521. get utilityLayer(): UtilityLayerRenderer;
  50522. /**
  50523. * Instatiates a gizmo manager
  50524. * @param scene the scene to overlay the gizmos on top of
  50525. */
  50526. constructor(scene: Scene);
  50527. /**
  50528. * Attaches a set of gizmos to the specified mesh
  50529. * @param mesh The mesh the gizmo's should be attached to
  50530. */
  50531. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50532. /**
  50533. * If the position gizmo is enabled
  50534. */
  50535. set positionGizmoEnabled(value: boolean);
  50536. get positionGizmoEnabled(): boolean;
  50537. /**
  50538. * If the rotation gizmo is enabled
  50539. */
  50540. set rotationGizmoEnabled(value: boolean);
  50541. get rotationGizmoEnabled(): boolean;
  50542. /**
  50543. * If the scale gizmo is enabled
  50544. */
  50545. set scaleGizmoEnabled(value: boolean);
  50546. get scaleGizmoEnabled(): boolean;
  50547. /**
  50548. * If the boundingBox gizmo is enabled
  50549. */
  50550. set boundingBoxGizmoEnabled(value: boolean);
  50551. get boundingBoxGizmoEnabled(): boolean;
  50552. /**
  50553. * Disposes of the gizmo manager
  50554. */
  50555. dispose(): void;
  50556. }
  50557. }
  50558. declare module "babylonjs/Lights/directionalLight" {
  50559. import { Camera } from "babylonjs/Cameras/camera";
  50560. import { Scene } from "babylonjs/scene";
  50561. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50563. import { Light } from "babylonjs/Lights/light";
  50564. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50565. import { Effect } from "babylonjs/Materials/effect";
  50566. /**
  50567. * A directional light is defined by a direction (what a surprise!).
  50568. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50569. * 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.
  50570. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50571. */
  50572. export class DirectionalLight extends ShadowLight {
  50573. private _shadowFrustumSize;
  50574. /**
  50575. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50576. */
  50577. get shadowFrustumSize(): number;
  50578. /**
  50579. * Specifies a fix frustum size for the shadow generation.
  50580. */
  50581. set shadowFrustumSize(value: number);
  50582. private _shadowOrthoScale;
  50583. /**
  50584. * Gets the shadow projection scale against the optimal computed one.
  50585. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50586. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50587. */
  50588. get shadowOrthoScale(): number;
  50589. /**
  50590. * Sets the shadow projection scale against the optimal computed one.
  50591. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50592. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50593. */
  50594. set shadowOrthoScale(value: number);
  50595. /**
  50596. * Automatically compute the projection matrix to best fit (including all the casters)
  50597. * on each frame.
  50598. */
  50599. autoUpdateExtends: boolean;
  50600. /**
  50601. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50602. * on each frame. autoUpdateExtends must be set to true for this to work
  50603. */
  50604. autoCalcShadowZBounds: boolean;
  50605. private _orthoLeft;
  50606. private _orthoRight;
  50607. private _orthoTop;
  50608. private _orthoBottom;
  50609. /**
  50610. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50611. * The directional light is emitted from everywhere in the given direction.
  50612. * It can cast shadows.
  50613. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50614. * @param name The friendly name of the light
  50615. * @param direction The direction of the light
  50616. * @param scene The scene the light belongs to
  50617. */
  50618. constructor(name: string, direction: Vector3, scene: Scene);
  50619. /**
  50620. * Returns the string "DirectionalLight".
  50621. * @return The class name
  50622. */
  50623. getClassName(): string;
  50624. /**
  50625. * Returns the integer 1.
  50626. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50627. */
  50628. getTypeID(): number;
  50629. /**
  50630. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50631. * Returns the DirectionalLight Shadow projection matrix.
  50632. */
  50633. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50634. /**
  50635. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50636. * Returns the DirectionalLight Shadow projection matrix.
  50637. */
  50638. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50639. /**
  50640. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50641. * Returns the DirectionalLight Shadow projection matrix.
  50642. */
  50643. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50644. protected _buildUniformLayout(): void;
  50645. /**
  50646. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50647. * @param effect The effect to update
  50648. * @param lightIndex The index of the light in the effect to update
  50649. * @returns The directional light
  50650. */
  50651. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50652. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50653. /**
  50654. * Gets the minZ used for shadow according to both the scene and the light.
  50655. *
  50656. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50657. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50658. * @param activeCamera The camera we are returning the min for
  50659. * @returns the depth min z
  50660. */
  50661. getDepthMinZ(activeCamera: Camera): number;
  50662. /**
  50663. * Gets the maxZ used for shadow according to both the scene and the light.
  50664. *
  50665. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50666. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50667. * @param activeCamera The camera we are returning the max for
  50668. * @returns the depth max z
  50669. */
  50670. getDepthMaxZ(activeCamera: Camera): number;
  50671. /**
  50672. * Prepares the list of defines specific to the light type.
  50673. * @param defines the list of defines
  50674. * @param lightIndex defines the index of the light for the effect
  50675. */
  50676. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50677. }
  50678. }
  50679. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50680. import { Mesh } from "babylonjs/Meshes/mesh";
  50681. /**
  50682. * Class containing static functions to help procedurally build meshes
  50683. */
  50684. export class HemisphereBuilder {
  50685. /**
  50686. * Creates a hemisphere mesh
  50687. * @param name defines the name of the mesh
  50688. * @param options defines the options used to create the mesh
  50689. * @param scene defines the hosting scene
  50690. * @returns the hemisphere mesh
  50691. */
  50692. static CreateHemisphere(name: string, options: {
  50693. segments?: number;
  50694. diameter?: number;
  50695. sideOrientation?: number;
  50696. }, scene: any): Mesh;
  50697. }
  50698. }
  50699. declare module "babylonjs/Lights/spotLight" {
  50700. import { Nullable } from "babylonjs/types";
  50701. import { Scene } from "babylonjs/scene";
  50702. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50704. import { Effect } from "babylonjs/Materials/effect";
  50705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50706. import { Light } from "babylonjs/Lights/light";
  50707. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50708. /**
  50709. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50710. * These values define a cone of light starting from the position, emitting toward the direction.
  50711. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50712. * and the exponent defines the speed of the decay of the light with distance (reach).
  50713. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50714. */
  50715. export class SpotLight extends ShadowLight {
  50716. private _angle;
  50717. private _innerAngle;
  50718. private _cosHalfAngle;
  50719. private _lightAngleScale;
  50720. private _lightAngleOffset;
  50721. /**
  50722. * Gets the cone angle of the spot light in Radians.
  50723. */
  50724. get angle(): number;
  50725. /**
  50726. * Sets the cone angle of the spot light in Radians.
  50727. */
  50728. set angle(value: number);
  50729. /**
  50730. * Only used in gltf falloff mode, this defines the angle where
  50731. * the directional falloff will start before cutting at angle which could be seen
  50732. * as outer angle.
  50733. */
  50734. get innerAngle(): number;
  50735. /**
  50736. * Only used in gltf falloff mode, this defines the angle where
  50737. * the directional falloff will start before cutting at angle which could be seen
  50738. * as outer angle.
  50739. */
  50740. set innerAngle(value: number);
  50741. private _shadowAngleScale;
  50742. /**
  50743. * Allows scaling the angle of the light for shadow generation only.
  50744. */
  50745. get shadowAngleScale(): number;
  50746. /**
  50747. * Allows scaling the angle of the light for shadow generation only.
  50748. */
  50749. set shadowAngleScale(value: number);
  50750. /**
  50751. * The light decay speed with the distance from the emission spot.
  50752. */
  50753. exponent: number;
  50754. private _projectionTextureMatrix;
  50755. /**
  50756. * Allows reading the projecton texture
  50757. */
  50758. get projectionTextureMatrix(): Matrix;
  50759. protected _projectionTextureLightNear: number;
  50760. /**
  50761. * Gets the near clip of the Spotlight for texture projection.
  50762. */
  50763. get projectionTextureLightNear(): number;
  50764. /**
  50765. * Sets the near clip of the Spotlight for texture projection.
  50766. */
  50767. set projectionTextureLightNear(value: number);
  50768. protected _projectionTextureLightFar: number;
  50769. /**
  50770. * Gets the far clip of the Spotlight for texture projection.
  50771. */
  50772. get projectionTextureLightFar(): number;
  50773. /**
  50774. * Sets the far clip of the Spotlight for texture projection.
  50775. */
  50776. set projectionTextureLightFar(value: number);
  50777. protected _projectionTextureUpDirection: Vector3;
  50778. /**
  50779. * Gets the Up vector of the Spotlight for texture projection.
  50780. */
  50781. get projectionTextureUpDirection(): Vector3;
  50782. /**
  50783. * Sets the Up vector of the Spotlight for texture projection.
  50784. */
  50785. set projectionTextureUpDirection(value: Vector3);
  50786. private _projectionTexture;
  50787. /**
  50788. * Gets the projection texture of the light.
  50789. */
  50790. get projectionTexture(): Nullable<BaseTexture>;
  50791. /**
  50792. * Sets the projection texture of the light.
  50793. */
  50794. set projectionTexture(value: Nullable<BaseTexture>);
  50795. private _projectionTextureViewLightDirty;
  50796. private _projectionTextureProjectionLightDirty;
  50797. private _projectionTextureDirty;
  50798. private _projectionTextureViewTargetVector;
  50799. private _projectionTextureViewLightMatrix;
  50800. private _projectionTextureProjectionLightMatrix;
  50801. private _projectionTextureScalingMatrix;
  50802. /**
  50803. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50804. * It can cast shadows.
  50805. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50806. * @param name The light friendly name
  50807. * @param position The position of the spot light in the scene
  50808. * @param direction The direction of the light in the scene
  50809. * @param angle The cone angle of the light in Radians
  50810. * @param exponent The light decay speed with the distance from the emission spot
  50811. * @param scene The scene the lights belongs to
  50812. */
  50813. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50814. /**
  50815. * Returns the string "SpotLight".
  50816. * @returns the class name
  50817. */
  50818. getClassName(): string;
  50819. /**
  50820. * Returns the integer 2.
  50821. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50822. */
  50823. getTypeID(): number;
  50824. /**
  50825. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50826. */
  50827. protected _setDirection(value: Vector3): void;
  50828. /**
  50829. * Overrides the position setter to recompute the projection texture view light Matrix.
  50830. */
  50831. protected _setPosition(value: Vector3): void;
  50832. /**
  50833. * 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.
  50834. * Returns the SpotLight.
  50835. */
  50836. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50837. protected _computeProjectionTextureViewLightMatrix(): void;
  50838. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50839. /**
  50840. * Main function for light texture projection matrix computing.
  50841. */
  50842. protected _computeProjectionTextureMatrix(): void;
  50843. protected _buildUniformLayout(): void;
  50844. private _computeAngleValues;
  50845. /**
  50846. * Sets the passed Effect "effect" with the Light textures.
  50847. * @param effect The effect to update
  50848. * @param lightIndex The index of the light in the effect to update
  50849. * @returns The light
  50850. */
  50851. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50852. /**
  50853. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50854. * @param effect The effect to update
  50855. * @param lightIndex The index of the light in the effect to update
  50856. * @returns The spot light
  50857. */
  50858. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50859. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50860. /**
  50861. * Disposes the light and the associated resources.
  50862. */
  50863. dispose(): void;
  50864. /**
  50865. * Prepares the list of defines specific to the light type.
  50866. * @param defines the list of defines
  50867. * @param lightIndex defines the index of the light for the effect
  50868. */
  50869. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50870. }
  50871. }
  50872. declare module "babylonjs/Gizmos/lightGizmo" {
  50873. import { Nullable } from "babylonjs/types";
  50874. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50875. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50876. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50877. import { Light } from "babylonjs/Lights/light";
  50878. /**
  50879. * Gizmo that enables viewing a light
  50880. */
  50881. export class LightGizmo extends Gizmo {
  50882. private _lightMesh;
  50883. private _material;
  50884. private _cachedPosition;
  50885. private _cachedForward;
  50886. private _attachedMeshParent;
  50887. /**
  50888. * Creates a LightGizmo
  50889. * @param gizmoLayer The utility layer the gizmo will be added to
  50890. */
  50891. constructor(gizmoLayer?: UtilityLayerRenderer);
  50892. private _light;
  50893. /**
  50894. * The light that the gizmo is attached to
  50895. */
  50896. set light(light: Nullable<Light>);
  50897. get light(): Nullable<Light>;
  50898. /**
  50899. * Gets the material used to render the light gizmo
  50900. */
  50901. get material(): StandardMaterial;
  50902. /**
  50903. * @hidden
  50904. * Updates the gizmo to match the attached mesh's position/rotation
  50905. */
  50906. protected _update(): void;
  50907. private static _Scale;
  50908. /**
  50909. * Creates the lines for a light mesh
  50910. */
  50911. private static _CreateLightLines;
  50912. /**
  50913. * Disposes of the light gizmo
  50914. */
  50915. dispose(): void;
  50916. private static _CreateHemisphericLightMesh;
  50917. private static _CreatePointLightMesh;
  50918. private static _CreateSpotLightMesh;
  50919. private static _CreateDirectionalLightMesh;
  50920. }
  50921. }
  50922. declare module "babylonjs/Gizmos/index" {
  50923. export * from "babylonjs/Gizmos/axisDragGizmo";
  50924. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50925. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50926. export * from "babylonjs/Gizmos/gizmo";
  50927. export * from "babylonjs/Gizmos/gizmoManager";
  50928. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50929. export * from "babylonjs/Gizmos/positionGizmo";
  50930. export * from "babylonjs/Gizmos/rotationGizmo";
  50931. export * from "babylonjs/Gizmos/scaleGizmo";
  50932. export * from "babylonjs/Gizmos/lightGizmo";
  50933. export * from "babylonjs/Gizmos/planeDragGizmo";
  50934. }
  50935. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50936. /** @hidden */
  50937. export var backgroundFragmentDeclaration: {
  50938. name: string;
  50939. shader: string;
  50940. };
  50941. }
  50942. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50943. /** @hidden */
  50944. export var backgroundUboDeclaration: {
  50945. name: string;
  50946. shader: string;
  50947. };
  50948. }
  50949. declare module "babylonjs/Shaders/background.fragment" {
  50950. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50951. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50952. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50953. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50954. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50955. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50956. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50957. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50958. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50959. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50960. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50961. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50962. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50963. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50964. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50965. /** @hidden */
  50966. export var backgroundPixelShader: {
  50967. name: string;
  50968. shader: string;
  50969. };
  50970. }
  50971. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50972. /** @hidden */
  50973. export var backgroundVertexDeclaration: {
  50974. name: string;
  50975. shader: string;
  50976. };
  50977. }
  50978. declare module "babylonjs/Shaders/background.vertex" {
  50979. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50980. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50981. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50982. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50983. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50984. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50985. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50986. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50987. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50988. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50989. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50990. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50991. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50992. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50993. /** @hidden */
  50994. export var backgroundVertexShader: {
  50995. name: string;
  50996. shader: string;
  50997. };
  50998. }
  50999. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51000. import { Nullable, int, float } from "babylonjs/types";
  51001. import { Scene } from "babylonjs/scene";
  51002. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51003. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51005. import { Mesh } from "babylonjs/Meshes/mesh";
  51006. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51007. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51008. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51009. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51010. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51011. import { Color3 } from "babylonjs/Maths/math.color";
  51012. import "babylonjs/Shaders/background.fragment";
  51013. import "babylonjs/Shaders/background.vertex";
  51014. /**
  51015. * Background material used to create an efficient environement around your scene.
  51016. */
  51017. export class BackgroundMaterial extends PushMaterial {
  51018. /**
  51019. * Standard reflectance value at parallel view angle.
  51020. */
  51021. static StandardReflectance0: number;
  51022. /**
  51023. * Standard reflectance value at grazing angle.
  51024. */
  51025. static StandardReflectance90: number;
  51026. protected _primaryColor: Color3;
  51027. /**
  51028. * Key light Color (multiply against the environement texture)
  51029. */
  51030. primaryColor: Color3;
  51031. protected __perceptualColor: Nullable<Color3>;
  51032. /**
  51033. * Experimental Internal Use Only.
  51034. *
  51035. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51036. * This acts as a helper to set the primary color to a more "human friendly" value.
  51037. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51038. * output color as close as possible from the chosen value.
  51039. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51040. * part of lighting setup.)
  51041. */
  51042. get _perceptualColor(): Nullable<Color3>;
  51043. set _perceptualColor(value: Nullable<Color3>);
  51044. protected _primaryColorShadowLevel: float;
  51045. /**
  51046. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51047. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51048. */
  51049. get primaryColorShadowLevel(): float;
  51050. set primaryColorShadowLevel(value: float);
  51051. protected _primaryColorHighlightLevel: float;
  51052. /**
  51053. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51054. * The primary color is used at the level chosen to define what the white area would look.
  51055. */
  51056. get primaryColorHighlightLevel(): float;
  51057. set primaryColorHighlightLevel(value: float);
  51058. protected _reflectionTexture: Nullable<BaseTexture>;
  51059. /**
  51060. * Reflection Texture used in the material.
  51061. * Should be author in a specific way for the best result (refer to the documentation).
  51062. */
  51063. reflectionTexture: Nullable<BaseTexture>;
  51064. protected _reflectionBlur: float;
  51065. /**
  51066. * Reflection Texture level of blur.
  51067. *
  51068. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51069. * texture twice.
  51070. */
  51071. reflectionBlur: float;
  51072. protected _diffuseTexture: Nullable<BaseTexture>;
  51073. /**
  51074. * Diffuse Texture used in the material.
  51075. * Should be author in a specific way for the best result (refer to the documentation).
  51076. */
  51077. diffuseTexture: Nullable<BaseTexture>;
  51078. protected _shadowLights: Nullable<IShadowLight[]>;
  51079. /**
  51080. * Specify the list of lights casting shadow on the material.
  51081. * All scene shadow lights will be included if null.
  51082. */
  51083. shadowLights: Nullable<IShadowLight[]>;
  51084. protected _shadowLevel: float;
  51085. /**
  51086. * Helps adjusting the shadow to a softer level if required.
  51087. * 0 means black shadows and 1 means no shadows.
  51088. */
  51089. shadowLevel: float;
  51090. protected _sceneCenter: Vector3;
  51091. /**
  51092. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51093. * It is usually zero but might be interesting to modify according to your setup.
  51094. */
  51095. sceneCenter: Vector3;
  51096. protected _opacityFresnel: boolean;
  51097. /**
  51098. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51099. * This helps ensuring a nice transition when the camera goes under the ground.
  51100. */
  51101. opacityFresnel: boolean;
  51102. protected _reflectionFresnel: boolean;
  51103. /**
  51104. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51105. * This helps adding a mirror texture on the ground.
  51106. */
  51107. reflectionFresnel: boolean;
  51108. protected _reflectionFalloffDistance: number;
  51109. /**
  51110. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51111. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51112. */
  51113. reflectionFalloffDistance: number;
  51114. protected _reflectionAmount: number;
  51115. /**
  51116. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51117. */
  51118. reflectionAmount: number;
  51119. protected _reflectionReflectance0: number;
  51120. /**
  51121. * This specifies the weight of the reflection at grazing angle.
  51122. */
  51123. reflectionReflectance0: number;
  51124. protected _reflectionReflectance90: number;
  51125. /**
  51126. * This specifies the weight of the reflection at a perpendicular point of view.
  51127. */
  51128. reflectionReflectance90: number;
  51129. /**
  51130. * Sets the reflection reflectance fresnel values according to the default standard
  51131. * empirically know to work well :-)
  51132. */
  51133. set reflectionStandardFresnelWeight(value: number);
  51134. protected _useRGBColor: boolean;
  51135. /**
  51136. * Helps to directly use the maps channels instead of their level.
  51137. */
  51138. useRGBColor: boolean;
  51139. protected _enableNoise: boolean;
  51140. /**
  51141. * This helps reducing the banding effect that could occur on the background.
  51142. */
  51143. enableNoise: boolean;
  51144. /**
  51145. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51146. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51147. * Recommended to be keep at 1.0 except for special cases.
  51148. */
  51149. get fovMultiplier(): number;
  51150. set fovMultiplier(value: number);
  51151. private _fovMultiplier;
  51152. /**
  51153. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51154. */
  51155. useEquirectangularFOV: boolean;
  51156. private _maxSimultaneousLights;
  51157. /**
  51158. * Number of Simultaneous lights allowed on the material.
  51159. */
  51160. maxSimultaneousLights: int;
  51161. /**
  51162. * Default configuration related to image processing available in the Background Material.
  51163. */
  51164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51165. /**
  51166. * Keep track of the image processing observer to allow dispose and replace.
  51167. */
  51168. private _imageProcessingObserver;
  51169. /**
  51170. * Attaches a new image processing configuration to the PBR Material.
  51171. * @param configuration (if null the scene configuration will be use)
  51172. */
  51173. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51174. /**
  51175. * Gets the image processing configuration used either in this material.
  51176. */
  51177. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51178. /**
  51179. * Sets the Default image processing configuration used either in the this material.
  51180. *
  51181. * If sets to null, the scene one is in use.
  51182. */
  51183. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51184. /**
  51185. * Gets wether the color curves effect is enabled.
  51186. */
  51187. get cameraColorCurvesEnabled(): boolean;
  51188. /**
  51189. * Sets wether the color curves effect is enabled.
  51190. */
  51191. set cameraColorCurvesEnabled(value: boolean);
  51192. /**
  51193. * Gets wether the color grading effect is enabled.
  51194. */
  51195. get cameraColorGradingEnabled(): boolean;
  51196. /**
  51197. * Gets wether the color grading effect is enabled.
  51198. */
  51199. set cameraColorGradingEnabled(value: boolean);
  51200. /**
  51201. * Gets wether tonemapping is enabled or not.
  51202. */
  51203. get cameraToneMappingEnabled(): boolean;
  51204. /**
  51205. * Sets wether tonemapping is enabled or not
  51206. */
  51207. set cameraToneMappingEnabled(value: boolean);
  51208. /**
  51209. * The camera exposure used on this material.
  51210. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51211. * This corresponds to a photographic exposure.
  51212. */
  51213. get cameraExposure(): float;
  51214. /**
  51215. * The camera exposure used on this material.
  51216. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51217. * This corresponds to a photographic exposure.
  51218. */
  51219. set cameraExposure(value: float);
  51220. /**
  51221. * Gets The camera contrast used on this material.
  51222. */
  51223. get cameraContrast(): float;
  51224. /**
  51225. * Sets The camera contrast used on this material.
  51226. */
  51227. set cameraContrast(value: float);
  51228. /**
  51229. * Gets the Color Grading 2D Lookup Texture.
  51230. */
  51231. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51232. /**
  51233. * Sets the Color Grading 2D Lookup Texture.
  51234. */
  51235. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51236. /**
  51237. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51238. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51239. * 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;
  51240. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51241. */
  51242. get cameraColorCurves(): Nullable<ColorCurves>;
  51243. /**
  51244. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51245. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51246. * 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;
  51247. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51248. */
  51249. set cameraColorCurves(value: Nullable<ColorCurves>);
  51250. /**
  51251. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51252. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51253. */
  51254. switchToBGR: boolean;
  51255. private _renderTargets;
  51256. private _reflectionControls;
  51257. private _white;
  51258. private _primaryShadowColor;
  51259. private _primaryHighlightColor;
  51260. /**
  51261. * Instantiates a Background Material in the given scene
  51262. * @param name The friendly name of the material
  51263. * @param scene The scene to add the material to
  51264. */
  51265. constructor(name: string, scene: Scene);
  51266. /**
  51267. * Gets a boolean indicating that current material needs to register RTT
  51268. */
  51269. get hasRenderTargetTextures(): boolean;
  51270. /**
  51271. * The entire material has been created in order to prevent overdraw.
  51272. * @returns false
  51273. */
  51274. needAlphaTesting(): boolean;
  51275. /**
  51276. * The entire material has been created in order to prevent overdraw.
  51277. * @returns true if blending is enable
  51278. */
  51279. needAlphaBlending(): boolean;
  51280. /**
  51281. * Checks wether the material is ready to be rendered for a given mesh.
  51282. * @param mesh The mesh to render
  51283. * @param subMesh The submesh to check against
  51284. * @param useInstances Specify wether or not the material is used with instances
  51285. * @returns true if all the dependencies are ready (Textures, Effects...)
  51286. */
  51287. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51288. /**
  51289. * Compute the primary color according to the chosen perceptual color.
  51290. */
  51291. private _computePrimaryColorFromPerceptualColor;
  51292. /**
  51293. * Compute the highlights and shadow colors according to their chosen levels.
  51294. */
  51295. private _computePrimaryColors;
  51296. /**
  51297. * Build the uniform buffer used in the material.
  51298. */
  51299. buildUniformLayout(): void;
  51300. /**
  51301. * Unbind the material.
  51302. */
  51303. unbind(): void;
  51304. /**
  51305. * Bind only the world matrix to the material.
  51306. * @param world The world matrix to bind.
  51307. */
  51308. bindOnlyWorldMatrix(world: Matrix): void;
  51309. /**
  51310. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51311. * @param world The world matrix to bind.
  51312. * @param subMesh The submesh to bind for.
  51313. */
  51314. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51315. /**
  51316. * Checks to see if a texture is used in the material.
  51317. * @param texture - Base texture to use.
  51318. * @returns - Boolean specifying if a texture is used in the material.
  51319. */
  51320. hasTexture(texture: BaseTexture): boolean;
  51321. /**
  51322. * Dispose the material.
  51323. * @param forceDisposeEffect Force disposal of the associated effect.
  51324. * @param forceDisposeTextures Force disposal of the associated textures.
  51325. */
  51326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51327. /**
  51328. * Clones the material.
  51329. * @param name The cloned name.
  51330. * @returns The cloned material.
  51331. */
  51332. clone(name: string): BackgroundMaterial;
  51333. /**
  51334. * Serializes the current material to its JSON representation.
  51335. * @returns The JSON representation.
  51336. */
  51337. serialize(): any;
  51338. /**
  51339. * Gets the class name of the material
  51340. * @returns "BackgroundMaterial"
  51341. */
  51342. getClassName(): string;
  51343. /**
  51344. * Parse a JSON input to create back a background material.
  51345. * @param source The JSON data to parse
  51346. * @param scene The scene to create the parsed material in
  51347. * @param rootUrl The root url of the assets the material depends upon
  51348. * @returns the instantiated BackgroundMaterial.
  51349. */
  51350. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51351. }
  51352. }
  51353. declare module "babylonjs/Helpers/environmentHelper" {
  51354. import { Observable } from "babylonjs/Misc/observable";
  51355. import { Nullable } from "babylonjs/types";
  51356. import { Scene } from "babylonjs/scene";
  51357. import { Vector3 } from "babylonjs/Maths/math.vector";
  51358. import { Color3 } from "babylonjs/Maths/math.color";
  51359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51360. import { Mesh } from "babylonjs/Meshes/mesh";
  51361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51362. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51363. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51364. import "babylonjs/Meshes/Builders/planeBuilder";
  51365. import "babylonjs/Meshes/Builders/boxBuilder";
  51366. /**
  51367. * Represents the different options available during the creation of
  51368. * a Environment helper.
  51369. *
  51370. * This can control the default ground, skybox and image processing setup of your scene.
  51371. */
  51372. export interface IEnvironmentHelperOptions {
  51373. /**
  51374. * Specifies whether or not to create a ground.
  51375. * True by default.
  51376. */
  51377. createGround: boolean;
  51378. /**
  51379. * Specifies the ground size.
  51380. * 15 by default.
  51381. */
  51382. groundSize: number;
  51383. /**
  51384. * The texture used on the ground for the main color.
  51385. * Comes from the BabylonJS CDN by default.
  51386. *
  51387. * Remarks: Can be either a texture or a url.
  51388. */
  51389. groundTexture: string | BaseTexture;
  51390. /**
  51391. * The color mixed in the ground texture by default.
  51392. * BabylonJS clearColor by default.
  51393. */
  51394. groundColor: Color3;
  51395. /**
  51396. * Specifies the ground opacity.
  51397. * 1 by default.
  51398. */
  51399. groundOpacity: number;
  51400. /**
  51401. * Enables the ground to receive shadows.
  51402. * True by default.
  51403. */
  51404. enableGroundShadow: boolean;
  51405. /**
  51406. * Helps preventing the shadow to be fully black on the ground.
  51407. * 0.5 by default.
  51408. */
  51409. groundShadowLevel: number;
  51410. /**
  51411. * Creates a mirror texture attach to the ground.
  51412. * false by default.
  51413. */
  51414. enableGroundMirror: boolean;
  51415. /**
  51416. * Specifies the ground mirror size ratio.
  51417. * 0.3 by default as the default kernel is 64.
  51418. */
  51419. groundMirrorSizeRatio: number;
  51420. /**
  51421. * Specifies the ground mirror blur kernel size.
  51422. * 64 by default.
  51423. */
  51424. groundMirrorBlurKernel: number;
  51425. /**
  51426. * Specifies the ground mirror visibility amount.
  51427. * 1 by default
  51428. */
  51429. groundMirrorAmount: number;
  51430. /**
  51431. * Specifies the ground mirror reflectance weight.
  51432. * This uses the standard weight of the background material to setup the fresnel effect
  51433. * of the mirror.
  51434. * 1 by default.
  51435. */
  51436. groundMirrorFresnelWeight: number;
  51437. /**
  51438. * Specifies the ground mirror Falloff distance.
  51439. * This can helps reducing the size of the reflection.
  51440. * 0 by Default.
  51441. */
  51442. groundMirrorFallOffDistance: number;
  51443. /**
  51444. * Specifies the ground mirror texture type.
  51445. * Unsigned Int by Default.
  51446. */
  51447. groundMirrorTextureType: number;
  51448. /**
  51449. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51450. * the shown objects.
  51451. */
  51452. groundYBias: number;
  51453. /**
  51454. * Specifies whether or not to create a skybox.
  51455. * True by default.
  51456. */
  51457. createSkybox: boolean;
  51458. /**
  51459. * Specifies the skybox size.
  51460. * 20 by default.
  51461. */
  51462. skyboxSize: number;
  51463. /**
  51464. * The texture used on the skybox for the main color.
  51465. * Comes from the BabylonJS CDN by default.
  51466. *
  51467. * Remarks: Can be either a texture or a url.
  51468. */
  51469. skyboxTexture: string | BaseTexture;
  51470. /**
  51471. * The color mixed in the skybox texture by default.
  51472. * BabylonJS clearColor by default.
  51473. */
  51474. skyboxColor: Color3;
  51475. /**
  51476. * The background rotation around the Y axis of the scene.
  51477. * This helps aligning the key lights of your scene with the background.
  51478. * 0 by default.
  51479. */
  51480. backgroundYRotation: number;
  51481. /**
  51482. * Compute automatically the size of the elements to best fit with the scene.
  51483. */
  51484. sizeAuto: boolean;
  51485. /**
  51486. * Default position of the rootMesh if autoSize is not true.
  51487. */
  51488. rootPosition: Vector3;
  51489. /**
  51490. * Sets up the image processing in the scene.
  51491. * true by default.
  51492. */
  51493. setupImageProcessing: boolean;
  51494. /**
  51495. * The texture used as your environment texture in the scene.
  51496. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51497. *
  51498. * Remarks: Can be either a texture or a url.
  51499. */
  51500. environmentTexture: string | BaseTexture;
  51501. /**
  51502. * The value of the exposure to apply to the scene.
  51503. * 0.6 by default if setupImageProcessing is true.
  51504. */
  51505. cameraExposure: number;
  51506. /**
  51507. * The value of the contrast to apply to the scene.
  51508. * 1.6 by default if setupImageProcessing is true.
  51509. */
  51510. cameraContrast: number;
  51511. /**
  51512. * Specifies whether or not tonemapping should be enabled in the scene.
  51513. * true by default if setupImageProcessing is true.
  51514. */
  51515. toneMappingEnabled: boolean;
  51516. }
  51517. /**
  51518. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51519. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51520. * It also helps with the default setup of your imageProcessing configuration.
  51521. */
  51522. export class EnvironmentHelper {
  51523. /**
  51524. * Default ground texture URL.
  51525. */
  51526. private static _groundTextureCDNUrl;
  51527. /**
  51528. * Default skybox texture URL.
  51529. */
  51530. private static _skyboxTextureCDNUrl;
  51531. /**
  51532. * Default environment texture URL.
  51533. */
  51534. private static _environmentTextureCDNUrl;
  51535. /**
  51536. * Creates the default options for the helper.
  51537. */
  51538. private static _getDefaultOptions;
  51539. private _rootMesh;
  51540. /**
  51541. * Gets the root mesh created by the helper.
  51542. */
  51543. get rootMesh(): Mesh;
  51544. private _skybox;
  51545. /**
  51546. * Gets the skybox created by the helper.
  51547. */
  51548. get skybox(): Nullable<Mesh>;
  51549. private _skyboxTexture;
  51550. /**
  51551. * Gets the skybox texture created by the helper.
  51552. */
  51553. get skyboxTexture(): Nullable<BaseTexture>;
  51554. private _skyboxMaterial;
  51555. /**
  51556. * Gets the skybox material created by the helper.
  51557. */
  51558. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51559. private _ground;
  51560. /**
  51561. * Gets the ground mesh created by the helper.
  51562. */
  51563. get ground(): Nullable<Mesh>;
  51564. private _groundTexture;
  51565. /**
  51566. * Gets the ground texture created by the helper.
  51567. */
  51568. get groundTexture(): Nullable<BaseTexture>;
  51569. private _groundMirror;
  51570. /**
  51571. * Gets the ground mirror created by the helper.
  51572. */
  51573. get groundMirror(): Nullable<MirrorTexture>;
  51574. /**
  51575. * Gets the ground mirror render list to helps pushing the meshes
  51576. * you wish in the ground reflection.
  51577. */
  51578. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51579. private _groundMaterial;
  51580. /**
  51581. * Gets the ground material created by the helper.
  51582. */
  51583. get groundMaterial(): Nullable<BackgroundMaterial>;
  51584. /**
  51585. * Stores the creation options.
  51586. */
  51587. private readonly _scene;
  51588. private _options;
  51589. /**
  51590. * This observable will be notified with any error during the creation of the environment,
  51591. * mainly texture creation errors.
  51592. */
  51593. onErrorObservable: Observable<{
  51594. message?: string;
  51595. exception?: any;
  51596. }>;
  51597. /**
  51598. * constructor
  51599. * @param options Defines the options we want to customize the helper
  51600. * @param scene The scene to add the material to
  51601. */
  51602. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51603. /**
  51604. * Updates the background according to the new options
  51605. * @param options
  51606. */
  51607. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51608. /**
  51609. * Sets the primary color of all the available elements.
  51610. * @param color the main color to affect to the ground and the background
  51611. */
  51612. setMainColor(color: Color3): void;
  51613. /**
  51614. * Setup the image processing according to the specified options.
  51615. */
  51616. private _setupImageProcessing;
  51617. /**
  51618. * Setup the environment texture according to the specified options.
  51619. */
  51620. private _setupEnvironmentTexture;
  51621. /**
  51622. * Setup the background according to the specified options.
  51623. */
  51624. private _setupBackground;
  51625. /**
  51626. * Get the scene sizes according to the setup.
  51627. */
  51628. private _getSceneSize;
  51629. /**
  51630. * Setup the ground according to the specified options.
  51631. */
  51632. private _setupGround;
  51633. /**
  51634. * Setup the ground material according to the specified options.
  51635. */
  51636. private _setupGroundMaterial;
  51637. /**
  51638. * Setup the ground diffuse texture according to the specified options.
  51639. */
  51640. private _setupGroundDiffuseTexture;
  51641. /**
  51642. * Setup the ground mirror texture according to the specified options.
  51643. */
  51644. private _setupGroundMirrorTexture;
  51645. /**
  51646. * Setup the ground to receive the mirror texture.
  51647. */
  51648. private _setupMirrorInGroundMaterial;
  51649. /**
  51650. * Setup the skybox according to the specified options.
  51651. */
  51652. private _setupSkybox;
  51653. /**
  51654. * Setup the skybox material according to the specified options.
  51655. */
  51656. private _setupSkyboxMaterial;
  51657. /**
  51658. * Setup the skybox reflection texture according to the specified options.
  51659. */
  51660. private _setupSkyboxReflectionTexture;
  51661. private _errorHandler;
  51662. /**
  51663. * Dispose all the elements created by the Helper.
  51664. */
  51665. dispose(): void;
  51666. }
  51667. }
  51668. declare module "babylonjs/Helpers/photoDome" {
  51669. import { Observable } from "babylonjs/Misc/observable";
  51670. import { Nullable } from "babylonjs/types";
  51671. import { Scene } from "babylonjs/scene";
  51672. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51673. import { Mesh } from "babylonjs/Meshes/mesh";
  51674. import { Texture } from "babylonjs/Materials/Textures/texture";
  51675. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51676. import "babylonjs/Meshes/Builders/sphereBuilder";
  51677. /**
  51678. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51679. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51680. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51681. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51682. */
  51683. export class PhotoDome extends TransformNode {
  51684. /**
  51685. * Define the image as a Monoscopic panoramic 360 image.
  51686. */
  51687. static readonly MODE_MONOSCOPIC: number;
  51688. /**
  51689. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51690. */
  51691. static readonly MODE_TOPBOTTOM: number;
  51692. /**
  51693. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51694. */
  51695. static readonly MODE_SIDEBYSIDE: number;
  51696. private _useDirectMapping;
  51697. /**
  51698. * The texture being displayed on the sphere
  51699. */
  51700. protected _photoTexture: Texture;
  51701. /**
  51702. * Gets or sets the texture being displayed on the sphere
  51703. */
  51704. get photoTexture(): Texture;
  51705. set photoTexture(value: Texture);
  51706. /**
  51707. * Observable raised when an error occured while loading the 360 image
  51708. */
  51709. onLoadErrorObservable: Observable<string>;
  51710. /**
  51711. * The skybox material
  51712. */
  51713. protected _material: BackgroundMaterial;
  51714. /**
  51715. * The surface used for the skybox
  51716. */
  51717. protected _mesh: Mesh;
  51718. /**
  51719. * Gets the mesh used for the skybox.
  51720. */
  51721. get mesh(): Mesh;
  51722. /**
  51723. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51724. * Also see the options.resolution property.
  51725. */
  51726. get fovMultiplier(): number;
  51727. set fovMultiplier(value: number);
  51728. private _imageMode;
  51729. /**
  51730. * Gets or set the current video mode for the video. It can be:
  51731. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51732. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51733. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51734. */
  51735. get imageMode(): number;
  51736. set imageMode(value: number);
  51737. /**
  51738. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51739. * @param name Element's name, child elements will append suffixes for their own names.
  51740. * @param urlsOfPhoto defines the url of the photo to display
  51741. * @param options defines an object containing optional or exposed sub element properties
  51742. * @param onError defines a callback called when an error occured while loading the texture
  51743. */
  51744. constructor(name: string, urlOfPhoto: string, options: {
  51745. resolution?: number;
  51746. size?: number;
  51747. useDirectMapping?: boolean;
  51748. faceForward?: boolean;
  51749. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51750. private _onBeforeCameraRenderObserver;
  51751. private _changeImageMode;
  51752. /**
  51753. * Releases resources associated with this node.
  51754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51756. */
  51757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51758. }
  51759. }
  51760. declare module "babylonjs/Misc/rgbdTextureTools" {
  51761. import "babylonjs/Shaders/rgbdDecode.fragment";
  51762. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51763. import { Texture } from "babylonjs/Materials/Textures/texture";
  51764. /**
  51765. * Class used to host RGBD texture specific utilities
  51766. */
  51767. export class RGBDTextureTools {
  51768. /**
  51769. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51770. * @param texture the texture to expand.
  51771. */
  51772. static ExpandRGBDTexture(texture: Texture): void;
  51773. }
  51774. }
  51775. declare module "babylonjs/Misc/brdfTextureTools" {
  51776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51777. import { Scene } from "babylonjs/scene";
  51778. /**
  51779. * Class used to host texture specific utilities
  51780. */
  51781. export class BRDFTextureTools {
  51782. /**
  51783. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51784. * @param scene defines the hosting scene
  51785. * @returns the environment BRDF texture
  51786. */
  51787. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51788. private static _environmentBRDFBase64Texture;
  51789. }
  51790. }
  51791. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51792. import { Nullable } from "babylonjs/types";
  51793. import { Color3 } from "babylonjs/Maths/math.color";
  51794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51795. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51796. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51797. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51798. import { Engine } from "babylonjs/Engines/engine";
  51799. import { Scene } from "babylonjs/scene";
  51800. /**
  51801. * @hidden
  51802. */
  51803. export interface IMaterialClearCoatDefines {
  51804. CLEARCOAT: boolean;
  51805. CLEARCOAT_DEFAULTIOR: boolean;
  51806. CLEARCOAT_TEXTURE: boolean;
  51807. CLEARCOAT_TEXTUREDIRECTUV: number;
  51808. CLEARCOAT_BUMP: boolean;
  51809. CLEARCOAT_BUMPDIRECTUV: number;
  51810. CLEARCOAT_TINT: boolean;
  51811. CLEARCOAT_TINT_TEXTURE: boolean;
  51812. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51813. /** @hidden */
  51814. _areTexturesDirty: boolean;
  51815. }
  51816. /**
  51817. * Define the code related to the clear coat parameters of the pbr material.
  51818. */
  51819. export class PBRClearCoatConfiguration {
  51820. /**
  51821. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51822. * The default fits with a polyurethane material.
  51823. */
  51824. private static readonly _DefaultIndexOfRefraction;
  51825. private _isEnabled;
  51826. /**
  51827. * Defines if the clear coat is enabled in the material.
  51828. */
  51829. isEnabled: boolean;
  51830. /**
  51831. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51832. */
  51833. intensity: number;
  51834. /**
  51835. * Defines the clear coat layer roughness.
  51836. */
  51837. roughness: number;
  51838. private _indexOfRefraction;
  51839. /**
  51840. * Defines the index of refraction of the clear coat.
  51841. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51842. * The default fits with a polyurethane material.
  51843. * Changing the default value is more performance intensive.
  51844. */
  51845. indexOfRefraction: number;
  51846. private _texture;
  51847. /**
  51848. * Stores the clear coat values in a texture.
  51849. */
  51850. texture: Nullable<BaseTexture>;
  51851. private _bumpTexture;
  51852. /**
  51853. * Define the clear coat specific bump texture.
  51854. */
  51855. bumpTexture: Nullable<BaseTexture>;
  51856. private _isTintEnabled;
  51857. /**
  51858. * Defines if the clear coat tint is enabled in the material.
  51859. */
  51860. isTintEnabled: boolean;
  51861. /**
  51862. * Defines the clear coat tint of the material.
  51863. * This is only use if tint is enabled
  51864. */
  51865. tintColor: Color3;
  51866. /**
  51867. * Defines the distance at which the tint color should be found in the
  51868. * clear coat media.
  51869. * This is only use if tint is enabled
  51870. */
  51871. tintColorAtDistance: number;
  51872. /**
  51873. * Defines the clear coat layer thickness.
  51874. * This is only use if tint is enabled
  51875. */
  51876. tintThickness: number;
  51877. private _tintTexture;
  51878. /**
  51879. * Stores the clear tint values in a texture.
  51880. * rgb is tint
  51881. * a is a thickness factor
  51882. */
  51883. tintTexture: Nullable<BaseTexture>;
  51884. /** @hidden */
  51885. private _internalMarkAllSubMeshesAsTexturesDirty;
  51886. /** @hidden */
  51887. _markAllSubMeshesAsTexturesDirty(): void;
  51888. /**
  51889. * Instantiate a new istance of clear coat configuration.
  51890. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51891. */
  51892. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51893. /**
  51894. * Gets wehter the submesh is ready to be used or not.
  51895. * @param defines the list of "defines" to update.
  51896. * @param scene defines the scene the material belongs to.
  51897. * @param engine defines the engine the material belongs to.
  51898. * @param disableBumpMap defines wether the material disables bump or not.
  51899. * @returns - boolean indicating that the submesh is ready or not.
  51900. */
  51901. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51902. /**
  51903. * Checks to see if a texture is used in the material.
  51904. * @param defines the list of "defines" to update.
  51905. * @param scene defines the scene to the material belongs to.
  51906. */
  51907. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51908. /**
  51909. * Binds the material data.
  51910. * @param uniformBuffer defines the Uniform buffer to fill in.
  51911. * @param scene defines the scene the material belongs to.
  51912. * @param engine defines the engine the material belongs to.
  51913. * @param disableBumpMap defines wether the material disables bump or not.
  51914. * @param isFrozen defines wether the material is frozen or not.
  51915. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51916. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51917. */
  51918. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51919. /**
  51920. * Checks to see if a texture is used in the material.
  51921. * @param texture - Base texture to use.
  51922. * @returns - Boolean specifying if a texture is used in the material.
  51923. */
  51924. hasTexture(texture: BaseTexture): boolean;
  51925. /**
  51926. * Returns an array of the actively used textures.
  51927. * @param activeTextures Array of BaseTextures
  51928. */
  51929. getActiveTextures(activeTextures: BaseTexture[]): void;
  51930. /**
  51931. * Returns the animatable textures.
  51932. * @param animatables Array of animatable textures.
  51933. */
  51934. getAnimatables(animatables: IAnimatable[]): void;
  51935. /**
  51936. * Disposes the resources of the material.
  51937. * @param forceDisposeTextures - Forces the disposal of all textures.
  51938. */
  51939. dispose(forceDisposeTextures?: boolean): void;
  51940. /**
  51941. * Get the current class name of the texture useful for serialization or dynamic coding.
  51942. * @returns "PBRClearCoatConfiguration"
  51943. */
  51944. getClassName(): string;
  51945. /**
  51946. * Add fallbacks to the effect fallbacks list.
  51947. * @param defines defines the Base texture to use.
  51948. * @param fallbacks defines the current fallback list.
  51949. * @param currentRank defines the current fallback rank.
  51950. * @returns the new fallback rank.
  51951. */
  51952. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51953. /**
  51954. * Add the required uniforms to the current list.
  51955. * @param uniforms defines the current uniform list.
  51956. */
  51957. static AddUniforms(uniforms: string[]): void;
  51958. /**
  51959. * Add the required samplers to the current list.
  51960. * @param samplers defines the current sampler list.
  51961. */
  51962. static AddSamplers(samplers: string[]): void;
  51963. /**
  51964. * Add the required uniforms to the current buffer.
  51965. * @param uniformBuffer defines the current uniform buffer.
  51966. */
  51967. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51968. /**
  51969. * Makes a duplicate of the current configuration into another one.
  51970. * @param clearCoatConfiguration define the config where to copy the info
  51971. */
  51972. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51973. /**
  51974. * Serializes this clear coat configuration.
  51975. * @returns - An object with the serialized config.
  51976. */
  51977. serialize(): any;
  51978. /**
  51979. * Parses a anisotropy Configuration from a serialized object.
  51980. * @param source - Serialized object.
  51981. * @param scene Defines the scene we are parsing for
  51982. * @param rootUrl Defines the rootUrl to load from
  51983. */
  51984. parse(source: any, scene: Scene, rootUrl: string): void;
  51985. }
  51986. }
  51987. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51990. import { Vector2 } from "babylonjs/Maths/math.vector";
  51991. import { Scene } from "babylonjs/scene";
  51992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51993. import { Nullable } from "babylonjs/types";
  51994. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51995. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51996. /**
  51997. * @hidden
  51998. */
  51999. export interface IMaterialAnisotropicDefines {
  52000. ANISOTROPIC: boolean;
  52001. ANISOTROPIC_TEXTURE: boolean;
  52002. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52003. MAINUV1: boolean;
  52004. _areTexturesDirty: boolean;
  52005. _needUVs: boolean;
  52006. }
  52007. /**
  52008. * Define the code related to the anisotropic parameters of the pbr material.
  52009. */
  52010. export class PBRAnisotropicConfiguration {
  52011. private _isEnabled;
  52012. /**
  52013. * Defines if the anisotropy is enabled in the material.
  52014. */
  52015. isEnabled: boolean;
  52016. /**
  52017. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52018. */
  52019. intensity: number;
  52020. /**
  52021. * Defines if the effect is along the tangents, bitangents or in between.
  52022. * By default, the effect is "strectching" the highlights along the tangents.
  52023. */
  52024. direction: Vector2;
  52025. private _texture;
  52026. /**
  52027. * Stores the anisotropy values in a texture.
  52028. * rg is direction (like normal from -1 to 1)
  52029. * b is a intensity
  52030. */
  52031. texture: Nullable<BaseTexture>;
  52032. /** @hidden */
  52033. private _internalMarkAllSubMeshesAsTexturesDirty;
  52034. /** @hidden */
  52035. _markAllSubMeshesAsTexturesDirty(): void;
  52036. /**
  52037. * Instantiate a new istance of anisotropy configuration.
  52038. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52039. */
  52040. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52041. /**
  52042. * Specifies that the submesh is ready to be used.
  52043. * @param defines the list of "defines" to update.
  52044. * @param scene defines the scene the material belongs to.
  52045. * @returns - boolean indicating that the submesh is ready or not.
  52046. */
  52047. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52048. /**
  52049. * Checks to see if a texture is used in the material.
  52050. * @param defines the list of "defines" to update.
  52051. * @param mesh the mesh we are preparing the defines for.
  52052. * @param scene defines the scene the material belongs to.
  52053. */
  52054. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52055. /**
  52056. * Binds the material data.
  52057. * @param uniformBuffer defines the Uniform buffer to fill in.
  52058. * @param scene defines the scene the material belongs to.
  52059. * @param isFrozen defines wether the material is frozen or not.
  52060. */
  52061. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52062. /**
  52063. * Checks to see if a texture is used in the material.
  52064. * @param texture - Base texture to use.
  52065. * @returns - Boolean specifying if a texture is used in the material.
  52066. */
  52067. hasTexture(texture: BaseTexture): boolean;
  52068. /**
  52069. * Returns an array of the actively used textures.
  52070. * @param activeTextures Array of BaseTextures
  52071. */
  52072. getActiveTextures(activeTextures: BaseTexture[]): void;
  52073. /**
  52074. * Returns the animatable textures.
  52075. * @param animatables Array of animatable textures.
  52076. */
  52077. getAnimatables(animatables: IAnimatable[]): void;
  52078. /**
  52079. * Disposes the resources of the material.
  52080. * @param forceDisposeTextures - Forces the disposal of all textures.
  52081. */
  52082. dispose(forceDisposeTextures?: boolean): void;
  52083. /**
  52084. * Get the current class name of the texture useful for serialization or dynamic coding.
  52085. * @returns "PBRAnisotropicConfiguration"
  52086. */
  52087. getClassName(): string;
  52088. /**
  52089. * Add fallbacks to the effect fallbacks list.
  52090. * @param defines defines the Base texture to use.
  52091. * @param fallbacks defines the current fallback list.
  52092. * @param currentRank defines the current fallback rank.
  52093. * @returns the new fallback rank.
  52094. */
  52095. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52096. /**
  52097. * Add the required uniforms to the current list.
  52098. * @param uniforms defines the current uniform list.
  52099. */
  52100. static AddUniforms(uniforms: string[]): void;
  52101. /**
  52102. * Add the required uniforms to the current buffer.
  52103. * @param uniformBuffer defines the current uniform buffer.
  52104. */
  52105. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52106. /**
  52107. * Add the required samplers to the current list.
  52108. * @param samplers defines the current sampler list.
  52109. */
  52110. static AddSamplers(samplers: string[]): void;
  52111. /**
  52112. * Makes a duplicate of the current configuration into another one.
  52113. * @param anisotropicConfiguration define the config where to copy the info
  52114. */
  52115. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52116. /**
  52117. * Serializes this anisotropy configuration.
  52118. * @returns - An object with the serialized config.
  52119. */
  52120. serialize(): any;
  52121. /**
  52122. * Parses a anisotropy Configuration from a serialized object.
  52123. * @param source - Serialized object.
  52124. * @param scene Defines the scene we are parsing for
  52125. * @param rootUrl Defines the rootUrl to load from
  52126. */
  52127. parse(source: any, scene: Scene, rootUrl: string): void;
  52128. }
  52129. }
  52130. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52131. import { Scene } from "babylonjs/scene";
  52132. /**
  52133. * @hidden
  52134. */
  52135. export interface IMaterialBRDFDefines {
  52136. BRDF_V_HEIGHT_CORRELATED: boolean;
  52137. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52138. SPHERICAL_HARMONICS: boolean;
  52139. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52140. /** @hidden */
  52141. _areMiscDirty: boolean;
  52142. }
  52143. /**
  52144. * Define the code related to the BRDF parameters of the pbr material.
  52145. */
  52146. export class PBRBRDFConfiguration {
  52147. /**
  52148. * Default value used for the energy conservation.
  52149. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52150. */
  52151. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52152. /**
  52153. * Default value used for the Smith Visibility Height Correlated mode.
  52154. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52155. */
  52156. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52157. /**
  52158. * Default value used for the IBL diffuse part.
  52159. * This can help switching back to the polynomials mode globally which is a tiny bit
  52160. * less GPU intensive at the drawback of a lower quality.
  52161. */
  52162. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52163. /**
  52164. * Default value used for activating energy conservation for the specular workflow.
  52165. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52166. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52167. */
  52168. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52169. private _useEnergyConservation;
  52170. /**
  52171. * Defines if the material uses energy conservation.
  52172. */
  52173. useEnergyConservation: boolean;
  52174. private _useSmithVisibilityHeightCorrelated;
  52175. /**
  52176. * LEGACY Mode set to false
  52177. * Defines if the material uses height smith correlated visibility term.
  52178. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52179. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52180. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52181. * Not relying on height correlated will also disable energy conservation.
  52182. */
  52183. useSmithVisibilityHeightCorrelated: boolean;
  52184. private _useSphericalHarmonics;
  52185. /**
  52186. * LEGACY Mode set to false
  52187. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52188. * diffuse part of the IBL.
  52189. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52190. * to the ground truth.
  52191. */
  52192. useSphericalHarmonics: boolean;
  52193. private _useSpecularGlossinessInputEnergyConservation;
  52194. /**
  52195. * Defines if the material uses energy conservation, when the specular workflow is active.
  52196. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52197. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52198. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52199. */
  52200. useSpecularGlossinessInputEnergyConservation: boolean;
  52201. /** @hidden */
  52202. private _internalMarkAllSubMeshesAsMiscDirty;
  52203. /** @hidden */
  52204. _markAllSubMeshesAsMiscDirty(): void;
  52205. /**
  52206. * Instantiate a new istance of clear coat configuration.
  52207. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52208. */
  52209. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52210. /**
  52211. * Checks to see if a texture is used in the material.
  52212. * @param defines the list of "defines" to update.
  52213. */
  52214. prepareDefines(defines: IMaterialBRDFDefines): void;
  52215. /**
  52216. * Get the current class name of the texture useful for serialization or dynamic coding.
  52217. * @returns "PBRClearCoatConfiguration"
  52218. */
  52219. getClassName(): string;
  52220. /**
  52221. * Makes a duplicate of the current configuration into another one.
  52222. * @param brdfConfiguration define the config where to copy the info
  52223. */
  52224. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52225. /**
  52226. * Serializes this BRDF configuration.
  52227. * @returns - An object with the serialized config.
  52228. */
  52229. serialize(): any;
  52230. /**
  52231. * Parses a anisotropy Configuration from a serialized object.
  52232. * @param source - Serialized object.
  52233. * @param scene Defines the scene we are parsing for
  52234. * @param rootUrl Defines the rootUrl to load from
  52235. */
  52236. parse(source: any, scene: Scene, rootUrl: string): void;
  52237. }
  52238. }
  52239. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52240. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52241. import { Color3 } from "babylonjs/Maths/math.color";
  52242. import { Scene } from "babylonjs/scene";
  52243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52244. import { Nullable } from "babylonjs/types";
  52245. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52246. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52247. /**
  52248. * @hidden
  52249. */
  52250. export interface IMaterialSheenDefines {
  52251. SHEEN: boolean;
  52252. SHEEN_TEXTURE: boolean;
  52253. SHEEN_TEXTUREDIRECTUV: number;
  52254. SHEEN_LINKWITHALBEDO: boolean;
  52255. /** @hidden */
  52256. _areTexturesDirty: boolean;
  52257. }
  52258. /**
  52259. * Define the code related to the Sheen parameters of the pbr material.
  52260. */
  52261. export class PBRSheenConfiguration {
  52262. private _isEnabled;
  52263. /**
  52264. * Defines if the material uses sheen.
  52265. */
  52266. isEnabled: boolean;
  52267. private _linkSheenWithAlbedo;
  52268. /**
  52269. * Defines if the sheen is linked to the sheen color.
  52270. */
  52271. linkSheenWithAlbedo: boolean;
  52272. /**
  52273. * Defines the sheen intensity.
  52274. */
  52275. intensity: number;
  52276. /**
  52277. * Defines the sheen color.
  52278. */
  52279. color: Color3;
  52280. private _texture;
  52281. /**
  52282. * Stores the sheen tint values in a texture.
  52283. * rgb is tint
  52284. * a is a intensity
  52285. */
  52286. texture: Nullable<BaseTexture>;
  52287. /** @hidden */
  52288. private _internalMarkAllSubMeshesAsTexturesDirty;
  52289. /** @hidden */
  52290. _markAllSubMeshesAsTexturesDirty(): void;
  52291. /**
  52292. * Instantiate a new istance of clear coat configuration.
  52293. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52294. */
  52295. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52296. /**
  52297. * Specifies that the submesh is ready to be used.
  52298. * @param defines the list of "defines" to update.
  52299. * @param scene defines the scene the material belongs to.
  52300. * @returns - boolean indicating that the submesh is ready or not.
  52301. */
  52302. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52303. /**
  52304. * Checks to see if a texture is used in the material.
  52305. * @param defines the list of "defines" to update.
  52306. * @param scene defines the scene the material belongs to.
  52307. */
  52308. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52309. /**
  52310. * Binds the material data.
  52311. * @param uniformBuffer defines the Uniform buffer to fill in.
  52312. * @param scene defines the scene the material belongs to.
  52313. * @param isFrozen defines wether the material is frozen or not.
  52314. */
  52315. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52316. /**
  52317. * Checks to see if a texture is used in the material.
  52318. * @param texture - Base texture to use.
  52319. * @returns - Boolean specifying if a texture is used in the material.
  52320. */
  52321. hasTexture(texture: BaseTexture): boolean;
  52322. /**
  52323. * Returns an array of the actively used textures.
  52324. * @param activeTextures Array of BaseTextures
  52325. */
  52326. getActiveTextures(activeTextures: BaseTexture[]): void;
  52327. /**
  52328. * Returns the animatable textures.
  52329. * @param animatables Array of animatable textures.
  52330. */
  52331. getAnimatables(animatables: IAnimatable[]): void;
  52332. /**
  52333. * Disposes the resources of the material.
  52334. * @param forceDisposeTextures - Forces the disposal of all textures.
  52335. */
  52336. dispose(forceDisposeTextures?: boolean): void;
  52337. /**
  52338. * Get the current class name of the texture useful for serialization or dynamic coding.
  52339. * @returns "PBRSheenConfiguration"
  52340. */
  52341. getClassName(): string;
  52342. /**
  52343. * Add fallbacks to the effect fallbacks list.
  52344. * @param defines defines the Base texture to use.
  52345. * @param fallbacks defines the current fallback list.
  52346. * @param currentRank defines the current fallback rank.
  52347. * @returns the new fallback rank.
  52348. */
  52349. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52350. /**
  52351. * Add the required uniforms to the current list.
  52352. * @param uniforms defines the current uniform list.
  52353. */
  52354. static AddUniforms(uniforms: string[]): void;
  52355. /**
  52356. * Add the required uniforms to the current buffer.
  52357. * @param uniformBuffer defines the current uniform buffer.
  52358. */
  52359. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52360. /**
  52361. * Add the required samplers to the current list.
  52362. * @param samplers defines the current sampler list.
  52363. */
  52364. static AddSamplers(samplers: string[]): void;
  52365. /**
  52366. * Makes a duplicate of the current configuration into another one.
  52367. * @param sheenConfiguration define the config where to copy the info
  52368. */
  52369. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52370. /**
  52371. * Serializes this BRDF configuration.
  52372. * @returns - An object with the serialized config.
  52373. */
  52374. serialize(): any;
  52375. /**
  52376. * Parses a anisotropy Configuration from a serialized object.
  52377. * @param source - Serialized object.
  52378. * @param scene Defines the scene we are parsing for
  52379. * @param rootUrl Defines the rootUrl to load from
  52380. */
  52381. parse(source: any, scene: Scene, rootUrl: string): void;
  52382. }
  52383. }
  52384. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52385. import { Nullable } from "babylonjs/types";
  52386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52387. import { Color3 } from "babylonjs/Maths/math.color";
  52388. import { SmartArray } from "babylonjs/Misc/smartArray";
  52389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52390. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52391. import { Effect } from "babylonjs/Materials/effect";
  52392. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52393. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52394. import { Engine } from "babylonjs/Engines/engine";
  52395. import { Scene } from "babylonjs/scene";
  52396. /**
  52397. * @hidden
  52398. */
  52399. export interface IMaterialSubSurfaceDefines {
  52400. SUBSURFACE: boolean;
  52401. SS_REFRACTION: boolean;
  52402. SS_TRANSLUCENCY: boolean;
  52403. SS_SCATERRING: boolean;
  52404. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52405. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52406. SS_REFRACTIONMAP_3D: boolean;
  52407. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52408. SS_LODINREFRACTIONALPHA: boolean;
  52409. SS_GAMMAREFRACTION: boolean;
  52410. SS_RGBDREFRACTION: boolean;
  52411. SS_LINEARSPECULARREFRACTION: boolean;
  52412. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52413. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52414. /** @hidden */
  52415. _areTexturesDirty: boolean;
  52416. }
  52417. /**
  52418. * Define the code related to the sub surface parameters of the pbr material.
  52419. */
  52420. export class PBRSubSurfaceConfiguration {
  52421. private _isRefractionEnabled;
  52422. /**
  52423. * Defines if the refraction is enabled in the material.
  52424. */
  52425. isRefractionEnabled: boolean;
  52426. private _isTranslucencyEnabled;
  52427. /**
  52428. * Defines if the translucency is enabled in the material.
  52429. */
  52430. isTranslucencyEnabled: boolean;
  52431. private _isScatteringEnabled;
  52432. /**
  52433. * Defines the refraction intensity of the material.
  52434. * The refraction when enabled replaces the Diffuse part of the material.
  52435. * The intensity helps transitionning between diffuse and refraction.
  52436. */
  52437. refractionIntensity: number;
  52438. /**
  52439. * Defines the translucency intensity of the material.
  52440. * When translucency has been enabled, this defines how much of the "translucency"
  52441. * is addded to the diffuse part of the material.
  52442. */
  52443. translucencyIntensity: number;
  52444. /**
  52445. * Defines the scattering intensity of the material.
  52446. * When scattering has been enabled, this defines how much of the "scattered light"
  52447. * is addded to the diffuse part of the material.
  52448. */
  52449. scatteringIntensity: number;
  52450. private _thicknessTexture;
  52451. /**
  52452. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52453. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52454. * 0 would mean minimumThickness
  52455. * 1 would mean maximumThickness
  52456. * The other channels might be use as a mask to vary the different effects intensity.
  52457. */
  52458. thicknessTexture: Nullable<BaseTexture>;
  52459. private _refractionTexture;
  52460. /**
  52461. * Defines the texture to use for refraction.
  52462. */
  52463. refractionTexture: Nullable<BaseTexture>;
  52464. private _indexOfRefraction;
  52465. /**
  52466. * Defines the index of refraction used in the material.
  52467. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52468. */
  52469. indexOfRefraction: number;
  52470. private _invertRefractionY;
  52471. /**
  52472. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52473. */
  52474. invertRefractionY: boolean;
  52475. private _linkRefractionWithTransparency;
  52476. /**
  52477. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52478. * Materials half opaque for instance using refraction could benefit from this control.
  52479. */
  52480. linkRefractionWithTransparency: boolean;
  52481. /**
  52482. * Defines the minimum thickness stored in the thickness map.
  52483. * If no thickness map is defined, this value will be used to simulate thickness.
  52484. */
  52485. minimumThickness: number;
  52486. /**
  52487. * Defines the maximum thickness stored in the thickness map.
  52488. */
  52489. maximumThickness: number;
  52490. /**
  52491. * Defines the volume tint of the material.
  52492. * This is used for both translucency and scattering.
  52493. */
  52494. tintColor: Color3;
  52495. /**
  52496. * Defines the distance at which the tint color should be found in the media.
  52497. * This is used for refraction only.
  52498. */
  52499. tintColorAtDistance: number;
  52500. /**
  52501. * Defines how far each channel transmit through the media.
  52502. * It is defined as a color to simplify it selection.
  52503. */
  52504. diffusionDistance: Color3;
  52505. private _useMaskFromThicknessTexture;
  52506. /**
  52507. * Stores the intensity of the different subsurface effects in the thickness texture.
  52508. * * the green channel is the translucency intensity.
  52509. * * the blue channel is the scattering intensity.
  52510. * * the alpha channel is the refraction intensity.
  52511. */
  52512. useMaskFromThicknessTexture: boolean;
  52513. /** @hidden */
  52514. private _internalMarkAllSubMeshesAsTexturesDirty;
  52515. /** @hidden */
  52516. _markAllSubMeshesAsTexturesDirty(): void;
  52517. /**
  52518. * Instantiate a new istance of sub surface configuration.
  52519. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52520. */
  52521. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52522. /**
  52523. * Gets wehter the submesh is ready to be used or not.
  52524. * @param defines the list of "defines" to update.
  52525. * @param scene defines the scene the material belongs to.
  52526. * @returns - boolean indicating that the submesh is ready or not.
  52527. */
  52528. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52529. /**
  52530. * Checks to see if a texture is used in the material.
  52531. * @param defines the list of "defines" to update.
  52532. * @param scene defines the scene to the material belongs to.
  52533. */
  52534. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52535. /**
  52536. * Binds the material data.
  52537. * @param uniformBuffer defines the Uniform buffer to fill in.
  52538. * @param scene defines the scene the material belongs to.
  52539. * @param engine defines the engine the material belongs to.
  52540. * @param isFrozen defines wether the material is frozen or not.
  52541. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52542. */
  52543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52544. /**
  52545. * Unbinds the material from the mesh.
  52546. * @param activeEffect defines the effect that should be unbound from.
  52547. * @returns true if unbound, otherwise false
  52548. */
  52549. unbind(activeEffect: Effect): boolean;
  52550. /**
  52551. * Returns the texture used for refraction or null if none is used.
  52552. * @param scene defines the scene the material belongs to.
  52553. * @returns - Refraction texture if present. If no refraction texture and refraction
  52554. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52555. */
  52556. private _getRefractionTexture;
  52557. /**
  52558. * Returns true if alpha blending should be disabled.
  52559. */
  52560. get disableAlphaBlending(): boolean;
  52561. /**
  52562. * Fills the list of render target textures.
  52563. * @param renderTargets the list of render targets to update
  52564. */
  52565. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52566. /**
  52567. * Checks to see if a texture is used in the material.
  52568. * @param texture - Base texture to use.
  52569. * @returns - Boolean specifying if a texture is used in the material.
  52570. */
  52571. hasTexture(texture: BaseTexture): boolean;
  52572. /**
  52573. * Gets a boolean indicating that current material needs to register RTT
  52574. * @returns true if this uses a render target otherwise false.
  52575. */
  52576. hasRenderTargetTextures(): boolean;
  52577. /**
  52578. * Returns an array of the actively used textures.
  52579. * @param activeTextures Array of BaseTextures
  52580. */
  52581. getActiveTextures(activeTextures: BaseTexture[]): void;
  52582. /**
  52583. * Returns the animatable textures.
  52584. * @param animatables Array of animatable textures.
  52585. */
  52586. getAnimatables(animatables: IAnimatable[]): void;
  52587. /**
  52588. * Disposes the resources of the material.
  52589. * @param forceDisposeTextures - Forces the disposal of all textures.
  52590. */
  52591. dispose(forceDisposeTextures?: boolean): void;
  52592. /**
  52593. * Get the current class name of the texture useful for serialization or dynamic coding.
  52594. * @returns "PBRSubSurfaceConfiguration"
  52595. */
  52596. getClassName(): string;
  52597. /**
  52598. * Add fallbacks to the effect fallbacks list.
  52599. * @param defines defines the Base texture to use.
  52600. * @param fallbacks defines the current fallback list.
  52601. * @param currentRank defines the current fallback rank.
  52602. * @returns the new fallback rank.
  52603. */
  52604. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52605. /**
  52606. * Add the required uniforms to the current list.
  52607. * @param uniforms defines the current uniform list.
  52608. */
  52609. static AddUniforms(uniforms: string[]): void;
  52610. /**
  52611. * Add the required samplers to the current list.
  52612. * @param samplers defines the current sampler list.
  52613. */
  52614. static AddSamplers(samplers: string[]): void;
  52615. /**
  52616. * Add the required uniforms to the current buffer.
  52617. * @param uniformBuffer defines the current uniform buffer.
  52618. */
  52619. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52620. /**
  52621. * Makes a duplicate of the current configuration into another one.
  52622. * @param configuration define the config where to copy the info
  52623. */
  52624. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52625. /**
  52626. * Serializes this Sub Surface configuration.
  52627. * @returns - An object with the serialized config.
  52628. */
  52629. serialize(): any;
  52630. /**
  52631. * Parses a anisotropy Configuration from a serialized object.
  52632. * @param source - Serialized object.
  52633. * @param scene Defines the scene we are parsing for
  52634. * @param rootUrl Defines the rootUrl to load from
  52635. */
  52636. parse(source: any, scene: Scene, rootUrl: string): void;
  52637. }
  52638. }
  52639. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52640. /** @hidden */
  52641. export var pbrFragmentDeclaration: {
  52642. name: string;
  52643. shader: string;
  52644. };
  52645. }
  52646. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52647. /** @hidden */
  52648. export var pbrUboDeclaration: {
  52649. name: string;
  52650. shader: string;
  52651. };
  52652. }
  52653. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52654. /** @hidden */
  52655. export var pbrFragmentExtraDeclaration: {
  52656. name: string;
  52657. shader: string;
  52658. };
  52659. }
  52660. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52661. /** @hidden */
  52662. export var pbrFragmentSamplersDeclaration: {
  52663. name: string;
  52664. shader: string;
  52665. };
  52666. }
  52667. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52668. /** @hidden */
  52669. export var pbrHelperFunctions: {
  52670. name: string;
  52671. shader: string;
  52672. };
  52673. }
  52674. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52675. /** @hidden */
  52676. export var harmonicsFunctions: {
  52677. name: string;
  52678. shader: string;
  52679. };
  52680. }
  52681. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52682. /** @hidden */
  52683. export var pbrDirectLightingSetupFunctions: {
  52684. name: string;
  52685. shader: string;
  52686. };
  52687. }
  52688. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52689. /** @hidden */
  52690. export var pbrDirectLightingFalloffFunctions: {
  52691. name: string;
  52692. shader: string;
  52693. };
  52694. }
  52695. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52696. /** @hidden */
  52697. export var pbrBRDFFunctions: {
  52698. name: string;
  52699. shader: string;
  52700. };
  52701. }
  52702. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52703. /** @hidden */
  52704. export var pbrDirectLightingFunctions: {
  52705. name: string;
  52706. shader: string;
  52707. };
  52708. }
  52709. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52710. /** @hidden */
  52711. export var pbrIBLFunctions: {
  52712. name: string;
  52713. shader: string;
  52714. };
  52715. }
  52716. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52717. /** @hidden */
  52718. export var pbrDebug: {
  52719. name: string;
  52720. shader: string;
  52721. };
  52722. }
  52723. declare module "babylonjs/Shaders/pbr.fragment" {
  52724. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52725. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52726. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52727. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52728. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52729. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52730. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52731. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52732. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52733. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52734. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52735. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52736. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52737. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52738. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52739. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52740. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52741. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52742. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52743. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52744. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52745. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52746. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52747. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52748. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52749. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52750. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52751. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52752. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52753. /** @hidden */
  52754. export var pbrPixelShader: {
  52755. name: string;
  52756. shader: string;
  52757. };
  52758. }
  52759. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52760. /** @hidden */
  52761. export var pbrVertexDeclaration: {
  52762. name: string;
  52763. shader: string;
  52764. };
  52765. }
  52766. declare module "babylonjs/Shaders/pbr.vertex" {
  52767. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52768. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52769. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52770. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52771. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52772. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52773. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52775. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52776. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52777. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52779. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52780. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52782. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52783. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52784. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52785. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52786. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52787. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52788. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52789. /** @hidden */
  52790. export var pbrVertexShader: {
  52791. name: string;
  52792. shader: string;
  52793. };
  52794. }
  52795. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52796. import { Nullable } from "babylonjs/types";
  52797. import { Scene } from "babylonjs/scene";
  52798. import { Matrix } from "babylonjs/Maths/math.vector";
  52799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52801. import { Mesh } from "babylonjs/Meshes/mesh";
  52802. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52803. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52804. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52805. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52806. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52807. import { Color3 } from "babylonjs/Maths/math.color";
  52808. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52809. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52810. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52811. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52813. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52814. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52815. import "babylonjs/Shaders/pbr.fragment";
  52816. import "babylonjs/Shaders/pbr.vertex";
  52817. /**
  52818. * Manages the defines for the PBR Material.
  52819. * @hidden
  52820. */
  52821. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52822. PBR: boolean;
  52823. MAINUV1: boolean;
  52824. MAINUV2: boolean;
  52825. UV1: boolean;
  52826. UV2: boolean;
  52827. ALBEDO: boolean;
  52828. ALBEDODIRECTUV: number;
  52829. VERTEXCOLOR: boolean;
  52830. AMBIENT: boolean;
  52831. AMBIENTDIRECTUV: number;
  52832. AMBIENTINGRAYSCALE: boolean;
  52833. OPACITY: boolean;
  52834. VERTEXALPHA: boolean;
  52835. OPACITYDIRECTUV: number;
  52836. OPACITYRGB: boolean;
  52837. ALPHATEST: boolean;
  52838. DEPTHPREPASS: boolean;
  52839. ALPHABLEND: boolean;
  52840. ALPHAFROMALBEDO: boolean;
  52841. ALPHATESTVALUE: string;
  52842. SPECULAROVERALPHA: boolean;
  52843. RADIANCEOVERALPHA: boolean;
  52844. ALPHAFRESNEL: boolean;
  52845. LINEARALPHAFRESNEL: boolean;
  52846. PREMULTIPLYALPHA: boolean;
  52847. EMISSIVE: boolean;
  52848. EMISSIVEDIRECTUV: number;
  52849. REFLECTIVITY: boolean;
  52850. REFLECTIVITYDIRECTUV: number;
  52851. SPECULARTERM: boolean;
  52852. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52853. MICROSURFACEAUTOMATIC: boolean;
  52854. LODBASEDMICROSFURACE: boolean;
  52855. MICROSURFACEMAP: boolean;
  52856. MICROSURFACEMAPDIRECTUV: number;
  52857. METALLICWORKFLOW: boolean;
  52858. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52859. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52860. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52861. AOSTOREINMETALMAPRED: boolean;
  52862. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52863. ENVIRONMENTBRDF: boolean;
  52864. ENVIRONMENTBRDF_RGBD: boolean;
  52865. NORMAL: boolean;
  52866. TANGENT: boolean;
  52867. BUMP: boolean;
  52868. BUMPDIRECTUV: number;
  52869. OBJECTSPACE_NORMALMAP: boolean;
  52870. PARALLAX: boolean;
  52871. PARALLAXOCCLUSION: boolean;
  52872. NORMALXYSCALE: boolean;
  52873. LIGHTMAP: boolean;
  52874. LIGHTMAPDIRECTUV: number;
  52875. USELIGHTMAPASSHADOWMAP: boolean;
  52876. GAMMALIGHTMAP: boolean;
  52877. RGBDLIGHTMAP: boolean;
  52878. REFLECTION: boolean;
  52879. REFLECTIONMAP_3D: boolean;
  52880. REFLECTIONMAP_SPHERICAL: boolean;
  52881. REFLECTIONMAP_PLANAR: boolean;
  52882. REFLECTIONMAP_CUBIC: boolean;
  52883. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52884. REFLECTIONMAP_PROJECTION: boolean;
  52885. REFLECTIONMAP_SKYBOX: boolean;
  52886. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52887. REFLECTIONMAP_EXPLICIT: boolean;
  52888. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52889. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52890. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52891. INVERTCUBICMAP: boolean;
  52892. USESPHERICALFROMREFLECTIONMAP: boolean;
  52893. USEIRRADIANCEMAP: boolean;
  52894. SPHERICAL_HARMONICS: boolean;
  52895. USESPHERICALINVERTEX: boolean;
  52896. REFLECTIONMAP_OPPOSITEZ: boolean;
  52897. LODINREFLECTIONALPHA: boolean;
  52898. GAMMAREFLECTION: boolean;
  52899. RGBDREFLECTION: boolean;
  52900. LINEARSPECULARREFLECTION: boolean;
  52901. RADIANCEOCCLUSION: boolean;
  52902. HORIZONOCCLUSION: boolean;
  52903. INSTANCES: boolean;
  52904. NUM_BONE_INFLUENCERS: number;
  52905. BonesPerMesh: number;
  52906. BONETEXTURE: boolean;
  52907. NONUNIFORMSCALING: boolean;
  52908. MORPHTARGETS: boolean;
  52909. MORPHTARGETS_NORMAL: boolean;
  52910. MORPHTARGETS_TANGENT: boolean;
  52911. MORPHTARGETS_UV: boolean;
  52912. NUM_MORPH_INFLUENCERS: number;
  52913. IMAGEPROCESSING: boolean;
  52914. VIGNETTE: boolean;
  52915. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52916. VIGNETTEBLENDMODEOPAQUE: boolean;
  52917. TONEMAPPING: boolean;
  52918. TONEMAPPING_ACES: boolean;
  52919. CONTRAST: boolean;
  52920. COLORCURVES: boolean;
  52921. COLORGRADING: boolean;
  52922. COLORGRADING3D: boolean;
  52923. SAMPLER3DGREENDEPTH: boolean;
  52924. SAMPLER3DBGRMAP: boolean;
  52925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52926. EXPOSURE: boolean;
  52927. MULTIVIEW: boolean;
  52928. USEPHYSICALLIGHTFALLOFF: boolean;
  52929. USEGLTFLIGHTFALLOFF: boolean;
  52930. TWOSIDEDLIGHTING: boolean;
  52931. SHADOWFLOAT: boolean;
  52932. CLIPPLANE: boolean;
  52933. CLIPPLANE2: boolean;
  52934. CLIPPLANE3: boolean;
  52935. CLIPPLANE4: boolean;
  52936. CLIPPLANE5: boolean;
  52937. CLIPPLANE6: boolean;
  52938. POINTSIZE: boolean;
  52939. FOG: boolean;
  52940. LOGARITHMICDEPTH: boolean;
  52941. FORCENORMALFORWARD: boolean;
  52942. SPECULARAA: boolean;
  52943. CLEARCOAT: boolean;
  52944. CLEARCOAT_DEFAULTIOR: boolean;
  52945. CLEARCOAT_TEXTURE: boolean;
  52946. CLEARCOAT_TEXTUREDIRECTUV: number;
  52947. CLEARCOAT_BUMP: boolean;
  52948. CLEARCOAT_BUMPDIRECTUV: number;
  52949. CLEARCOAT_TINT: boolean;
  52950. CLEARCOAT_TINT_TEXTURE: boolean;
  52951. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52952. ANISOTROPIC: boolean;
  52953. ANISOTROPIC_TEXTURE: boolean;
  52954. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52955. BRDF_V_HEIGHT_CORRELATED: boolean;
  52956. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52957. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52958. SHEEN: boolean;
  52959. SHEEN_TEXTURE: boolean;
  52960. SHEEN_TEXTUREDIRECTUV: number;
  52961. SHEEN_LINKWITHALBEDO: boolean;
  52962. SUBSURFACE: boolean;
  52963. SS_REFRACTION: boolean;
  52964. SS_TRANSLUCENCY: boolean;
  52965. SS_SCATERRING: boolean;
  52966. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52967. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52968. SS_REFRACTIONMAP_3D: boolean;
  52969. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52970. SS_LODINREFRACTIONALPHA: boolean;
  52971. SS_GAMMAREFRACTION: boolean;
  52972. SS_RGBDREFRACTION: boolean;
  52973. SS_LINEARSPECULARREFRACTION: boolean;
  52974. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52975. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52976. UNLIT: boolean;
  52977. DEBUGMODE: number;
  52978. /**
  52979. * Initializes the PBR Material defines.
  52980. */
  52981. constructor();
  52982. /**
  52983. * Resets the PBR Material defines.
  52984. */
  52985. reset(): void;
  52986. }
  52987. /**
  52988. * The Physically based material base class of BJS.
  52989. *
  52990. * This offers the main features of a standard PBR material.
  52991. * For more information, please refer to the documentation :
  52992. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52993. */
  52994. export abstract class PBRBaseMaterial extends PushMaterial {
  52995. /**
  52996. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52997. */
  52998. static readonly PBRMATERIAL_OPAQUE: number;
  52999. /**
  53000. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53001. */
  53002. static readonly PBRMATERIAL_ALPHATEST: number;
  53003. /**
  53004. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53005. */
  53006. static readonly PBRMATERIAL_ALPHABLEND: number;
  53007. /**
  53008. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53009. * They are also discarded below the alpha cutoff threshold to improve performances.
  53010. */
  53011. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53012. /**
  53013. * Defines the default value of how much AO map is occluding the analytical lights
  53014. * (point spot...).
  53015. */
  53016. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53017. /**
  53018. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53019. */
  53020. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53021. /**
  53022. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53023. * to enhance interoperability with other engines.
  53024. */
  53025. static readonly LIGHTFALLOFF_GLTF: number;
  53026. /**
  53027. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53028. * to enhance interoperability with other materials.
  53029. */
  53030. static readonly LIGHTFALLOFF_STANDARD: number;
  53031. /**
  53032. * Intensity of the direct lights e.g. the four lights available in your scene.
  53033. * This impacts both the direct diffuse and specular highlights.
  53034. */
  53035. protected _directIntensity: number;
  53036. /**
  53037. * Intensity of the emissive part of the material.
  53038. * This helps controlling the emissive effect without modifying the emissive color.
  53039. */
  53040. protected _emissiveIntensity: number;
  53041. /**
  53042. * Intensity of the environment e.g. how much the environment will light the object
  53043. * either through harmonics for rough material or through the refelction for shiny ones.
  53044. */
  53045. protected _environmentIntensity: number;
  53046. /**
  53047. * This is a special control allowing the reduction of the specular highlights coming from the
  53048. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53049. */
  53050. protected _specularIntensity: number;
  53051. /**
  53052. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53053. */
  53054. private _lightingInfos;
  53055. /**
  53056. * Debug Control allowing disabling the bump map on this material.
  53057. */
  53058. protected _disableBumpMap: boolean;
  53059. /**
  53060. * AKA Diffuse Texture in standard nomenclature.
  53061. */
  53062. protected _albedoTexture: Nullable<BaseTexture>;
  53063. /**
  53064. * AKA Occlusion Texture in other nomenclature.
  53065. */
  53066. protected _ambientTexture: Nullable<BaseTexture>;
  53067. /**
  53068. * AKA Occlusion Texture Intensity in other nomenclature.
  53069. */
  53070. protected _ambientTextureStrength: number;
  53071. /**
  53072. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53073. * 1 means it completely occludes it
  53074. * 0 mean it has no impact
  53075. */
  53076. protected _ambientTextureImpactOnAnalyticalLights: number;
  53077. /**
  53078. * Stores the alpha values in a texture.
  53079. */
  53080. protected _opacityTexture: Nullable<BaseTexture>;
  53081. /**
  53082. * Stores the reflection values in a texture.
  53083. */
  53084. protected _reflectionTexture: Nullable<BaseTexture>;
  53085. /**
  53086. * Stores the emissive values in a texture.
  53087. */
  53088. protected _emissiveTexture: Nullable<BaseTexture>;
  53089. /**
  53090. * AKA Specular texture in other nomenclature.
  53091. */
  53092. protected _reflectivityTexture: Nullable<BaseTexture>;
  53093. /**
  53094. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53095. */
  53096. protected _metallicTexture: Nullable<BaseTexture>;
  53097. /**
  53098. * Specifies the metallic scalar of the metallic/roughness workflow.
  53099. * Can also be used to scale the metalness values of the metallic texture.
  53100. */
  53101. protected _metallic: Nullable<number>;
  53102. /**
  53103. * Specifies the roughness scalar of the metallic/roughness workflow.
  53104. * Can also be used to scale the roughness values of the metallic texture.
  53105. */
  53106. protected _roughness: Nullable<number>;
  53107. /**
  53108. * Specifies the an F0 factor to help configuring the material F0.
  53109. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53110. * to 0.5 the previously hard coded value stays the same.
  53111. * Can also be used to scale the F0 values of the metallic texture.
  53112. */
  53113. protected _metallicF0Factor: number;
  53114. /**
  53115. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53116. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53117. * your expectation as it multiplies with the texture data.
  53118. */
  53119. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53120. /**
  53121. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53122. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53123. */
  53124. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53125. /**
  53126. * Stores surface normal data used to displace a mesh in a texture.
  53127. */
  53128. protected _bumpTexture: Nullable<BaseTexture>;
  53129. /**
  53130. * Stores the pre-calculated light information of a mesh in a texture.
  53131. */
  53132. protected _lightmapTexture: Nullable<BaseTexture>;
  53133. /**
  53134. * The color of a material in ambient lighting.
  53135. */
  53136. protected _ambientColor: Color3;
  53137. /**
  53138. * AKA Diffuse Color in other nomenclature.
  53139. */
  53140. protected _albedoColor: Color3;
  53141. /**
  53142. * AKA Specular Color in other nomenclature.
  53143. */
  53144. protected _reflectivityColor: Color3;
  53145. /**
  53146. * The color applied when light is reflected from a material.
  53147. */
  53148. protected _reflectionColor: Color3;
  53149. /**
  53150. * The color applied when light is emitted from a material.
  53151. */
  53152. protected _emissiveColor: Color3;
  53153. /**
  53154. * AKA Glossiness in other nomenclature.
  53155. */
  53156. protected _microSurface: number;
  53157. /**
  53158. * Specifies that the material will use the light map as a show map.
  53159. */
  53160. protected _useLightmapAsShadowmap: boolean;
  53161. /**
  53162. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53163. * makes the reflect vector face the model (under horizon).
  53164. */
  53165. protected _useHorizonOcclusion: boolean;
  53166. /**
  53167. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53168. * too much the area relying on ambient texture to define their ambient occlusion.
  53169. */
  53170. protected _useRadianceOcclusion: boolean;
  53171. /**
  53172. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53173. */
  53174. protected _useAlphaFromAlbedoTexture: boolean;
  53175. /**
  53176. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53177. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53178. */
  53179. protected _useSpecularOverAlpha: boolean;
  53180. /**
  53181. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53182. */
  53183. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53184. /**
  53185. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53186. */
  53187. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53188. /**
  53189. * Specifies if the metallic texture contains the roughness information in its green channel.
  53190. */
  53191. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53192. /**
  53193. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53194. */
  53195. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53196. /**
  53197. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53198. */
  53199. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53200. /**
  53201. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53202. */
  53203. protected _useAmbientInGrayScale: boolean;
  53204. /**
  53205. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53206. * The material will try to infer what glossiness each pixel should be.
  53207. */
  53208. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53209. /**
  53210. * Defines the falloff type used in this material.
  53211. * It by default is Physical.
  53212. */
  53213. protected _lightFalloff: number;
  53214. /**
  53215. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53216. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53217. */
  53218. protected _useRadianceOverAlpha: boolean;
  53219. /**
  53220. * Allows using an object space normal map (instead of tangent space).
  53221. */
  53222. protected _useObjectSpaceNormalMap: boolean;
  53223. /**
  53224. * Allows using the bump map in parallax mode.
  53225. */
  53226. protected _useParallax: boolean;
  53227. /**
  53228. * Allows using the bump map in parallax occlusion mode.
  53229. */
  53230. protected _useParallaxOcclusion: boolean;
  53231. /**
  53232. * Controls the scale bias of the parallax mode.
  53233. */
  53234. protected _parallaxScaleBias: number;
  53235. /**
  53236. * If sets to true, disables all the lights affecting the material.
  53237. */
  53238. protected _disableLighting: boolean;
  53239. /**
  53240. * Number of Simultaneous lights allowed on the material.
  53241. */
  53242. protected _maxSimultaneousLights: number;
  53243. /**
  53244. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53245. */
  53246. protected _invertNormalMapX: boolean;
  53247. /**
  53248. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53249. */
  53250. protected _invertNormalMapY: boolean;
  53251. /**
  53252. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53253. */
  53254. protected _twoSidedLighting: boolean;
  53255. /**
  53256. * Defines the alpha limits in alpha test mode.
  53257. */
  53258. protected _alphaCutOff: number;
  53259. /**
  53260. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53261. */
  53262. protected _forceAlphaTest: boolean;
  53263. /**
  53264. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53265. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53266. */
  53267. protected _useAlphaFresnel: boolean;
  53268. /**
  53269. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53270. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53271. */
  53272. protected _useLinearAlphaFresnel: boolean;
  53273. /**
  53274. * The transparency mode of the material.
  53275. */
  53276. protected _transparencyMode: Nullable<number>;
  53277. /**
  53278. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53279. * from cos thetav and roughness:
  53280. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53281. */
  53282. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53283. /**
  53284. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53285. */
  53286. protected _forceIrradianceInFragment: boolean;
  53287. /**
  53288. * Force normal to face away from face.
  53289. */
  53290. protected _forceNormalForward: boolean;
  53291. /**
  53292. * Enables specular anti aliasing in the PBR shader.
  53293. * It will both interacts on the Geometry for analytical and IBL lighting.
  53294. * It also prefilter the roughness map based on the bump values.
  53295. */
  53296. protected _enableSpecularAntiAliasing: boolean;
  53297. /**
  53298. * Default configuration related to image processing available in the PBR Material.
  53299. */
  53300. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53301. /**
  53302. * Keep track of the image processing observer to allow dispose and replace.
  53303. */
  53304. private _imageProcessingObserver;
  53305. /**
  53306. * Attaches a new image processing configuration to the PBR Material.
  53307. * @param configuration
  53308. */
  53309. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53310. /**
  53311. * Stores the available render targets.
  53312. */
  53313. private _renderTargets;
  53314. /**
  53315. * Sets the global ambient color for the material used in lighting calculations.
  53316. */
  53317. private _globalAmbientColor;
  53318. /**
  53319. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53320. */
  53321. private _useLogarithmicDepth;
  53322. /**
  53323. * If set to true, no lighting calculations will be applied.
  53324. */
  53325. private _unlit;
  53326. private _debugMode;
  53327. /**
  53328. * @hidden
  53329. * This is reserved for the inspector.
  53330. * Defines the material debug mode.
  53331. * It helps seeing only some components of the material while troubleshooting.
  53332. */
  53333. debugMode: number;
  53334. /**
  53335. * @hidden
  53336. * This is reserved for the inspector.
  53337. * Specify from where on screen the debug mode should start.
  53338. * The value goes from -1 (full screen) to 1 (not visible)
  53339. * It helps with side by side comparison against the final render
  53340. * This defaults to -1
  53341. */
  53342. private debugLimit;
  53343. /**
  53344. * @hidden
  53345. * This is reserved for the inspector.
  53346. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53347. * You can use the factor to better multiply the final value.
  53348. */
  53349. private debugFactor;
  53350. /**
  53351. * Defines the clear coat layer parameters for the material.
  53352. */
  53353. readonly clearCoat: PBRClearCoatConfiguration;
  53354. /**
  53355. * Defines the anisotropic parameters for the material.
  53356. */
  53357. readonly anisotropy: PBRAnisotropicConfiguration;
  53358. /**
  53359. * Defines the BRDF parameters for the material.
  53360. */
  53361. readonly brdf: PBRBRDFConfiguration;
  53362. /**
  53363. * Defines the Sheen parameters for the material.
  53364. */
  53365. readonly sheen: PBRSheenConfiguration;
  53366. /**
  53367. * Defines the SubSurface parameters for the material.
  53368. */
  53369. readonly subSurface: PBRSubSurfaceConfiguration;
  53370. /**
  53371. * Custom callback helping to override the default shader used in the material.
  53372. */
  53373. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53374. protected _rebuildInParallel: boolean;
  53375. /**
  53376. * Instantiates a new PBRMaterial instance.
  53377. *
  53378. * @param name The material name
  53379. * @param scene The scene the material will be use in.
  53380. */
  53381. constructor(name: string, scene: Scene);
  53382. /**
  53383. * Gets a boolean indicating that current material needs to register RTT
  53384. */
  53385. get hasRenderTargetTextures(): boolean;
  53386. /**
  53387. * Gets the name of the material class.
  53388. */
  53389. getClassName(): string;
  53390. /**
  53391. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53392. */
  53393. get useLogarithmicDepth(): boolean;
  53394. /**
  53395. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53396. */
  53397. set useLogarithmicDepth(value: boolean);
  53398. /**
  53399. * Gets the current transparency mode.
  53400. */
  53401. get transparencyMode(): Nullable<number>;
  53402. /**
  53403. * Sets the transparency mode of the material.
  53404. *
  53405. * | Value | Type | Description |
  53406. * | ----- | ----------------------------------- | ----------- |
  53407. * | 0 | OPAQUE | |
  53408. * | 1 | ALPHATEST | |
  53409. * | 2 | ALPHABLEND | |
  53410. * | 3 | ALPHATESTANDBLEND | |
  53411. *
  53412. */
  53413. set transparencyMode(value: Nullable<number>);
  53414. /**
  53415. * Returns true if alpha blending should be disabled.
  53416. */
  53417. private get _disableAlphaBlending();
  53418. /**
  53419. * Specifies whether or not this material should be rendered in alpha blend mode.
  53420. */
  53421. needAlphaBlending(): boolean;
  53422. /**
  53423. * Specifies if the mesh will require alpha blending.
  53424. * @param mesh - BJS mesh.
  53425. */
  53426. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53427. /**
  53428. * Specifies whether or not this material should be rendered in alpha test mode.
  53429. */
  53430. needAlphaTesting(): boolean;
  53431. /**
  53432. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53433. */
  53434. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53435. /**
  53436. * Gets the texture used for the alpha test.
  53437. */
  53438. getAlphaTestTexture(): Nullable<BaseTexture>;
  53439. /**
  53440. * Specifies that the submesh is ready to be used.
  53441. * @param mesh - BJS mesh.
  53442. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53443. * @param useInstances - Specifies that instances should be used.
  53444. * @returns - boolean indicating that the submesh is ready or not.
  53445. */
  53446. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53447. /**
  53448. * Specifies if the material uses metallic roughness workflow.
  53449. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53450. */
  53451. isMetallicWorkflow(): boolean;
  53452. private _prepareEffect;
  53453. private _prepareDefines;
  53454. /**
  53455. * Force shader compilation
  53456. */
  53457. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53458. /**
  53459. * Initializes the uniform buffer layout for the shader.
  53460. */
  53461. buildUniformLayout(): void;
  53462. /**
  53463. * Unbinds the material from the mesh
  53464. */
  53465. unbind(): void;
  53466. /**
  53467. * Binds the submesh data.
  53468. * @param world - The world matrix.
  53469. * @param mesh - The BJS mesh.
  53470. * @param subMesh - A submesh of the BJS mesh.
  53471. */
  53472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53473. /**
  53474. * Returns the animatable textures.
  53475. * @returns - Array of animatable textures.
  53476. */
  53477. getAnimatables(): IAnimatable[];
  53478. /**
  53479. * Returns the texture used for reflections.
  53480. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53481. */
  53482. private _getReflectionTexture;
  53483. /**
  53484. * Returns an array of the actively used textures.
  53485. * @returns - Array of BaseTextures
  53486. */
  53487. getActiveTextures(): BaseTexture[];
  53488. /**
  53489. * Checks to see if a texture is used in the material.
  53490. * @param texture - Base texture to use.
  53491. * @returns - Boolean specifying if a texture is used in the material.
  53492. */
  53493. hasTexture(texture: BaseTexture): boolean;
  53494. /**
  53495. * Disposes the resources of the material.
  53496. * @param forceDisposeEffect - Forces the disposal of effects.
  53497. * @param forceDisposeTextures - Forces the disposal of all textures.
  53498. */
  53499. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53500. }
  53501. }
  53502. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53503. import { Nullable } from "babylonjs/types";
  53504. import { Scene } from "babylonjs/scene";
  53505. import { Color3 } from "babylonjs/Maths/math.color";
  53506. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53507. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53509. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53510. /**
  53511. * The Physically based material of BJS.
  53512. *
  53513. * This offers the main features of a standard PBR material.
  53514. * For more information, please refer to the documentation :
  53515. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53516. */
  53517. export class PBRMaterial extends PBRBaseMaterial {
  53518. /**
  53519. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53520. */
  53521. static readonly PBRMATERIAL_OPAQUE: number;
  53522. /**
  53523. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53524. */
  53525. static readonly PBRMATERIAL_ALPHATEST: number;
  53526. /**
  53527. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53528. */
  53529. static readonly PBRMATERIAL_ALPHABLEND: number;
  53530. /**
  53531. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53532. * They are also discarded below the alpha cutoff threshold to improve performances.
  53533. */
  53534. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53535. /**
  53536. * Defines the default value of how much AO map is occluding the analytical lights
  53537. * (point spot...).
  53538. */
  53539. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53540. /**
  53541. * Intensity of the direct lights e.g. the four lights available in your scene.
  53542. * This impacts both the direct diffuse and specular highlights.
  53543. */
  53544. directIntensity: number;
  53545. /**
  53546. * Intensity of the emissive part of the material.
  53547. * This helps controlling the emissive effect without modifying the emissive color.
  53548. */
  53549. emissiveIntensity: number;
  53550. /**
  53551. * Intensity of the environment e.g. how much the environment will light the object
  53552. * either through harmonics for rough material or through the refelction for shiny ones.
  53553. */
  53554. environmentIntensity: number;
  53555. /**
  53556. * This is a special control allowing the reduction of the specular highlights coming from the
  53557. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53558. */
  53559. specularIntensity: number;
  53560. /**
  53561. * Debug Control allowing disabling the bump map on this material.
  53562. */
  53563. disableBumpMap: boolean;
  53564. /**
  53565. * AKA Diffuse Texture in standard nomenclature.
  53566. */
  53567. albedoTexture: BaseTexture;
  53568. /**
  53569. * AKA Occlusion Texture in other nomenclature.
  53570. */
  53571. ambientTexture: BaseTexture;
  53572. /**
  53573. * AKA Occlusion Texture Intensity in other nomenclature.
  53574. */
  53575. ambientTextureStrength: number;
  53576. /**
  53577. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53578. * 1 means it completely occludes it
  53579. * 0 mean it has no impact
  53580. */
  53581. ambientTextureImpactOnAnalyticalLights: number;
  53582. /**
  53583. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53584. */
  53585. opacityTexture: BaseTexture;
  53586. /**
  53587. * Stores the reflection values in a texture.
  53588. */
  53589. reflectionTexture: Nullable<BaseTexture>;
  53590. /**
  53591. * Stores the emissive values in a texture.
  53592. */
  53593. emissiveTexture: BaseTexture;
  53594. /**
  53595. * AKA Specular texture in other nomenclature.
  53596. */
  53597. reflectivityTexture: BaseTexture;
  53598. /**
  53599. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53600. */
  53601. metallicTexture: BaseTexture;
  53602. /**
  53603. * Specifies the metallic scalar of the metallic/roughness workflow.
  53604. * Can also be used to scale the metalness values of the metallic texture.
  53605. */
  53606. metallic: Nullable<number>;
  53607. /**
  53608. * Specifies the roughness scalar of the metallic/roughness workflow.
  53609. * Can also be used to scale the roughness values of the metallic texture.
  53610. */
  53611. roughness: Nullable<number>;
  53612. /**
  53613. * Specifies the an F0 factor to help configuring the material F0.
  53614. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53615. * to 0.5 the previously hard coded value stays the same.
  53616. * Can also be used to scale the F0 values of the metallic texture.
  53617. */
  53618. metallicF0Factor: number;
  53619. /**
  53620. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53621. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53622. * your expectation as it multiplies with the texture data.
  53623. */
  53624. useMetallicF0FactorFromMetallicTexture: boolean;
  53625. /**
  53626. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53627. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53628. */
  53629. microSurfaceTexture: BaseTexture;
  53630. /**
  53631. * Stores surface normal data used to displace a mesh in a texture.
  53632. */
  53633. bumpTexture: BaseTexture;
  53634. /**
  53635. * Stores the pre-calculated light information of a mesh in a texture.
  53636. */
  53637. lightmapTexture: BaseTexture;
  53638. /**
  53639. * Stores the refracted light information in a texture.
  53640. */
  53641. get refractionTexture(): Nullable<BaseTexture>;
  53642. set refractionTexture(value: Nullable<BaseTexture>);
  53643. /**
  53644. * The color of a material in ambient lighting.
  53645. */
  53646. ambientColor: Color3;
  53647. /**
  53648. * AKA Diffuse Color in other nomenclature.
  53649. */
  53650. albedoColor: Color3;
  53651. /**
  53652. * AKA Specular Color in other nomenclature.
  53653. */
  53654. reflectivityColor: Color3;
  53655. /**
  53656. * The color reflected from the material.
  53657. */
  53658. reflectionColor: Color3;
  53659. /**
  53660. * The color emitted from the material.
  53661. */
  53662. emissiveColor: Color3;
  53663. /**
  53664. * AKA Glossiness in other nomenclature.
  53665. */
  53666. microSurface: number;
  53667. /**
  53668. * source material index of refraction (IOR)' / 'destination material IOR.
  53669. */
  53670. get indexOfRefraction(): number;
  53671. set indexOfRefraction(value: number);
  53672. /**
  53673. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53674. */
  53675. get invertRefractionY(): boolean;
  53676. set invertRefractionY(value: boolean);
  53677. /**
  53678. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53679. * Materials half opaque for instance using refraction could benefit from this control.
  53680. */
  53681. get linkRefractionWithTransparency(): boolean;
  53682. set linkRefractionWithTransparency(value: boolean);
  53683. /**
  53684. * If true, the light map contains occlusion information instead of lighting info.
  53685. */
  53686. useLightmapAsShadowmap: boolean;
  53687. /**
  53688. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53689. */
  53690. useAlphaFromAlbedoTexture: boolean;
  53691. /**
  53692. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53693. */
  53694. forceAlphaTest: boolean;
  53695. /**
  53696. * Defines the alpha limits in alpha test mode.
  53697. */
  53698. alphaCutOff: number;
  53699. /**
  53700. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53701. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53702. */
  53703. useSpecularOverAlpha: boolean;
  53704. /**
  53705. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53706. */
  53707. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53708. /**
  53709. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53710. */
  53711. useRoughnessFromMetallicTextureAlpha: boolean;
  53712. /**
  53713. * Specifies if the metallic texture contains the roughness information in its green channel.
  53714. */
  53715. useRoughnessFromMetallicTextureGreen: boolean;
  53716. /**
  53717. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53718. */
  53719. useMetallnessFromMetallicTextureBlue: boolean;
  53720. /**
  53721. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53722. */
  53723. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53724. /**
  53725. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53726. */
  53727. useAmbientInGrayScale: boolean;
  53728. /**
  53729. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53730. * The material will try to infer what glossiness each pixel should be.
  53731. */
  53732. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53733. /**
  53734. * BJS is using an harcoded light falloff based on a manually sets up range.
  53735. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53736. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53737. */
  53738. get usePhysicalLightFalloff(): boolean;
  53739. /**
  53740. * BJS is using an harcoded light falloff based on a manually sets up range.
  53741. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53742. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53743. */
  53744. set usePhysicalLightFalloff(value: boolean);
  53745. /**
  53746. * In order to support the falloff compatibility with gltf, a special mode has been added
  53747. * to reproduce the gltf light falloff.
  53748. */
  53749. get useGLTFLightFalloff(): boolean;
  53750. /**
  53751. * In order to support the falloff compatibility with gltf, a special mode has been added
  53752. * to reproduce the gltf light falloff.
  53753. */
  53754. set useGLTFLightFalloff(value: boolean);
  53755. /**
  53756. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53757. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53758. */
  53759. useRadianceOverAlpha: boolean;
  53760. /**
  53761. * Allows using an object space normal map (instead of tangent space).
  53762. */
  53763. useObjectSpaceNormalMap: boolean;
  53764. /**
  53765. * Allows using the bump map in parallax mode.
  53766. */
  53767. useParallax: boolean;
  53768. /**
  53769. * Allows using the bump map in parallax occlusion mode.
  53770. */
  53771. useParallaxOcclusion: boolean;
  53772. /**
  53773. * Controls the scale bias of the parallax mode.
  53774. */
  53775. parallaxScaleBias: number;
  53776. /**
  53777. * If sets to true, disables all the lights affecting the material.
  53778. */
  53779. disableLighting: boolean;
  53780. /**
  53781. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53782. */
  53783. forceIrradianceInFragment: boolean;
  53784. /**
  53785. * Number of Simultaneous lights allowed on the material.
  53786. */
  53787. maxSimultaneousLights: number;
  53788. /**
  53789. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53790. */
  53791. invertNormalMapX: boolean;
  53792. /**
  53793. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53794. */
  53795. invertNormalMapY: boolean;
  53796. /**
  53797. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53798. */
  53799. twoSidedLighting: boolean;
  53800. /**
  53801. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53802. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53803. */
  53804. useAlphaFresnel: boolean;
  53805. /**
  53806. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53807. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53808. */
  53809. useLinearAlphaFresnel: boolean;
  53810. /**
  53811. * Let user defines the brdf lookup texture used for IBL.
  53812. * A default 8bit version is embedded but you could point at :
  53813. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53814. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53815. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53816. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53817. */
  53818. environmentBRDFTexture: Nullable<BaseTexture>;
  53819. /**
  53820. * Force normal to face away from face.
  53821. */
  53822. forceNormalForward: boolean;
  53823. /**
  53824. * Enables specular anti aliasing in the PBR shader.
  53825. * It will both interacts on the Geometry for analytical and IBL lighting.
  53826. * It also prefilter the roughness map based on the bump values.
  53827. */
  53828. enableSpecularAntiAliasing: boolean;
  53829. /**
  53830. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53831. * makes the reflect vector face the model (under horizon).
  53832. */
  53833. useHorizonOcclusion: boolean;
  53834. /**
  53835. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53836. * too much the area relying on ambient texture to define their ambient occlusion.
  53837. */
  53838. useRadianceOcclusion: boolean;
  53839. /**
  53840. * If set to true, no lighting calculations will be applied.
  53841. */
  53842. unlit: boolean;
  53843. /**
  53844. * Gets the image processing configuration used either in this material.
  53845. */
  53846. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53847. /**
  53848. * Sets the Default image processing configuration used either in the this material.
  53849. *
  53850. * If sets to null, the scene one is in use.
  53851. */
  53852. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53853. /**
  53854. * Gets wether the color curves effect is enabled.
  53855. */
  53856. get cameraColorCurvesEnabled(): boolean;
  53857. /**
  53858. * Sets wether the color curves effect is enabled.
  53859. */
  53860. set cameraColorCurvesEnabled(value: boolean);
  53861. /**
  53862. * Gets wether the color grading effect is enabled.
  53863. */
  53864. get cameraColorGradingEnabled(): boolean;
  53865. /**
  53866. * Gets wether the color grading effect is enabled.
  53867. */
  53868. set cameraColorGradingEnabled(value: boolean);
  53869. /**
  53870. * Gets wether tonemapping is enabled or not.
  53871. */
  53872. get cameraToneMappingEnabled(): boolean;
  53873. /**
  53874. * Sets wether tonemapping is enabled or not
  53875. */
  53876. set cameraToneMappingEnabled(value: boolean);
  53877. /**
  53878. * The camera exposure used on this material.
  53879. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53880. * This corresponds to a photographic exposure.
  53881. */
  53882. get cameraExposure(): number;
  53883. /**
  53884. * The camera exposure used on this material.
  53885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53886. * This corresponds to a photographic exposure.
  53887. */
  53888. set cameraExposure(value: number);
  53889. /**
  53890. * Gets The camera contrast used on this material.
  53891. */
  53892. get cameraContrast(): number;
  53893. /**
  53894. * Sets The camera contrast used on this material.
  53895. */
  53896. set cameraContrast(value: number);
  53897. /**
  53898. * Gets the Color Grading 2D Lookup Texture.
  53899. */
  53900. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53901. /**
  53902. * Sets the Color Grading 2D Lookup Texture.
  53903. */
  53904. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53905. /**
  53906. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53907. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53908. * 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;
  53909. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53910. */
  53911. get cameraColorCurves(): Nullable<ColorCurves>;
  53912. /**
  53913. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53914. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53915. * 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;
  53916. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53917. */
  53918. set cameraColorCurves(value: Nullable<ColorCurves>);
  53919. /**
  53920. * Instantiates a new PBRMaterial instance.
  53921. *
  53922. * @param name The material name
  53923. * @param scene The scene the material will be use in.
  53924. */
  53925. constructor(name: string, scene: Scene);
  53926. /**
  53927. * Returns the name of this material class.
  53928. */
  53929. getClassName(): string;
  53930. /**
  53931. * Makes a duplicate of the current material.
  53932. * @param name - name to use for the new material.
  53933. */
  53934. clone(name: string): PBRMaterial;
  53935. /**
  53936. * Serializes this PBR Material.
  53937. * @returns - An object with the serialized material.
  53938. */
  53939. serialize(): any;
  53940. /**
  53941. * Parses a PBR Material from a serialized object.
  53942. * @param source - Serialized object.
  53943. * @param scene - BJS scene instance.
  53944. * @param rootUrl - url for the scene object
  53945. * @returns - PBRMaterial
  53946. */
  53947. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53948. }
  53949. }
  53950. declare module "babylonjs/Misc/dds" {
  53951. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53953. import { Nullable } from "babylonjs/types";
  53954. import { Scene } from "babylonjs/scene";
  53955. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53956. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53957. /**
  53958. * Direct draw surface info
  53959. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53960. */
  53961. export interface DDSInfo {
  53962. /**
  53963. * Width of the texture
  53964. */
  53965. width: number;
  53966. /**
  53967. * Width of the texture
  53968. */
  53969. height: number;
  53970. /**
  53971. * Number of Mipmaps for the texture
  53972. * @see https://en.wikipedia.org/wiki/Mipmap
  53973. */
  53974. mipmapCount: number;
  53975. /**
  53976. * If the textures format is a known fourCC format
  53977. * @see https://www.fourcc.org/
  53978. */
  53979. isFourCC: boolean;
  53980. /**
  53981. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53982. */
  53983. isRGB: boolean;
  53984. /**
  53985. * If the texture is a lumincance format
  53986. */
  53987. isLuminance: boolean;
  53988. /**
  53989. * If this is a cube texture
  53990. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53991. */
  53992. isCube: boolean;
  53993. /**
  53994. * If the texture is a compressed format eg. FOURCC_DXT1
  53995. */
  53996. isCompressed: boolean;
  53997. /**
  53998. * The dxgiFormat of the texture
  53999. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54000. */
  54001. dxgiFormat: number;
  54002. /**
  54003. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54004. */
  54005. textureType: number;
  54006. /**
  54007. * Sphericle polynomial created for the dds texture
  54008. */
  54009. sphericalPolynomial?: SphericalPolynomial;
  54010. }
  54011. /**
  54012. * Class used to provide DDS decompression tools
  54013. */
  54014. export class DDSTools {
  54015. /**
  54016. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54017. */
  54018. static StoreLODInAlphaChannel: boolean;
  54019. /**
  54020. * Gets DDS information from an array buffer
  54021. * @param data defines the array buffer view to read data from
  54022. * @returns the DDS information
  54023. */
  54024. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54025. private static _FloatView;
  54026. private static _Int32View;
  54027. private static _ToHalfFloat;
  54028. private static _FromHalfFloat;
  54029. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54030. private static _GetHalfFloatRGBAArrayBuffer;
  54031. private static _GetFloatRGBAArrayBuffer;
  54032. private static _GetFloatAsUIntRGBAArrayBuffer;
  54033. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54034. private static _GetRGBAArrayBuffer;
  54035. private static _ExtractLongWordOrder;
  54036. private static _GetRGBArrayBuffer;
  54037. private static _GetLuminanceArrayBuffer;
  54038. /**
  54039. * Uploads DDS Levels to a Babylon Texture
  54040. * @hidden
  54041. */
  54042. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54043. }
  54044. module "babylonjs/Engines/thinEngine" {
  54045. interface ThinEngine {
  54046. /**
  54047. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54048. * @param rootUrl defines the url where the file to load is located
  54049. * @param scene defines the current scene
  54050. * @param lodScale defines scale to apply to the mip map selection
  54051. * @param lodOffset defines offset to apply to the mip map selection
  54052. * @param onLoad defines an optional callback raised when the texture is loaded
  54053. * @param onError defines an optional callback raised if there is an issue to load the texture
  54054. * @param format defines the format of the data
  54055. * @param forcedExtension defines the extension to use to pick the right loader
  54056. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54057. * @returns the cube texture as an InternalTexture
  54058. */
  54059. 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;
  54060. }
  54061. }
  54062. }
  54063. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54064. import { Nullable } from "babylonjs/types";
  54065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54066. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54067. /**
  54068. * Implementation of the DDS Texture Loader.
  54069. * @hidden
  54070. */
  54071. export class _DDSTextureLoader implements IInternalTextureLoader {
  54072. /**
  54073. * Defines wether the loader supports cascade loading the different faces.
  54074. */
  54075. readonly supportCascades: boolean;
  54076. /**
  54077. * This returns if the loader support the current file information.
  54078. * @param extension defines the file extension of the file being loaded
  54079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54080. * @param fallback defines the fallback internal texture if any
  54081. * @param isBase64 defines whether the texture is encoded as a base64
  54082. * @param isBuffer defines whether the texture data are stored as a buffer
  54083. * @returns true if the loader can load the specified file
  54084. */
  54085. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54086. /**
  54087. * Transform the url before loading if required.
  54088. * @param rootUrl the url of the texture
  54089. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54090. * @returns the transformed texture
  54091. */
  54092. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54093. /**
  54094. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54095. * @param rootUrl the url of the texture
  54096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54097. * @returns the fallback texture
  54098. */
  54099. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54100. /**
  54101. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54102. * @param data contains the texture data
  54103. * @param texture defines the BabylonJS internal texture
  54104. * @param createPolynomials will be true if polynomials have been requested
  54105. * @param onLoad defines the callback to trigger once the texture is ready
  54106. * @param onError defines the callback to trigger in case of error
  54107. */
  54108. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54109. /**
  54110. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54111. * @param data contains the texture data
  54112. * @param texture defines the BabylonJS internal texture
  54113. * @param callback defines the method to call once ready to upload
  54114. */
  54115. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54116. }
  54117. }
  54118. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54119. import { Nullable } from "babylonjs/types";
  54120. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54121. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54122. /**
  54123. * Implementation of the ENV Texture Loader.
  54124. * @hidden
  54125. */
  54126. export class _ENVTextureLoader implements IInternalTextureLoader {
  54127. /**
  54128. * Defines wether the loader supports cascade loading the different faces.
  54129. */
  54130. readonly supportCascades: boolean;
  54131. /**
  54132. * This returns if the loader support the current file information.
  54133. * @param extension defines the file extension of the file being loaded
  54134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54135. * @param fallback defines the fallback internal texture if any
  54136. * @param isBase64 defines whether the texture is encoded as a base64
  54137. * @param isBuffer defines whether the texture data are stored as a buffer
  54138. * @returns true if the loader can load the specified file
  54139. */
  54140. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54141. /**
  54142. * Transform the url before loading if required.
  54143. * @param rootUrl the url of the texture
  54144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54145. * @returns the transformed texture
  54146. */
  54147. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54148. /**
  54149. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54150. * @param rootUrl the url of the texture
  54151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54152. * @returns the fallback texture
  54153. */
  54154. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54155. /**
  54156. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54157. * @param data contains the texture data
  54158. * @param texture defines the BabylonJS internal texture
  54159. * @param createPolynomials will be true if polynomials have been requested
  54160. * @param onLoad defines the callback to trigger once the texture is ready
  54161. * @param onError defines the callback to trigger in case of error
  54162. */
  54163. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54164. /**
  54165. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54166. * @param data contains the texture data
  54167. * @param texture defines the BabylonJS internal texture
  54168. * @param callback defines the method to call once ready to upload
  54169. */
  54170. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54171. }
  54172. }
  54173. declare module "babylonjs/Misc/khronosTextureContainer" {
  54174. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54175. /**
  54176. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54177. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54178. */
  54179. export class KhronosTextureContainer {
  54180. /** contents of the KTX container file */
  54181. data: ArrayBufferView;
  54182. private static HEADER_LEN;
  54183. private static COMPRESSED_2D;
  54184. private static COMPRESSED_3D;
  54185. private static TEX_2D;
  54186. private static TEX_3D;
  54187. /**
  54188. * Gets the openGL type
  54189. */
  54190. glType: number;
  54191. /**
  54192. * Gets the openGL type size
  54193. */
  54194. glTypeSize: number;
  54195. /**
  54196. * Gets the openGL format
  54197. */
  54198. glFormat: number;
  54199. /**
  54200. * Gets the openGL internal format
  54201. */
  54202. glInternalFormat: number;
  54203. /**
  54204. * Gets the base internal format
  54205. */
  54206. glBaseInternalFormat: number;
  54207. /**
  54208. * Gets image width in pixel
  54209. */
  54210. pixelWidth: number;
  54211. /**
  54212. * Gets image height in pixel
  54213. */
  54214. pixelHeight: number;
  54215. /**
  54216. * Gets image depth in pixels
  54217. */
  54218. pixelDepth: number;
  54219. /**
  54220. * Gets the number of array elements
  54221. */
  54222. numberOfArrayElements: number;
  54223. /**
  54224. * Gets the number of faces
  54225. */
  54226. numberOfFaces: number;
  54227. /**
  54228. * Gets the number of mipmap levels
  54229. */
  54230. numberOfMipmapLevels: number;
  54231. /**
  54232. * Gets the bytes of key value data
  54233. */
  54234. bytesOfKeyValueData: number;
  54235. /**
  54236. * Gets the load type
  54237. */
  54238. loadType: number;
  54239. /**
  54240. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54241. */
  54242. isInvalid: boolean;
  54243. /**
  54244. * Creates a new KhronosTextureContainer
  54245. * @param data contents of the KTX container file
  54246. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54247. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54248. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54249. */
  54250. constructor(
  54251. /** contents of the KTX container file */
  54252. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54253. /**
  54254. * Uploads KTX content to a Babylon Texture.
  54255. * It is assumed that the texture has already been created & is currently bound
  54256. * @hidden
  54257. */
  54258. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54259. private _upload2DCompressedLevels;
  54260. }
  54261. }
  54262. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54263. import { Nullable } from "babylonjs/types";
  54264. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54265. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54266. /**
  54267. * Implementation of the KTX Texture Loader.
  54268. * @hidden
  54269. */
  54270. export class _KTXTextureLoader implements IInternalTextureLoader {
  54271. /**
  54272. * Defines wether the loader supports cascade loading the different faces.
  54273. */
  54274. readonly supportCascades: boolean;
  54275. /**
  54276. * This returns if the loader support the current file information.
  54277. * @param extension defines the file extension of the file being loaded
  54278. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54279. * @param fallback defines the fallback internal texture if any
  54280. * @param isBase64 defines whether the texture is encoded as a base64
  54281. * @param isBuffer defines whether the texture data are stored as a buffer
  54282. * @returns true if the loader can load the specified file
  54283. */
  54284. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54285. /**
  54286. * Transform the url before loading if required.
  54287. * @param rootUrl the url of the texture
  54288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54289. * @returns the transformed texture
  54290. */
  54291. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54292. /**
  54293. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54294. * @param rootUrl the url of the texture
  54295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54296. * @returns the fallback texture
  54297. */
  54298. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54299. /**
  54300. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54301. * @param data contains the texture data
  54302. * @param texture defines the BabylonJS internal texture
  54303. * @param createPolynomials will be true if polynomials have been requested
  54304. * @param onLoad defines the callback to trigger once the texture is ready
  54305. * @param onError defines the callback to trigger in case of error
  54306. */
  54307. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54308. /**
  54309. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54310. * @param data contains the texture data
  54311. * @param texture defines the BabylonJS internal texture
  54312. * @param callback defines the method to call once ready to upload
  54313. */
  54314. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54315. }
  54316. }
  54317. declare module "babylonjs/Helpers/sceneHelpers" {
  54318. import { Nullable } from "babylonjs/types";
  54319. import { Mesh } from "babylonjs/Meshes/mesh";
  54320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54321. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54322. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54323. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54324. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54325. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54326. import "babylonjs/Meshes/Builders/boxBuilder";
  54327. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54328. /** @hidden */
  54329. export var _forceSceneHelpersToBundle: boolean;
  54330. module "babylonjs/scene" {
  54331. interface Scene {
  54332. /**
  54333. * Creates a default light for the scene.
  54334. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54335. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54336. */
  54337. createDefaultLight(replace?: boolean): void;
  54338. /**
  54339. * Creates a default camera for the scene.
  54340. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54341. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54342. * @param replace has default false, when true replaces the active camera in the scene
  54343. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54344. */
  54345. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54346. /**
  54347. * Creates a default camera and a default light.
  54348. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54349. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54350. * @param replace has the default false, when true replaces the active camera/light in the scene
  54351. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54352. */
  54353. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54354. /**
  54355. * Creates a new sky box
  54356. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54357. * @param environmentTexture defines the texture to use as environment texture
  54358. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54359. * @param scale defines the overall scale of the skybox
  54360. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54361. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54362. * @returns a new mesh holding the sky box
  54363. */
  54364. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54365. /**
  54366. * Creates a new environment
  54367. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54368. * @param options defines the options you can use to configure the environment
  54369. * @returns the new EnvironmentHelper
  54370. */
  54371. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54372. /**
  54373. * Creates a new VREXperienceHelper
  54374. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54375. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54376. * @returns a new VREXperienceHelper
  54377. */
  54378. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54379. /**
  54380. * Creates a new WebXRDefaultExperience
  54381. * @see http://doc.babylonjs.com/how_to/webxr
  54382. * @param options experience options
  54383. * @returns a promise for a new WebXRDefaultExperience
  54384. */
  54385. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54386. }
  54387. }
  54388. }
  54389. declare module "babylonjs/Helpers/videoDome" {
  54390. import { Scene } from "babylonjs/scene";
  54391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54392. import { Mesh } from "babylonjs/Meshes/mesh";
  54393. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54394. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54395. import "babylonjs/Meshes/Builders/sphereBuilder";
  54396. /**
  54397. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54398. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54399. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54400. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54401. */
  54402. export class VideoDome extends TransformNode {
  54403. /**
  54404. * Define the video source as a Monoscopic panoramic 360 video.
  54405. */
  54406. static readonly MODE_MONOSCOPIC: number;
  54407. /**
  54408. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54409. */
  54410. static readonly MODE_TOPBOTTOM: number;
  54411. /**
  54412. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54413. */
  54414. static readonly MODE_SIDEBYSIDE: number;
  54415. private _halfDome;
  54416. private _useDirectMapping;
  54417. /**
  54418. * The video texture being displayed on the sphere
  54419. */
  54420. protected _videoTexture: VideoTexture;
  54421. /**
  54422. * Gets the video texture being displayed on the sphere
  54423. */
  54424. get videoTexture(): VideoTexture;
  54425. /**
  54426. * The skybox material
  54427. */
  54428. protected _material: BackgroundMaterial;
  54429. /**
  54430. * The surface used for the skybox
  54431. */
  54432. protected _mesh: Mesh;
  54433. /**
  54434. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54435. */
  54436. private _halfDomeMask;
  54437. /**
  54438. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54439. * Also see the options.resolution property.
  54440. */
  54441. get fovMultiplier(): number;
  54442. set fovMultiplier(value: number);
  54443. private _videoMode;
  54444. /**
  54445. * Gets or set the current video mode for the video. It can be:
  54446. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54447. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54448. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54449. */
  54450. get videoMode(): number;
  54451. set videoMode(value: number);
  54452. /**
  54453. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54454. *
  54455. */
  54456. get halfDome(): boolean;
  54457. /**
  54458. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54459. */
  54460. set halfDome(enabled: boolean);
  54461. /**
  54462. * Oberserver used in Stereoscopic VR Mode.
  54463. */
  54464. private _onBeforeCameraRenderObserver;
  54465. /**
  54466. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54467. * @param name Element's name, child elements will append suffixes for their own names.
  54468. * @param urlsOrVideo defines the url(s) or the video element to use
  54469. * @param options An object containing optional or exposed sub element properties
  54470. */
  54471. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54472. resolution?: number;
  54473. clickToPlay?: boolean;
  54474. autoPlay?: boolean;
  54475. loop?: boolean;
  54476. size?: number;
  54477. poster?: string;
  54478. faceForward?: boolean;
  54479. useDirectMapping?: boolean;
  54480. halfDomeMode?: boolean;
  54481. }, scene: Scene);
  54482. private _changeVideoMode;
  54483. /**
  54484. * Releases resources associated with this node.
  54485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54487. */
  54488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54489. }
  54490. }
  54491. declare module "babylonjs/Helpers/index" {
  54492. export * from "babylonjs/Helpers/environmentHelper";
  54493. export * from "babylonjs/Helpers/photoDome";
  54494. export * from "babylonjs/Helpers/sceneHelpers";
  54495. export * from "babylonjs/Helpers/videoDome";
  54496. }
  54497. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54498. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54499. import { IDisposable } from "babylonjs/scene";
  54500. import { Engine } from "babylonjs/Engines/engine";
  54501. /**
  54502. * This class can be used to get instrumentation data from a Babylon engine
  54503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54504. */
  54505. export class EngineInstrumentation implements IDisposable {
  54506. /**
  54507. * Define the instrumented engine.
  54508. */
  54509. engine: Engine;
  54510. private _captureGPUFrameTime;
  54511. private _gpuFrameTimeToken;
  54512. private _gpuFrameTime;
  54513. private _captureShaderCompilationTime;
  54514. private _shaderCompilationTime;
  54515. private _onBeginFrameObserver;
  54516. private _onEndFrameObserver;
  54517. private _onBeforeShaderCompilationObserver;
  54518. private _onAfterShaderCompilationObserver;
  54519. /**
  54520. * Gets the perf counter used for GPU frame time
  54521. */
  54522. get gpuFrameTimeCounter(): PerfCounter;
  54523. /**
  54524. * Gets the GPU frame time capture status
  54525. */
  54526. get captureGPUFrameTime(): boolean;
  54527. /**
  54528. * Enable or disable the GPU frame time capture
  54529. */
  54530. set captureGPUFrameTime(value: boolean);
  54531. /**
  54532. * Gets the perf counter used for shader compilation time
  54533. */
  54534. get shaderCompilationTimeCounter(): PerfCounter;
  54535. /**
  54536. * Gets the shader compilation time capture status
  54537. */
  54538. get captureShaderCompilationTime(): boolean;
  54539. /**
  54540. * Enable or disable the shader compilation time capture
  54541. */
  54542. set captureShaderCompilationTime(value: boolean);
  54543. /**
  54544. * Instantiates a new engine instrumentation.
  54545. * This class can be used to get instrumentation data from a Babylon engine
  54546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54547. * @param engine Defines the engine to instrument
  54548. */
  54549. constructor(
  54550. /**
  54551. * Define the instrumented engine.
  54552. */
  54553. engine: Engine);
  54554. /**
  54555. * Dispose and release associated resources.
  54556. */
  54557. dispose(): void;
  54558. }
  54559. }
  54560. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54561. import { Scene, IDisposable } from "babylonjs/scene";
  54562. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54563. /**
  54564. * This class can be used to get instrumentation data from a Babylon engine
  54565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54566. */
  54567. export class SceneInstrumentation implements IDisposable {
  54568. /**
  54569. * Defines the scene to instrument
  54570. */
  54571. scene: Scene;
  54572. private _captureActiveMeshesEvaluationTime;
  54573. private _activeMeshesEvaluationTime;
  54574. private _captureRenderTargetsRenderTime;
  54575. private _renderTargetsRenderTime;
  54576. private _captureFrameTime;
  54577. private _frameTime;
  54578. private _captureRenderTime;
  54579. private _renderTime;
  54580. private _captureInterFrameTime;
  54581. private _interFrameTime;
  54582. private _captureParticlesRenderTime;
  54583. private _particlesRenderTime;
  54584. private _captureSpritesRenderTime;
  54585. private _spritesRenderTime;
  54586. private _capturePhysicsTime;
  54587. private _physicsTime;
  54588. private _captureAnimationsTime;
  54589. private _animationsTime;
  54590. private _captureCameraRenderTime;
  54591. private _cameraRenderTime;
  54592. private _onBeforeActiveMeshesEvaluationObserver;
  54593. private _onAfterActiveMeshesEvaluationObserver;
  54594. private _onBeforeRenderTargetsRenderObserver;
  54595. private _onAfterRenderTargetsRenderObserver;
  54596. private _onAfterRenderObserver;
  54597. private _onBeforeDrawPhaseObserver;
  54598. private _onAfterDrawPhaseObserver;
  54599. private _onBeforeAnimationsObserver;
  54600. private _onBeforeParticlesRenderingObserver;
  54601. private _onAfterParticlesRenderingObserver;
  54602. private _onBeforeSpritesRenderingObserver;
  54603. private _onAfterSpritesRenderingObserver;
  54604. private _onBeforePhysicsObserver;
  54605. private _onAfterPhysicsObserver;
  54606. private _onAfterAnimationsObserver;
  54607. private _onBeforeCameraRenderObserver;
  54608. private _onAfterCameraRenderObserver;
  54609. /**
  54610. * Gets the perf counter used for active meshes evaluation time
  54611. */
  54612. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54613. /**
  54614. * Gets the active meshes evaluation time capture status
  54615. */
  54616. get captureActiveMeshesEvaluationTime(): boolean;
  54617. /**
  54618. * Enable or disable the active meshes evaluation time capture
  54619. */
  54620. set captureActiveMeshesEvaluationTime(value: boolean);
  54621. /**
  54622. * Gets the perf counter used for render targets render time
  54623. */
  54624. get renderTargetsRenderTimeCounter(): PerfCounter;
  54625. /**
  54626. * Gets the render targets render time capture status
  54627. */
  54628. get captureRenderTargetsRenderTime(): boolean;
  54629. /**
  54630. * Enable or disable the render targets render time capture
  54631. */
  54632. set captureRenderTargetsRenderTime(value: boolean);
  54633. /**
  54634. * Gets the perf counter used for particles render time
  54635. */
  54636. get particlesRenderTimeCounter(): PerfCounter;
  54637. /**
  54638. * Gets the particles render time capture status
  54639. */
  54640. get captureParticlesRenderTime(): boolean;
  54641. /**
  54642. * Enable or disable the particles render time capture
  54643. */
  54644. set captureParticlesRenderTime(value: boolean);
  54645. /**
  54646. * Gets the perf counter used for sprites render time
  54647. */
  54648. get spritesRenderTimeCounter(): PerfCounter;
  54649. /**
  54650. * Gets the sprites render time capture status
  54651. */
  54652. get captureSpritesRenderTime(): boolean;
  54653. /**
  54654. * Enable or disable the sprites render time capture
  54655. */
  54656. set captureSpritesRenderTime(value: boolean);
  54657. /**
  54658. * Gets the perf counter used for physics time
  54659. */
  54660. get physicsTimeCounter(): PerfCounter;
  54661. /**
  54662. * Gets the physics time capture status
  54663. */
  54664. get capturePhysicsTime(): boolean;
  54665. /**
  54666. * Enable or disable the physics time capture
  54667. */
  54668. set capturePhysicsTime(value: boolean);
  54669. /**
  54670. * Gets the perf counter used for animations time
  54671. */
  54672. get animationsTimeCounter(): PerfCounter;
  54673. /**
  54674. * Gets the animations time capture status
  54675. */
  54676. get captureAnimationsTime(): boolean;
  54677. /**
  54678. * Enable or disable the animations time capture
  54679. */
  54680. set captureAnimationsTime(value: boolean);
  54681. /**
  54682. * Gets the perf counter used for frame time capture
  54683. */
  54684. get frameTimeCounter(): PerfCounter;
  54685. /**
  54686. * Gets the frame time capture status
  54687. */
  54688. get captureFrameTime(): boolean;
  54689. /**
  54690. * Enable or disable the frame time capture
  54691. */
  54692. set captureFrameTime(value: boolean);
  54693. /**
  54694. * Gets the perf counter used for inter-frames time capture
  54695. */
  54696. get interFrameTimeCounter(): PerfCounter;
  54697. /**
  54698. * Gets the inter-frames time capture status
  54699. */
  54700. get captureInterFrameTime(): boolean;
  54701. /**
  54702. * Enable or disable the inter-frames time capture
  54703. */
  54704. set captureInterFrameTime(value: boolean);
  54705. /**
  54706. * Gets the perf counter used for render time capture
  54707. */
  54708. get renderTimeCounter(): PerfCounter;
  54709. /**
  54710. * Gets the render time capture status
  54711. */
  54712. get captureRenderTime(): boolean;
  54713. /**
  54714. * Enable or disable the render time capture
  54715. */
  54716. set captureRenderTime(value: boolean);
  54717. /**
  54718. * Gets the perf counter used for camera render time capture
  54719. */
  54720. get cameraRenderTimeCounter(): PerfCounter;
  54721. /**
  54722. * Gets the camera render time capture status
  54723. */
  54724. get captureCameraRenderTime(): boolean;
  54725. /**
  54726. * Enable or disable the camera render time capture
  54727. */
  54728. set captureCameraRenderTime(value: boolean);
  54729. /**
  54730. * Gets the perf counter used for draw calls
  54731. */
  54732. get drawCallsCounter(): PerfCounter;
  54733. /**
  54734. * Instantiates a new scene instrumentation.
  54735. * This class can be used to get instrumentation data from a Babylon engine
  54736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54737. * @param scene Defines the scene to instrument
  54738. */
  54739. constructor(
  54740. /**
  54741. * Defines the scene to instrument
  54742. */
  54743. scene: Scene);
  54744. /**
  54745. * Dispose and release associated resources.
  54746. */
  54747. dispose(): void;
  54748. }
  54749. }
  54750. declare module "babylonjs/Instrumentation/index" {
  54751. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54752. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54753. export * from "babylonjs/Instrumentation/timeToken";
  54754. }
  54755. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54756. /** @hidden */
  54757. export var glowMapGenerationPixelShader: {
  54758. name: string;
  54759. shader: string;
  54760. };
  54761. }
  54762. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54763. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54766. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54768. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54769. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54770. /** @hidden */
  54771. export var glowMapGenerationVertexShader: {
  54772. name: string;
  54773. shader: string;
  54774. };
  54775. }
  54776. declare module "babylonjs/Layers/effectLayer" {
  54777. import { Observable } from "babylonjs/Misc/observable";
  54778. import { Nullable } from "babylonjs/types";
  54779. import { Camera } from "babylonjs/Cameras/camera";
  54780. import { Scene } from "babylonjs/scene";
  54781. import { ISize } from "babylonjs/Maths/math.size";
  54782. import { Color4 } from "babylonjs/Maths/math.color";
  54783. import { Engine } from "babylonjs/Engines/engine";
  54784. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54786. import { Mesh } from "babylonjs/Meshes/mesh";
  54787. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54790. import { Effect } from "babylonjs/Materials/effect";
  54791. import { Material } from "babylonjs/Materials/material";
  54792. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54793. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54794. /**
  54795. * Effect layer options. This helps customizing the behaviour
  54796. * of the effect layer.
  54797. */
  54798. export interface IEffectLayerOptions {
  54799. /**
  54800. * Multiplication factor apply to the canvas size to compute the render target size
  54801. * used to generated the objects (the smaller the faster).
  54802. */
  54803. mainTextureRatio: number;
  54804. /**
  54805. * Enforces a fixed size texture to ensure effect stability across devices.
  54806. */
  54807. mainTextureFixedSize?: number;
  54808. /**
  54809. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54810. */
  54811. alphaBlendingMode: number;
  54812. /**
  54813. * The camera attached to the layer.
  54814. */
  54815. camera: Nullable<Camera>;
  54816. /**
  54817. * The rendering group to draw the layer in.
  54818. */
  54819. renderingGroupId: number;
  54820. }
  54821. /**
  54822. * The effect layer Helps adding post process effect blended with the main pass.
  54823. *
  54824. * This can be for instance use to generate glow or higlight effects on the scene.
  54825. *
  54826. * The effect layer class can not be used directly and is intented to inherited from to be
  54827. * customized per effects.
  54828. */
  54829. export abstract class EffectLayer {
  54830. private _vertexBuffers;
  54831. private _indexBuffer;
  54832. private _cachedDefines;
  54833. private _effectLayerMapGenerationEffect;
  54834. private _effectLayerOptions;
  54835. private _mergeEffect;
  54836. protected _scene: Scene;
  54837. protected _engine: Engine;
  54838. protected _maxSize: number;
  54839. protected _mainTextureDesiredSize: ISize;
  54840. protected _mainTexture: RenderTargetTexture;
  54841. protected _shouldRender: boolean;
  54842. protected _postProcesses: PostProcess[];
  54843. protected _textures: BaseTexture[];
  54844. protected _emissiveTextureAndColor: {
  54845. texture: Nullable<BaseTexture>;
  54846. color: Color4;
  54847. };
  54848. /**
  54849. * The name of the layer
  54850. */
  54851. name: string;
  54852. /**
  54853. * The clear color of the texture used to generate the glow map.
  54854. */
  54855. neutralColor: Color4;
  54856. /**
  54857. * Specifies whether the highlight layer is enabled or not.
  54858. */
  54859. isEnabled: boolean;
  54860. /**
  54861. * Gets the camera attached to the layer.
  54862. */
  54863. get camera(): Nullable<Camera>;
  54864. /**
  54865. * Gets the rendering group id the layer should render in.
  54866. */
  54867. get renderingGroupId(): number;
  54868. set renderingGroupId(renderingGroupId: number);
  54869. /**
  54870. * An event triggered when the effect layer has been disposed.
  54871. */
  54872. onDisposeObservable: Observable<EffectLayer>;
  54873. /**
  54874. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54875. */
  54876. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54877. /**
  54878. * An event triggered when the generated texture is being merged in the scene.
  54879. */
  54880. onBeforeComposeObservable: Observable<EffectLayer>;
  54881. /**
  54882. * An event triggered when the mesh is rendered into the effect render target.
  54883. */
  54884. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54885. /**
  54886. * An event triggered after the mesh has been rendered into the effect render target.
  54887. */
  54888. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54889. /**
  54890. * An event triggered when the generated texture has been merged in the scene.
  54891. */
  54892. onAfterComposeObservable: Observable<EffectLayer>;
  54893. /**
  54894. * An event triggered when the efffect layer changes its size.
  54895. */
  54896. onSizeChangedObservable: Observable<EffectLayer>;
  54897. /** @hidden */
  54898. static _SceneComponentInitialization: (scene: Scene) => void;
  54899. /**
  54900. * Instantiates a new effect Layer and references it in the scene.
  54901. * @param name The name of the layer
  54902. * @param scene The scene to use the layer in
  54903. */
  54904. constructor(
  54905. /** The Friendly of the effect in the scene */
  54906. name: string, scene: Scene);
  54907. /**
  54908. * Get the effect name of the layer.
  54909. * @return The effect name
  54910. */
  54911. abstract getEffectName(): string;
  54912. /**
  54913. * Checks for the readiness of the element composing the layer.
  54914. * @param subMesh the mesh to check for
  54915. * @param useInstances specify whether or not to use instances to render the mesh
  54916. * @return true if ready otherwise, false
  54917. */
  54918. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54919. /**
  54920. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  54921. * @returns true if the effect requires stencil during the main canvas render pass.
  54922. */
  54923. abstract needStencil(): boolean;
  54924. /**
  54925. * Create the merge effect. This is the shader use to blit the information back
  54926. * to the main canvas at the end of the scene rendering.
  54927. * @returns The effect containing the shader used to merge the effect on the main canvas
  54928. */
  54929. protected abstract _createMergeEffect(): Effect;
  54930. /**
  54931. * Creates the render target textures and post processes used in the effect layer.
  54932. */
  54933. protected abstract _createTextureAndPostProcesses(): void;
  54934. /**
  54935. * Implementation specific of rendering the generating effect on the main canvas.
  54936. * @param effect The effect used to render through
  54937. */
  54938. protected abstract _internalRender(effect: Effect): void;
  54939. /**
  54940. * Sets the required values for both the emissive texture and and the main color.
  54941. */
  54942. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54943. /**
  54944. * Free any resources and references associated to a mesh.
  54945. * Internal use
  54946. * @param mesh The mesh to free.
  54947. */
  54948. abstract _disposeMesh(mesh: Mesh): void;
  54949. /**
  54950. * Serializes this layer (Glow or Highlight for example)
  54951. * @returns a serialized layer object
  54952. */
  54953. abstract serialize?(): any;
  54954. /**
  54955. * Initializes the effect layer with the required options.
  54956. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54957. */
  54958. protected _init(options: Partial<IEffectLayerOptions>): void;
  54959. /**
  54960. * Generates the index buffer of the full screen quad blending to the main canvas.
  54961. */
  54962. private _generateIndexBuffer;
  54963. /**
  54964. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54965. */
  54966. private _generateVertexBuffer;
  54967. /**
  54968. * Sets the main texture desired size which is the closest power of two
  54969. * of the engine canvas size.
  54970. */
  54971. private _setMainTextureSize;
  54972. /**
  54973. * Creates the main texture for the effect layer.
  54974. */
  54975. protected _createMainTexture(): void;
  54976. /**
  54977. * Adds specific effects defines.
  54978. * @param defines The defines to add specifics to.
  54979. */
  54980. protected _addCustomEffectDefines(defines: string[]): void;
  54981. /**
  54982. * Checks for the readiness of the element composing the layer.
  54983. * @param subMesh the mesh to check for
  54984. * @param useInstances specify whether or not to use instances to render the mesh
  54985. * @param emissiveTexture the associated emissive texture used to generate the glow
  54986. * @return true if ready otherwise, false
  54987. */
  54988. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54989. /**
  54990. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54991. */
  54992. render(): void;
  54993. /**
  54994. * Determine if a given mesh will be used in the current effect.
  54995. * @param mesh mesh to test
  54996. * @returns true if the mesh will be used
  54997. */
  54998. hasMesh(mesh: AbstractMesh): boolean;
  54999. /**
  55000. * Returns true if the layer contains information to display, otherwise false.
  55001. * @returns true if the glow layer should be rendered
  55002. */
  55003. shouldRender(): boolean;
  55004. /**
  55005. * Returns true if the mesh should render, otherwise false.
  55006. * @param mesh The mesh to render
  55007. * @returns true if it should render otherwise false
  55008. */
  55009. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55010. /**
  55011. * Returns true if the mesh can be rendered, otherwise false.
  55012. * @param mesh The mesh to render
  55013. * @param material The material used on the mesh
  55014. * @returns true if it can be rendered otherwise false
  55015. */
  55016. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55017. /**
  55018. * Returns true if the mesh should render, otherwise false.
  55019. * @param mesh The mesh to render
  55020. * @returns true if it should render otherwise false
  55021. */
  55022. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55023. /**
  55024. * Renders the submesh passed in parameter to the generation map.
  55025. */
  55026. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55027. /**
  55028. * Defines whether the current material of the mesh should be use to render the effect.
  55029. * @param mesh defines the current mesh to render
  55030. */
  55031. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55032. /**
  55033. * Rebuild the required buffers.
  55034. * @hidden Internal use only.
  55035. */
  55036. _rebuild(): void;
  55037. /**
  55038. * Dispose only the render target textures and post process.
  55039. */
  55040. private _disposeTextureAndPostProcesses;
  55041. /**
  55042. * Dispose the highlight layer and free resources.
  55043. */
  55044. dispose(): void;
  55045. /**
  55046. * Gets the class name of the effect layer
  55047. * @returns the string with the class name of the effect layer
  55048. */
  55049. getClassName(): string;
  55050. /**
  55051. * Creates an effect layer from parsed effect layer data
  55052. * @param parsedEffectLayer defines effect layer data
  55053. * @param scene defines the current scene
  55054. * @param rootUrl defines the root URL containing the effect layer information
  55055. * @returns a parsed effect Layer
  55056. */
  55057. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55058. }
  55059. }
  55060. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55061. import { Scene } from "babylonjs/scene";
  55062. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55063. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55064. import { AbstractScene } from "babylonjs/abstractScene";
  55065. module "babylonjs/abstractScene" {
  55066. interface AbstractScene {
  55067. /**
  55068. * The list of effect layers (highlights/glow) added to the scene
  55069. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55070. * @see http://doc.babylonjs.com/how_to/glow_layer
  55071. */
  55072. effectLayers: Array<EffectLayer>;
  55073. /**
  55074. * Removes the given effect layer from this scene.
  55075. * @param toRemove defines the effect layer to remove
  55076. * @returns the index of the removed effect layer
  55077. */
  55078. removeEffectLayer(toRemove: EffectLayer): number;
  55079. /**
  55080. * Adds the given effect layer to this scene
  55081. * @param newEffectLayer defines the effect layer to add
  55082. */
  55083. addEffectLayer(newEffectLayer: EffectLayer): void;
  55084. }
  55085. }
  55086. /**
  55087. * Defines the layer scene component responsible to manage any effect layers
  55088. * in a given scene.
  55089. */
  55090. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55091. /**
  55092. * The component name helpfull to identify the component in the list of scene components.
  55093. */
  55094. readonly name: string;
  55095. /**
  55096. * The scene the component belongs to.
  55097. */
  55098. scene: Scene;
  55099. private _engine;
  55100. private _renderEffects;
  55101. private _needStencil;
  55102. private _previousStencilState;
  55103. /**
  55104. * Creates a new instance of the component for the given scene
  55105. * @param scene Defines the scene to register the component in
  55106. */
  55107. constructor(scene: Scene);
  55108. /**
  55109. * Registers the component in a given scene
  55110. */
  55111. register(): void;
  55112. /**
  55113. * Rebuilds the elements related to this component in case of
  55114. * context lost for instance.
  55115. */
  55116. rebuild(): void;
  55117. /**
  55118. * Serializes the component data to the specified json object
  55119. * @param serializationObject The object to serialize to
  55120. */
  55121. serialize(serializationObject: any): void;
  55122. /**
  55123. * Adds all the elements from the container to the scene
  55124. * @param container the container holding the elements
  55125. */
  55126. addFromContainer(container: AbstractScene): void;
  55127. /**
  55128. * Removes all the elements in the container from the scene
  55129. * @param container contains the elements to remove
  55130. * @param dispose if the removed element should be disposed (default: false)
  55131. */
  55132. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55133. /**
  55134. * Disposes the component and the associated ressources.
  55135. */
  55136. dispose(): void;
  55137. private _isReadyForMesh;
  55138. private _renderMainTexture;
  55139. private _setStencil;
  55140. private _setStencilBack;
  55141. private _draw;
  55142. private _drawCamera;
  55143. private _drawRenderingGroup;
  55144. }
  55145. }
  55146. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55147. /** @hidden */
  55148. export var glowMapMergePixelShader: {
  55149. name: string;
  55150. shader: string;
  55151. };
  55152. }
  55153. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55154. /** @hidden */
  55155. export var glowMapMergeVertexShader: {
  55156. name: string;
  55157. shader: string;
  55158. };
  55159. }
  55160. declare module "babylonjs/Layers/glowLayer" {
  55161. import { Nullable } from "babylonjs/types";
  55162. import { Camera } from "babylonjs/Cameras/camera";
  55163. import { Scene } from "babylonjs/scene";
  55164. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55166. import { Mesh } from "babylonjs/Meshes/mesh";
  55167. import { Texture } from "babylonjs/Materials/Textures/texture";
  55168. import { Effect } from "babylonjs/Materials/effect";
  55169. import { Material } from "babylonjs/Materials/material";
  55170. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55171. import { Color4 } from "babylonjs/Maths/math.color";
  55172. import "babylonjs/Shaders/glowMapMerge.fragment";
  55173. import "babylonjs/Shaders/glowMapMerge.vertex";
  55174. import "babylonjs/Layers/effectLayerSceneComponent";
  55175. module "babylonjs/abstractScene" {
  55176. interface AbstractScene {
  55177. /**
  55178. * Return a the first highlight layer of the scene with a given name.
  55179. * @param name The name of the highlight layer to look for.
  55180. * @return The highlight layer if found otherwise null.
  55181. */
  55182. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55183. }
  55184. }
  55185. /**
  55186. * Glow layer options. This helps customizing the behaviour
  55187. * of the glow layer.
  55188. */
  55189. export interface IGlowLayerOptions {
  55190. /**
  55191. * Multiplication factor apply to the canvas size to compute the render target size
  55192. * used to generated the glowing objects (the smaller the faster).
  55193. */
  55194. mainTextureRatio: number;
  55195. /**
  55196. * Enforces a fixed size texture to ensure resize independant blur.
  55197. */
  55198. mainTextureFixedSize?: number;
  55199. /**
  55200. * How big is the kernel of the blur texture.
  55201. */
  55202. blurKernelSize: number;
  55203. /**
  55204. * The camera attached to the layer.
  55205. */
  55206. camera: Nullable<Camera>;
  55207. /**
  55208. * Enable MSAA by chosing the number of samples.
  55209. */
  55210. mainTextureSamples?: number;
  55211. /**
  55212. * The rendering group to draw the layer in.
  55213. */
  55214. renderingGroupId: number;
  55215. }
  55216. /**
  55217. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55218. *
  55219. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55220. *
  55221. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55222. */
  55223. export class GlowLayer extends EffectLayer {
  55224. /**
  55225. * Effect Name of the layer.
  55226. */
  55227. static readonly EffectName: string;
  55228. /**
  55229. * The default blur kernel size used for the glow.
  55230. */
  55231. static DefaultBlurKernelSize: number;
  55232. /**
  55233. * The default texture size ratio used for the glow.
  55234. */
  55235. static DefaultTextureRatio: number;
  55236. /**
  55237. * Sets the kernel size of the blur.
  55238. */
  55239. set blurKernelSize(value: number);
  55240. /**
  55241. * Gets the kernel size of the blur.
  55242. */
  55243. get blurKernelSize(): number;
  55244. /**
  55245. * Sets the glow intensity.
  55246. */
  55247. set intensity(value: number);
  55248. /**
  55249. * Gets the glow intensity.
  55250. */
  55251. get intensity(): number;
  55252. private _options;
  55253. private _intensity;
  55254. private _horizontalBlurPostprocess1;
  55255. private _verticalBlurPostprocess1;
  55256. private _horizontalBlurPostprocess2;
  55257. private _verticalBlurPostprocess2;
  55258. private _blurTexture1;
  55259. private _blurTexture2;
  55260. private _postProcesses1;
  55261. private _postProcesses2;
  55262. private _includedOnlyMeshes;
  55263. private _excludedMeshes;
  55264. private _meshesUsingTheirOwnMaterials;
  55265. /**
  55266. * Callback used to let the user override the color selection on a per mesh basis
  55267. */
  55268. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55269. /**
  55270. * Callback used to let the user override the texture selection on a per mesh basis
  55271. */
  55272. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55273. /**
  55274. * Instantiates a new glow Layer and references it to the scene.
  55275. * @param name The name of the layer
  55276. * @param scene The scene to use the layer in
  55277. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55278. */
  55279. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55280. /**
  55281. * Get the effect name of the layer.
  55282. * @return The effect name
  55283. */
  55284. getEffectName(): string;
  55285. /**
  55286. * Create the merge effect. This is the shader use to blit the information back
  55287. * to the main canvas at the end of the scene rendering.
  55288. */
  55289. protected _createMergeEffect(): Effect;
  55290. /**
  55291. * Creates the render target textures and post processes used in the glow layer.
  55292. */
  55293. protected _createTextureAndPostProcesses(): void;
  55294. /**
  55295. * Checks for the readiness of the element composing the layer.
  55296. * @param subMesh the mesh to check for
  55297. * @param useInstances specify wether or not to use instances to render the mesh
  55298. * @param emissiveTexture the associated emissive texture used to generate the glow
  55299. * @return true if ready otherwise, false
  55300. */
  55301. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55302. /**
  55303. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55304. */
  55305. needStencil(): boolean;
  55306. /**
  55307. * Returns true if the mesh can be rendered, otherwise false.
  55308. * @param mesh The mesh to render
  55309. * @param material The material used on the mesh
  55310. * @returns true if it can be rendered otherwise false
  55311. */
  55312. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55313. /**
  55314. * Implementation specific of rendering the generating effect on the main canvas.
  55315. * @param effect The effect used to render through
  55316. */
  55317. protected _internalRender(effect: Effect): void;
  55318. /**
  55319. * Sets the required values for both the emissive texture and and the main color.
  55320. */
  55321. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55322. /**
  55323. * Returns true if the mesh should render, otherwise false.
  55324. * @param mesh The mesh to render
  55325. * @returns true if it should render otherwise false
  55326. */
  55327. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55328. /**
  55329. * Adds specific effects defines.
  55330. * @param defines The defines to add specifics to.
  55331. */
  55332. protected _addCustomEffectDefines(defines: string[]): void;
  55333. /**
  55334. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55335. * @param mesh The mesh to exclude from the glow layer
  55336. */
  55337. addExcludedMesh(mesh: Mesh): void;
  55338. /**
  55339. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55340. * @param mesh The mesh to remove
  55341. */
  55342. removeExcludedMesh(mesh: Mesh): void;
  55343. /**
  55344. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55345. * @param mesh The mesh to include in the glow layer
  55346. */
  55347. addIncludedOnlyMesh(mesh: Mesh): void;
  55348. /**
  55349. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55350. * @param mesh The mesh to remove
  55351. */
  55352. removeIncludedOnlyMesh(mesh: Mesh): void;
  55353. /**
  55354. * Determine if a given mesh will be used in the glow layer
  55355. * @param mesh The mesh to test
  55356. * @returns true if the mesh will be highlighted by the current glow layer
  55357. */
  55358. hasMesh(mesh: AbstractMesh): boolean;
  55359. /**
  55360. * Defines whether the current material of the mesh should be use to render the effect.
  55361. * @param mesh defines the current mesh to render
  55362. */
  55363. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55364. /**
  55365. * Add a mesh to be rendered through its own material and not with emissive only.
  55366. * @param mesh The mesh for which we need to use its material
  55367. */
  55368. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55369. /**
  55370. * Remove a mesh from being rendered through its own material and not with emissive only.
  55371. * @param mesh The mesh for which we need to not use its material
  55372. */
  55373. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55374. /**
  55375. * Free any resources and references associated to a mesh.
  55376. * Internal use
  55377. * @param mesh The mesh to free.
  55378. * @hidden
  55379. */
  55380. _disposeMesh(mesh: Mesh): void;
  55381. /**
  55382. * Gets the class name of the effect layer
  55383. * @returns the string with the class name of the effect layer
  55384. */
  55385. getClassName(): string;
  55386. /**
  55387. * Serializes this glow layer
  55388. * @returns a serialized glow layer object
  55389. */
  55390. serialize(): any;
  55391. /**
  55392. * Creates a Glow Layer from parsed glow layer data
  55393. * @param parsedGlowLayer defines glow layer data
  55394. * @param scene defines the current scene
  55395. * @param rootUrl defines the root URL containing the glow layer information
  55396. * @returns a parsed Glow Layer
  55397. */
  55398. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55399. }
  55400. }
  55401. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55402. /** @hidden */
  55403. export var glowBlurPostProcessPixelShader: {
  55404. name: string;
  55405. shader: string;
  55406. };
  55407. }
  55408. declare module "babylonjs/Layers/highlightLayer" {
  55409. import { Observable } from "babylonjs/Misc/observable";
  55410. import { Nullable } from "babylonjs/types";
  55411. import { Camera } from "babylonjs/Cameras/camera";
  55412. import { Scene } from "babylonjs/scene";
  55413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55415. import { Mesh } from "babylonjs/Meshes/mesh";
  55416. import { Effect } from "babylonjs/Materials/effect";
  55417. import { Material } from "babylonjs/Materials/material";
  55418. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55419. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55420. import "babylonjs/Shaders/glowMapMerge.fragment";
  55421. import "babylonjs/Shaders/glowMapMerge.vertex";
  55422. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55423. module "babylonjs/abstractScene" {
  55424. interface AbstractScene {
  55425. /**
  55426. * Return a the first highlight layer of the scene with a given name.
  55427. * @param name The name of the highlight layer to look for.
  55428. * @return The highlight layer if found otherwise null.
  55429. */
  55430. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55431. }
  55432. }
  55433. /**
  55434. * Highlight layer options. This helps customizing the behaviour
  55435. * of the highlight layer.
  55436. */
  55437. export interface IHighlightLayerOptions {
  55438. /**
  55439. * Multiplication factor apply to the canvas size to compute the render target size
  55440. * used to generated the glowing objects (the smaller the faster).
  55441. */
  55442. mainTextureRatio: number;
  55443. /**
  55444. * Enforces a fixed size texture to ensure resize independant blur.
  55445. */
  55446. mainTextureFixedSize?: number;
  55447. /**
  55448. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55449. * of the picture to blur (the smaller the faster).
  55450. */
  55451. blurTextureSizeRatio: number;
  55452. /**
  55453. * How big in texel of the blur texture is the vertical blur.
  55454. */
  55455. blurVerticalSize: number;
  55456. /**
  55457. * How big in texel of the blur texture is the horizontal blur.
  55458. */
  55459. blurHorizontalSize: number;
  55460. /**
  55461. * Alpha blending mode used to apply the blur. Default is combine.
  55462. */
  55463. alphaBlendingMode: number;
  55464. /**
  55465. * The camera attached to the layer.
  55466. */
  55467. camera: Nullable<Camera>;
  55468. /**
  55469. * Should we display highlight as a solid stroke?
  55470. */
  55471. isStroke?: boolean;
  55472. /**
  55473. * The rendering group to draw the layer in.
  55474. */
  55475. renderingGroupId: number;
  55476. }
  55477. /**
  55478. * The highlight layer Helps adding a glow effect around a mesh.
  55479. *
  55480. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55481. * glowy meshes to your scene.
  55482. *
  55483. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55484. */
  55485. export class HighlightLayer extends EffectLayer {
  55486. name: string;
  55487. /**
  55488. * Effect Name of the highlight layer.
  55489. */
  55490. static readonly EffectName: string;
  55491. /**
  55492. * The neutral color used during the preparation of the glow effect.
  55493. * This is black by default as the blend operation is a blend operation.
  55494. */
  55495. static NeutralColor: Color4;
  55496. /**
  55497. * Stencil value used for glowing meshes.
  55498. */
  55499. static GlowingMeshStencilReference: number;
  55500. /**
  55501. * Stencil value used for the other meshes in the scene.
  55502. */
  55503. static NormalMeshStencilReference: number;
  55504. /**
  55505. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55506. */
  55507. innerGlow: boolean;
  55508. /**
  55509. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55510. */
  55511. outerGlow: boolean;
  55512. /**
  55513. * Specifies the horizontal size of the blur.
  55514. */
  55515. set blurHorizontalSize(value: number);
  55516. /**
  55517. * Specifies the vertical size of the blur.
  55518. */
  55519. set blurVerticalSize(value: number);
  55520. /**
  55521. * Gets the horizontal size of the blur.
  55522. */
  55523. get blurHorizontalSize(): number;
  55524. /**
  55525. * Gets the vertical size of the blur.
  55526. */
  55527. get blurVerticalSize(): number;
  55528. /**
  55529. * An event triggered when the highlight layer is being blurred.
  55530. */
  55531. onBeforeBlurObservable: Observable<HighlightLayer>;
  55532. /**
  55533. * An event triggered when the highlight layer has been blurred.
  55534. */
  55535. onAfterBlurObservable: Observable<HighlightLayer>;
  55536. private _instanceGlowingMeshStencilReference;
  55537. private _options;
  55538. private _downSamplePostprocess;
  55539. private _horizontalBlurPostprocess;
  55540. private _verticalBlurPostprocess;
  55541. private _blurTexture;
  55542. private _meshes;
  55543. private _excludedMeshes;
  55544. /**
  55545. * Instantiates a new highlight Layer and references it to the scene..
  55546. * @param name The name of the layer
  55547. * @param scene The scene to use the layer in
  55548. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55549. */
  55550. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55551. /**
  55552. * Get the effect name of the layer.
  55553. * @return The effect name
  55554. */
  55555. getEffectName(): string;
  55556. /**
  55557. * Create the merge effect. This is the shader use to blit the information back
  55558. * to the main canvas at the end of the scene rendering.
  55559. */
  55560. protected _createMergeEffect(): Effect;
  55561. /**
  55562. * Creates the render target textures and post processes used in the highlight layer.
  55563. */
  55564. protected _createTextureAndPostProcesses(): void;
  55565. /**
  55566. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55567. */
  55568. needStencil(): boolean;
  55569. /**
  55570. * Checks for the readiness of the element composing the layer.
  55571. * @param subMesh the mesh to check for
  55572. * @param useInstances specify wether or not to use instances to render the mesh
  55573. * @param emissiveTexture the associated emissive texture used to generate the glow
  55574. * @return true if ready otherwise, false
  55575. */
  55576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55577. /**
  55578. * Implementation specific of rendering the generating effect on the main canvas.
  55579. * @param effect The effect used to render through
  55580. */
  55581. protected _internalRender(effect: Effect): void;
  55582. /**
  55583. * Returns true if the layer contains information to display, otherwise false.
  55584. */
  55585. shouldRender(): boolean;
  55586. /**
  55587. * Returns true if the mesh should render, otherwise false.
  55588. * @param mesh The mesh to render
  55589. * @returns true if it should render otherwise false
  55590. */
  55591. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55592. /**
  55593. * Sets the required values for both the emissive texture and and the main color.
  55594. */
  55595. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55596. /**
  55597. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55598. * @param mesh The mesh to exclude from the highlight layer
  55599. */
  55600. addExcludedMesh(mesh: Mesh): void;
  55601. /**
  55602. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55603. * @param mesh The mesh to highlight
  55604. */
  55605. removeExcludedMesh(mesh: Mesh): void;
  55606. /**
  55607. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55608. * @param mesh mesh to test
  55609. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55610. */
  55611. hasMesh(mesh: AbstractMesh): boolean;
  55612. /**
  55613. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55614. * @param mesh The mesh to highlight
  55615. * @param color The color of the highlight
  55616. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55617. */
  55618. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55619. /**
  55620. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55621. * @param mesh The mesh to highlight
  55622. */
  55623. removeMesh(mesh: Mesh): void;
  55624. /**
  55625. * Force the stencil to the normal expected value for none glowing parts
  55626. */
  55627. private _defaultStencilReference;
  55628. /**
  55629. * Free any resources and references associated to a mesh.
  55630. * Internal use
  55631. * @param mesh The mesh to free.
  55632. * @hidden
  55633. */
  55634. _disposeMesh(mesh: Mesh): void;
  55635. /**
  55636. * Dispose the highlight layer and free resources.
  55637. */
  55638. dispose(): void;
  55639. /**
  55640. * Gets the class name of the effect layer
  55641. * @returns the string with the class name of the effect layer
  55642. */
  55643. getClassName(): string;
  55644. /**
  55645. * Serializes this Highlight layer
  55646. * @returns a serialized Highlight layer object
  55647. */
  55648. serialize(): any;
  55649. /**
  55650. * Creates a Highlight layer from parsed Highlight layer data
  55651. * @param parsedHightlightLayer defines the Highlight layer data
  55652. * @param scene defines the current scene
  55653. * @param rootUrl defines the root URL containing the Highlight layer information
  55654. * @returns a parsed Highlight layer
  55655. */
  55656. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55657. }
  55658. }
  55659. declare module "babylonjs/Layers/layerSceneComponent" {
  55660. import { Scene } from "babylonjs/scene";
  55661. import { ISceneComponent } from "babylonjs/sceneComponent";
  55662. import { Layer } from "babylonjs/Layers/layer";
  55663. import { AbstractScene } from "babylonjs/abstractScene";
  55664. module "babylonjs/abstractScene" {
  55665. interface AbstractScene {
  55666. /**
  55667. * The list of layers (background and foreground) of the scene
  55668. */
  55669. layers: Array<Layer>;
  55670. }
  55671. }
  55672. /**
  55673. * Defines the layer scene component responsible to manage any layers
  55674. * in a given scene.
  55675. */
  55676. export class LayerSceneComponent implements ISceneComponent {
  55677. /**
  55678. * The component name helpfull to identify the component in the list of scene components.
  55679. */
  55680. readonly name: string;
  55681. /**
  55682. * The scene the component belongs to.
  55683. */
  55684. scene: Scene;
  55685. private _engine;
  55686. /**
  55687. * Creates a new instance of the component for the given scene
  55688. * @param scene Defines the scene to register the component in
  55689. */
  55690. constructor(scene: Scene);
  55691. /**
  55692. * Registers the component in a given scene
  55693. */
  55694. register(): void;
  55695. /**
  55696. * Rebuilds the elements related to this component in case of
  55697. * context lost for instance.
  55698. */
  55699. rebuild(): void;
  55700. /**
  55701. * Disposes the component and the associated ressources.
  55702. */
  55703. dispose(): void;
  55704. private _draw;
  55705. private _drawCameraPredicate;
  55706. private _drawCameraBackground;
  55707. private _drawCameraForeground;
  55708. private _drawRenderTargetPredicate;
  55709. private _drawRenderTargetBackground;
  55710. private _drawRenderTargetForeground;
  55711. /**
  55712. * Adds all the elements from the container to the scene
  55713. * @param container the container holding the elements
  55714. */
  55715. addFromContainer(container: AbstractScene): void;
  55716. /**
  55717. * Removes all the elements in the container from the scene
  55718. * @param container contains the elements to remove
  55719. * @param dispose if the removed element should be disposed (default: false)
  55720. */
  55721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55722. }
  55723. }
  55724. declare module "babylonjs/Shaders/layer.fragment" {
  55725. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55726. /** @hidden */
  55727. export var layerPixelShader: {
  55728. name: string;
  55729. shader: string;
  55730. };
  55731. }
  55732. declare module "babylonjs/Shaders/layer.vertex" {
  55733. /** @hidden */
  55734. export var layerVertexShader: {
  55735. name: string;
  55736. shader: string;
  55737. };
  55738. }
  55739. declare module "babylonjs/Layers/layer" {
  55740. import { Observable } from "babylonjs/Misc/observable";
  55741. import { Nullable } from "babylonjs/types";
  55742. import { Scene } from "babylonjs/scene";
  55743. import { Vector2 } from "babylonjs/Maths/math.vector";
  55744. import { Color4 } from "babylonjs/Maths/math.color";
  55745. import { Texture } from "babylonjs/Materials/Textures/texture";
  55746. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55747. import "babylonjs/Shaders/layer.fragment";
  55748. import "babylonjs/Shaders/layer.vertex";
  55749. /**
  55750. * This represents a full screen 2d layer.
  55751. * This can be useful to display a picture in the background of your scene for instance.
  55752. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55753. */
  55754. export class Layer {
  55755. /**
  55756. * Define the name of the layer.
  55757. */
  55758. name: string;
  55759. /**
  55760. * Define the texture the layer should display.
  55761. */
  55762. texture: Nullable<Texture>;
  55763. /**
  55764. * Is the layer in background or foreground.
  55765. */
  55766. isBackground: boolean;
  55767. /**
  55768. * Define the color of the layer (instead of texture).
  55769. */
  55770. color: Color4;
  55771. /**
  55772. * Define the scale of the layer in order to zoom in out of the texture.
  55773. */
  55774. scale: Vector2;
  55775. /**
  55776. * Define an offset for the layer in order to shift the texture.
  55777. */
  55778. offset: Vector2;
  55779. /**
  55780. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55781. */
  55782. alphaBlendingMode: number;
  55783. /**
  55784. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55785. * Alpha test will not mix with the background color in case of transparency.
  55786. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55787. */
  55788. alphaTest: boolean;
  55789. /**
  55790. * Define a mask to restrict the layer to only some of the scene cameras.
  55791. */
  55792. layerMask: number;
  55793. /**
  55794. * Define the list of render target the layer is visible into.
  55795. */
  55796. renderTargetTextures: RenderTargetTexture[];
  55797. /**
  55798. * Define if the layer is only used in renderTarget or if it also
  55799. * renders in the main frame buffer of the canvas.
  55800. */
  55801. renderOnlyInRenderTargetTextures: boolean;
  55802. private _scene;
  55803. private _vertexBuffers;
  55804. private _indexBuffer;
  55805. private _effect;
  55806. private _previousDefines;
  55807. /**
  55808. * An event triggered when the layer is disposed.
  55809. */
  55810. onDisposeObservable: Observable<Layer>;
  55811. private _onDisposeObserver;
  55812. /**
  55813. * Back compatibility with callback before the onDisposeObservable existed.
  55814. * The set callback will be triggered when the layer has been disposed.
  55815. */
  55816. set onDispose(callback: () => void);
  55817. /**
  55818. * An event triggered before rendering the scene
  55819. */
  55820. onBeforeRenderObservable: Observable<Layer>;
  55821. private _onBeforeRenderObserver;
  55822. /**
  55823. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55824. * The set callback will be triggered just before rendering the layer.
  55825. */
  55826. set onBeforeRender(callback: () => void);
  55827. /**
  55828. * An event triggered after rendering the scene
  55829. */
  55830. onAfterRenderObservable: Observable<Layer>;
  55831. private _onAfterRenderObserver;
  55832. /**
  55833. * Back compatibility with callback before the onAfterRenderObservable existed.
  55834. * The set callback will be triggered just after rendering the layer.
  55835. */
  55836. set onAfterRender(callback: () => void);
  55837. /**
  55838. * Instantiates a new layer.
  55839. * This represents a full screen 2d layer.
  55840. * This can be useful to display a picture in the background of your scene for instance.
  55841. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55842. * @param name Define the name of the layer in the scene
  55843. * @param imgUrl Define the url of the texture to display in the layer
  55844. * @param scene Define the scene the layer belongs to
  55845. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55846. * @param color Defines a color for the layer
  55847. */
  55848. constructor(
  55849. /**
  55850. * Define the name of the layer.
  55851. */
  55852. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55853. private _createIndexBuffer;
  55854. /** @hidden */
  55855. _rebuild(): void;
  55856. /**
  55857. * Renders the layer in the scene.
  55858. */
  55859. render(): void;
  55860. /**
  55861. * Disposes and releases the associated ressources.
  55862. */
  55863. dispose(): void;
  55864. }
  55865. }
  55866. declare module "babylonjs/Layers/index" {
  55867. export * from "babylonjs/Layers/effectLayer";
  55868. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55869. export * from "babylonjs/Layers/glowLayer";
  55870. export * from "babylonjs/Layers/highlightLayer";
  55871. export * from "babylonjs/Layers/layer";
  55872. export * from "babylonjs/Layers/layerSceneComponent";
  55873. }
  55874. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55875. /** @hidden */
  55876. export var lensFlarePixelShader: {
  55877. name: string;
  55878. shader: string;
  55879. };
  55880. }
  55881. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55882. /** @hidden */
  55883. export var lensFlareVertexShader: {
  55884. name: string;
  55885. shader: string;
  55886. };
  55887. }
  55888. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55889. import { Scene } from "babylonjs/scene";
  55890. import { Vector3 } from "babylonjs/Maths/math.vector";
  55891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55892. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55893. import "babylonjs/Shaders/lensFlare.fragment";
  55894. import "babylonjs/Shaders/lensFlare.vertex";
  55895. import { Viewport } from "babylonjs/Maths/math.viewport";
  55896. /**
  55897. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55898. * It is usually composed of several `lensFlare`.
  55899. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55900. */
  55901. export class LensFlareSystem {
  55902. /**
  55903. * Define the name of the lens flare system
  55904. */
  55905. name: string;
  55906. /**
  55907. * List of lens flares used in this system.
  55908. */
  55909. lensFlares: LensFlare[];
  55910. /**
  55911. * Define a limit from the border the lens flare can be visible.
  55912. */
  55913. borderLimit: number;
  55914. /**
  55915. * Define a viewport border we do not want to see the lens flare in.
  55916. */
  55917. viewportBorder: number;
  55918. /**
  55919. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55920. */
  55921. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55922. /**
  55923. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55924. */
  55925. layerMask: number;
  55926. /**
  55927. * Define the id of the lens flare system in the scene.
  55928. * (equal to name by default)
  55929. */
  55930. id: string;
  55931. private _scene;
  55932. private _emitter;
  55933. private _vertexBuffers;
  55934. private _indexBuffer;
  55935. private _effect;
  55936. private _positionX;
  55937. private _positionY;
  55938. private _isEnabled;
  55939. /** @hidden */
  55940. static _SceneComponentInitialization: (scene: Scene) => void;
  55941. /**
  55942. * Instantiates a lens flare system.
  55943. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55944. * It is usually composed of several `lensFlare`.
  55945. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55946. * @param name Define the name of the lens flare system in the scene
  55947. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55948. * @param scene Define the scene the lens flare system belongs to
  55949. */
  55950. constructor(
  55951. /**
  55952. * Define the name of the lens flare system
  55953. */
  55954. name: string, emitter: any, scene: Scene);
  55955. /**
  55956. * Define if the lens flare system is enabled.
  55957. */
  55958. get isEnabled(): boolean;
  55959. set isEnabled(value: boolean);
  55960. /**
  55961. * Get the scene the effects belongs to.
  55962. * @returns the scene holding the lens flare system
  55963. */
  55964. getScene(): Scene;
  55965. /**
  55966. * Get the emitter of the lens flare system.
  55967. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55968. * @returns the emitter of the lens flare system
  55969. */
  55970. getEmitter(): any;
  55971. /**
  55972. * Set the emitter of the lens flare system.
  55973. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55974. * @param newEmitter Define the new emitter of the system
  55975. */
  55976. setEmitter(newEmitter: any): void;
  55977. /**
  55978. * Get the lens flare system emitter position.
  55979. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55980. * @returns the position
  55981. */
  55982. getEmitterPosition(): Vector3;
  55983. /**
  55984. * @hidden
  55985. */
  55986. computeEffectivePosition(globalViewport: Viewport): boolean;
  55987. /** @hidden */
  55988. _isVisible(): boolean;
  55989. /**
  55990. * @hidden
  55991. */
  55992. render(): boolean;
  55993. /**
  55994. * Dispose and release the lens flare with its associated resources.
  55995. */
  55996. dispose(): void;
  55997. /**
  55998. * Parse a lens flare system from a JSON repressentation
  55999. * @param parsedLensFlareSystem Define the JSON to parse
  56000. * @param scene Define the scene the parsed system should be instantiated in
  56001. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56002. * @returns the parsed system
  56003. */
  56004. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56005. /**
  56006. * Serialize the current Lens Flare System into a JSON representation.
  56007. * @returns the serialized JSON
  56008. */
  56009. serialize(): any;
  56010. }
  56011. }
  56012. declare module "babylonjs/LensFlares/lensFlare" {
  56013. import { Nullable } from "babylonjs/types";
  56014. import { Color3 } from "babylonjs/Maths/math.color";
  56015. import { Texture } from "babylonjs/Materials/Textures/texture";
  56016. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56017. /**
  56018. * This represents one of the lens effect in a `lensFlareSystem`.
  56019. * It controls one of the indiviual texture used in the effect.
  56020. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56021. */
  56022. export class LensFlare {
  56023. /**
  56024. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56025. */
  56026. size: number;
  56027. /**
  56028. * 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.
  56029. */
  56030. position: number;
  56031. /**
  56032. * Define the lens color.
  56033. */
  56034. color: Color3;
  56035. /**
  56036. * Define the lens texture.
  56037. */
  56038. texture: Nullable<Texture>;
  56039. /**
  56040. * Define the alpha mode to render this particular lens.
  56041. */
  56042. alphaMode: number;
  56043. private _system;
  56044. /**
  56045. * Creates a new Lens Flare.
  56046. * This represents one of the lens effect in a `lensFlareSystem`.
  56047. * It controls one of the indiviual texture used in the effect.
  56048. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56049. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56050. * @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.
  56051. * @param color Define the lens color
  56052. * @param imgUrl Define the lens texture url
  56053. * @param system Define the `lensFlareSystem` this flare is part of
  56054. * @returns The newly created Lens Flare
  56055. */
  56056. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56057. /**
  56058. * Instantiates a new Lens Flare.
  56059. * This represents one of the lens effect in a `lensFlareSystem`.
  56060. * It controls one of the indiviual texture used in the effect.
  56061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56062. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56063. * @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.
  56064. * @param color Define the lens color
  56065. * @param imgUrl Define the lens texture url
  56066. * @param system Define the `lensFlareSystem` this flare is part of
  56067. */
  56068. constructor(
  56069. /**
  56070. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56071. */
  56072. size: number,
  56073. /**
  56074. * 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.
  56075. */
  56076. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56077. /**
  56078. * Dispose and release the lens flare with its associated resources.
  56079. */
  56080. dispose(): void;
  56081. }
  56082. }
  56083. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56084. import { Nullable } from "babylonjs/types";
  56085. import { Scene } from "babylonjs/scene";
  56086. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56087. import { AbstractScene } from "babylonjs/abstractScene";
  56088. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56089. module "babylonjs/abstractScene" {
  56090. interface AbstractScene {
  56091. /**
  56092. * The list of lens flare system added to the scene
  56093. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56094. */
  56095. lensFlareSystems: Array<LensFlareSystem>;
  56096. /**
  56097. * Removes the given lens flare system from this scene.
  56098. * @param toRemove The lens flare system to remove
  56099. * @returns The index of the removed lens flare system
  56100. */
  56101. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56102. /**
  56103. * Adds the given lens flare system to this scene
  56104. * @param newLensFlareSystem The lens flare system to add
  56105. */
  56106. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56107. /**
  56108. * Gets a lens flare system using its name
  56109. * @param name defines the name to look for
  56110. * @returns the lens flare system or null if not found
  56111. */
  56112. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56113. /**
  56114. * Gets a lens flare system using its id
  56115. * @param id defines the id to look for
  56116. * @returns the lens flare system or null if not found
  56117. */
  56118. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56119. }
  56120. }
  56121. /**
  56122. * Defines the lens flare scene component responsible to manage any lens flares
  56123. * in a given scene.
  56124. */
  56125. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56126. /**
  56127. * The component name helpfull to identify the component in the list of scene components.
  56128. */
  56129. readonly name: string;
  56130. /**
  56131. * The scene the component belongs to.
  56132. */
  56133. scene: Scene;
  56134. /**
  56135. * Creates a new instance of the component for the given scene
  56136. * @param scene Defines the scene to register the component in
  56137. */
  56138. constructor(scene: Scene);
  56139. /**
  56140. * Registers the component in a given scene
  56141. */
  56142. register(): void;
  56143. /**
  56144. * Rebuilds the elements related to this component in case of
  56145. * context lost for instance.
  56146. */
  56147. rebuild(): void;
  56148. /**
  56149. * Adds all the elements from the container to the scene
  56150. * @param container the container holding the elements
  56151. */
  56152. addFromContainer(container: AbstractScene): void;
  56153. /**
  56154. * Removes all the elements in the container from the scene
  56155. * @param container contains the elements to remove
  56156. * @param dispose if the removed element should be disposed (default: false)
  56157. */
  56158. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56159. /**
  56160. * Serializes the component data to the specified json object
  56161. * @param serializationObject The object to serialize to
  56162. */
  56163. serialize(serializationObject: any): void;
  56164. /**
  56165. * Disposes the component and the associated ressources.
  56166. */
  56167. dispose(): void;
  56168. private _draw;
  56169. }
  56170. }
  56171. declare module "babylonjs/LensFlares/index" {
  56172. export * from "babylonjs/LensFlares/lensFlare";
  56173. export * from "babylonjs/LensFlares/lensFlareSystem";
  56174. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56175. }
  56176. declare module "babylonjs/Shaders/depth.fragment" {
  56177. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56178. /** @hidden */
  56179. export var depthPixelShader: {
  56180. name: string;
  56181. shader: string;
  56182. };
  56183. }
  56184. declare module "babylonjs/Shaders/depth.vertex" {
  56185. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56186. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56188. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56189. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56190. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56191. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56192. /** @hidden */
  56193. export var depthVertexShader: {
  56194. name: string;
  56195. shader: string;
  56196. };
  56197. }
  56198. declare module "babylonjs/Rendering/depthRenderer" {
  56199. import { Nullable } from "babylonjs/types";
  56200. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56201. import { Scene } from "babylonjs/scene";
  56202. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56203. import { Camera } from "babylonjs/Cameras/camera";
  56204. import "babylonjs/Shaders/depth.fragment";
  56205. import "babylonjs/Shaders/depth.vertex";
  56206. /**
  56207. * This represents a depth renderer in Babylon.
  56208. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56209. */
  56210. export class DepthRenderer {
  56211. private _scene;
  56212. private _depthMap;
  56213. private _effect;
  56214. private readonly _storeNonLinearDepth;
  56215. private readonly _clearColor;
  56216. /** Get if the depth renderer is using packed depth or not */
  56217. readonly isPacked: boolean;
  56218. private _cachedDefines;
  56219. private _camera;
  56220. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56221. enabled: boolean;
  56222. /**
  56223. * Specifiess that the depth renderer will only be used within
  56224. * the camera it is created for.
  56225. * This can help forcing its rendering during the camera processing.
  56226. */
  56227. useOnlyInActiveCamera: boolean;
  56228. /** @hidden */
  56229. static _SceneComponentInitialization: (scene: Scene) => void;
  56230. /**
  56231. * Instantiates a depth renderer
  56232. * @param scene The scene the renderer belongs to
  56233. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56234. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56235. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56236. */
  56237. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56238. /**
  56239. * Creates the depth rendering effect and checks if the effect is ready.
  56240. * @param subMesh The submesh to be used to render the depth map of
  56241. * @param useInstances If multiple world instances should be used
  56242. * @returns if the depth renderer is ready to render the depth map
  56243. */
  56244. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56245. /**
  56246. * Gets the texture which the depth map will be written to.
  56247. * @returns The depth map texture
  56248. */
  56249. getDepthMap(): RenderTargetTexture;
  56250. /**
  56251. * Disposes of the depth renderer.
  56252. */
  56253. dispose(): void;
  56254. }
  56255. }
  56256. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56257. /** @hidden */
  56258. export var minmaxReduxPixelShader: {
  56259. name: string;
  56260. shader: string;
  56261. };
  56262. }
  56263. declare module "babylonjs/Misc/minMaxReducer" {
  56264. import { Nullable } from "babylonjs/types";
  56265. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56266. import { Camera } from "babylonjs/Cameras/camera";
  56267. import { Observer } from "babylonjs/Misc/observable";
  56268. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56269. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56270. import { Observable } from "babylonjs/Misc/observable";
  56271. import "babylonjs/Shaders/minmaxRedux.fragment";
  56272. /**
  56273. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56274. * and maximum values from all values of the texture.
  56275. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56276. * The source values are read from the red channel of the texture.
  56277. */
  56278. export class MinMaxReducer {
  56279. /**
  56280. * Observable triggered when the computation has been performed
  56281. */
  56282. onAfterReductionPerformed: Observable<{
  56283. min: number;
  56284. max: number;
  56285. }>;
  56286. protected _camera: Camera;
  56287. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56288. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56289. protected _postProcessManager: PostProcessManager;
  56290. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56291. protected _forceFullscreenViewport: boolean;
  56292. /**
  56293. * Creates a min/max reducer
  56294. * @param camera The camera to use for the post processes
  56295. */
  56296. constructor(camera: Camera);
  56297. /**
  56298. * Gets the texture used to read the values from.
  56299. */
  56300. get sourceTexture(): Nullable<RenderTargetTexture>;
  56301. /**
  56302. * Sets the source texture to read the values from.
  56303. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56304. * because in such textures '1' value must not be taken into account to compute the maximum
  56305. * as this value is used to clear the texture.
  56306. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56307. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56308. * @param depthRedux Indicates if the texture is a depth texture or not
  56309. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56310. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56311. */
  56312. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56313. /**
  56314. * Defines the refresh rate of the computation.
  56315. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56316. */
  56317. get refreshRate(): number;
  56318. set refreshRate(value: number);
  56319. protected _activated: boolean;
  56320. /**
  56321. * Gets the activation status of the reducer
  56322. */
  56323. get activated(): boolean;
  56324. /**
  56325. * Activates the reduction computation.
  56326. * When activated, the observers registered in onAfterReductionPerformed are
  56327. * called after the compuation is performed
  56328. */
  56329. activate(): void;
  56330. /**
  56331. * Deactivates the reduction computation.
  56332. */
  56333. deactivate(): void;
  56334. /**
  56335. * Disposes the min/max reducer
  56336. * @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.
  56337. */
  56338. dispose(disposeAll?: boolean): void;
  56339. }
  56340. }
  56341. declare module "babylonjs/Misc/depthReducer" {
  56342. import { Nullable } from "babylonjs/types";
  56343. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56344. import { Camera } from "babylonjs/Cameras/camera";
  56345. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56346. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56347. /**
  56348. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56349. */
  56350. export class DepthReducer extends MinMaxReducer {
  56351. private _depthRenderer;
  56352. private _depthRendererId;
  56353. /**
  56354. * Gets the depth renderer used for the computation.
  56355. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56356. */
  56357. get depthRenderer(): Nullable<DepthRenderer>;
  56358. /**
  56359. * Creates a depth reducer
  56360. * @param camera The camera used to render the depth texture
  56361. */
  56362. constructor(camera: Camera);
  56363. /**
  56364. * Sets the depth renderer to use to generate the depth map
  56365. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56366. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56367. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56368. */
  56369. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56370. /** @hidden */
  56371. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56372. /**
  56373. * Activates the reduction computation.
  56374. * When activated, the observers registered in onAfterReductionPerformed are
  56375. * called after the compuation is performed
  56376. */
  56377. activate(): void;
  56378. /**
  56379. * Deactivates the reduction computation.
  56380. */
  56381. deactivate(): void;
  56382. /**
  56383. * Disposes the depth reducer
  56384. * @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.
  56385. */
  56386. dispose(disposeAll?: boolean): void;
  56387. }
  56388. }
  56389. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56390. import { Nullable } from "babylonjs/types";
  56391. import { Scene } from "babylonjs/scene";
  56392. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56393. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56394. import { Effect } from "babylonjs/Materials/effect";
  56395. import "babylonjs/Shaders/shadowMap.fragment";
  56396. import "babylonjs/Shaders/shadowMap.vertex";
  56397. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56398. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56399. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56400. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56401. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56402. /**
  56403. * A CSM implementation allowing casting shadows on large scenes.
  56404. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56405. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56406. */
  56407. export class CascadedShadowGenerator extends ShadowGenerator {
  56408. private static readonly frustumCornersNDCSpace;
  56409. /**
  56410. * Name of the CSM class
  56411. */
  56412. static CLASSNAME: string;
  56413. /**
  56414. * Defines the default number of cascades used by the CSM.
  56415. */
  56416. static readonly DEFAULT_CASCADES_COUNT: number;
  56417. /**
  56418. * Defines the minimum number of cascades used by the CSM.
  56419. */
  56420. static readonly MIN_CASCADES_COUNT: number;
  56421. /**
  56422. * Defines the maximum number of cascades used by the CSM.
  56423. */
  56424. static readonly MAX_CASCADES_COUNT: number;
  56425. protected _validateFilter(filter: number): number;
  56426. /**
  56427. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56428. */
  56429. penumbraDarkness: number;
  56430. private _numCascades;
  56431. /**
  56432. * Gets or set the number of cascades used by the CSM.
  56433. */
  56434. get numCascades(): number;
  56435. set numCascades(value: number);
  56436. /**
  56437. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56438. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56439. */
  56440. stabilizeCascades: boolean;
  56441. private _freezeShadowCastersBoundingInfo;
  56442. private _freezeShadowCastersBoundingInfoObservable;
  56443. /**
  56444. * Enables or disables the shadow casters bounding info computation.
  56445. * If your shadow casters don't move, you can disable this feature.
  56446. * If it is enabled, the bounding box computation is done every frame.
  56447. */
  56448. get freezeShadowCastersBoundingInfo(): boolean;
  56449. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56450. private _scbiMin;
  56451. private _scbiMax;
  56452. protected _computeShadowCastersBoundingInfo(): void;
  56453. protected _shadowCastersBoundingInfo: BoundingInfo;
  56454. /**
  56455. * Gets or sets the shadow casters bounding info.
  56456. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56457. * so that the system won't overwrite the bounds you provide
  56458. */
  56459. get shadowCastersBoundingInfo(): BoundingInfo;
  56460. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56461. protected _breaksAreDirty: boolean;
  56462. protected _minDistance: number;
  56463. protected _maxDistance: number;
  56464. /**
  56465. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56466. *
  56467. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56468. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56469. * @param min minimal distance for the breaks (default to 0.)
  56470. * @param max maximal distance for the breaks (default to 1.)
  56471. */
  56472. setMinMaxDistance(min: number, max: number): void;
  56473. /** Gets the minimal distance used in the cascade break computation */
  56474. get minDistance(): number;
  56475. /** Gets the maximal distance used in the cascade break computation */
  56476. get maxDistance(): number;
  56477. /**
  56478. * Gets the class name of that object
  56479. * @returns "CascadedShadowGenerator"
  56480. */
  56481. getClassName(): string;
  56482. private _cascadeMinExtents;
  56483. private _cascadeMaxExtents;
  56484. /**
  56485. * Gets a cascade minimum extents
  56486. * @param cascadeIndex index of the cascade
  56487. * @returns the minimum cascade extents
  56488. */
  56489. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56490. /**
  56491. * Gets a cascade maximum extents
  56492. * @param cascadeIndex index of the cascade
  56493. * @returns the maximum cascade extents
  56494. */
  56495. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56496. private _cascades;
  56497. private _currentLayer;
  56498. private _viewSpaceFrustumsZ;
  56499. private _viewMatrices;
  56500. private _projectionMatrices;
  56501. private _transformMatrices;
  56502. private _transformMatricesAsArray;
  56503. private _frustumLengths;
  56504. private _lightSizeUVCorrection;
  56505. private _depthCorrection;
  56506. private _frustumCornersWorldSpace;
  56507. private _frustumCenter;
  56508. private _shadowCameraPos;
  56509. private _shadowMaxZ;
  56510. /**
  56511. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56512. * It defaults to camera.maxZ
  56513. */
  56514. get shadowMaxZ(): number;
  56515. /**
  56516. * Sets the shadow max z distance.
  56517. */
  56518. set shadowMaxZ(value: number);
  56519. protected _debug: boolean;
  56520. /**
  56521. * Gets or sets the debug flag.
  56522. * When enabled, the cascades are materialized by different colors on the screen.
  56523. */
  56524. get debug(): boolean;
  56525. set debug(dbg: boolean);
  56526. private _depthClamp;
  56527. /**
  56528. * Gets or sets the depth clamping value.
  56529. *
  56530. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56531. * to account for the shadow casters far away.
  56532. *
  56533. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56534. */
  56535. get depthClamp(): boolean;
  56536. set depthClamp(value: boolean);
  56537. private _cascadeBlendPercentage;
  56538. /**
  56539. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56540. * It defaults to 0.1 (10% blending).
  56541. */
  56542. get cascadeBlendPercentage(): number;
  56543. set cascadeBlendPercentage(value: number);
  56544. private _lambda;
  56545. /**
  56546. * Gets or set the lambda parameter.
  56547. * This parameter is used to split the camera frustum and create the cascades.
  56548. * 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.
  56549. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56550. */
  56551. get lambda(): number;
  56552. set lambda(value: number);
  56553. /**
  56554. * Gets the view matrix corresponding to a given cascade
  56555. * @param cascadeNum cascade to retrieve the view matrix from
  56556. * @returns the cascade view matrix
  56557. */
  56558. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56559. /**
  56560. * Gets the projection matrix corresponding to a given cascade
  56561. * @param cascadeNum cascade to retrieve the projection matrix from
  56562. * @returns the cascade projection matrix
  56563. */
  56564. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56565. /**
  56566. * Gets the transformation matrix corresponding to a given cascade
  56567. * @param cascadeNum cascade to retrieve the transformation matrix from
  56568. * @returns the cascade transformation matrix
  56569. */
  56570. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56571. private _depthRenderer;
  56572. /**
  56573. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56574. *
  56575. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56576. *
  56577. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56578. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56579. * @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
  56580. */
  56581. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56582. private _depthReducer;
  56583. private _autoCalcDepthBounds;
  56584. /**
  56585. * Gets or sets the autoCalcDepthBounds property.
  56586. *
  56587. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56588. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56589. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56590. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56591. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56592. */
  56593. get autoCalcDepthBounds(): boolean;
  56594. set autoCalcDepthBounds(value: boolean);
  56595. /**
  56596. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56597. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56598. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56599. * for setting the refresh rate on the renderer yourself!
  56600. */
  56601. get autoCalcDepthBoundsRefreshRate(): number;
  56602. set autoCalcDepthBoundsRefreshRate(value: number);
  56603. /**
  56604. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56605. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56606. * you change the camera near/far planes!
  56607. */
  56608. splitFrustum(): void;
  56609. private _splitFrustum;
  56610. private _computeMatrices;
  56611. private _computeFrustumInWorldSpace;
  56612. private _computeCascadeFrustum;
  56613. /** @hidden */
  56614. static _SceneComponentInitialization: (scene: Scene) => void;
  56615. /**
  56616. * Creates a Cascaded Shadow Generator object.
  56617. * A ShadowGenerator is the required tool to use the shadows.
  56618. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56619. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56620. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56621. * @param light The directional light object generating the shadows.
  56622. * @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.
  56623. */
  56624. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56625. protected _initializeGenerator(): void;
  56626. protected _createTargetRenderTexture(): void;
  56627. protected _initializeShadowMap(): void;
  56628. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56629. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56630. /**
  56631. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56632. * @param defines Defines of the material we want to update
  56633. * @param lightIndex Index of the light in the enabled light list of the material
  56634. */
  56635. prepareDefines(defines: any, lightIndex: number): void;
  56636. /**
  56637. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56638. * defined in the generator but impacting the effect).
  56639. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56640. * @param effect The effect we are binfing the information for
  56641. */
  56642. bindShadowLight(lightIndex: string, effect: Effect): void;
  56643. /**
  56644. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56645. * (eq to view projection * shadow projection matrices)
  56646. * @returns The transform matrix used to create the shadow map
  56647. */
  56648. getTransformMatrix(): Matrix;
  56649. /**
  56650. * Disposes the ShadowGenerator.
  56651. * Returns nothing.
  56652. */
  56653. dispose(): void;
  56654. /**
  56655. * Serializes the shadow generator setup to a json object.
  56656. * @returns The serialized JSON object
  56657. */
  56658. serialize(): any;
  56659. /**
  56660. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56661. * @param parsedShadowGenerator The JSON object to parse
  56662. * @param scene The scene to create the shadow map for
  56663. * @returns The parsed shadow generator
  56664. */
  56665. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56666. }
  56667. }
  56668. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56669. import { Scene } from "babylonjs/scene";
  56670. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56671. import { AbstractScene } from "babylonjs/abstractScene";
  56672. /**
  56673. * Defines the shadow generator component responsible to manage any shadow generators
  56674. * in a given scene.
  56675. */
  56676. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56677. /**
  56678. * The component name helpfull to identify the component in the list of scene components.
  56679. */
  56680. readonly name: string;
  56681. /**
  56682. * The scene the component belongs to.
  56683. */
  56684. scene: Scene;
  56685. /**
  56686. * Creates a new instance of the component for the given scene
  56687. * @param scene Defines the scene to register the component in
  56688. */
  56689. constructor(scene: Scene);
  56690. /**
  56691. * Registers the component in a given scene
  56692. */
  56693. register(): void;
  56694. /**
  56695. * Rebuilds the elements related to this component in case of
  56696. * context lost for instance.
  56697. */
  56698. rebuild(): void;
  56699. /**
  56700. * Serializes the component data to the specified json object
  56701. * @param serializationObject The object to serialize to
  56702. */
  56703. serialize(serializationObject: any): void;
  56704. /**
  56705. * Adds all the elements from the container to the scene
  56706. * @param container the container holding the elements
  56707. */
  56708. addFromContainer(container: AbstractScene): void;
  56709. /**
  56710. * Removes all the elements in the container from the scene
  56711. * @param container contains the elements to remove
  56712. * @param dispose if the removed element should be disposed (default: false)
  56713. */
  56714. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56715. /**
  56716. * Rebuilds the elements related to this component in case of
  56717. * context lost for instance.
  56718. */
  56719. dispose(): void;
  56720. private _gatherRenderTargets;
  56721. }
  56722. }
  56723. declare module "babylonjs/Lights/Shadows/index" {
  56724. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56725. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56726. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56727. }
  56728. declare module "babylonjs/Lights/pointLight" {
  56729. import { Scene } from "babylonjs/scene";
  56730. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56732. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56733. import { Effect } from "babylonjs/Materials/effect";
  56734. /**
  56735. * A point light is a light defined by an unique point in world space.
  56736. * The light is emitted in every direction from this point.
  56737. * A good example of a point light is a standard light bulb.
  56738. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56739. */
  56740. export class PointLight extends ShadowLight {
  56741. private _shadowAngle;
  56742. /**
  56743. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56744. * This specifies what angle the shadow will use to be created.
  56745. *
  56746. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56747. */
  56748. get shadowAngle(): number;
  56749. /**
  56750. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56751. * This specifies what angle the shadow will use to be created.
  56752. *
  56753. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56754. */
  56755. set shadowAngle(value: number);
  56756. /**
  56757. * Gets the direction if it has been set.
  56758. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56759. */
  56760. get direction(): Vector3;
  56761. /**
  56762. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56763. */
  56764. set direction(value: Vector3);
  56765. /**
  56766. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56767. * A PointLight emits the light in every direction.
  56768. * It can cast shadows.
  56769. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56770. * ```javascript
  56771. * var pointLight = new PointLight("pl", camera.position, scene);
  56772. * ```
  56773. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56774. * @param name The light friendly name
  56775. * @param position The position of the point light in the scene
  56776. * @param scene The scene the lights belongs to
  56777. */
  56778. constructor(name: string, position: Vector3, scene: Scene);
  56779. /**
  56780. * Returns the string "PointLight"
  56781. * @returns the class name
  56782. */
  56783. getClassName(): string;
  56784. /**
  56785. * Returns the integer 0.
  56786. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56787. */
  56788. getTypeID(): number;
  56789. /**
  56790. * Specifies wether or not the shadowmap should be a cube texture.
  56791. * @returns true if the shadowmap needs to be a cube texture.
  56792. */
  56793. needCube(): boolean;
  56794. /**
  56795. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56796. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56797. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56798. */
  56799. getShadowDirection(faceIndex?: number): Vector3;
  56800. /**
  56801. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56802. * - fov = PI / 2
  56803. * - aspect ratio : 1.0
  56804. * - z-near and far equal to the active camera minZ and maxZ.
  56805. * Returns the PointLight.
  56806. */
  56807. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56808. protected _buildUniformLayout(): void;
  56809. /**
  56810. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56811. * @param effect The effect to update
  56812. * @param lightIndex The index of the light in the effect to update
  56813. * @returns The point light
  56814. */
  56815. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56816. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56817. /**
  56818. * Prepares the list of defines specific to the light type.
  56819. * @param defines the list of defines
  56820. * @param lightIndex defines the index of the light for the effect
  56821. */
  56822. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56823. }
  56824. }
  56825. declare module "babylonjs/Lights/index" {
  56826. export * from "babylonjs/Lights/light";
  56827. export * from "babylonjs/Lights/shadowLight";
  56828. export * from "babylonjs/Lights/Shadows/index";
  56829. export * from "babylonjs/Lights/directionalLight";
  56830. export * from "babylonjs/Lights/hemisphericLight";
  56831. export * from "babylonjs/Lights/pointLight";
  56832. export * from "babylonjs/Lights/spotLight";
  56833. }
  56834. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56835. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56836. /**
  56837. * Header information of HDR texture files.
  56838. */
  56839. export interface HDRInfo {
  56840. /**
  56841. * The height of the texture in pixels.
  56842. */
  56843. height: number;
  56844. /**
  56845. * The width of the texture in pixels.
  56846. */
  56847. width: number;
  56848. /**
  56849. * The index of the beginning of the data in the binary file.
  56850. */
  56851. dataPosition: number;
  56852. }
  56853. /**
  56854. * This groups tools to convert HDR texture to native colors array.
  56855. */
  56856. export class HDRTools {
  56857. private static Ldexp;
  56858. private static Rgbe2float;
  56859. private static readStringLine;
  56860. /**
  56861. * Reads header information from an RGBE texture stored in a native array.
  56862. * More information on this format are available here:
  56863. * https://en.wikipedia.org/wiki/RGBE_image_format
  56864. *
  56865. * @param uint8array The binary file stored in native array.
  56866. * @return The header information.
  56867. */
  56868. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56869. /**
  56870. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56871. * This RGBE texture needs to store the information as a panorama.
  56872. *
  56873. * More information on this format are available here:
  56874. * https://en.wikipedia.org/wiki/RGBE_image_format
  56875. *
  56876. * @param buffer The binary file stored in an array buffer.
  56877. * @param size The expected size of the extracted cubemap.
  56878. * @return The Cube Map information.
  56879. */
  56880. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56881. /**
  56882. * Returns the pixels data extracted from an RGBE texture.
  56883. * This pixels will be stored left to right up to down in the R G B order in one array.
  56884. *
  56885. * More information on this format are available here:
  56886. * https://en.wikipedia.org/wiki/RGBE_image_format
  56887. *
  56888. * @param uint8array The binary file stored in an array buffer.
  56889. * @param hdrInfo The header information of the file.
  56890. * @return The pixels data in RGB right to left up to down order.
  56891. */
  56892. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  56893. private static RGBE_ReadPixels_RLE;
  56894. }
  56895. }
  56896. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  56897. import { Nullable } from "babylonjs/types";
  56898. import { Scene } from "babylonjs/scene";
  56899. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56901. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56902. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56903. /**
  56904. * This represents a texture coming from an HDR input.
  56905. *
  56906. * The only supported format is currently panorama picture stored in RGBE format.
  56907. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56908. */
  56909. export class HDRCubeTexture extends BaseTexture {
  56910. private static _facesMapping;
  56911. private _generateHarmonics;
  56912. private _noMipmap;
  56913. private _textureMatrix;
  56914. private _size;
  56915. private _onLoad;
  56916. private _onError;
  56917. /**
  56918. * The texture URL.
  56919. */
  56920. url: string;
  56921. /**
  56922. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56923. */
  56924. coordinatesMode: number;
  56925. protected _isBlocking: boolean;
  56926. /**
  56927. * Sets wether or not the texture is blocking during loading.
  56928. */
  56929. set isBlocking(value: boolean);
  56930. /**
  56931. * Gets wether or not the texture is blocking during loading.
  56932. */
  56933. get isBlocking(): boolean;
  56934. protected _rotationY: number;
  56935. /**
  56936. * Sets texture matrix rotation angle around Y axis in radians.
  56937. */
  56938. set rotationY(value: number);
  56939. /**
  56940. * Gets texture matrix rotation angle around Y axis radians.
  56941. */
  56942. get rotationY(): number;
  56943. /**
  56944. * Gets or sets the center of the bounding box associated with the cube texture
  56945. * It must define where the camera used to render the texture was set
  56946. */
  56947. boundingBoxPosition: Vector3;
  56948. private _boundingBoxSize;
  56949. /**
  56950. * Gets or sets the size of the bounding box associated with the cube texture
  56951. * When defined, the cubemap will switch to local mode
  56952. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56953. * @example https://www.babylonjs-playground.com/#RNASML
  56954. */
  56955. set boundingBoxSize(value: Vector3);
  56956. get boundingBoxSize(): Vector3;
  56957. /**
  56958. * Instantiates an HDRTexture from the following parameters.
  56959. *
  56960. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56961. * @param scene The scene the texture will be used in
  56962. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56963. * @param noMipmap Forces to not generate the mipmap if true
  56964. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56965. * @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)
  56966. * @param reserved Reserved flag for internal use.
  56967. */
  56968. 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>);
  56969. /**
  56970. * Get the current class name of the texture useful for serialization or dynamic coding.
  56971. * @returns "HDRCubeTexture"
  56972. */
  56973. getClassName(): string;
  56974. /**
  56975. * Occurs when the file is raw .hdr file.
  56976. */
  56977. private loadTexture;
  56978. clone(): HDRCubeTexture;
  56979. delayLoad(): void;
  56980. /**
  56981. * Get the texture reflection matrix used to rotate/transform the reflection.
  56982. * @returns the reflection matrix
  56983. */
  56984. getReflectionTextureMatrix(): Matrix;
  56985. /**
  56986. * Set the texture reflection matrix used to rotate/transform the reflection.
  56987. * @param value Define the reflection matrix to set
  56988. */
  56989. setReflectionTextureMatrix(value: Matrix): void;
  56990. /**
  56991. * Parses a JSON representation of an HDR Texture in order to create the texture
  56992. * @param parsedTexture Define the JSON representation
  56993. * @param scene Define the scene the texture should be created in
  56994. * @param rootUrl Define the root url in case we need to load relative dependencies
  56995. * @returns the newly created texture after parsing
  56996. */
  56997. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  56998. serialize(): any;
  56999. }
  57000. }
  57001. declare module "babylonjs/Physics/physicsEngine" {
  57002. import { Nullable } from "babylonjs/types";
  57003. import { Vector3 } from "babylonjs/Maths/math.vector";
  57004. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57005. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57006. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57007. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57008. /**
  57009. * Class used to control physics engine
  57010. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57011. */
  57012. export class PhysicsEngine implements IPhysicsEngine {
  57013. private _physicsPlugin;
  57014. /**
  57015. * Global value used to control the smallest number supported by the simulation
  57016. */
  57017. static Epsilon: number;
  57018. private _impostors;
  57019. private _joints;
  57020. private _subTimeStep;
  57021. /**
  57022. * Gets the gravity vector used by the simulation
  57023. */
  57024. gravity: Vector3;
  57025. /**
  57026. * Factory used to create the default physics plugin.
  57027. * @returns The default physics plugin
  57028. */
  57029. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57030. /**
  57031. * Creates a new Physics Engine
  57032. * @param gravity defines the gravity vector used by the simulation
  57033. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57034. */
  57035. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57036. /**
  57037. * Sets the gravity vector used by the simulation
  57038. * @param gravity defines the gravity vector to use
  57039. */
  57040. setGravity(gravity: Vector3): void;
  57041. /**
  57042. * Set the time step of the physics engine.
  57043. * Default is 1/60.
  57044. * To slow it down, enter 1/600 for example.
  57045. * To speed it up, 1/30
  57046. * @param newTimeStep defines the new timestep to apply to this world.
  57047. */
  57048. setTimeStep(newTimeStep?: number): void;
  57049. /**
  57050. * Get the time step of the physics engine.
  57051. * @returns the current time step
  57052. */
  57053. getTimeStep(): number;
  57054. /**
  57055. * Set the sub time step of the physics engine.
  57056. * Default is 0 meaning there is no sub steps
  57057. * To increase physics resolution precision, set a small value (like 1 ms)
  57058. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57059. */
  57060. setSubTimeStep(subTimeStep?: number): void;
  57061. /**
  57062. * Get the sub time step of the physics engine.
  57063. * @returns the current sub time step
  57064. */
  57065. getSubTimeStep(): number;
  57066. /**
  57067. * Release all resources
  57068. */
  57069. dispose(): void;
  57070. /**
  57071. * Gets the name of the current physics plugin
  57072. * @returns the name of the plugin
  57073. */
  57074. getPhysicsPluginName(): string;
  57075. /**
  57076. * Adding a new impostor for the impostor tracking.
  57077. * This will be done by the impostor itself.
  57078. * @param impostor the impostor to add
  57079. */
  57080. addImpostor(impostor: PhysicsImpostor): void;
  57081. /**
  57082. * Remove an impostor from the engine.
  57083. * This impostor and its mesh will not longer be updated by the physics engine.
  57084. * @param impostor the impostor to remove
  57085. */
  57086. removeImpostor(impostor: PhysicsImpostor): void;
  57087. /**
  57088. * Add a joint to the physics engine
  57089. * @param mainImpostor defines the main impostor to which the joint is added.
  57090. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57091. * @param joint defines the joint that will connect both impostors.
  57092. */
  57093. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57094. /**
  57095. * Removes a joint from the simulation
  57096. * @param mainImpostor defines the impostor used with the joint
  57097. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57098. * @param joint defines the joint to remove
  57099. */
  57100. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57101. /**
  57102. * Called by the scene. No need to call it.
  57103. * @param delta defines the timespam between frames
  57104. */
  57105. _step(delta: number): void;
  57106. /**
  57107. * Gets the current plugin used to run the simulation
  57108. * @returns current plugin
  57109. */
  57110. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57111. /**
  57112. * Gets the list of physic impostors
  57113. * @returns an array of PhysicsImpostor
  57114. */
  57115. getImpostors(): Array<PhysicsImpostor>;
  57116. /**
  57117. * Gets the impostor for a physics enabled object
  57118. * @param object defines the object impersonated by the impostor
  57119. * @returns the PhysicsImpostor or null if not found
  57120. */
  57121. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57122. /**
  57123. * Gets the impostor for a physics body object
  57124. * @param body defines physics body used by the impostor
  57125. * @returns the PhysicsImpostor or null if not found
  57126. */
  57127. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57128. /**
  57129. * Does a raycast in the physics world
  57130. * @param from when should the ray start?
  57131. * @param to when should the ray end?
  57132. * @returns PhysicsRaycastResult
  57133. */
  57134. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57135. }
  57136. }
  57137. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57138. import { Nullable } from "babylonjs/types";
  57139. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57141. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57142. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57143. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57144. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57145. /** @hidden */
  57146. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57147. private _useDeltaForWorldStep;
  57148. world: any;
  57149. name: string;
  57150. private _physicsMaterials;
  57151. private _fixedTimeStep;
  57152. private _cannonRaycastResult;
  57153. private _raycastResult;
  57154. private _physicsBodysToRemoveAfterStep;
  57155. BJSCANNON: any;
  57156. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57157. setGravity(gravity: Vector3): void;
  57158. setTimeStep(timeStep: number): void;
  57159. getTimeStep(): number;
  57160. executeStep(delta: number): void;
  57161. private _removeMarkedPhysicsBodiesFromWorld;
  57162. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57163. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57164. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57165. private _processChildMeshes;
  57166. removePhysicsBody(impostor: PhysicsImpostor): void;
  57167. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57168. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57169. private _addMaterial;
  57170. private _checkWithEpsilon;
  57171. private _createShape;
  57172. private _createHeightmap;
  57173. private _minus90X;
  57174. private _plus90X;
  57175. private _tmpPosition;
  57176. private _tmpDeltaPosition;
  57177. private _tmpUnityRotation;
  57178. private _updatePhysicsBodyTransformation;
  57179. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57180. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57181. isSupported(): boolean;
  57182. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57183. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57184. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57185. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57186. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57187. getBodyMass(impostor: PhysicsImpostor): number;
  57188. getBodyFriction(impostor: PhysicsImpostor): number;
  57189. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57190. getBodyRestitution(impostor: PhysicsImpostor): number;
  57191. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57192. sleepBody(impostor: PhysicsImpostor): void;
  57193. wakeUpBody(impostor: PhysicsImpostor): void;
  57194. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57195. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57196. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57197. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57198. getRadius(impostor: PhysicsImpostor): number;
  57199. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57200. dispose(): void;
  57201. private _extendNamespace;
  57202. /**
  57203. * Does a raycast in the physics world
  57204. * @param from when should the ray start?
  57205. * @param to when should the ray end?
  57206. * @returns PhysicsRaycastResult
  57207. */
  57208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57209. }
  57210. }
  57211. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57212. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57213. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57214. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57216. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57217. import { Nullable } from "babylonjs/types";
  57218. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57219. /** @hidden */
  57220. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57221. world: any;
  57222. name: string;
  57223. BJSOIMO: any;
  57224. private _raycastResult;
  57225. constructor(iterations?: number, oimoInjection?: any);
  57226. setGravity(gravity: Vector3): void;
  57227. setTimeStep(timeStep: number): void;
  57228. getTimeStep(): number;
  57229. private _tmpImpostorsArray;
  57230. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57231. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57232. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57233. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57234. private _tmpPositionVector;
  57235. removePhysicsBody(impostor: PhysicsImpostor): void;
  57236. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57237. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57238. isSupported(): boolean;
  57239. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57240. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57241. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57242. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57243. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57244. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57245. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57246. getBodyMass(impostor: PhysicsImpostor): number;
  57247. getBodyFriction(impostor: PhysicsImpostor): number;
  57248. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57249. getBodyRestitution(impostor: PhysicsImpostor): number;
  57250. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57251. sleepBody(impostor: PhysicsImpostor): void;
  57252. wakeUpBody(impostor: PhysicsImpostor): void;
  57253. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57254. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57255. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57256. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57257. getRadius(impostor: PhysicsImpostor): number;
  57258. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57259. dispose(): void;
  57260. /**
  57261. * Does a raycast in the physics world
  57262. * @param from when should the ray start?
  57263. * @param to when should the ray end?
  57264. * @returns PhysicsRaycastResult
  57265. */
  57266. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57267. }
  57268. }
  57269. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57270. import { Nullable } from "babylonjs/types";
  57271. import { Scene } from "babylonjs/scene";
  57272. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57273. import { Color4 } from "babylonjs/Maths/math.color";
  57274. import { Mesh } from "babylonjs/Meshes/mesh";
  57275. /**
  57276. * Class containing static functions to help procedurally build meshes
  57277. */
  57278. export class RibbonBuilder {
  57279. /**
  57280. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57281. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57282. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57283. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57284. * * 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
  57285. * * 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
  57286. * * 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
  57287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57290. * * 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
  57291. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57292. * * 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
  57293. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57295. * @param name defines the name of the mesh
  57296. * @param options defines the options used to create the mesh
  57297. * @param scene defines the hosting scene
  57298. * @returns the ribbon mesh
  57299. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57301. */
  57302. static CreateRibbon(name: string, options: {
  57303. pathArray: Vector3[][];
  57304. closeArray?: boolean;
  57305. closePath?: boolean;
  57306. offset?: number;
  57307. updatable?: boolean;
  57308. sideOrientation?: number;
  57309. frontUVs?: Vector4;
  57310. backUVs?: Vector4;
  57311. instance?: Mesh;
  57312. invertUV?: boolean;
  57313. uvs?: Vector2[];
  57314. colors?: Color4[];
  57315. }, scene?: Nullable<Scene>): Mesh;
  57316. }
  57317. }
  57318. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57319. import { Nullable } from "babylonjs/types";
  57320. import { Scene } from "babylonjs/scene";
  57321. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57322. import { Mesh } from "babylonjs/Meshes/mesh";
  57323. /**
  57324. * Class containing static functions to help procedurally build meshes
  57325. */
  57326. export class ShapeBuilder {
  57327. /**
  57328. * 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.
  57329. * * 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.
  57330. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57331. * * 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.
  57332. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57333. * * 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
  57334. * * 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
  57335. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57338. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57340. * @param name defines the name of the mesh
  57341. * @param options defines the options used to create the mesh
  57342. * @param scene defines the hosting scene
  57343. * @returns the extruded shape mesh
  57344. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57346. */
  57347. static ExtrudeShape(name: string, options: {
  57348. shape: Vector3[];
  57349. path: Vector3[];
  57350. scale?: number;
  57351. rotation?: number;
  57352. cap?: number;
  57353. updatable?: boolean;
  57354. sideOrientation?: number;
  57355. frontUVs?: Vector4;
  57356. backUVs?: Vector4;
  57357. instance?: Mesh;
  57358. invertUV?: boolean;
  57359. }, scene?: Nullable<Scene>): Mesh;
  57360. /**
  57361. * Creates an custom extruded shape mesh.
  57362. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57363. * * 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.
  57364. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57365. * * 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
  57366. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57367. * * 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
  57368. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57369. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57370. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57371. * * 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
  57372. * * 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
  57373. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57378. * @param name defines the name of the mesh
  57379. * @param options defines the options used to create the mesh
  57380. * @param scene defines the hosting scene
  57381. * @returns the custom extruded shape mesh
  57382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57383. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57385. */
  57386. static ExtrudeShapeCustom(name: string, options: {
  57387. shape: Vector3[];
  57388. path: Vector3[];
  57389. scaleFunction?: any;
  57390. rotationFunction?: any;
  57391. ribbonCloseArray?: boolean;
  57392. ribbonClosePath?: boolean;
  57393. cap?: number;
  57394. updatable?: boolean;
  57395. sideOrientation?: number;
  57396. frontUVs?: Vector4;
  57397. backUVs?: Vector4;
  57398. instance?: Mesh;
  57399. invertUV?: boolean;
  57400. }, scene?: Nullable<Scene>): Mesh;
  57401. private static _ExtrudeShapeGeneric;
  57402. }
  57403. }
  57404. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57405. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57406. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57407. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57408. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57409. import { Nullable } from "babylonjs/types";
  57410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57411. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57412. /**
  57413. * AmmoJS Physics plugin
  57414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57415. * @see https://github.com/kripken/ammo.js/
  57416. */
  57417. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57418. private _useDeltaForWorldStep;
  57419. /**
  57420. * Reference to the Ammo library
  57421. */
  57422. bjsAMMO: any;
  57423. /**
  57424. * Created ammoJS world which physics bodies are added to
  57425. */
  57426. world: any;
  57427. /**
  57428. * Name of the plugin
  57429. */
  57430. name: string;
  57431. private _timeStep;
  57432. private _fixedTimeStep;
  57433. private _maxSteps;
  57434. private _tmpQuaternion;
  57435. private _tmpAmmoTransform;
  57436. private _tmpAmmoQuaternion;
  57437. private _tmpAmmoConcreteContactResultCallback;
  57438. private _collisionConfiguration;
  57439. private _dispatcher;
  57440. private _overlappingPairCache;
  57441. private _solver;
  57442. private _softBodySolver;
  57443. private _tmpAmmoVectorA;
  57444. private _tmpAmmoVectorB;
  57445. private _tmpAmmoVectorC;
  57446. private _tmpAmmoVectorD;
  57447. private _tmpContactCallbackResult;
  57448. private _tmpAmmoVectorRCA;
  57449. private _tmpAmmoVectorRCB;
  57450. private _raycastResult;
  57451. private static readonly DISABLE_COLLISION_FLAG;
  57452. private static readonly KINEMATIC_FLAG;
  57453. private static readonly DISABLE_DEACTIVATION_FLAG;
  57454. /**
  57455. * Initializes the ammoJS plugin
  57456. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57457. * @param ammoInjection can be used to inject your own ammo reference
  57458. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57459. */
  57460. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57461. /**
  57462. * Sets the gravity of the physics world (m/(s^2))
  57463. * @param gravity Gravity to set
  57464. */
  57465. setGravity(gravity: Vector3): void;
  57466. /**
  57467. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57468. * @param timeStep timestep to use in seconds
  57469. */
  57470. setTimeStep(timeStep: number): void;
  57471. /**
  57472. * 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)
  57473. * @param fixedTimeStep fixedTimeStep to use in seconds
  57474. */
  57475. setFixedTimeStep(fixedTimeStep: number): void;
  57476. /**
  57477. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57478. * @param maxSteps the maximum number of steps by the physics engine per frame
  57479. */
  57480. setMaxSteps(maxSteps: number): void;
  57481. /**
  57482. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57483. * @returns the current timestep in seconds
  57484. */
  57485. getTimeStep(): number;
  57486. /**
  57487. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57488. */
  57489. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57490. private _isImpostorInContact;
  57491. private _isImpostorPairInContact;
  57492. private _stepSimulation;
  57493. /**
  57494. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57495. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57496. * After the step the babylon meshes are set to the position of the physics imposters
  57497. * @param delta amount of time to step forward
  57498. * @param impostors array of imposters to update before/after the step
  57499. */
  57500. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57501. /**
  57502. * Update babylon mesh to match physics world object
  57503. * @param impostor imposter to match
  57504. */
  57505. private _afterSoftStep;
  57506. /**
  57507. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57508. * @param impostor imposter to match
  57509. */
  57510. private _ropeStep;
  57511. /**
  57512. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57513. * @param impostor imposter to match
  57514. */
  57515. private _softbodyOrClothStep;
  57516. private _tmpVector;
  57517. private _tmpMatrix;
  57518. /**
  57519. * Applies an impulse on the imposter
  57520. * @param impostor imposter to apply impulse to
  57521. * @param force amount of force to be applied to the imposter
  57522. * @param contactPoint the location to apply the impulse on the imposter
  57523. */
  57524. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57525. /**
  57526. * Applies a force on the imposter
  57527. * @param impostor imposter to apply force
  57528. * @param force amount of force to be applied to the imposter
  57529. * @param contactPoint the location to apply the force on the imposter
  57530. */
  57531. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57532. /**
  57533. * Creates a physics body using the plugin
  57534. * @param impostor the imposter to create the physics body on
  57535. */
  57536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57537. /**
  57538. * Removes the physics body from the imposter and disposes of the body's memory
  57539. * @param impostor imposter to remove the physics body from
  57540. */
  57541. removePhysicsBody(impostor: PhysicsImpostor): void;
  57542. /**
  57543. * Generates a joint
  57544. * @param impostorJoint the imposter joint to create the joint with
  57545. */
  57546. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57547. /**
  57548. * Removes a joint
  57549. * @param impostorJoint the imposter joint to remove the joint from
  57550. */
  57551. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57552. private _addMeshVerts;
  57553. /**
  57554. * Initialise the soft body vertices to match its object's (mesh) vertices
  57555. * Softbody vertices (nodes) are in world space and to match this
  57556. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57557. * @param impostor to create the softbody for
  57558. */
  57559. private _softVertexData;
  57560. /**
  57561. * Create an impostor's soft body
  57562. * @param impostor to create the softbody for
  57563. */
  57564. private _createSoftbody;
  57565. /**
  57566. * Create cloth for an impostor
  57567. * @param impostor to create the softbody for
  57568. */
  57569. private _createCloth;
  57570. /**
  57571. * Create rope for an impostor
  57572. * @param impostor to create the softbody for
  57573. */
  57574. private _createRope;
  57575. /**
  57576. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57577. * @param impostor to create the custom physics shape for
  57578. */
  57579. private _createCustom;
  57580. private _addHullVerts;
  57581. private _createShape;
  57582. /**
  57583. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57584. * @param impostor imposter containing the physics body and babylon object
  57585. */
  57586. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57587. /**
  57588. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57589. * @param impostor imposter containing the physics body and babylon object
  57590. * @param newPosition new position
  57591. * @param newRotation new rotation
  57592. */
  57593. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57594. /**
  57595. * If this plugin is supported
  57596. * @returns true if its supported
  57597. */
  57598. isSupported(): boolean;
  57599. /**
  57600. * Sets the linear velocity of the physics body
  57601. * @param impostor imposter to set the velocity on
  57602. * @param velocity velocity to set
  57603. */
  57604. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57605. /**
  57606. * Sets the angular velocity of the physics body
  57607. * @param impostor imposter to set the velocity on
  57608. * @param velocity velocity to set
  57609. */
  57610. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57611. /**
  57612. * gets the linear velocity
  57613. * @param impostor imposter to get linear velocity from
  57614. * @returns linear velocity
  57615. */
  57616. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57617. /**
  57618. * gets the angular velocity
  57619. * @param impostor imposter to get angular velocity from
  57620. * @returns angular velocity
  57621. */
  57622. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57623. /**
  57624. * Sets the mass of physics body
  57625. * @param impostor imposter to set the mass on
  57626. * @param mass mass to set
  57627. */
  57628. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57629. /**
  57630. * Gets the mass of the physics body
  57631. * @param impostor imposter to get the mass from
  57632. * @returns mass
  57633. */
  57634. getBodyMass(impostor: PhysicsImpostor): number;
  57635. /**
  57636. * Gets friction of the impostor
  57637. * @param impostor impostor to get friction from
  57638. * @returns friction value
  57639. */
  57640. getBodyFriction(impostor: PhysicsImpostor): number;
  57641. /**
  57642. * Sets friction of the impostor
  57643. * @param impostor impostor to set friction on
  57644. * @param friction friction value
  57645. */
  57646. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57647. /**
  57648. * Gets restitution of the impostor
  57649. * @param impostor impostor to get restitution from
  57650. * @returns restitution value
  57651. */
  57652. getBodyRestitution(impostor: PhysicsImpostor): number;
  57653. /**
  57654. * Sets resitution of the impostor
  57655. * @param impostor impostor to set resitution on
  57656. * @param restitution resitution value
  57657. */
  57658. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57659. /**
  57660. * Gets pressure inside the impostor
  57661. * @param impostor impostor to get pressure from
  57662. * @returns pressure value
  57663. */
  57664. getBodyPressure(impostor: PhysicsImpostor): number;
  57665. /**
  57666. * Sets pressure inside a soft body impostor
  57667. * Cloth and rope must remain 0 pressure
  57668. * @param impostor impostor to set pressure on
  57669. * @param pressure pressure value
  57670. */
  57671. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57672. /**
  57673. * Gets stiffness of the impostor
  57674. * @param impostor impostor to get stiffness from
  57675. * @returns pressure value
  57676. */
  57677. getBodyStiffness(impostor: PhysicsImpostor): number;
  57678. /**
  57679. * Sets stiffness of the impostor
  57680. * @param impostor impostor to set stiffness on
  57681. * @param stiffness stiffness value from 0 to 1
  57682. */
  57683. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57684. /**
  57685. * Gets velocityIterations of the impostor
  57686. * @param impostor impostor to get velocity iterations from
  57687. * @returns velocityIterations value
  57688. */
  57689. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57690. /**
  57691. * Sets velocityIterations of the impostor
  57692. * @param impostor impostor to set velocity iterations on
  57693. * @param velocityIterations velocityIterations value
  57694. */
  57695. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57696. /**
  57697. * Gets positionIterations of the impostor
  57698. * @param impostor impostor to get position iterations from
  57699. * @returns positionIterations value
  57700. */
  57701. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57702. /**
  57703. * Sets positionIterations of the impostor
  57704. * @param impostor impostor to set position on
  57705. * @param positionIterations positionIterations value
  57706. */
  57707. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57708. /**
  57709. * Append an anchor to a cloth object
  57710. * @param impostor is the cloth impostor to add anchor to
  57711. * @param otherImpostor is the rigid impostor to anchor to
  57712. * @param width ratio across width from 0 to 1
  57713. * @param height ratio up height from 0 to 1
  57714. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57715. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57716. */
  57717. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57718. /**
  57719. * Append an hook to a rope object
  57720. * @param impostor is the rope impostor to add hook to
  57721. * @param otherImpostor is the rigid impostor to hook to
  57722. * @param length ratio along the rope from 0 to 1
  57723. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57724. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57725. */
  57726. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57727. /**
  57728. * Sleeps the physics body and stops it from being active
  57729. * @param impostor impostor to sleep
  57730. */
  57731. sleepBody(impostor: PhysicsImpostor): void;
  57732. /**
  57733. * Activates the physics body
  57734. * @param impostor impostor to activate
  57735. */
  57736. wakeUpBody(impostor: PhysicsImpostor): void;
  57737. /**
  57738. * Updates the distance parameters of the joint
  57739. * @param joint joint to update
  57740. * @param maxDistance maximum distance of the joint
  57741. * @param minDistance minimum distance of the joint
  57742. */
  57743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57744. /**
  57745. * Sets a motor on the joint
  57746. * @param joint joint to set motor on
  57747. * @param speed speed of the motor
  57748. * @param maxForce maximum force of the motor
  57749. * @param motorIndex index of the motor
  57750. */
  57751. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57752. /**
  57753. * Sets the motors limit
  57754. * @param joint joint to set limit on
  57755. * @param upperLimit upper limit
  57756. * @param lowerLimit lower limit
  57757. */
  57758. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57759. /**
  57760. * Syncs the position and rotation of a mesh with the impostor
  57761. * @param mesh mesh to sync
  57762. * @param impostor impostor to update the mesh with
  57763. */
  57764. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57765. /**
  57766. * Gets the radius of the impostor
  57767. * @param impostor impostor to get radius from
  57768. * @returns the radius
  57769. */
  57770. getRadius(impostor: PhysicsImpostor): number;
  57771. /**
  57772. * Gets the box size of the impostor
  57773. * @param impostor impostor to get box size from
  57774. * @param result the resulting box size
  57775. */
  57776. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57777. /**
  57778. * Disposes of the impostor
  57779. */
  57780. dispose(): void;
  57781. /**
  57782. * Does a raycast in the physics world
  57783. * @param from when should the ray start?
  57784. * @param to when should the ray end?
  57785. * @returns PhysicsRaycastResult
  57786. */
  57787. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57788. }
  57789. }
  57790. declare module "babylonjs/Probes/reflectionProbe" {
  57791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57792. import { Vector3 } from "babylonjs/Maths/math.vector";
  57793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57794. import { Nullable } from "babylonjs/types";
  57795. import { Scene } from "babylonjs/scene";
  57796. module "babylonjs/abstractScene" {
  57797. interface AbstractScene {
  57798. /**
  57799. * The list of reflection probes added to the scene
  57800. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57801. */
  57802. reflectionProbes: Array<ReflectionProbe>;
  57803. /**
  57804. * Removes the given reflection probe from this scene.
  57805. * @param toRemove The reflection probe to remove
  57806. * @returns The index of the removed reflection probe
  57807. */
  57808. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57809. /**
  57810. * Adds the given reflection probe to this scene.
  57811. * @param newReflectionProbe The reflection probe to add
  57812. */
  57813. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57814. }
  57815. }
  57816. /**
  57817. * Class used to generate realtime reflection / refraction cube textures
  57818. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57819. */
  57820. export class ReflectionProbe {
  57821. /** defines the name of the probe */
  57822. name: string;
  57823. private _scene;
  57824. private _renderTargetTexture;
  57825. private _projectionMatrix;
  57826. private _viewMatrix;
  57827. private _target;
  57828. private _add;
  57829. private _attachedMesh;
  57830. private _invertYAxis;
  57831. /** Gets or sets probe position (center of the cube map) */
  57832. position: Vector3;
  57833. /**
  57834. * Creates a new reflection probe
  57835. * @param name defines the name of the probe
  57836. * @param size defines the texture resolution (for each face)
  57837. * @param scene defines the hosting scene
  57838. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57839. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57840. */
  57841. constructor(
  57842. /** defines the name of the probe */
  57843. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57844. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57845. get samples(): number;
  57846. set samples(value: number);
  57847. /** Gets or sets the refresh rate to use (on every frame by default) */
  57848. get refreshRate(): number;
  57849. set refreshRate(value: number);
  57850. /**
  57851. * Gets the hosting scene
  57852. * @returns a Scene
  57853. */
  57854. getScene(): Scene;
  57855. /** Gets the internal CubeTexture used to render to */
  57856. get cubeTexture(): RenderTargetTexture;
  57857. /** Gets the list of meshes to render */
  57858. get renderList(): Nullable<AbstractMesh[]>;
  57859. /**
  57860. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57861. * @param mesh defines the mesh to attach to
  57862. */
  57863. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57864. /**
  57865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57866. * @param renderingGroupId The rendering group id corresponding to its index
  57867. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57868. */
  57869. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57870. /**
  57871. * Clean all associated resources
  57872. */
  57873. dispose(): void;
  57874. /**
  57875. * Converts the reflection probe information to a readable string for debug purpose.
  57876. * @param fullDetails Supports for multiple levels of logging within scene loading
  57877. * @returns the human readable reflection probe info
  57878. */
  57879. toString(fullDetails?: boolean): string;
  57880. /**
  57881. * Get the class name of the relfection probe.
  57882. * @returns "ReflectionProbe"
  57883. */
  57884. getClassName(): string;
  57885. /**
  57886. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  57887. * @returns The JSON representation of the texture
  57888. */
  57889. serialize(): any;
  57890. /**
  57891. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  57892. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  57893. * @param scene Define the scene the parsed reflection probe should be instantiated in
  57894. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  57895. * @returns The parsed reflection probe if successful
  57896. */
  57897. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  57898. }
  57899. }
  57900. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  57901. /** @hidden */
  57902. export var _BabylonLoaderRegistered: boolean;
  57903. /**
  57904. * Helps setting up some configuration for the babylon file loader.
  57905. */
  57906. export class BabylonFileLoaderConfiguration {
  57907. /**
  57908. * The loader does not allow injecting custom physix engine into the plugins.
  57909. * Unfortunately in ES6, we need to manually inject them into the plugin.
  57910. * So you could set this variable to your engine import to make it work.
  57911. */
  57912. static LoaderInjectedPhysicsEngine: any;
  57913. }
  57914. }
  57915. declare module "babylonjs/Loading/Plugins/index" {
  57916. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  57917. }
  57918. declare module "babylonjs/Loading/index" {
  57919. export * from "babylonjs/Loading/loadingScreen";
  57920. export * from "babylonjs/Loading/Plugins/index";
  57921. export * from "babylonjs/Loading/sceneLoader";
  57922. export * from "babylonjs/Loading/sceneLoaderFlags";
  57923. }
  57924. declare module "babylonjs/Materials/Background/index" {
  57925. export * from "babylonjs/Materials/Background/backgroundMaterial";
  57926. }
  57927. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  57928. import { Scene } from "babylonjs/scene";
  57929. import { Color3 } from "babylonjs/Maths/math.color";
  57930. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57932. /**
  57933. * The Physically based simple base material of BJS.
  57934. *
  57935. * This enables better naming and convention enforcements on top of the pbrMaterial.
  57936. * It is used as the base class for both the specGloss and metalRough conventions.
  57937. */
  57938. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  57939. /**
  57940. * Number of Simultaneous lights allowed on the material.
  57941. */
  57942. maxSimultaneousLights: number;
  57943. /**
  57944. * If sets to true, disables all the lights affecting the material.
  57945. */
  57946. disableLighting: boolean;
  57947. /**
  57948. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  57949. */
  57950. environmentTexture: BaseTexture;
  57951. /**
  57952. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57953. */
  57954. invertNormalMapX: boolean;
  57955. /**
  57956. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57957. */
  57958. invertNormalMapY: boolean;
  57959. /**
  57960. * Normal map used in the model.
  57961. */
  57962. normalTexture: BaseTexture;
  57963. /**
  57964. * Emissivie color used to self-illuminate the model.
  57965. */
  57966. emissiveColor: Color3;
  57967. /**
  57968. * Emissivie texture used to self-illuminate the model.
  57969. */
  57970. emissiveTexture: BaseTexture;
  57971. /**
  57972. * Occlusion Channel Strenght.
  57973. */
  57974. occlusionStrength: number;
  57975. /**
  57976. * Occlusion Texture of the material (adding extra occlusion effects).
  57977. */
  57978. occlusionTexture: BaseTexture;
  57979. /**
  57980. * Defines the alpha limits in alpha test mode.
  57981. */
  57982. alphaCutOff: number;
  57983. /**
  57984. * Gets the current double sided mode.
  57985. */
  57986. get doubleSided(): boolean;
  57987. /**
  57988. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57989. */
  57990. set doubleSided(value: boolean);
  57991. /**
  57992. * Stores the pre-calculated light information of a mesh in a texture.
  57993. */
  57994. lightmapTexture: BaseTexture;
  57995. /**
  57996. * If true, the light map contains occlusion information instead of lighting info.
  57997. */
  57998. useLightmapAsShadowmap: boolean;
  57999. /**
  58000. * Instantiates a new PBRMaterial instance.
  58001. *
  58002. * @param name The material name
  58003. * @param scene The scene the material will be use in.
  58004. */
  58005. constructor(name: string, scene: Scene);
  58006. getClassName(): string;
  58007. }
  58008. }
  58009. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58010. import { Scene } from "babylonjs/scene";
  58011. import { Color3 } from "babylonjs/Maths/math.color";
  58012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58013. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58014. /**
  58015. * The PBR material of BJS following the metal roughness convention.
  58016. *
  58017. * This fits to the PBR convention in the GLTF definition:
  58018. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58019. */
  58020. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58021. /**
  58022. * The base color has two different interpretations depending on the value of metalness.
  58023. * When the material is a metal, the base color is the specific measured reflectance value
  58024. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58025. * of the material.
  58026. */
  58027. baseColor: Color3;
  58028. /**
  58029. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58030. * well as opacity information in the alpha channel.
  58031. */
  58032. baseTexture: BaseTexture;
  58033. /**
  58034. * Specifies the metallic scalar value of the material.
  58035. * Can also be used to scale the metalness values of the metallic texture.
  58036. */
  58037. metallic: number;
  58038. /**
  58039. * Specifies the roughness scalar value of the material.
  58040. * Can also be used to scale the roughness values of the metallic texture.
  58041. */
  58042. roughness: number;
  58043. /**
  58044. * Texture containing both the metallic value in the B channel and the
  58045. * roughness value in the G channel to keep better precision.
  58046. */
  58047. metallicRoughnessTexture: BaseTexture;
  58048. /**
  58049. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58050. *
  58051. * @param name The material name
  58052. * @param scene The scene the material will be use in.
  58053. */
  58054. constructor(name: string, scene: Scene);
  58055. /**
  58056. * Return the currrent class name of the material.
  58057. */
  58058. getClassName(): string;
  58059. /**
  58060. * Makes a duplicate of the current material.
  58061. * @param name - name to use for the new material.
  58062. */
  58063. clone(name: string): PBRMetallicRoughnessMaterial;
  58064. /**
  58065. * Serialize the material to a parsable JSON object.
  58066. */
  58067. serialize(): any;
  58068. /**
  58069. * Parses a JSON object correponding to the serialize function.
  58070. */
  58071. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58072. }
  58073. }
  58074. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58075. import { Scene } from "babylonjs/scene";
  58076. import { Color3 } from "babylonjs/Maths/math.color";
  58077. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58078. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58079. /**
  58080. * The PBR material of BJS following the specular glossiness convention.
  58081. *
  58082. * This fits to the PBR convention in the GLTF definition:
  58083. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58084. */
  58085. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58086. /**
  58087. * Specifies the diffuse color of the material.
  58088. */
  58089. diffuseColor: Color3;
  58090. /**
  58091. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58092. * channel.
  58093. */
  58094. diffuseTexture: BaseTexture;
  58095. /**
  58096. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58097. */
  58098. specularColor: Color3;
  58099. /**
  58100. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58101. */
  58102. glossiness: number;
  58103. /**
  58104. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58105. */
  58106. specularGlossinessTexture: BaseTexture;
  58107. /**
  58108. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58109. *
  58110. * @param name The material name
  58111. * @param scene The scene the material will be use in.
  58112. */
  58113. constructor(name: string, scene: Scene);
  58114. /**
  58115. * Return the currrent class name of the material.
  58116. */
  58117. getClassName(): string;
  58118. /**
  58119. * Makes a duplicate of the current material.
  58120. * @param name - name to use for the new material.
  58121. */
  58122. clone(name: string): PBRSpecularGlossinessMaterial;
  58123. /**
  58124. * Serialize the material to a parsable JSON object.
  58125. */
  58126. serialize(): any;
  58127. /**
  58128. * Parses a JSON object correponding to the serialize function.
  58129. */
  58130. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58131. }
  58132. }
  58133. declare module "babylonjs/Materials/PBR/index" {
  58134. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58135. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58136. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58137. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58138. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58139. }
  58140. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58141. import { Nullable } from "babylonjs/types";
  58142. import { Scene } from "babylonjs/scene";
  58143. import { Matrix } from "babylonjs/Maths/math.vector";
  58144. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58145. /**
  58146. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58147. * It can help converting any input color in a desired output one. This can then be used to create effects
  58148. * from sepia, black and white to sixties or futuristic rendering...
  58149. *
  58150. * The only supported format is currently 3dl.
  58151. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58152. */
  58153. export class ColorGradingTexture extends BaseTexture {
  58154. /**
  58155. * The current texture matrix. (will always be identity in color grading texture)
  58156. */
  58157. private _textureMatrix;
  58158. /**
  58159. * The texture URL.
  58160. */
  58161. url: string;
  58162. /**
  58163. * Empty line regex stored for GC.
  58164. */
  58165. private static _noneEmptyLineRegex;
  58166. private _engine;
  58167. /**
  58168. * Instantiates a ColorGradingTexture from the following parameters.
  58169. *
  58170. * @param url The location of the color gradind data (currently only supporting 3dl)
  58171. * @param scene The scene the texture will be used in
  58172. */
  58173. constructor(url: string, scene: Scene);
  58174. /**
  58175. * Returns the texture matrix used in most of the material.
  58176. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58177. */
  58178. getTextureMatrix(): Matrix;
  58179. /**
  58180. * Occurs when the file being loaded is a .3dl LUT file.
  58181. */
  58182. private load3dlTexture;
  58183. /**
  58184. * Starts the loading process of the texture.
  58185. */
  58186. private loadTexture;
  58187. /**
  58188. * Clones the color gradind texture.
  58189. */
  58190. clone(): ColorGradingTexture;
  58191. /**
  58192. * Called during delayed load for textures.
  58193. */
  58194. delayLoad(): void;
  58195. /**
  58196. * Parses a color grading texture serialized by Babylon.
  58197. * @param parsedTexture The texture information being parsedTexture
  58198. * @param scene The scene to load the texture in
  58199. * @param rootUrl The root url of the data assets to load
  58200. * @return A color gradind texture
  58201. */
  58202. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58203. /**
  58204. * Serializes the LUT texture to json format.
  58205. */
  58206. serialize(): any;
  58207. }
  58208. }
  58209. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58210. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58211. import { Scene } from "babylonjs/scene";
  58212. import { Nullable } from "babylonjs/types";
  58213. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58214. /**
  58215. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58216. */
  58217. export class EquiRectangularCubeTexture extends BaseTexture {
  58218. /** The six faces of the cube. */
  58219. private static _FacesMapping;
  58220. private _noMipmap;
  58221. private _onLoad;
  58222. private _onError;
  58223. /** The size of the cubemap. */
  58224. private _size;
  58225. /** The buffer of the image. */
  58226. private _buffer;
  58227. /** The width of the input image. */
  58228. private _width;
  58229. /** The height of the input image. */
  58230. private _height;
  58231. /** The URL to the image. */
  58232. url: string;
  58233. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58234. coordinatesMode: number;
  58235. /**
  58236. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58237. * @param url The location of the image
  58238. * @param scene The scene the texture will be used in
  58239. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58240. * @param noMipmap Forces to not generate the mipmap if true
  58241. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58242. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58243. * @param onLoad — defines a callback called when texture is loaded
  58244. * @param onError — defines a callback called if there is an error
  58245. */
  58246. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58247. /**
  58248. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58249. */
  58250. private loadImage;
  58251. /**
  58252. * Convert the image buffer into a cubemap and create a CubeTexture.
  58253. */
  58254. private loadTexture;
  58255. /**
  58256. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58257. * @param buffer The ArrayBuffer that should be converted.
  58258. * @returns The buffer as Float32Array.
  58259. */
  58260. private getFloat32ArrayFromArrayBuffer;
  58261. /**
  58262. * Get the current class name of the texture useful for serialization or dynamic coding.
  58263. * @returns "EquiRectangularCubeTexture"
  58264. */
  58265. getClassName(): string;
  58266. /**
  58267. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58268. * @returns A clone of the current EquiRectangularCubeTexture.
  58269. */
  58270. clone(): EquiRectangularCubeTexture;
  58271. }
  58272. }
  58273. declare module "babylonjs/Misc/tga" {
  58274. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58275. /**
  58276. * Based on jsTGALoader - Javascript loader for TGA file
  58277. * By Vincent Thibault
  58278. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58279. */
  58280. export class TGATools {
  58281. private static _TYPE_INDEXED;
  58282. private static _TYPE_RGB;
  58283. private static _TYPE_GREY;
  58284. private static _TYPE_RLE_INDEXED;
  58285. private static _TYPE_RLE_RGB;
  58286. private static _TYPE_RLE_GREY;
  58287. private static _ORIGIN_MASK;
  58288. private static _ORIGIN_SHIFT;
  58289. private static _ORIGIN_BL;
  58290. private static _ORIGIN_BR;
  58291. private static _ORIGIN_UL;
  58292. private static _ORIGIN_UR;
  58293. /**
  58294. * Gets the header of a TGA file
  58295. * @param data defines the TGA data
  58296. * @returns the header
  58297. */
  58298. static GetTGAHeader(data: Uint8Array): any;
  58299. /**
  58300. * Uploads TGA content to a Babylon Texture
  58301. * @hidden
  58302. */
  58303. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58304. /** @hidden */
  58305. 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;
  58306. /** @hidden */
  58307. 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;
  58308. /** @hidden */
  58309. 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;
  58310. /** @hidden */
  58311. 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;
  58312. /** @hidden */
  58313. 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;
  58314. /** @hidden */
  58315. 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;
  58316. }
  58317. }
  58318. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58319. import { Nullable } from "babylonjs/types";
  58320. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58321. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58322. /**
  58323. * Implementation of the TGA Texture Loader.
  58324. * @hidden
  58325. */
  58326. export class _TGATextureLoader implements IInternalTextureLoader {
  58327. /**
  58328. * Defines wether the loader supports cascade loading the different faces.
  58329. */
  58330. readonly supportCascades: boolean;
  58331. /**
  58332. * This returns if the loader support the current file information.
  58333. * @param extension defines the file extension of the file being loaded
  58334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58335. * @param fallback defines the fallback internal texture if any
  58336. * @param isBase64 defines whether the texture is encoded as a base64
  58337. * @param isBuffer defines whether the texture data are stored as a buffer
  58338. * @returns true if the loader can load the specified file
  58339. */
  58340. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58341. /**
  58342. * Transform the url before loading if required.
  58343. * @param rootUrl the url of the texture
  58344. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58345. * @returns the transformed texture
  58346. */
  58347. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58348. /**
  58349. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58350. * @param rootUrl the url of the texture
  58351. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58352. * @returns the fallback texture
  58353. */
  58354. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58355. /**
  58356. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58357. * @param data contains the texture data
  58358. * @param texture defines the BabylonJS internal texture
  58359. * @param createPolynomials will be true if polynomials have been requested
  58360. * @param onLoad defines the callback to trigger once the texture is ready
  58361. * @param onError defines the callback to trigger in case of error
  58362. */
  58363. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58364. /**
  58365. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58366. * @param data contains the texture data
  58367. * @param texture defines the BabylonJS internal texture
  58368. * @param callback defines the method to call once ready to upload
  58369. */
  58370. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58371. }
  58372. }
  58373. declare module "babylonjs/Misc/basis" {
  58374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58375. /**
  58376. * Info about the .basis files
  58377. */
  58378. class BasisFileInfo {
  58379. /**
  58380. * If the file has alpha
  58381. */
  58382. hasAlpha: boolean;
  58383. /**
  58384. * Info about each image of the basis file
  58385. */
  58386. images: Array<{
  58387. levels: Array<{
  58388. width: number;
  58389. height: number;
  58390. transcodedPixels: ArrayBufferView;
  58391. }>;
  58392. }>;
  58393. }
  58394. /**
  58395. * Result of transcoding a basis file
  58396. */
  58397. class TranscodeResult {
  58398. /**
  58399. * Info about the .basis file
  58400. */
  58401. fileInfo: BasisFileInfo;
  58402. /**
  58403. * Format to use when loading the file
  58404. */
  58405. format: number;
  58406. }
  58407. /**
  58408. * Configuration options for the Basis transcoder
  58409. */
  58410. export class BasisTranscodeConfiguration {
  58411. /**
  58412. * Supported compression formats used to determine the supported output format of the transcoder
  58413. */
  58414. supportedCompressionFormats?: {
  58415. /**
  58416. * etc1 compression format
  58417. */
  58418. etc1?: boolean;
  58419. /**
  58420. * s3tc compression format
  58421. */
  58422. s3tc?: boolean;
  58423. /**
  58424. * pvrtc compression format
  58425. */
  58426. pvrtc?: boolean;
  58427. /**
  58428. * etc2 compression format
  58429. */
  58430. etc2?: boolean;
  58431. };
  58432. /**
  58433. * If mipmap levels should be loaded for transcoded images (Default: true)
  58434. */
  58435. loadMipmapLevels?: boolean;
  58436. /**
  58437. * Index of a single image to load (Default: all images)
  58438. */
  58439. loadSingleImage?: number;
  58440. }
  58441. /**
  58442. * Used to load .Basis files
  58443. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58444. */
  58445. export class BasisTools {
  58446. private static _IgnoreSupportedFormats;
  58447. /**
  58448. * URL to use when loading the basis transcoder
  58449. */
  58450. static JSModuleURL: string;
  58451. /**
  58452. * URL to use when loading the wasm module for the transcoder
  58453. */
  58454. static WasmModuleURL: string;
  58455. /**
  58456. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58457. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58458. * @returns internal format corresponding to the Basis format
  58459. */
  58460. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58461. private static _WorkerPromise;
  58462. private static _Worker;
  58463. private static _actionId;
  58464. private static _CreateWorkerAsync;
  58465. /**
  58466. * Transcodes a loaded image file to compressed pixel data
  58467. * @param data image data to transcode
  58468. * @param config configuration options for the transcoding
  58469. * @returns a promise resulting in the transcoded image
  58470. */
  58471. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58472. /**
  58473. * Loads a texture from the transcode result
  58474. * @param texture texture load to
  58475. * @param transcodeResult the result of transcoding the basis file to load from
  58476. */
  58477. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58478. }
  58479. }
  58480. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58481. import { Nullable } from "babylonjs/types";
  58482. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58483. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58484. /**
  58485. * Loader for .basis file format
  58486. */
  58487. export class _BasisTextureLoader implements IInternalTextureLoader {
  58488. /**
  58489. * Defines whether the loader supports cascade loading the different faces.
  58490. */
  58491. readonly supportCascades: boolean;
  58492. /**
  58493. * This returns if the loader support the current file information.
  58494. * @param extension defines the file extension of the file being loaded
  58495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58496. * @param fallback defines the fallback internal texture if any
  58497. * @param isBase64 defines whether the texture is encoded as a base64
  58498. * @param isBuffer defines whether the texture data are stored as a buffer
  58499. * @returns true if the loader can load the specified file
  58500. */
  58501. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58502. /**
  58503. * Transform the url before loading if required.
  58504. * @param rootUrl the url of the texture
  58505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58506. * @returns the transformed texture
  58507. */
  58508. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58509. /**
  58510. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58511. * @param rootUrl the url of the texture
  58512. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58513. * @returns the fallback texture
  58514. */
  58515. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58516. /**
  58517. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58518. * @param data contains the texture data
  58519. * @param texture defines the BabylonJS internal texture
  58520. * @param createPolynomials will be true if polynomials have been requested
  58521. * @param onLoad defines the callback to trigger once the texture is ready
  58522. * @param onError defines the callback to trigger in case of error
  58523. */
  58524. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58525. /**
  58526. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58527. * @param data contains the texture data
  58528. * @param texture defines the BabylonJS internal texture
  58529. * @param callback defines the method to call once ready to upload
  58530. */
  58531. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58532. }
  58533. }
  58534. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58535. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58536. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58537. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58538. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58539. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58540. }
  58541. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58542. import { Scene } from "babylonjs/scene";
  58543. import { Texture } from "babylonjs/Materials/Textures/texture";
  58544. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58545. /**
  58546. * 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.
  58547. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58548. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58549. */
  58550. export class CustomProceduralTexture extends ProceduralTexture {
  58551. private _animate;
  58552. private _time;
  58553. private _config;
  58554. private _texturePath;
  58555. /**
  58556. * Instantiates a new Custom Procedural Texture.
  58557. * 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.
  58558. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58559. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58560. * @param name Define the name of the texture
  58561. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58562. * @param size Define the size of the texture to create
  58563. * @param scene Define the scene the texture belongs to
  58564. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58565. * @param generateMipMaps Define if the texture should creates mip maps or not
  58566. */
  58567. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58568. private _loadJson;
  58569. /**
  58570. * Is the texture ready to be used ? (rendered at least once)
  58571. * @returns true if ready, otherwise, false.
  58572. */
  58573. isReady(): boolean;
  58574. /**
  58575. * Render the texture to its associated render target.
  58576. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58577. */
  58578. render(useCameraPostProcess?: boolean): void;
  58579. /**
  58580. * Update the list of dependant textures samplers in the shader.
  58581. */
  58582. updateTextures(): void;
  58583. /**
  58584. * Update the uniform values of the procedural texture in the shader.
  58585. */
  58586. updateShaderUniforms(): void;
  58587. /**
  58588. * Define if the texture animates or not.
  58589. */
  58590. get animate(): boolean;
  58591. set animate(value: boolean);
  58592. }
  58593. }
  58594. declare module "babylonjs/Shaders/noise.fragment" {
  58595. /** @hidden */
  58596. export var noisePixelShader: {
  58597. name: string;
  58598. shader: string;
  58599. };
  58600. }
  58601. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58602. import { Nullable } from "babylonjs/types";
  58603. import { Scene } from "babylonjs/scene";
  58604. import { Texture } from "babylonjs/Materials/Textures/texture";
  58605. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58606. import "babylonjs/Shaders/noise.fragment";
  58607. /**
  58608. * Class used to generate noise procedural textures
  58609. */
  58610. export class NoiseProceduralTexture extends ProceduralTexture {
  58611. private _time;
  58612. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58613. brightness: number;
  58614. /** Defines the number of octaves to process */
  58615. octaves: number;
  58616. /** Defines the level of persistence (0.8 by default) */
  58617. persistence: number;
  58618. /** Gets or sets animation speed factor (default is 1) */
  58619. animationSpeedFactor: number;
  58620. /**
  58621. * Creates a new NoiseProceduralTexture
  58622. * @param name defines the name fo the texture
  58623. * @param size defines the size of the texture (default is 256)
  58624. * @param scene defines the hosting scene
  58625. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58626. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58627. */
  58628. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58629. private _updateShaderUniforms;
  58630. protected _getDefines(): string;
  58631. /** Generate the current state of the procedural texture */
  58632. render(useCameraPostProcess?: boolean): void;
  58633. /**
  58634. * Serializes this noise procedural texture
  58635. * @returns a serialized noise procedural texture object
  58636. */
  58637. serialize(): any;
  58638. /**
  58639. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58640. * @param parsedTexture defines parsed texture data
  58641. * @param scene defines the current scene
  58642. * @param rootUrl defines the root URL containing noise procedural texture information
  58643. * @returns a parsed NoiseProceduralTexture
  58644. */
  58645. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58646. }
  58647. }
  58648. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58649. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58650. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58651. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58652. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58653. }
  58654. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58655. import { Nullable } from "babylonjs/types";
  58656. import { Scene } from "babylonjs/scene";
  58657. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58658. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58659. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58660. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58661. /**
  58662. * Raw cube texture where the raw buffers are passed in
  58663. */
  58664. export class RawCubeTexture extends CubeTexture {
  58665. /**
  58666. * Creates a cube texture where the raw buffers are passed in.
  58667. * @param scene defines the scene the texture is attached to
  58668. * @param data defines the array of data to use to create each face
  58669. * @param size defines the size of the textures
  58670. * @param format defines the format of the data
  58671. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58672. * @param generateMipMaps defines if the engine should generate the mip levels
  58673. * @param invertY defines if data must be stored with Y axis inverted
  58674. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58675. * @param compression defines the compression used (null by default)
  58676. */
  58677. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58678. /**
  58679. * Updates the raw cube texture.
  58680. * @param data defines the data to store
  58681. * @param format defines the data format
  58682. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58683. * @param invertY defines if data must be stored with Y axis inverted
  58684. * @param compression defines the compression used (null by default)
  58685. * @param level defines which level of the texture to update
  58686. */
  58687. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58688. /**
  58689. * Updates a raw cube texture with RGBD encoded data.
  58690. * @param data defines the array of data [mipmap][face] to use to create each face
  58691. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58692. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58693. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58694. * @returns a promsie that resolves when the operation is complete
  58695. */
  58696. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58697. /**
  58698. * Clones the raw cube texture.
  58699. * @return a new cube texture
  58700. */
  58701. clone(): CubeTexture;
  58702. /** @hidden */
  58703. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58704. }
  58705. }
  58706. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58707. import { Scene } from "babylonjs/scene";
  58708. import { Texture } from "babylonjs/Materials/Textures/texture";
  58709. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58710. /**
  58711. * Class used to store 3D textures containing user data
  58712. */
  58713. export class RawTexture3D extends Texture {
  58714. /** Gets or sets the texture format to use */
  58715. format: number;
  58716. private _engine;
  58717. /**
  58718. * Create a new RawTexture3D
  58719. * @param data defines the data of the texture
  58720. * @param width defines the width of the texture
  58721. * @param height defines the height of the texture
  58722. * @param depth defines the depth of the texture
  58723. * @param format defines the texture format to use
  58724. * @param scene defines the hosting scene
  58725. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58726. * @param invertY defines if texture must be stored with Y axis inverted
  58727. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58729. */
  58730. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58731. /** Gets or sets the texture format to use */
  58732. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58733. /**
  58734. * Update the texture with new data
  58735. * @param data defines the data to store in the texture
  58736. */
  58737. update(data: ArrayBufferView): void;
  58738. }
  58739. }
  58740. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58741. import { Scene } from "babylonjs/scene";
  58742. import { Texture } from "babylonjs/Materials/Textures/texture";
  58743. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58744. /**
  58745. * Class used to store 2D array textures containing user data
  58746. */
  58747. export class RawTexture2DArray extends Texture {
  58748. /** Gets or sets the texture format to use */
  58749. format: number;
  58750. private _engine;
  58751. /**
  58752. * Create a new RawTexture2DArray
  58753. * @param data defines the data of the texture
  58754. * @param width defines the width of the texture
  58755. * @param height defines the height of the texture
  58756. * @param depth defines the number of layers of the texture
  58757. * @param format defines the texture format to use
  58758. * @param scene defines the hosting scene
  58759. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58760. * @param invertY defines if texture must be stored with Y axis inverted
  58761. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58762. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58763. */
  58764. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58765. /** Gets or sets the texture format to use */
  58766. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58767. /**
  58768. * Update the texture with new data
  58769. * @param data defines the data to store in the texture
  58770. */
  58771. update(data: ArrayBufferView): void;
  58772. }
  58773. }
  58774. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58775. import { Scene } from "babylonjs/scene";
  58776. import { Plane } from "babylonjs/Maths/math.plane";
  58777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58778. /**
  58779. * Creates a refraction texture used by refraction channel of the standard material.
  58780. * It is like a mirror but to see through a material.
  58781. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58782. */
  58783. export class RefractionTexture extends RenderTargetTexture {
  58784. /**
  58785. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58786. * 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.
  58787. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58788. */
  58789. refractionPlane: Plane;
  58790. /**
  58791. * Define how deep under the surface we should see.
  58792. */
  58793. depth: number;
  58794. /**
  58795. * Creates a refraction texture used by refraction channel of the standard material.
  58796. * It is like a mirror but to see through a material.
  58797. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58798. * @param name Define the texture name
  58799. * @param size Define the size of the underlying texture
  58800. * @param scene Define the scene the refraction belongs to
  58801. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58802. */
  58803. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58804. /**
  58805. * Clone the refraction texture.
  58806. * @returns the cloned texture
  58807. */
  58808. clone(): RefractionTexture;
  58809. /**
  58810. * Serialize the texture to a JSON representation you could use in Parse later on
  58811. * @returns the serialized JSON representation
  58812. */
  58813. serialize(): any;
  58814. }
  58815. }
  58816. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58817. import { Nullable } from "babylonjs/types";
  58818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58819. import { Matrix } from "babylonjs/Maths/math.vector";
  58820. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58821. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58822. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58823. import { Scene } from "babylonjs/scene";
  58824. /**
  58825. * Defines the options related to the creation of an HtmlElementTexture
  58826. */
  58827. export interface IHtmlElementTextureOptions {
  58828. /**
  58829. * Defines wether mip maps should be created or not.
  58830. */
  58831. generateMipMaps?: boolean;
  58832. /**
  58833. * Defines the sampling mode of the texture.
  58834. */
  58835. samplingMode?: number;
  58836. /**
  58837. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58838. */
  58839. engine: Nullable<ThinEngine>;
  58840. /**
  58841. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58842. */
  58843. scene: Nullable<Scene>;
  58844. }
  58845. /**
  58846. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58847. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58848. * is automatically managed.
  58849. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58850. * in your application.
  58851. *
  58852. * As the update is not automatic, you need to call them manually.
  58853. */
  58854. export class HtmlElementTexture extends BaseTexture {
  58855. /**
  58856. * The texture URL.
  58857. */
  58858. element: HTMLVideoElement | HTMLCanvasElement;
  58859. private static readonly DefaultOptions;
  58860. private _textureMatrix;
  58861. private _engine;
  58862. private _isVideo;
  58863. private _generateMipMaps;
  58864. private _samplingMode;
  58865. /**
  58866. * Instantiates a HtmlElementTexture from the following parameters.
  58867. *
  58868. * @param name Defines the name of the texture
  58869. * @param element Defines the video or canvas the texture is filled with
  58870. * @param options Defines the other none mandatory texture creation options
  58871. */
  58872. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58873. private _createInternalTexture;
  58874. /**
  58875. * Returns the texture matrix used in most of the material.
  58876. */
  58877. getTextureMatrix(): Matrix;
  58878. /**
  58879. * Updates the content of the texture.
  58880. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58881. */
  58882. update(invertY?: Nullable<boolean>): void;
  58883. }
  58884. }
  58885. declare module "babylonjs/Materials/Textures/index" {
  58886. export * from "babylonjs/Materials/Textures/baseTexture";
  58887. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  58888. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  58889. export * from "babylonjs/Materials/Textures/cubeTexture";
  58890. export * from "babylonjs/Materials/Textures/dynamicTexture";
  58891. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  58892. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  58893. export * from "babylonjs/Materials/Textures/internalTexture";
  58894. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  58895. export * from "babylonjs/Materials/Textures/Loaders/index";
  58896. export * from "babylonjs/Materials/Textures/mirrorTexture";
  58897. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  58898. export * from "babylonjs/Materials/Textures/Procedurals/index";
  58899. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  58900. export * from "babylonjs/Materials/Textures/rawTexture";
  58901. export * from "babylonjs/Materials/Textures/rawTexture3D";
  58902. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  58903. export * from "babylonjs/Materials/Textures/refractionTexture";
  58904. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  58905. export * from "babylonjs/Materials/Textures/texture";
  58906. export * from "babylonjs/Materials/Textures/videoTexture";
  58907. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  58908. }
  58909. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  58910. /**
  58911. * Enum used to define the target of a block
  58912. */
  58913. export enum NodeMaterialBlockTargets {
  58914. /** Vertex shader */
  58915. Vertex = 1,
  58916. /** Fragment shader */
  58917. Fragment = 2,
  58918. /** Neutral */
  58919. Neutral = 4,
  58920. /** Vertex and Fragment */
  58921. VertexAndFragment = 3
  58922. }
  58923. }
  58924. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  58925. /**
  58926. * Defines the kind of connection point for node based material
  58927. */
  58928. export enum NodeMaterialBlockConnectionPointTypes {
  58929. /** Float */
  58930. Float = 1,
  58931. /** Int */
  58932. Int = 2,
  58933. /** Vector2 */
  58934. Vector2 = 4,
  58935. /** Vector3 */
  58936. Vector3 = 8,
  58937. /** Vector4 */
  58938. Vector4 = 16,
  58939. /** Color3 */
  58940. Color3 = 32,
  58941. /** Color4 */
  58942. Color4 = 64,
  58943. /** Matrix */
  58944. Matrix = 128,
  58945. /** Detect type based on connection */
  58946. AutoDetect = 1024,
  58947. /** Output type that will be defined by input type */
  58948. BasedOnInput = 2048
  58949. }
  58950. }
  58951. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  58952. /**
  58953. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  58954. */
  58955. export enum NodeMaterialBlockConnectionPointMode {
  58956. /** Value is an uniform */
  58957. Uniform = 0,
  58958. /** Value is a mesh attribute */
  58959. Attribute = 1,
  58960. /** Value is a varying between vertex and fragment shaders */
  58961. Varying = 2,
  58962. /** Mode is undefined */
  58963. Undefined = 3
  58964. }
  58965. }
  58966. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  58967. /**
  58968. * Enum used to define system values e.g. values automatically provided by the system
  58969. */
  58970. export enum NodeMaterialSystemValues {
  58971. /** World */
  58972. World = 1,
  58973. /** View */
  58974. View = 2,
  58975. /** Projection */
  58976. Projection = 3,
  58977. /** ViewProjection */
  58978. ViewProjection = 4,
  58979. /** WorldView */
  58980. WorldView = 5,
  58981. /** WorldViewProjection */
  58982. WorldViewProjection = 6,
  58983. /** CameraPosition */
  58984. CameraPosition = 7,
  58985. /** Fog Color */
  58986. FogColor = 8,
  58987. /** Delta time */
  58988. DeltaTime = 9
  58989. }
  58990. }
  58991. declare module "babylonjs/Materials/Node/Enums/index" {
  58992. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58993. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58994. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  58995. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58996. }
  58997. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  58998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58999. /**
  59000. * Root class for all node material optimizers
  59001. */
  59002. export class NodeMaterialOptimizer {
  59003. /**
  59004. * Function used to optimize a NodeMaterial graph
  59005. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59006. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59007. */
  59008. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59009. }
  59010. }
  59011. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59015. import { Scene } from "babylonjs/scene";
  59016. /**
  59017. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59018. */
  59019. export class TransformBlock extends NodeMaterialBlock {
  59020. /**
  59021. * Defines the value to use to complement W value to transform it to a Vector4
  59022. */
  59023. complementW: number;
  59024. /**
  59025. * Defines the value to use to complement z value to transform it to a Vector4
  59026. */
  59027. complementZ: number;
  59028. /**
  59029. * Creates a new TransformBlock
  59030. * @param name defines the block name
  59031. */
  59032. constructor(name: string);
  59033. /**
  59034. * Gets the current class name
  59035. * @returns the class name
  59036. */
  59037. getClassName(): string;
  59038. /**
  59039. * Gets the vector input
  59040. */
  59041. get vector(): NodeMaterialConnectionPoint;
  59042. /**
  59043. * Gets the output component
  59044. */
  59045. get output(): NodeMaterialConnectionPoint;
  59046. /**
  59047. * Gets the matrix transform input
  59048. */
  59049. get transform(): NodeMaterialConnectionPoint;
  59050. protected _buildBlock(state: NodeMaterialBuildState): this;
  59051. serialize(): any;
  59052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59053. protected _dumpPropertiesCode(): string;
  59054. }
  59055. }
  59056. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59060. /**
  59061. * Block used to output the vertex position
  59062. */
  59063. export class VertexOutputBlock extends NodeMaterialBlock {
  59064. /**
  59065. * Creates a new VertexOutputBlock
  59066. * @param name defines the block name
  59067. */
  59068. constructor(name: string);
  59069. /**
  59070. * Gets the current class name
  59071. * @returns the class name
  59072. */
  59073. getClassName(): string;
  59074. /**
  59075. * Gets the vector input component
  59076. */
  59077. get vector(): NodeMaterialConnectionPoint;
  59078. protected _buildBlock(state: NodeMaterialBuildState): this;
  59079. }
  59080. }
  59081. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59085. /**
  59086. * Block used to output the final color
  59087. */
  59088. export class FragmentOutputBlock extends NodeMaterialBlock {
  59089. /**
  59090. * Create a new FragmentOutputBlock
  59091. * @param name defines the block name
  59092. */
  59093. constructor(name: string);
  59094. /**
  59095. * Gets the current class name
  59096. * @returns the class name
  59097. */
  59098. getClassName(): string;
  59099. /**
  59100. * Gets the rgba input component
  59101. */
  59102. get rgba(): NodeMaterialConnectionPoint;
  59103. /**
  59104. * Gets the rgb input component
  59105. */
  59106. get rgb(): NodeMaterialConnectionPoint;
  59107. /**
  59108. * Gets the a input component
  59109. */
  59110. get a(): NodeMaterialConnectionPoint;
  59111. protected _buildBlock(state: NodeMaterialBuildState): this;
  59112. }
  59113. }
  59114. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59118. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59120. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59121. import { Effect } from "babylonjs/Materials/effect";
  59122. import { Mesh } from "babylonjs/Meshes/mesh";
  59123. import { Nullable } from "babylonjs/types";
  59124. import { Scene } from "babylonjs/scene";
  59125. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59126. /**
  59127. * Block used to read a reflection texture from a sampler
  59128. */
  59129. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59130. private _define3DName;
  59131. private _defineCubicName;
  59132. private _defineExplicitName;
  59133. private _defineProjectionName;
  59134. private _defineLocalCubicName;
  59135. private _defineSphericalName;
  59136. private _definePlanarName;
  59137. private _defineEquirectangularName;
  59138. private _defineMirroredEquirectangularFixedName;
  59139. private _defineEquirectangularFixedName;
  59140. private _defineSkyboxName;
  59141. private _cubeSamplerName;
  59142. private _2DSamplerName;
  59143. private _positionUVWName;
  59144. private _directionWName;
  59145. private _reflectionCoordsName;
  59146. private _reflection2DCoordsName;
  59147. private _reflectionColorName;
  59148. private _reflectionMatrixName;
  59149. /**
  59150. * Gets or sets the texture associated with the node
  59151. */
  59152. texture: Nullable<BaseTexture>;
  59153. /**
  59154. * Create a new TextureBlock
  59155. * @param name defines the block name
  59156. */
  59157. constructor(name: string);
  59158. /**
  59159. * Gets the current class name
  59160. * @returns the class name
  59161. */
  59162. getClassName(): string;
  59163. /**
  59164. * Gets the world position input component
  59165. */
  59166. get position(): NodeMaterialConnectionPoint;
  59167. /**
  59168. * Gets the world position input component
  59169. */
  59170. get worldPosition(): NodeMaterialConnectionPoint;
  59171. /**
  59172. * Gets the world normal input component
  59173. */
  59174. get worldNormal(): NodeMaterialConnectionPoint;
  59175. /**
  59176. * Gets the world input component
  59177. */
  59178. get world(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the camera (or eye) position component
  59181. */
  59182. get cameraPosition(): NodeMaterialConnectionPoint;
  59183. /**
  59184. * Gets the view input component
  59185. */
  59186. get view(): NodeMaterialConnectionPoint;
  59187. /**
  59188. * Gets the rgb output component
  59189. */
  59190. get rgb(): NodeMaterialConnectionPoint;
  59191. /**
  59192. * Gets the r output component
  59193. */
  59194. get r(): NodeMaterialConnectionPoint;
  59195. /**
  59196. * Gets the g output component
  59197. */
  59198. get g(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the b output component
  59201. */
  59202. get b(): NodeMaterialConnectionPoint;
  59203. autoConfigure(material: NodeMaterial): void;
  59204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59205. isReady(): boolean;
  59206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59207. private _injectVertexCode;
  59208. private _writeOutput;
  59209. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59210. protected _dumpPropertiesCode(): string;
  59211. serialize(): any;
  59212. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59213. }
  59214. }
  59215. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59217. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59218. import { Scene } from "babylonjs/scene";
  59219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59220. import { Matrix } from "babylonjs/Maths/math.vector";
  59221. import { Mesh } from "babylonjs/Meshes/mesh";
  59222. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59223. import { Observable } from "babylonjs/Misc/observable";
  59224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59225. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59226. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59227. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59228. import { Nullable } from "babylonjs/types";
  59229. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59230. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59231. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59232. /**
  59233. * Interface used to configure the node material editor
  59234. */
  59235. export interface INodeMaterialEditorOptions {
  59236. /** Define the URl to load node editor script */
  59237. editorURL?: string;
  59238. }
  59239. /** @hidden */
  59240. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59241. NORMAL: boolean;
  59242. TANGENT: boolean;
  59243. UV1: boolean;
  59244. /** BONES */
  59245. NUM_BONE_INFLUENCERS: number;
  59246. BonesPerMesh: number;
  59247. BONETEXTURE: boolean;
  59248. /** MORPH TARGETS */
  59249. MORPHTARGETS: boolean;
  59250. MORPHTARGETS_NORMAL: boolean;
  59251. MORPHTARGETS_TANGENT: boolean;
  59252. MORPHTARGETS_UV: boolean;
  59253. NUM_MORPH_INFLUENCERS: number;
  59254. /** IMAGE PROCESSING */
  59255. IMAGEPROCESSING: boolean;
  59256. VIGNETTE: boolean;
  59257. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59258. VIGNETTEBLENDMODEOPAQUE: boolean;
  59259. TONEMAPPING: boolean;
  59260. TONEMAPPING_ACES: boolean;
  59261. CONTRAST: boolean;
  59262. EXPOSURE: boolean;
  59263. COLORCURVES: boolean;
  59264. COLORGRADING: boolean;
  59265. COLORGRADING3D: boolean;
  59266. SAMPLER3DGREENDEPTH: boolean;
  59267. SAMPLER3DBGRMAP: boolean;
  59268. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59269. /** MISC. */
  59270. BUMPDIRECTUV: number;
  59271. constructor();
  59272. setValue(name: string, value: boolean): void;
  59273. }
  59274. /**
  59275. * Class used to configure NodeMaterial
  59276. */
  59277. export interface INodeMaterialOptions {
  59278. /**
  59279. * Defines if blocks should emit comments
  59280. */
  59281. emitComments: boolean;
  59282. }
  59283. /**
  59284. * Class used to create a node based material built by assembling shader blocks
  59285. */
  59286. export class NodeMaterial extends PushMaterial {
  59287. private static _BuildIdGenerator;
  59288. private _options;
  59289. private _vertexCompilationState;
  59290. private _fragmentCompilationState;
  59291. private _sharedData;
  59292. private _buildId;
  59293. private _buildWasSuccessful;
  59294. private _cachedWorldViewMatrix;
  59295. private _cachedWorldViewProjectionMatrix;
  59296. private _optimizers;
  59297. private _animationFrame;
  59298. /** Define the Url to load node editor script */
  59299. static EditorURL: string;
  59300. /** Define the Url to load snippets */
  59301. static SnippetUrl: string;
  59302. private BJSNODEMATERIALEDITOR;
  59303. /** Get the inspector from bundle or global */
  59304. private _getGlobalNodeMaterialEditor;
  59305. /**
  59306. * Gets or sets data used by visual editor
  59307. * @see https://nme.babylonjs.com
  59308. */
  59309. editorData: any;
  59310. /**
  59311. * 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)
  59312. */
  59313. ignoreAlpha: boolean;
  59314. /**
  59315. * Defines the maximum number of lights that can be used in the material
  59316. */
  59317. maxSimultaneousLights: number;
  59318. /**
  59319. * Observable raised when the material is built
  59320. */
  59321. onBuildObservable: Observable<NodeMaterial>;
  59322. /**
  59323. * Gets or sets the root nodes of the material vertex shader
  59324. */
  59325. _vertexOutputNodes: NodeMaterialBlock[];
  59326. /**
  59327. * Gets or sets the root nodes of the material fragment (pixel) shader
  59328. */
  59329. _fragmentOutputNodes: NodeMaterialBlock[];
  59330. /** Gets or sets options to control the node material overall behavior */
  59331. get options(): INodeMaterialOptions;
  59332. set options(options: INodeMaterialOptions);
  59333. /**
  59334. * Default configuration related to image processing available in the standard Material.
  59335. */
  59336. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59337. /**
  59338. * Gets the image processing configuration used either in this material.
  59339. */
  59340. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59341. /**
  59342. * Sets the Default image processing configuration used either in the this material.
  59343. *
  59344. * If sets to null, the scene one is in use.
  59345. */
  59346. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59347. /**
  59348. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59349. */
  59350. attachedBlocks: NodeMaterialBlock[];
  59351. /**
  59352. * Create a new node based material
  59353. * @param name defines the material name
  59354. * @param scene defines the hosting scene
  59355. * @param options defines creation option
  59356. */
  59357. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59358. /**
  59359. * Gets the current class name of the material e.g. "NodeMaterial"
  59360. * @returns the class name
  59361. */
  59362. getClassName(): string;
  59363. /**
  59364. * Keep track of the image processing observer to allow dispose and replace.
  59365. */
  59366. private _imageProcessingObserver;
  59367. /**
  59368. * Attaches a new image processing configuration to the Standard Material.
  59369. * @param configuration
  59370. */
  59371. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59372. /**
  59373. * Get a block by its name
  59374. * @param name defines the name of the block to retrieve
  59375. * @returns the required block or null if not found
  59376. */
  59377. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59378. /**
  59379. * Get a block by its name
  59380. * @param predicate defines the predicate used to find the good candidate
  59381. * @returns the required block or null if not found
  59382. */
  59383. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59384. /**
  59385. * Get an input block by its name
  59386. * @param predicate defines the predicate used to find the good candidate
  59387. * @returns the required input block or null if not found
  59388. */
  59389. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59390. /**
  59391. * Gets the list of input blocks attached to this material
  59392. * @returns an array of InputBlocks
  59393. */
  59394. getInputBlocks(): InputBlock[];
  59395. /**
  59396. * Adds a new optimizer to the list of optimizers
  59397. * @param optimizer defines the optimizers to add
  59398. * @returns the current material
  59399. */
  59400. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59401. /**
  59402. * Remove an optimizer from the list of optimizers
  59403. * @param optimizer defines the optimizers to remove
  59404. * @returns the current material
  59405. */
  59406. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59407. /**
  59408. * Add a new block to the list of output nodes
  59409. * @param node defines the node to add
  59410. * @returns the current material
  59411. */
  59412. addOutputNode(node: NodeMaterialBlock): this;
  59413. /**
  59414. * Remove a block from the list of root nodes
  59415. * @param node defines the node to remove
  59416. * @returns the current material
  59417. */
  59418. removeOutputNode(node: NodeMaterialBlock): this;
  59419. private _addVertexOutputNode;
  59420. private _removeVertexOutputNode;
  59421. private _addFragmentOutputNode;
  59422. private _removeFragmentOutputNode;
  59423. /**
  59424. * Specifies if the material will require alpha blending
  59425. * @returns a boolean specifying if alpha blending is needed
  59426. */
  59427. needAlphaBlending(): boolean;
  59428. /**
  59429. * Specifies if this material should be rendered in alpha test mode
  59430. * @returns a boolean specifying if an alpha test is needed.
  59431. */
  59432. needAlphaTesting(): boolean;
  59433. private _initializeBlock;
  59434. private _resetDualBlocks;
  59435. /**
  59436. * Remove a block from the current node material
  59437. * @param block defines the block to remove
  59438. */
  59439. removeBlock(block: NodeMaterialBlock): void;
  59440. /**
  59441. * Build the material and generates the inner effect
  59442. * @param verbose defines if the build should log activity
  59443. */
  59444. build(verbose?: boolean): void;
  59445. /**
  59446. * Runs an otpimization phase to try to improve the shader code
  59447. */
  59448. optimize(): void;
  59449. private _prepareDefinesForAttributes;
  59450. /**
  59451. * Get if the submesh is ready to be used and all its information available.
  59452. * Child classes can use it to update shaders
  59453. * @param mesh defines the mesh to check
  59454. * @param subMesh defines which submesh to check
  59455. * @param useInstances specifies that instances should be used
  59456. * @returns a boolean indicating that the submesh is ready or not
  59457. */
  59458. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59459. /**
  59460. * Get a string representing the shaders built by the current node graph
  59461. */
  59462. get compiledShaders(): string;
  59463. /**
  59464. * Binds the world matrix to the material
  59465. * @param world defines the world transformation matrix
  59466. */
  59467. bindOnlyWorldMatrix(world: Matrix): void;
  59468. /**
  59469. * Binds the submesh to this material by preparing the effect and shader to draw
  59470. * @param world defines the world transformation matrix
  59471. * @param mesh defines the mesh containing the submesh
  59472. * @param subMesh defines the submesh to bind the material to
  59473. */
  59474. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59475. /**
  59476. * Gets the active textures from the material
  59477. * @returns an array of textures
  59478. */
  59479. getActiveTextures(): BaseTexture[];
  59480. /**
  59481. * Gets the list of texture blocks
  59482. * @returns an array of texture blocks
  59483. */
  59484. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59485. /**
  59486. * Specifies if the material uses a texture
  59487. * @param texture defines the texture to check against the material
  59488. * @returns a boolean specifying if the material uses the texture
  59489. */
  59490. hasTexture(texture: BaseTexture): boolean;
  59491. /**
  59492. * Disposes the material
  59493. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59494. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59495. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59496. */
  59497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59498. /** Creates the node editor window. */
  59499. private _createNodeEditor;
  59500. /**
  59501. * Launch the node material editor
  59502. * @param config Define the configuration of the editor
  59503. * @return a promise fulfilled when the node editor is visible
  59504. */
  59505. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59506. /**
  59507. * Clear the current material
  59508. */
  59509. clear(): void;
  59510. /**
  59511. * Clear the current material and set it to a default state
  59512. */
  59513. setToDefault(): void;
  59514. /**
  59515. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59516. * @param url defines the url to load from
  59517. * @returns a promise that will fullfil when the material is fully loaded
  59518. */
  59519. loadAsync(url: string): Promise<void>;
  59520. private _gatherBlocks;
  59521. /**
  59522. * Generate a string containing the code declaration required to create an equivalent of this material
  59523. * @returns a string
  59524. */
  59525. generateCode(): string;
  59526. /**
  59527. * Serializes this material in a JSON representation
  59528. * @returns the serialized material object
  59529. */
  59530. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59531. private _restoreConnections;
  59532. /**
  59533. * Clear the current graph and load a new one from a serialization object
  59534. * @param source defines the JSON representation of the material
  59535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59536. */
  59537. loadFromSerialization(source: any, rootUrl?: string): void;
  59538. /**
  59539. * Creates a node material from parsed material data
  59540. * @param source defines the JSON representation of the material
  59541. * @param scene defines the hosting scene
  59542. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59543. * @returns a new node material
  59544. */
  59545. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59546. /**
  59547. * Creates a node material from a snippet saved by the node material editor
  59548. * @param snippetId defines the snippet to load
  59549. * @param scene defines the hosting scene
  59550. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59551. * @returns a promise that will resolve to the new node material
  59552. */
  59553. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59554. /**
  59555. * Creates a new node material set to default basic configuration
  59556. * @param name defines the name of the material
  59557. * @param scene defines the hosting scene
  59558. * @returns a new NodeMaterial
  59559. */
  59560. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59561. }
  59562. }
  59563. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59566. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59569. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59570. import { Effect } from "babylonjs/Materials/effect";
  59571. import { Mesh } from "babylonjs/Meshes/mesh";
  59572. import { Nullable } from "babylonjs/types";
  59573. import { Texture } from "babylonjs/Materials/Textures/texture";
  59574. import { Scene } from "babylonjs/scene";
  59575. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59576. /**
  59577. * Block used to read a texture from a sampler
  59578. */
  59579. export class TextureBlock extends NodeMaterialBlock {
  59580. private _defineName;
  59581. private _linearDefineName;
  59582. private _tempTextureRead;
  59583. private _samplerName;
  59584. private _transformedUVName;
  59585. private _textureTransformName;
  59586. private _textureInfoName;
  59587. private _mainUVName;
  59588. private _mainUVDefineName;
  59589. /**
  59590. * Gets or sets the texture associated with the node
  59591. */
  59592. texture: Nullable<Texture>;
  59593. /**
  59594. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59595. */
  59596. convertToGammaSpace: boolean;
  59597. /**
  59598. * Create a new TextureBlock
  59599. * @param name defines the block name
  59600. */
  59601. constructor(name: string);
  59602. /**
  59603. * Gets the current class name
  59604. * @returns the class name
  59605. */
  59606. getClassName(): string;
  59607. /**
  59608. * Gets the uv input component
  59609. */
  59610. get uv(): NodeMaterialConnectionPoint;
  59611. /**
  59612. * Gets the rgba output component
  59613. */
  59614. get rgba(): NodeMaterialConnectionPoint;
  59615. /**
  59616. * Gets the rgb output component
  59617. */
  59618. get rgb(): NodeMaterialConnectionPoint;
  59619. /**
  59620. * Gets the r output component
  59621. */
  59622. get r(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the g output component
  59625. */
  59626. get g(): NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the b output component
  59629. */
  59630. get b(): NodeMaterialConnectionPoint;
  59631. /**
  59632. * Gets the a output component
  59633. */
  59634. get a(): NodeMaterialConnectionPoint;
  59635. get target(): NodeMaterialBlockTargets;
  59636. autoConfigure(material: NodeMaterial): void;
  59637. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59639. isReady(): boolean;
  59640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59641. private get _isMixed();
  59642. private _injectVertexCode;
  59643. private _writeTextureRead;
  59644. private _writeOutput;
  59645. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59646. protected _dumpPropertiesCode(): string;
  59647. serialize(): any;
  59648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59649. }
  59650. }
  59651. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  59652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59654. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59655. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59656. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59657. import { Scene } from "babylonjs/scene";
  59658. /**
  59659. * Class used to store shared data between 2 NodeMaterialBuildState
  59660. */
  59661. export class NodeMaterialBuildStateSharedData {
  59662. /**
  59663. * Gets the list of emitted varyings
  59664. */
  59665. temps: string[];
  59666. /**
  59667. * Gets the list of emitted varyings
  59668. */
  59669. varyings: string[];
  59670. /**
  59671. * Gets the varying declaration string
  59672. */
  59673. varyingDeclaration: string;
  59674. /**
  59675. * Input blocks
  59676. */
  59677. inputBlocks: InputBlock[];
  59678. /**
  59679. * Input blocks
  59680. */
  59681. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  59682. /**
  59683. * Bindable blocks (Blocks that need to set data to the effect)
  59684. */
  59685. bindableBlocks: NodeMaterialBlock[];
  59686. /**
  59687. * List of blocks that can provide a compilation fallback
  59688. */
  59689. blocksWithFallbacks: NodeMaterialBlock[];
  59690. /**
  59691. * List of blocks that can provide a define update
  59692. */
  59693. blocksWithDefines: NodeMaterialBlock[];
  59694. /**
  59695. * List of blocks that can provide a repeatable content
  59696. */
  59697. repeatableContentBlocks: NodeMaterialBlock[];
  59698. /**
  59699. * List of blocks that can provide a dynamic list of uniforms
  59700. */
  59701. dynamicUniformBlocks: NodeMaterialBlock[];
  59702. /**
  59703. * List of blocks that can block the isReady function for the material
  59704. */
  59705. blockingBlocks: NodeMaterialBlock[];
  59706. /**
  59707. * Gets the list of animated inputs
  59708. */
  59709. animatedInputs: InputBlock[];
  59710. /**
  59711. * Build Id used to avoid multiple recompilations
  59712. */
  59713. buildId: number;
  59714. /** List of emitted variables */
  59715. variableNames: {
  59716. [key: string]: number;
  59717. };
  59718. /** List of emitted defines */
  59719. defineNames: {
  59720. [key: string]: number;
  59721. };
  59722. /** Should emit comments? */
  59723. emitComments: boolean;
  59724. /** Emit build activity */
  59725. verbose: boolean;
  59726. /** Gets or sets the hosting scene */
  59727. scene: Scene;
  59728. /**
  59729. * Gets the compilation hints emitted at compilation time
  59730. */
  59731. hints: {
  59732. needWorldViewMatrix: boolean;
  59733. needWorldViewProjectionMatrix: boolean;
  59734. needAlphaBlending: boolean;
  59735. needAlphaTesting: boolean;
  59736. };
  59737. /**
  59738. * List of compilation checks
  59739. */
  59740. checks: {
  59741. emitVertex: boolean;
  59742. emitFragment: boolean;
  59743. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  59744. };
  59745. /** Creates a new shared data */
  59746. constructor();
  59747. /**
  59748. * Emits console errors and exceptions if there is a failing check
  59749. */
  59750. emitErrors(): void;
  59751. }
  59752. }
  59753. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  59754. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59755. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59756. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  59757. /**
  59758. * Class used to store node based material build state
  59759. */
  59760. export class NodeMaterialBuildState {
  59761. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  59762. supportUniformBuffers: boolean;
  59763. /**
  59764. * Gets the list of emitted attributes
  59765. */
  59766. attributes: string[];
  59767. /**
  59768. * Gets the list of emitted uniforms
  59769. */
  59770. uniforms: string[];
  59771. /**
  59772. * Gets the list of emitted constants
  59773. */
  59774. constants: string[];
  59775. /**
  59776. * Gets the list of emitted samplers
  59777. */
  59778. samplers: string[];
  59779. /**
  59780. * Gets the list of emitted functions
  59781. */
  59782. functions: {
  59783. [key: string]: string;
  59784. };
  59785. /**
  59786. * Gets the list of emitted extensions
  59787. */
  59788. extensions: {
  59789. [key: string]: string;
  59790. };
  59791. /**
  59792. * Gets the target of the compilation state
  59793. */
  59794. target: NodeMaterialBlockTargets;
  59795. /**
  59796. * Gets the list of emitted counters
  59797. */
  59798. counters: {
  59799. [key: string]: number;
  59800. };
  59801. /**
  59802. * Shared data between multiple NodeMaterialBuildState instances
  59803. */
  59804. sharedData: NodeMaterialBuildStateSharedData;
  59805. /** @hidden */
  59806. _vertexState: NodeMaterialBuildState;
  59807. /** @hidden */
  59808. _attributeDeclaration: string;
  59809. /** @hidden */
  59810. _uniformDeclaration: string;
  59811. /** @hidden */
  59812. _constantDeclaration: string;
  59813. /** @hidden */
  59814. _samplerDeclaration: string;
  59815. /** @hidden */
  59816. _varyingTransfer: string;
  59817. private _repeatableContentAnchorIndex;
  59818. /** @hidden */
  59819. _builtCompilationString: string;
  59820. /**
  59821. * Gets the emitted compilation strings
  59822. */
  59823. compilationString: string;
  59824. /**
  59825. * Finalize the compilation strings
  59826. * @param state defines the current compilation state
  59827. */
  59828. finalize(state: NodeMaterialBuildState): void;
  59829. /** @hidden */
  59830. get _repeatableContentAnchor(): string;
  59831. /** @hidden */
  59832. _getFreeVariableName(prefix: string): string;
  59833. /** @hidden */
  59834. _getFreeDefineName(prefix: string): string;
  59835. /** @hidden */
  59836. _excludeVariableName(name: string): void;
  59837. /** @hidden */
  59838. _emit2DSampler(name: string): void;
  59839. /** @hidden */
  59840. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  59841. /** @hidden */
  59842. _emitExtension(name: string, extension: string): void;
  59843. /** @hidden */
  59844. _emitFunction(name: string, code: string, comments: string): void;
  59845. /** @hidden */
  59846. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  59847. replaceStrings?: {
  59848. search: RegExp;
  59849. replace: string;
  59850. }[];
  59851. repeatKey?: string;
  59852. }): string;
  59853. /** @hidden */
  59854. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  59855. repeatKey?: string;
  59856. removeAttributes?: boolean;
  59857. removeUniforms?: boolean;
  59858. removeVaryings?: boolean;
  59859. removeIfDef?: boolean;
  59860. replaceStrings?: {
  59861. search: RegExp;
  59862. replace: string;
  59863. }[];
  59864. }, storeKey?: string): void;
  59865. /** @hidden */
  59866. _registerTempVariable(name: string): boolean;
  59867. /** @hidden */
  59868. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  59869. /** @hidden */
  59870. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  59871. /** @hidden */
  59872. _emitFloat(value: number): string;
  59873. }
  59874. }
  59875. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  59876. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59878. import { Nullable } from "babylonjs/types";
  59879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59880. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59881. import { Effect } from "babylonjs/Materials/effect";
  59882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59883. import { Mesh } from "babylonjs/Meshes/mesh";
  59884. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59885. import { Scene } from "babylonjs/scene";
  59886. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59887. /**
  59888. * Defines a block that can be used inside a node based material
  59889. */
  59890. export class NodeMaterialBlock {
  59891. private _buildId;
  59892. private _buildTarget;
  59893. private _target;
  59894. private _isFinalMerger;
  59895. private _isInput;
  59896. protected _isUnique: boolean;
  59897. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  59898. inputsAreExclusive: boolean;
  59899. /** @hidden */
  59900. _codeVariableName: string;
  59901. /** @hidden */
  59902. _inputs: NodeMaterialConnectionPoint[];
  59903. /** @hidden */
  59904. _outputs: NodeMaterialConnectionPoint[];
  59905. /** @hidden */
  59906. _preparationId: number;
  59907. /**
  59908. * Gets or sets the name of the block
  59909. */
  59910. name: string;
  59911. /**
  59912. * Gets or sets the unique id of the node
  59913. */
  59914. uniqueId: number;
  59915. /**
  59916. * Gets or sets the comments associated with this block
  59917. */
  59918. comments: string;
  59919. /**
  59920. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  59921. */
  59922. get isUnique(): boolean;
  59923. /**
  59924. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  59925. */
  59926. get isFinalMerger(): boolean;
  59927. /**
  59928. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59929. */
  59930. get isInput(): boolean;
  59931. /**
  59932. * Gets or sets the build Id
  59933. */
  59934. get buildId(): number;
  59935. set buildId(value: number);
  59936. /**
  59937. * Gets or sets the target of the block
  59938. */
  59939. get target(): NodeMaterialBlockTargets;
  59940. set target(value: NodeMaterialBlockTargets);
  59941. /**
  59942. * Gets the list of input points
  59943. */
  59944. get inputs(): NodeMaterialConnectionPoint[];
  59945. /** Gets the list of output points */
  59946. get outputs(): NodeMaterialConnectionPoint[];
  59947. /**
  59948. * Find an input by its name
  59949. * @param name defines the name of the input to look for
  59950. * @returns the input or null if not found
  59951. */
  59952. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59953. /**
  59954. * Find an output by its name
  59955. * @param name defines the name of the outputto look for
  59956. * @returns the output or null if not found
  59957. */
  59958. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59959. /**
  59960. * Creates a new NodeMaterialBlock
  59961. * @param name defines the block name
  59962. * @param target defines the target of that block (Vertex by default)
  59963. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  59964. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59965. */
  59966. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  59967. /**
  59968. * Initialize the block and prepare the context for build
  59969. * @param state defines the state that will be used for the build
  59970. */
  59971. initialize(state: NodeMaterialBuildState): void;
  59972. /**
  59973. * Bind data to effect. Will only be called for blocks with isBindable === true
  59974. * @param effect defines the effect to bind data to
  59975. * @param nodeMaterial defines the hosting NodeMaterial
  59976. * @param mesh defines the mesh that will be rendered
  59977. */
  59978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59979. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  59980. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  59981. protected _writeFloat(value: number): string;
  59982. /**
  59983. * Gets the current class name e.g. "NodeMaterialBlock"
  59984. * @returns the class name
  59985. */
  59986. getClassName(): string;
  59987. /**
  59988. * Register a new input. Must be called inside a block constructor
  59989. * @param name defines the connection point name
  59990. * @param type defines the connection point type
  59991. * @param isOptional defines a boolean indicating that this input can be omitted
  59992. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59993. * @returns the current block
  59994. */
  59995. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  59996. /**
  59997. * Register a new output. Must be called inside a block constructor
  59998. * @param name defines the connection point name
  59999. * @param type defines the connection point type
  60000. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60001. * @returns the current block
  60002. */
  60003. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60004. /**
  60005. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60006. * @param forOutput defines an optional connection point to check compatibility with
  60007. * @returns the first available input or null
  60008. */
  60009. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60010. /**
  60011. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60012. * @param forBlock defines an optional block to check compatibility with
  60013. * @returns the first available input or null
  60014. */
  60015. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60016. /**
  60017. * Gets the sibling of the given output
  60018. * @param current defines the current output
  60019. * @returns the next output in the list or null
  60020. */
  60021. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60022. /**
  60023. * Connect current block with another block
  60024. * @param other defines the block to connect with
  60025. * @param options define the various options to help pick the right connections
  60026. * @returns the current block
  60027. */
  60028. connectTo(other: NodeMaterialBlock, options?: {
  60029. input?: string;
  60030. output?: string;
  60031. outputSwizzle?: string;
  60032. }): this | undefined;
  60033. protected _buildBlock(state: NodeMaterialBuildState): void;
  60034. /**
  60035. * Add uniforms, samplers and uniform buffers at compilation time
  60036. * @param state defines the state to update
  60037. * @param nodeMaterial defines the node material requesting the update
  60038. * @param defines defines the material defines to update
  60039. * @param uniformBuffers defines the list of uniform buffer names
  60040. */
  60041. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60042. /**
  60043. * Add potential fallbacks if shader compilation fails
  60044. * @param mesh defines the mesh to be rendered
  60045. * @param fallbacks defines the current prioritized list of fallbacks
  60046. */
  60047. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60048. /**
  60049. * Initialize defines for shader compilation
  60050. * @param mesh defines the mesh to be rendered
  60051. * @param nodeMaterial defines the node material requesting the update
  60052. * @param defines defines the material defines to update
  60053. * @param useInstances specifies that instances should be used
  60054. */
  60055. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60056. /**
  60057. * Update defines for shader compilation
  60058. * @param mesh defines the mesh to be rendered
  60059. * @param nodeMaterial defines the node material requesting the update
  60060. * @param defines defines the material defines to update
  60061. * @param useInstances specifies that instances should be used
  60062. */
  60063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60064. /**
  60065. * Lets the block try to connect some inputs automatically
  60066. * @param material defines the hosting NodeMaterial
  60067. */
  60068. autoConfigure(material: NodeMaterial): void;
  60069. /**
  60070. * Function called when a block is declared as repeatable content generator
  60071. * @param vertexShaderState defines the current compilation state for the vertex shader
  60072. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60073. * @param mesh defines the mesh to be rendered
  60074. * @param defines defines the material defines to update
  60075. */
  60076. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60077. /**
  60078. * Checks if the block is ready
  60079. * @param mesh defines the mesh to be rendered
  60080. * @param nodeMaterial defines the node material requesting the update
  60081. * @param defines defines the material defines to update
  60082. * @param useInstances specifies that instances should be used
  60083. * @returns true if the block is ready
  60084. */
  60085. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60086. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60087. private _processBuild;
  60088. /**
  60089. * Compile the current node and generate the shader code
  60090. * @param state defines the current compilation state (uniforms, samplers, current string)
  60091. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60092. * @returns true if already built
  60093. */
  60094. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60095. protected _inputRename(name: string): string;
  60096. protected _outputRename(name: string): string;
  60097. protected _dumpPropertiesCode(): string;
  60098. /** @hidden */
  60099. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60100. /** @hidden */
  60101. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60102. /**
  60103. * Clone the current block to a new identical block
  60104. * @param scene defines the hosting scene
  60105. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60106. * @returns a copy of the current block
  60107. */
  60108. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60109. /**
  60110. * Serializes this block in a JSON representation
  60111. * @returns the serialized block object
  60112. */
  60113. serialize(): any;
  60114. /** @hidden */
  60115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60116. /**
  60117. * Release resources
  60118. */
  60119. dispose(): void;
  60120. }
  60121. }
  60122. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60123. /**
  60124. * Enum defining the type of animations supported by InputBlock
  60125. */
  60126. export enum AnimatedInputBlockTypes {
  60127. /** No animation */
  60128. None = 0,
  60129. /** Time based animation. Will only work for floats */
  60130. Time = 1
  60131. }
  60132. }
  60133. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60135. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60136. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60137. import { Nullable } from "babylonjs/types";
  60138. import { Effect } from "babylonjs/Materials/effect";
  60139. import { Matrix } from "babylonjs/Maths/math.vector";
  60140. import { Scene } from "babylonjs/scene";
  60141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60143. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60144. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60145. /**
  60146. * Block used to expose an input value
  60147. */
  60148. export class InputBlock extends NodeMaterialBlock {
  60149. private _mode;
  60150. private _associatedVariableName;
  60151. private _storedValue;
  60152. private _valueCallback;
  60153. private _type;
  60154. private _animationType;
  60155. /** Gets or set a value used to limit the range of float values */
  60156. min: number;
  60157. /** Gets or set a value used to limit the range of float values */
  60158. max: number;
  60159. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60160. isBoolean: boolean;
  60161. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60162. matrixMode: number;
  60163. /** @hidden */
  60164. _systemValue: Nullable<NodeMaterialSystemValues>;
  60165. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60166. visibleInInspector: boolean;
  60167. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60168. isConstant: boolean;
  60169. /** Gets or sets the group to use to display this block in the Inspector */
  60170. groupInInspector: string;
  60171. /**
  60172. * Gets or sets the connection point type (default is float)
  60173. */
  60174. get type(): NodeMaterialBlockConnectionPointTypes;
  60175. /**
  60176. * Creates a new InputBlock
  60177. * @param name defines the block name
  60178. * @param target defines the target of that block (Vertex by default)
  60179. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60180. */
  60181. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60182. /**
  60183. * Gets the output component
  60184. */
  60185. get output(): NodeMaterialConnectionPoint;
  60186. /**
  60187. * Set the source of this connection point to a vertex attribute
  60188. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60189. * @returns the current connection point
  60190. */
  60191. setAsAttribute(attributeName?: string): InputBlock;
  60192. /**
  60193. * Set the source of this connection point to a system value
  60194. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60195. * @returns the current connection point
  60196. */
  60197. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60198. /**
  60199. * Gets or sets the value of that point.
  60200. * Please note that this value will be ignored if valueCallback is defined
  60201. */
  60202. get value(): any;
  60203. set value(value: any);
  60204. /**
  60205. * Gets or sets a callback used to get the value of that point.
  60206. * Please note that setting this value will force the connection point to ignore the value property
  60207. */
  60208. get valueCallback(): () => any;
  60209. set valueCallback(value: () => any);
  60210. /**
  60211. * Gets or sets the associated variable name in the shader
  60212. */
  60213. get associatedVariableName(): string;
  60214. set associatedVariableName(value: string);
  60215. /** Gets or sets the type of animation applied to the input */
  60216. get animationType(): AnimatedInputBlockTypes;
  60217. set animationType(value: AnimatedInputBlockTypes);
  60218. /**
  60219. * Gets a boolean indicating that this connection point not defined yet
  60220. */
  60221. get isUndefined(): boolean;
  60222. /**
  60223. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60224. * In this case the connection point name must be the name of the uniform to use.
  60225. * Can only be set on inputs
  60226. */
  60227. get isUniform(): boolean;
  60228. set isUniform(value: boolean);
  60229. /**
  60230. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60231. * In this case the connection point name must be the name of the attribute to use
  60232. * Can only be set on inputs
  60233. */
  60234. get isAttribute(): boolean;
  60235. set isAttribute(value: boolean);
  60236. /**
  60237. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60238. * Can only be set on exit points
  60239. */
  60240. get isVarying(): boolean;
  60241. set isVarying(value: boolean);
  60242. /**
  60243. * Gets a boolean indicating that the current connection point is a system value
  60244. */
  60245. get isSystemValue(): boolean;
  60246. /**
  60247. * Gets or sets the current well known value or null if not defined as a system value
  60248. */
  60249. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60250. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60251. /**
  60252. * Gets the current class name
  60253. * @returns the class name
  60254. */
  60255. getClassName(): string;
  60256. /**
  60257. * Animate the input if animationType !== None
  60258. * @param scene defines the rendering scene
  60259. */
  60260. animate(scene: Scene): void;
  60261. private _emitDefine;
  60262. initialize(state: NodeMaterialBuildState): void;
  60263. /**
  60264. * Set the input block to its default value (based on its type)
  60265. */
  60266. setDefaultValue(): void;
  60267. private _emitConstant;
  60268. private _emit;
  60269. /** @hidden */
  60270. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60271. /** @hidden */
  60272. _transmit(effect: Effect, scene: Scene): void;
  60273. protected _buildBlock(state: NodeMaterialBuildState): void;
  60274. protected _dumpPropertiesCode(): string;
  60275. serialize(): any;
  60276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60277. }
  60278. }
  60279. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60280. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60281. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60282. import { Nullable } from "babylonjs/types";
  60283. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60284. import { Observable } from "babylonjs/Misc/observable";
  60285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60286. /**
  60287. * Enum used to define the compatibility state between two connection points
  60288. */
  60289. export enum NodeMaterialConnectionPointCompatibilityStates {
  60290. /** Points are compatibles */
  60291. Compatible = 0,
  60292. /** Points are incompatible because of their types */
  60293. TypeIncompatible = 1,
  60294. /** Points are incompatible because of their targets (vertex vs fragment) */
  60295. TargetIncompatible = 2
  60296. }
  60297. /**
  60298. * Defines the direction of a connection point
  60299. */
  60300. export enum NodeMaterialConnectionPointDirection {
  60301. /** Input */
  60302. Input = 0,
  60303. /** Output */
  60304. Output = 1
  60305. }
  60306. /**
  60307. * Defines a connection point for a block
  60308. */
  60309. export class NodeMaterialConnectionPoint {
  60310. /** @hidden */
  60311. _ownerBlock: NodeMaterialBlock;
  60312. /** @hidden */
  60313. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60314. private _endpoints;
  60315. private _associatedVariableName;
  60316. private _direction;
  60317. /** @hidden */
  60318. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60319. /** @hidden */
  60320. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60321. private _type;
  60322. /** @hidden */
  60323. _enforceAssociatedVariableName: boolean;
  60324. /** Gets the direction of the point */
  60325. get direction(): NodeMaterialConnectionPointDirection;
  60326. /**
  60327. * Gets or sets the additional types supported by this connection point
  60328. */
  60329. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60330. /**
  60331. * Gets or sets the additional types excluded by this connection point
  60332. */
  60333. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60334. /**
  60335. * Observable triggered when this point is connected
  60336. */
  60337. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60338. /**
  60339. * Gets or sets the associated variable name in the shader
  60340. */
  60341. get associatedVariableName(): string;
  60342. set associatedVariableName(value: string);
  60343. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60344. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60345. /**
  60346. * Gets or sets the connection point type (default is float)
  60347. */
  60348. get type(): NodeMaterialBlockConnectionPointTypes;
  60349. set type(value: NodeMaterialBlockConnectionPointTypes);
  60350. /**
  60351. * Gets or sets the connection point name
  60352. */
  60353. name: string;
  60354. /**
  60355. * Gets or sets a boolean indicating that this connection point can be omitted
  60356. */
  60357. isOptional: boolean;
  60358. /**
  60359. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60360. */
  60361. define: string;
  60362. /** @hidden */
  60363. _prioritizeVertex: boolean;
  60364. private _target;
  60365. /** Gets or sets the target of that connection point */
  60366. get target(): NodeMaterialBlockTargets;
  60367. set target(value: NodeMaterialBlockTargets);
  60368. /**
  60369. * Gets a boolean indicating that the current point is connected
  60370. */
  60371. get isConnected(): boolean;
  60372. /**
  60373. * Gets a boolean indicating that the current point is connected to an input block
  60374. */
  60375. get isConnectedToInputBlock(): boolean;
  60376. /**
  60377. * Gets a the connected input block (if any)
  60378. */
  60379. get connectInputBlock(): Nullable<InputBlock>;
  60380. /** Get the other side of the connection (if any) */
  60381. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60382. /** Get the block that owns this connection point */
  60383. get ownerBlock(): NodeMaterialBlock;
  60384. /** Get the block connected on the other side of this connection (if any) */
  60385. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60386. /** Get the block connected on the endpoints of this connection (if any) */
  60387. get connectedBlocks(): Array<NodeMaterialBlock>;
  60388. /** Gets the list of connected endpoints */
  60389. get endpoints(): NodeMaterialConnectionPoint[];
  60390. /** Gets a boolean indicating if that output point is connected to at least one input */
  60391. get hasEndpoints(): boolean;
  60392. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60393. get isConnectedInVertexShader(): boolean;
  60394. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60395. get isConnectedInFragmentShader(): boolean;
  60396. /**
  60397. * Creates a new connection point
  60398. * @param name defines the connection point name
  60399. * @param ownerBlock defines the block hosting this connection point
  60400. * @param direction defines the direction of the connection point
  60401. */
  60402. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60403. /**
  60404. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60405. * @returns the class name
  60406. */
  60407. getClassName(): string;
  60408. /**
  60409. * Gets a boolean indicating if the current point can be connected to another point
  60410. * @param connectionPoint defines the other connection point
  60411. * @returns a boolean
  60412. */
  60413. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60414. /**
  60415. * Gets a number indicating if the current point can be connected to another point
  60416. * @param connectionPoint defines the other connection point
  60417. * @returns a number defining the compatibility state
  60418. */
  60419. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60420. /**
  60421. * Connect this point to another connection point
  60422. * @param connectionPoint defines the other connection point
  60423. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60424. * @returns the current connection point
  60425. */
  60426. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60427. /**
  60428. * Disconnect this point from one of his endpoint
  60429. * @param endpoint defines the other connection point
  60430. * @returns the current connection point
  60431. */
  60432. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60433. /**
  60434. * Serializes this point in a JSON representation
  60435. * @returns the serialized point object
  60436. */
  60437. serialize(): any;
  60438. /**
  60439. * Release resources
  60440. */
  60441. dispose(): void;
  60442. }
  60443. }
  60444. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60448. import { Mesh } from "babylonjs/Meshes/mesh";
  60449. import { Effect } from "babylonjs/Materials/effect";
  60450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60451. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60452. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60453. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60454. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60455. /**
  60456. * Block used to add support for vertex skinning (bones)
  60457. */
  60458. export class BonesBlock extends NodeMaterialBlock {
  60459. /**
  60460. * Creates a new BonesBlock
  60461. * @param name defines the block name
  60462. */
  60463. constructor(name: string);
  60464. /**
  60465. * Initialize the block and prepare the context for build
  60466. * @param state defines the state that will be used for the build
  60467. */
  60468. initialize(state: NodeMaterialBuildState): void;
  60469. /**
  60470. * Gets the current class name
  60471. * @returns the class name
  60472. */
  60473. getClassName(): string;
  60474. /**
  60475. * Gets the matrix indices input component
  60476. */
  60477. get matricesIndices(): NodeMaterialConnectionPoint;
  60478. /**
  60479. * Gets the matrix weights input component
  60480. */
  60481. get matricesWeights(): NodeMaterialConnectionPoint;
  60482. /**
  60483. * Gets the extra matrix indices input component
  60484. */
  60485. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60486. /**
  60487. * Gets the extra matrix weights input component
  60488. */
  60489. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60490. /**
  60491. * Gets the world input component
  60492. */
  60493. get world(): NodeMaterialConnectionPoint;
  60494. /**
  60495. * Gets the output component
  60496. */
  60497. get output(): NodeMaterialConnectionPoint;
  60498. autoConfigure(material: NodeMaterial): void;
  60499. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60500. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60502. protected _buildBlock(state: NodeMaterialBuildState): this;
  60503. }
  60504. }
  60505. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60510. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60511. /**
  60512. * Block used to add support for instances
  60513. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60514. */
  60515. export class InstancesBlock extends NodeMaterialBlock {
  60516. /**
  60517. * Creates a new InstancesBlock
  60518. * @param name defines the block name
  60519. */
  60520. constructor(name: string);
  60521. /**
  60522. * Gets the current class name
  60523. * @returns the class name
  60524. */
  60525. getClassName(): string;
  60526. /**
  60527. * Gets the first world row input component
  60528. */
  60529. get world0(): NodeMaterialConnectionPoint;
  60530. /**
  60531. * Gets the second world row input component
  60532. */
  60533. get world1(): NodeMaterialConnectionPoint;
  60534. /**
  60535. * Gets the third world row input component
  60536. */
  60537. get world2(): NodeMaterialConnectionPoint;
  60538. /**
  60539. * Gets the forth world row input component
  60540. */
  60541. get world3(): NodeMaterialConnectionPoint;
  60542. /**
  60543. * Gets the world input component
  60544. */
  60545. get world(): NodeMaterialConnectionPoint;
  60546. /**
  60547. * Gets the output component
  60548. */
  60549. get output(): NodeMaterialConnectionPoint;
  60550. /**
  60551. * Gets the isntanceID component
  60552. */
  60553. get instanceID(): NodeMaterialConnectionPoint;
  60554. autoConfigure(material: NodeMaterial): void;
  60555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60556. protected _buildBlock(state: NodeMaterialBuildState): this;
  60557. }
  60558. }
  60559. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60564. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60565. import { Effect } from "babylonjs/Materials/effect";
  60566. import { Mesh } from "babylonjs/Meshes/mesh";
  60567. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60569. /**
  60570. * Block used to add morph targets support to vertex shader
  60571. */
  60572. export class MorphTargetsBlock extends NodeMaterialBlock {
  60573. private _repeatableContentAnchor;
  60574. /**
  60575. * Create a new MorphTargetsBlock
  60576. * @param name defines the block name
  60577. */
  60578. constructor(name: string);
  60579. /**
  60580. * Gets the current class name
  60581. * @returns the class name
  60582. */
  60583. getClassName(): string;
  60584. /**
  60585. * Gets the position input component
  60586. */
  60587. get position(): NodeMaterialConnectionPoint;
  60588. /**
  60589. * Gets the normal input component
  60590. */
  60591. get normal(): NodeMaterialConnectionPoint;
  60592. /**
  60593. * Gets the tangent input component
  60594. */
  60595. get tangent(): NodeMaterialConnectionPoint;
  60596. /**
  60597. * Gets the tangent input component
  60598. */
  60599. get uv(): NodeMaterialConnectionPoint;
  60600. /**
  60601. * Gets the position output component
  60602. */
  60603. get positionOutput(): NodeMaterialConnectionPoint;
  60604. /**
  60605. * Gets the normal output component
  60606. */
  60607. get normalOutput(): NodeMaterialConnectionPoint;
  60608. /**
  60609. * Gets the tangent output component
  60610. */
  60611. get tangentOutput(): NodeMaterialConnectionPoint;
  60612. /**
  60613. * Gets the tangent output component
  60614. */
  60615. get uvOutput(): NodeMaterialConnectionPoint;
  60616. initialize(state: NodeMaterialBuildState): void;
  60617. autoConfigure(material: NodeMaterial): void;
  60618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60620. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60621. protected _buildBlock(state: NodeMaterialBuildState): this;
  60622. }
  60623. }
  60624. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60628. import { Nullable } from "babylonjs/types";
  60629. import { Scene } from "babylonjs/scene";
  60630. import { Effect } from "babylonjs/Materials/effect";
  60631. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60632. import { Mesh } from "babylonjs/Meshes/mesh";
  60633. import { Light } from "babylonjs/Lights/light";
  60634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60635. /**
  60636. * Block used to get data information from a light
  60637. */
  60638. export class LightInformationBlock extends NodeMaterialBlock {
  60639. private _lightDataUniformName;
  60640. private _lightColorUniformName;
  60641. private _lightTypeDefineName;
  60642. /**
  60643. * Gets or sets the light associated with this block
  60644. */
  60645. light: Nullable<Light>;
  60646. /**
  60647. * Creates a new LightInformationBlock
  60648. * @param name defines the block name
  60649. */
  60650. constructor(name: string);
  60651. /**
  60652. * Gets the current class name
  60653. * @returns the class name
  60654. */
  60655. getClassName(): string;
  60656. /**
  60657. * Gets the world position input component
  60658. */
  60659. get worldPosition(): NodeMaterialConnectionPoint;
  60660. /**
  60661. * Gets the direction output component
  60662. */
  60663. get direction(): NodeMaterialConnectionPoint;
  60664. /**
  60665. * Gets the direction output component
  60666. */
  60667. get color(): NodeMaterialConnectionPoint;
  60668. /**
  60669. * Gets the direction output component
  60670. */
  60671. get intensity(): NodeMaterialConnectionPoint;
  60672. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60674. protected _buildBlock(state: NodeMaterialBuildState): this;
  60675. serialize(): any;
  60676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60677. }
  60678. }
  60679. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  60680. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  60681. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  60682. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  60683. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  60684. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  60685. }
  60686. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  60687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60691. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60692. import { Effect } from "babylonjs/Materials/effect";
  60693. import { Mesh } from "babylonjs/Meshes/mesh";
  60694. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60695. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60696. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60697. /**
  60698. * Block used to add image processing support to fragment shader
  60699. */
  60700. export class ImageProcessingBlock extends NodeMaterialBlock {
  60701. /**
  60702. * Create a new ImageProcessingBlock
  60703. * @param name defines the block name
  60704. */
  60705. constructor(name: string);
  60706. /**
  60707. * Gets the current class name
  60708. * @returns the class name
  60709. */
  60710. getClassName(): string;
  60711. /**
  60712. * Gets the color input component
  60713. */
  60714. get color(): NodeMaterialConnectionPoint;
  60715. /**
  60716. * Gets the output component
  60717. */
  60718. get output(): NodeMaterialConnectionPoint;
  60719. /**
  60720. * Initialize the block and prepare the context for build
  60721. * @param state defines the state that will be used for the build
  60722. */
  60723. initialize(state: NodeMaterialBuildState): void;
  60724. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60726. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60727. protected _buildBlock(state: NodeMaterialBuildState): this;
  60728. }
  60729. }
  60730. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  60731. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60732. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60733. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60734. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60736. import { Effect } from "babylonjs/Materials/effect";
  60737. import { Mesh } from "babylonjs/Meshes/mesh";
  60738. import { Scene } from "babylonjs/scene";
  60739. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  60740. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  60741. /**
  60742. * Block used to pertub normals based on a normal map
  60743. */
  60744. export class PerturbNormalBlock extends NodeMaterialBlock {
  60745. private _tangentSpaceParameterName;
  60746. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60747. invertX: boolean;
  60748. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60749. invertY: boolean;
  60750. /**
  60751. * Create a new PerturbNormalBlock
  60752. * @param name defines the block name
  60753. */
  60754. constructor(name: string);
  60755. /**
  60756. * Gets the current class name
  60757. * @returns the class name
  60758. */
  60759. getClassName(): string;
  60760. /**
  60761. * Gets the world position input component
  60762. */
  60763. get worldPosition(): NodeMaterialConnectionPoint;
  60764. /**
  60765. * Gets the world normal input component
  60766. */
  60767. get worldNormal(): NodeMaterialConnectionPoint;
  60768. /**
  60769. * Gets the world tangent input component
  60770. */
  60771. get worldTangent(): NodeMaterialConnectionPoint;
  60772. /**
  60773. * Gets the uv input component
  60774. */
  60775. get uv(): NodeMaterialConnectionPoint;
  60776. /**
  60777. * Gets the normal map color input component
  60778. */
  60779. get normalMapColor(): NodeMaterialConnectionPoint;
  60780. /**
  60781. * Gets the strength input component
  60782. */
  60783. get strength(): NodeMaterialConnectionPoint;
  60784. /**
  60785. * Gets the output component
  60786. */
  60787. get output(): NodeMaterialConnectionPoint;
  60788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60790. autoConfigure(material: NodeMaterial): void;
  60791. protected _buildBlock(state: NodeMaterialBuildState): this;
  60792. protected _dumpPropertiesCode(): string;
  60793. serialize(): any;
  60794. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60795. }
  60796. }
  60797. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  60798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60801. /**
  60802. * Block used to discard a pixel if a value is smaller than a cutoff
  60803. */
  60804. export class DiscardBlock extends NodeMaterialBlock {
  60805. /**
  60806. * Create a new DiscardBlock
  60807. * @param name defines the block name
  60808. */
  60809. constructor(name: string);
  60810. /**
  60811. * Gets the current class name
  60812. * @returns the class name
  60813. */
  60814. getClassName(): string;
  60815. /**
  60816. * Gets the color input component
  60817. */
  60818. get value(): NodeMaterialConnectionPoint;
  60819. /**
  60820. * Gets the cutoff input component
  60821. */
  60822. get cutoff(): NodeMaterialConnectionPoint;
  60823. protected _buildBlock(state: NodeMaterialBuildState): this;
  60824. }
  60825. }
  60826. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  60827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60830. /**
  60831. * Block used to test if the fragment shader is front facing
  60832. */
  60833. export class FrontFacingBlock extends NodeMaterialBlock {
  60834. /**
  60835. * Creates a new FrontFacingBlock
  60836. * @param name defines the block name
  60837. */
  60838. constructor(name: string);
  60839. /**
  60840. * Gets the current class name
  60841. * @returns the class name
  60842. */
  60843. getClassName(): string;
  60844. /**
  60845. * Gets the output component
  60846. */
  60847. get output(): NodeMaterialConnectionPoint;
  60848. protected _buildBlock(state: NodeMaterialBuildState): this;
  60849. }
  60850. }
  60851. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  60852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60855. /**
  60856. * Block used to get the derivative value on x and y of a given input
  60857. */
  60858. export class DerivativeBlock extends NodeMaterialBlock {
  60859. /**
  60860. * Create a new DerivativeBlock
  60861. * @param name defines the block name
  60862. */
  60863. constructor(name: string);
  60864. /**
  60865. * Gets the current class name
  60866. * @returns the class name
  60867. */
  60868. getClassName(): string;
  60869. /**
  60870. * Gets the input component
  60871. */
  60872. get input(): NodeMaterialConnectionPoint;
  60873. /**
  60874. * Gets the derivative output on x
  60875. */
  60876. get dx(): NodeMaterialConnectionPoint;
  60877. /**
  60878. * Gets the derivative output on y
  60879. */
  60880. get dy(): NodeMaterialConnectionPoint;
  60881. protected _buildBlock(state: NodeMaterialBuildState): this;
  60882. }
  60883. }
  60884. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  60885. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  60886. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  60887. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  60888. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  60889. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  60890. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  60891. }
  60892. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  60893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60895. import { Mesh } from "babylonjs/Meshes/mesh";
  60896. import { Effect } from "babylonjs/Materials/effect";
  60897. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60899. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60900. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60901. /**
  60902. * Block used to add support for scene fog
  60903. */
  60904. export class FogBlock extends NodeMaterialBlock {
  60905. private _fogDistanceName;
  60906. private _fogParameters;
  60907. /**
  60908. * Create a new FogBlock
  60909. * @param name defines the block name
  60910. */
  60911. constructor(name: string);
  60912. /**
  60913. * Gets the current class name
  60914. * @returns the class name
  60915. */
  60916. getClassName(): string;
  60917. /**
  60918. * Gets the world position input component
  60919. */
  60920. get worldPosition(): NodeMaterialConnectionPoint;
  60921. /**
  60922. * Gets the view input component
  60923. */
  60924. get view(): NodeMaterialConnectionPoint;
  60925. /**
  60926. * Gets the color input component
  60927. */
  60928. get input(): NodeMaterialConnectionPoint;
  60929. /**
  60930. * Gets the fog color input component
  60931. */
  60932. get fogColor(): NodeMaterialConnectionPoint;
  60933. /**
  60934. * Gets the output component
  60935. */
  60936. get output(): NodeMaterialConnectionPoint;
  60937. autoConfigure(material: NodeMaterial): void;
  60938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60940. protected _buildBlock(state: NodeMaterialBuildState): this;
  60941. }
  60942. }
  60943. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  60944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60948. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60949. import { Effect } from "babylonjs/Materials/effect";
  60950. import { Mesh } from "babylonjs/Meshes/mesh";
  60951. import { Light } from "babylonjs/Lights/light";
  60952. import { Nullable } from "babylonjs/types";
  60953. import { Scene } from "babylonjs/scene";
  60954. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60955. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60956. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60957. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60958. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60959. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60960. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60961. /**
  60962. * Block used to add light in the fragment shader
  60963. */
  60964. export class LightBlock extends NodeMaterialBlock {
  60965. private _lightId;
  60966. /**
  60967. * Gets or sets the light associated with this block
  60968. */
  60969. light: Nullable<Light>;
  60970. /**
  60971. * Create a new LightBlock
  60972. * @param name defines the block name
  60973. */
  60974. constructor(name: string);
  60975. /**
  60976. * Gets the current class name
  60977. * @returns the class name
  60978. */
  60979. getClassName(): string;
  60980. /**
  60981. * Gets the world position input component
  60982. */
  60983. get worldPosition(): NodeMaterialConnectionPoint;
  60984. /**
  60985. * Gets the world normal input component
  60986. */
  60987. get worldNormal(): NodeMaterialConnectionPoint;
  60988. /**
  60989. * Gets the camera (or eye) position component
  60990. */
  60991. get cameraPosition(): NodeMaterialConnectionPoint;
  60992. /**
  60993. * Gets the glossiness component
  60994. */
  60995. get glossiness(): NodeMaterialConnectionPoint;
  60996. /**
  60997. * Gets the glossinness power component
  60998. */
  60999. get glossPower(): NodeMaterialConnectionPoint;
  61000. /**
  61001. * Gets the diffuse color component
  61002. */
  61003. get diffuseColor(): NodeMaterialConnectionPoint;
  61004. /**
  61005. * Gets the specular color component
  61006. */
  61007. get specularColor(): NodeMaterialConnectionPoint;
  61008. /**
  61009. * Gets the diffuse output component
  61010. */
  61011. get diffuseOutput(): NodeMaterialConnectionPoint;
  61012. /**
  61013. * Gets the specular output component
  61014. */
  61015. get specularOutput(): NodeMaterialConnectionPoint;
  61016. /**
  61017. * Gets the shadow output component
  61018. */
  61019. get shadow(): NodeMaterialConnectionPoint;
  61020. autoConfigure(material: NodeMaterial): void;
  61021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61022. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61023. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61024. private _injectVertexCode;
  61025. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61026. serialize(): any;
  61027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61028. }
  61029. }
  61030. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61031. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61032. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61033. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61034. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61035. }
  61036. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61037. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61038. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61039. }
  61040. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61044. /**
  61045. * Block used to multiply 2 values
  61046. */
  61047. export class MultiplyBlock extends NodeMaterialBlock {
  61048. /**
  61049. * Creates a new MultiplyBlock
  61050. * @param name defines the block name
  61051. */
  61052. constructor(name: string);
  61053. /**
  61054. * Gets the current class name
  61055. * @returns the class name
  61056. */
  61057. getClassName(): string;
  61058. /**
  61059. * Gets the left operand input component
  61060. */
  61061. get left(): NodeMaterialConnectionPoint;
  61062. /**
  61063. * Gets the right operand input component
  61064. */
  61065. get right(): NodeMaterialConnectionPoint;
  61066. /**
  61067. * Gets the output component
  61068. */
  61069. get output(): NodeMaterialConnectionPoint;
  61070. protected _buildBlock(state: NodeMaterialBuildState): this;
  61071. }
  61072. }
  61073. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61077. /**
  61078. * Block used to add 2 vectors
  61079. */
  61080. export class AddBlock extends NodeMaterialBlock {
  61081. /**
  61082. * Creates a new AddBlock
  61083. * @param name defines the block name
  61084. */
  61085. constructor(name: string);
  61086. /**
  61087. * Gets the current class name
  61088. * @returns the class name
  61089. */
  61090. getClassName(): string;
  61091. /**
  61092. * Gets the left operand input component
  61093. */
  61094. get left(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Gets the right operand input component
  61097. */
  61098. get right(): NodeMaterialConnectionPoint;
  61099. /**
  61100. * Gets the output component
  61101. */
  61102. get output(): NodeMaterialConnectionPoint;
  61103. protected _buildBlock(state: NodeMaterialBuildState): this;
  61104. }
  61105. }
  61106. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61107. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61108. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61110. /**
  61111. * Block used to scale a vector by a float
  61112. */
  61113. export class ScaleBlock extends NodeMaterialBlock {
  61114. /**
  61115. * Creates a new ScaleBlock
  61116. * @param name defines the block name
  61117. */
  61118. constructor(name: string);
  61119. /**
  61120. * Gets the current class name
  61121. * @returns the class name
  61122. */
  61123. getClassName(): string;
  61124. /**
  61125. * Gets the input component
  61126. */
  61127. get input(): NodeMaterialConnectionPoint;
  61128. /**
  61129. * Gets the factor input component
  61130. */
  61131. get factor(): NodeMaterialConnectionPoint;
  61132. /**
  61133. * Gets the output component
  61134. */
  61135. get output(): NodeMaterialConnectionPoint;
  61136. protected _buildBlock(state: NodeMaterialBuildState): this;
  61137. }
  61138. }
  61139. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61140. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61141. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61142. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61143. import { Scene } from "babylonjs/scene";
  61144. /**
  61145. * Block used to clamp a float
  61146. */
  61147. export class ClampBlock extends NodeMaterialBlock {
  61148. /** Gets or sets the minimum range */
  61149. minimum: number;
  61150. /** Gets or sets the maximum range */
  61151. maximum: number;
  61152. /**
  61153. * Creates a new ClampBlock
  61154. * @param name defines the block name
  61155. */
  61156. constructor(name: string);
  61157. /**
  61158. * Gets the current class name
  61159. * @returns the class name
  61160. */
  61161. getClassName(): string;
  61162. /**
  61163. * Gets the value input component
  61164. */
  61165. get value(): NodeMaterialConnectionPoint;
  61166. /**
  61167. * Gets the output component
  61168. */
  61169. get output(): NodeMaterialConnectionPoint;
  61170. protected _buildBlock(state: NodeMaterialBuildState): this;
  61171. protected _dumpPropertiesCode(): string;
  61172. serialize(): any;
  61173. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61174. }
  61175. }
  61176. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61180. /**
  61181. * Block used to apply a cross product between 2 vectors
  61182. */
  61183. export class CrossBlock extends NodeMaterialBlock {
  61184. /**
  61185. * Creates a new CrossBlock
  61186. * @param name defines the block name
  61187. */
  61188. constructor(name: string);
  61189. /**
  61190. * Gets the current class name
  61191. * @returns the class name
  61192. */
  61193. getClassName(): string;
  61194. /**
  61195. * Gets the left operand input component
  61196. */
  61197. get left(): NodeMaterialConnectionPoint;
  61198. /**
  61199. * Gets the right operand input component
  61200. */
  61201. get right(): NodeMaterialConnectionPoint;
  61202. /**
  61203. * Gets the output component
  61204. */
  61205. get output(): NodeMaterialConnectionPoint;
  61206. protected _buildBlock(state: NodeMaterialBuildState): this;
  61207. }
  61208. }
  61209. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61213. /**
  61214. * Block used to apply a dot product between 2 vectors
  61215. */
  61216. export class DotBlock extends NodeMaterialBlock {
  61217. /**
  61218. * Creates a new DotBlock
  61219. * @param name defines the block name
  61220. */
  61221. constructor(name: string);
  61222. /**
  61223. * Gets the current class name
  61224. * @returns the class name
  61225. */
  61226. getClassName(): string;
  61227. /**
  61228. * Gets the left operand input component
  61229. */
  61230. get left(): NodeMaterialConnectionPoint;
  61231. /**
  61232. * Gets the right operand input component
  61233. */
  61234. get right(): NodeMaterialConnectionPoint;
  61235. /**
  61236. * Gets the output component
  61237. */
  61238. get output(): NodeMaterialConnectionPoint;
  61239. protected _buildBlock(state: NodeMaterialBuildState): this;
  61240. }
  61241. }
  61242. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61246. import { Vector2 } from "babylonjs/Maths/math.vector";
  61247. import { Scene } from "babylonjs/scene";
  61248. /**
  61249. * Block used to remap a float from a range to a new one
  61250. */
  61251. export class RemapBlock extends NodeMaterialBlock {
  61252. /**
  61253. * Gets or sets the source range
  61254. */
  61255. sourceRange: Vector2;
  61256. /**
  61257. * Gets or sets the target range
  61258. */
  61259. targetRange: Vector2;
  61260. /**
  61261. * Creates a new RemapBlock
  61262. * @param name defines the block name
  61263. */
  61264. constructor(name: string);
  61265. /**
  61266. * Gets the current class name
  61267. * @returns the class name
  61268. */
  61269. getClassName(): string;
  61270. /**
  61271. * Gets the input component
  61272. */
  61273. get input(): NodeMaterialConnectionPoint;
  61274. /**
  61275. * Gets the source min input component
  61276. */
  61277. get sourceMin(): NodeMaterialConnectionPoint;
  61278. /**
  61279. * Gets the source max input component
  61280. */
  61281. get sourceMax(): NodeMaterialConnectionPoint;
  61282. /**
  61283. * Gets the target min input component
  61284. */
  61285. get targetMin(): NodeMaterialConnectionPoint;
  61286. /**
  61287. * Gets the target max input component
  61288. */
  61289. get targetMax(): NodeMaterialConnectionPoint;
  61290. /**
  61291. * Gets the output component
  61292. */
  61293. get output(): NodeMaterialConnectionPoint;
  61294. protected _buildBlock(state: NodeMaterialBuildState): this;
  61295. protected _dumpPropertiesCode(): string;
  61296. serialize(): any;
  61297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61298. }
  61299. }
  61300. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61304. /**
  61305. * Block used to normalize a vector
  61306. */
  61307. export class NormalizeBlock extends NodeMaterialBlock {
  61308. /**
  61309. * Creates a new NormalizeBlock
  61310. * @param name defines the block name
  61311. */
  61312. constructor(name: string);
  61313. /**
  61314. * Gets the current class name
  61315. * @returns the class name
  61316. */
  61317. getClassName(): string;
  61318. /**
  61319. * Gets the input component
  61320. */
  61321. get input(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the output component
  61324. */
  61325. get output(): NodeMaterialConnectionPoint;
  61326. protected _buildBlock(state: NodeMaterialBuildState): this;
  61327. }
  61328. }
  61329. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61333. import { Scene } from "babylonjs/scene";
  61334. /**
  61335. * Operations supported by the Trigonometry block
  61336. */
  61337. export enum TrigonometryBlockOperations {
  61338. /** Cos */
  61339. Cos = 0,
  61340. /** Sin */
  61341. Sin = 1,
  61342. /** Abs */
  61343. Abs = 2,
  61344. /** Exp */
  61345. Exp = 3,
  61346. /** Exp2 */
  61347. Exp2 = 4,
  61348. /** Round */
  61349. Round = 5,
  61350. /** Floor */
  61351. Floor = 6,
  61352. /** Ceiling */
  61353. Ceiling = 7,
  61354. /** Square root */
  61355. Sqrt = 8,
  61356. /** Log */
  61357. Log = 9,
  61358. /** Tangent */
  61359. Tan = 10,
  61360. /** Arc tangent */
  61361. ArcTan = 11,
  61362. /** Arc cosinus */
  61363. ArcCos = 12,
  61364. /** Arc sinus */
  61365. ArcSin = 13,
  61366. /** Fraction */
  61367. Fract = 14,
  61368. /** Sign */
  61369. Sign = 15,
  61370. /** To radians (from degrees) */
  61371. Radians = 16,
  61372. /** To degrees (from radians) */
  61373. Degrees = 17
  61374. }
  61375. /**
  61376. * Block used to apply trigonometry operation to floats
  61377. */
  61378. export class TrigonometryBlock extends NodeMaterialBlock {
  61379. /**
  61380. * Gets or sets the operation applied by the block
  61381. */
  61382. operation: TrigonometryBlockOperations;
  61383. /**
  61384. * Creates a new TrigonometryBlock
  61385. * @param name defines the block name
  61386. */
  61387. constructor(name: string);
  61388. /**
  61389. * Gets the current class name
  61390. * @returns the class name
  61391. */
  61392. getClassName(): string;
  61393. /**
  61394. * Gets the input component
  61395. */
  61396. get input(): NodeMaterialConnectionPoint;
  61397. /**
  61398. * Gets the output component
  61399. */
  61400. get output(): NodeMaterialConnectionPoint;
  61401. protected _buildBlock(state: NodeMaterialBuildState): this;
  61402. serialize(): any;
  61403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61404. protected _dumpPropertiesCode(): string;
  61405. }
  61406. }
  61407. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61409. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61411. /**
  61412. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61413. */
  61414. export class ColorMergerBlock extends NodeMaterialBlock {
  61415. /**
  61416. * Create a new ColorMergerBlock
  61417. * @param name defines the block name
  61418. */
  61419. constructor(name: string);
  61420. /**
  61421. * Gets the current class name
  61422. * @returns the class name
  61423. */
  61424. getClassName(): string;
  61425. /**
  61426. * Gets the rgb component (input)
  61427. */
  61428. get rgbIn(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the r component (input)
  61431. */
  61432. get r(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the g component (input)
  61435. */
  61436. get g(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the b component (input)
  61439. */
  61440. get b(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the a component (input)
  61443. */
  61444. get a(): NodeMaterialConnectionPoint;
  61445. /**
  61446. * Gets the rgba component (output)
  61447. */
  61448. get rgba(): NodeMaterialConnectionPoint;
  61449. /**
  61450. * Gets the rgb component (output)
  61451. */
  61452. get rgbOut(): NodeMaterialConnectionPoint;
  61453. /**
  61454. * Gets the rgb component (output)
  61455. * @deprecated Please use rgbOut instead.
  61456. */
  61457. get rgb(): NodeMaterialConnectionPoint;
  61458. protected _buildBlock(state: NodeMaterialBuildState): this;
  61459. }
  61460. }
  61461. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61465. /**
  61466. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61467. */
  61468. export class VectorMergerBlock extends NodeMaterialBlock {
  61469. /**
  61470. * Create a new VectorMergerBlock
  61471. * @param name defines the block name
  61472. */
  61473. constructor(name: string);
  61474. /**
  61475. * Gets the current class name
  61476. * @returns the class name
  61477. */
  61478. getClassName(): string;
  61479. /**
  61480. * Gets the xyz component (input)
  61481. */
  61482. get xyzIn(): NodeMaterialConnectionPoint;
  61483. /**
  61484. * Gets the xy component (input)
  61485. */
  61486. get xyIn(): NodeMaterialConnectionPoint;
  61487. /**
  61488. * Gets the x component (input)
  61489. */
  61490. get x(): NodeMaterialConnectionPoint;
  61491. /**
  61492. * Gets the y component (input)
  61493. */
  61494. get y(): NodeMaterialConnectionPoint;
  61495. /**
  61496. * Gets the z component (input)
  61497. */
  61498. get z(): NodeMaterialConnectionPoint;
  61499. /**
  61500. * Gets the w component (input)
  61501. */
  61502. get w(): NodeMaterialConnectionPoint;
  61503. /**
  61504. * Gets the xyzw component (output)
  61505. */
  61506. get xyzw(): NodeMaterialConnectionPoint;
  61507. /**
  61508. * Gets the xyz component (output)
  61509. */
  61510. get xyzOut(): NodeMaterialConnectionPoint;
  61511. /**
  61512. * Gets the xy component (output)
  61513. */
  61514. get xyOut(): NodeMaterialConnectionPoint;
  61515. /**
  61516. * Gets the xy component (output)
  61517. * @deprecated Please use xyOut instead.
  61518. */
  61519. get xy(): NodeMaterialConnectionPoint;
  61520. /**
  61521. * Gets the xyz component (output)
  61522. * @deprecated Please use xyzOut instead.
  61523. */
  61524. get xyz(): NodeMaterialConnectionPoint;
  61525. protected _buildBlock(state: NodeMaterialBuildState): this;
  61526. }
  61527. }
  61528. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61532. /**
  61533. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61534. */
  61535. export class ColorSplitterBlock extends NodeMaterialBlock {
  61536. /**
  61537. * Create a new ColorSplitterBlock
  61538. * @param name defines the block name
  61539. */
  61540. constructor(name: string);
  61541. /**
  61542. * Gets the current class name
  61543. * @returns the class name
  61544. */
  61545. getClassName(): string;
  61546. /**
  61547. * Gets the rgba component (input)
  61548. */
  61549. get rgba(): NodeMaterialConnectionPoint;
  61550. /**
  61551. * Gets the rgb component (input)
  61552. */
  61553. get rgbIn(): NodeMaterialConnectionPoint;
  61554. /**
  61555. * Gets the rgb component (output)
  61556. */
  61557. get rgbOut(): NodeMaterialConnectionPoint;
  61558. /**
  61559. * Gets the r component (output)
  61560. */
  61561. get r(): NodeMaterialConnectionPoint;
  61562. /**
  61563. * Gets the g component (output)
  61564. */
  61565. get g(): NodeMaterialConnectionPoint;
  61566. /**
  61567. * Gets the b component (output)
  61568. */
  61569. get b(): NodeMaterialConnectionPoint;
  61570. /**
  61571. * Gets the a component (output)
  61572. */
  61573. get a(): NodeMaterialConnectionPoint;
  61574. protected _inputRename(name: string): string;
  61575. protected _outputRename(name: string): string;
  61576. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61577. }
  61578. }
  61579. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61583. /**
  61584. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61585. */
  61586. export class VectorSplitterBlock extends NodeMaterialBlock {
  61587. /**
  61588. * Create a new VectorSplitterBlock
  61589. * @param name defines the block name
  61590. */
  61591. constructor(name: string);
  61592. /**
  61593. * Gets the current class name
  61594. * @returns the class name
  61595. */
  61596. getClassName(): string;
  61597. /**
  61598. * Gets the xyzw component (input)
  61599. */
  61600. get xyzw(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the xyz component (input)
  61603. */
  61604. get xyzIn(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the xy component (input)
  61607. */
  61608. get xyIn(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the xyz component (output)
  61611. */
  61612. get xyzOut(): NodeMaterialConnectionPoint;
  61613. /**
  61614. * Gets the xy component (output)
  61615. */
  61616. get xyOut(): NodeMaterialConnectionPoint;
  61617. /**
  61618. * Gets the x component (output)
  61619. */
  61620. get x(): NodeMaterialConnectionPoint;
  61621. /**
  61622. * Gets the y component (output)
  61623. */
  61624. get y(): NodeMaterialConnectionPoint;
  61625. /**
  61626. * Gets the z component (output)
  61627. */
  61628. get z(): NodeMaterialConnectionPoint;
  61629. /**
  61630. * Gets the w component (output)
  61631. */
  61632. get w(): NodeMaterialConnectionPoint;
  61633. protected _inputRename(name: string): string;
  61634. protected _outputRename(name: string): string;
  61635. protected _buildBlock(state: NodeMaterialBuildState): this;
  61636. }
  61637. }
  61638. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  61639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61642. /**
  61643. * Block used to lerp between 2 values
  61644. */
  61645. export class LerpBlock extends NodeMaterialBlock {
  61646. /**
  61647. * Creates a new LerpBlock
  61648. * @param name defines the block name
  61649. */
  61650. constructor(name: string);
  61651. /**
  61652. * Gets the current class name
  61653. * @returns the class name
  61654. */
  61655. getClassName(): string;
  61656. /**
  61657. * Gets the left operand input component
  61658. */
  61659. get left(): NodeMaterialConnectionPoint;
  61660. /**
  61661. * Gets the right operand input component
  61662. */
  61663. get right(): NodeMaterialConnectionPoint;
  61664. /**
  61665. * Gets the gradient operand input component
  61666. */
  61667. get gradient(): NodeMaterialConnectionPoint;
  61668. /**
  61669. * Gets the output component
  61670. */
  61671. get output(): NodeMaterialConnectionPoint;
  61672. protected _buildBlock(state: NodeMaterialBuildState): this;
  61673. }
  61674. }
  61675. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  61676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61679. /**
  61680. * Block used to divide 2 vectors
  61681. */
  61682. export class DivideBlock extends NodeMaterialBlock {
  61683. /**
  61684. * Creates a new DivideBlock
  61685. * @param name defines the block name
  61686. */
  61687. constructor(name: string);
  61688. /**
  61689. * Gets the current class name
  61690. * @returns the class name
  61691. */
  61692. getClassName(): string;
  61693. /**
  61694. * Gets the left operand input component
  61695. */
  61696. get left(): NodeMaterialConnectionPoint;
  61697. /**
  61698. * Gets the right operand input component
  61699. */
  61700. get right(): NodeMaterialConnectionPoint;
  61701. /**
  61702. * Gets the output component
  61703. */
  61704. get output(): NodeMaterialConnectionPoint;
  61705. protected _buildBlock(state: NodeMaterialBuildState): this;
  61706. }
  61707. }
  61708. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  61709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61712. /**
  61713. * Block used to subtract 2 vectors
  61714. */
  61715. export class SubtractBlock extends NodeMaterialBlock {
  61716. /**
  61717. * Creates a new SubtractBlock
  61718. * @param name defines the block name
  61719. */
  61720. constructor(name: string);
  61721. /**
  61722. * Gets the current class name
  61723. * @returns the class name
  61724. */
  61725. getClassName(): string;
  61726. /**
  61727. * Gets the left operand input component
  61728. */
  61729. get left(): NodeMaterialConnectionPoint;
  61730. /**
  61731. * Gets the right operand input component
  61732. */
  61733. get right(): NodeMaterialConnectionPoint;
  61734. /**
  61735. * Gets the output component
  61736. */
  61737. get output(): NodeMaterialConnectionPoint;
  61738. protected _buildBlock(state: NodeMaterialBuildState): this;
  61739. }
  61740. }
  61741. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  61742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61745. /**
  61746. * Block used to step a value
  61747. */
  61748. export class StepBlock extends NodeMaterialBlock {
  61749. /**
  61750. * Creates a new StepBlock
  61751. * @param name defines the block name
  61752. */
  61753. constructor(name: string);
  61754. /**
  61755. * Gets the current class name
  61756. * @returns the class name
  61757. */
  61758. getClassName(): string;
  61759. /**
  61760. * Gets the value operand input component
  61761. */
  61762. get value(): NodeMaterialConnectionPoint;
  61763. /**
  61764. * Gets the edge operand input component
  61765. */
  61766. get edge(): NodeMaterialConnectionPoint;
  61767. /**
  61768. * Gets the output component
  61769. */
  61770. get output(): NodeMaterialConnectionPoint;
  61771. protected _buildBlock(state: NodeMaterialBuildState): this;
  61772. }
  61773. }
  61774. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  61775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61778. /**
  61779. * Block used to get the opposite (1 - x) of a value
  61780. */
  61781. export class OneMinusBlock extends NodeMaterialBlock {
  61782. /**
  61783. * Creates a new OneMinusBlock
  61784. * @param name defines the block name
  61785. */
  61786. constructor(name: string);
  61787. /**
  61788. * Gets the current class name
  61789. * @returns the class name
  61790. */
  61791. getClassName(): string;
  61792. /**
  61793. * Gets the input component
  61794. */
  61795. get input(): NodeMaterialConnectionPoint;
  61796. /**
  61797. * Gets the output component
  61798. */
  61799. get output(): NodeMaterialConnectionPoint;
  61800. protected _buildBlock(state: NodeMaterialBuildState): this;
  61801. }
  61802. }
  61803. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  61804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61807. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61808. /**
  61809. * Block used to get the view direction
  61810. */
  61811. export class ViewDirectionBlock extends NodeMaterialBlock {
  61812. /**
  61813. * Creates a new ViewDirectionBlock
  61814. * @param name defines the block name
  61815. */
  61816. constructor(name: string);
  61817. /**
  61818. * Gets the current class name
  61819. * @returns the class name
  61820. */
  61821. getClassName(): string;
  61822. /**
  61823. * Gets the world position component
  61824. */
  61825. get worldPosition(): NodeMaterialConnectionPoint;
  61826. /**
  61827. * Gets the camera position component
  61828. */
  61829. get cameraPosition(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the output component
  61832. */
  61833. get output(): NodeMaterialConnectionPoint;
  61834. autoConfigure(material: NodeMaterial): void;
  61835. protected _buildBlock(state: NodeMaterialBuildState): this;
  61836. }
  61837. }
  61838. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  61839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61842. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61843. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  61844. /**
  61845. * Block used to compute fresnel value
  61846. */
  61847. export class FresnelBlock extends NodeMaterialBlock {
  61848. /**
  61849. * Create a new FresnelBlock
  61850. * @param name defines the block name
  61851. */
  61852. constructor(name: string);
  61853. /**
  61854. * Gets the current class name
  61855. * @returns the class name
  61856. */
  61857. getClassName(): string;
  61858. /**
  61859. * Gets the world normal input component
  61860. */
  61861. get worldNormal(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the view direction input component
  61864. */
  61865. get viewDirection(): NodeMaterialConnectionPoint;
  61866. /**
  61867. * Gets the bias input component
  61868. */
  61869. get bias(): NodeMaterialConnectionPoint;
  61870. /**
  61871. * Gets the camera (or eye) position component
  61872. */
  61873. get power(): NodeMaterialConnectionPoint;
  61874. /**
  61875. * Gets the fresnel output component
  61876. */
  61877. get fresnel(): NodeMaterialConnectionPoint;
  61878. autoConfigure(material: NodeMaterial): void;
  61879. protected _buildBlock(state: NodeMaterialBuildState): this;
  61880. }
  61881. }
  61882. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  61883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61886. /**
  61887. * Block used to get the max of 2 values
  61888. */
  61889. export class MaxBlock extends NodeMaterialBlock {
  61890. /**
  61891. * Creates a new MaxBlock
  61892. * @param name defines the block name
  61893. */
  61894. constructor(name: string);
  61895. /**
  61896. * Gets the current class name
  61897. * @returns the class name
  61898. */
  61899. getClassName(): string;
  61900. /**
  61901. * Gets the left operand input component
  61902. */
  61903. get left(): NodeMaterialConnectionPoint;
  61904. /**
  61905. * Gets the right operand input component
  61906. */
  61907. get right(): NodeMaterialConnectionPoint;
  61908. /**
  61909. * Gets the output component
  61910. */
  61911. get output(): NodeMaterialConnectionPoint;
  61912. protected _buildBlock(state: NodeMaterialBuildState): this;
  61913. }
  61914. }
  61915. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  61916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61919. /**
  61920. * Block used to get the min of 2 values
  61921. */
  61922. export class MinBlock extends NodeMaterialBlock {
  61923. /**
  61924. * Creates a new MinBlock
  61925. * @param name defines the block name
  61926. */
  61927. constructor(name: string);
  61928. /**
  61929. * Gets the current class name
  61930. * @returns the class name
  61931. */
  61932. getClassName(): string;
  61933. /**
  61934. * Gets the left operand input component
  61935. */
  61936. get left(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the right operand input component
  61939. */
  61940. get right(): NodeMaterialConnectionPoint;
  61941. /**
  61942. * Gets the output component
  61943. */
  61944. get output(): NodeMaterialConnectionPoint;
  61945. protected _buildBlock(state: NodeMaterialBuildState): this;
  61946. }
  61947. }
  61948. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  61949. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61950. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61951. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61952. /**
  61953. * Block used to get the distance between 2 values
  61954. */
  61955. export class DistanceBlock extends NodeMaterialBlock {
  61956. /**
  61957. * Creates a new DistanceBlock
  61958. * @param name defines the block name
  61959. */
  61960. constructor(name: string);
  61961. /**
  61962. * Gets the current class name
  61963. * @returns the class name
  61964. */
  61965. getClassName(): string;
  61966. /**
  61967. * Gets the left operand input component
  61968. */
  61969. get left(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the right operand input component
  61972. */
  61973. get right(): NodeMaterialConnectionPoint;
  61974. /**
  61975. * Gets the output component
  61976. */
  61977. get output(): NodeMaterialConnectionPoint;
  61978. protected _buildBlock(state: NodeMaterialBuildState): this;
  61979. }
  61980. }
  61981. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  61982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61985. /**
  61986. * Block used to get the length of a vector
  61987. */
  61988. export class LengthBlock extends NodeMaterialBlock {
  61989. /**
  61990. * Creates a new LengthBlock
  61991. * @param name defines the block name
  61992. */
  61993. constructor(name: string);
  61994. /**
  61995. * Gets the current class name
  61996. * @returns the class name
  61997. */
  61998. getClassName(): string;
  61999. /**
  62000. * Gets the value input component
  62001. */
  62002. get value(): NodeMaterialConnectionPoint;
  62003. /**
  62004. * Gets the output component
  62005. */
  62006. get output(): NodeMaterialConnectionPoint;
  62007. protected _buildBlock(state: NodeMaterialBuildState): this;
  62008. }
  62009. }
  62010. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62014. /**
  62015. * Block used to get negative version of a value (i.e. x * -1)
  62016. */
  62017. export class NegateBlock extends NodeMaterialBlock {
  62018. /**
  62019. * Creates a new NegateBlock
  62020. * @param name defines the block name
  62021. */
  62022. constructor(name: string);
  62023. /**
  62024. * Gets the current class name
  62025. * @returns the class name
  62026. */
  62027. getClassName(): string;
  62028. /**
  62029. * Gets the value input component
  62030. */
  62031. get value(): NodeMaterialConnectionPoint;
  62032. /**
  62033. * Gets the output component
  62034. */
  62035. get output(): NodeMaterialConnectionPoint;
  62036. protected _buildBlock(state: NodeMaterialBuildState): this;
  62037. }
  62038. }
  62039. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62042. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62043. /**
  62044. * Block used to get the value of the first parameter raised to the power of the second
  62045. */
  62046. export class PowBlock extends NodeMaterialBlock {
  62047. /**
  62048. * Creates a new PowBlock
  62049. * @param name defines the block name
  62050. */
  62051. constructor(name: string);
  62052. /**
  62053. * Gets the current class name
  62054. * @returns the class name
  62055. */
  62056. getClassName(): string;
  62057. /**
  62058. * Gets the value operand input component
  62059. */
  62060. get value(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the power operand input component
  62063. */
  62064. get power(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the output component
  62067. */
  62068. get output(): NodeMaterialConnectionPoint;
  62069. protected _buildBlock(state: NodeMaterialBuildState): this;
  62070. }
  62071. }
  62072. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62076. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62077. /**
  62078. * Block used to get a random number
  62079. */
  62080. export class RandomNumberBlock extends NodeMaterialBlock {
  62081. /**
  62082. * Creates a new RandomNumberBlock
  62083. * @param name defines the block name
  62084. */
  62085. constructor(name: string);
  62086. /**
  62087. * Gets the current class name
  62088. * @returns the class name
  62089. */
  62090. getClassName(): string;
  62091. /**
  62092. * Gets the seed input component
  62093. */
  62094. get seed(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the output component
  62097. */
  62098. get output(): NodeMaterialConnectionPoint;
  62099. protected _buildBlock(state: NodeMaterialBuildState): this;
  62100. }
  62101. }
  62102. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62103. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62104. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62105. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62106. /**
  62107. * Block used to compute arc tangent of 2 values
  62108. */
  62109. export class ArcTan2Block extends NodeMaterialBlock {
  62110. /**
  62111. * Creates a new ArcTan2Block
  62112. * @param name defines the block name
  62113. */
  62114. constructor(name: string);
  62115. /**
  62116. * Gets the current class name
  62117. * @returns the class name
  62118. */
  62119. getClassName(): string;
  62120. /**
  62121. * Gets the x operand input component
  62122. */
  62123. get x(): NodeMaterialConnectionPoint;
  62124. /**
  62125. * Gets the y operand input component
  62126. */
  62127. get y(): NodeMaterialConnectionPoint;
  62128. /**
  62129. * Gets the output component
  62130. */
  62131. get output(): NodeMaterialConnectionPoint;
  62132. protected _buildBlock(state: NodeMaterialBuildState): this;
  62133. }
  62134. }
  62135. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62139. /**
  62140. * Block used to smooth step a value
  62141. */
  62142. export class SmoothStepBlock extends NodeMaterialBlock {
  62143. /**
  62144. * Creates a new SmoothStepBlock
  62145. * @param name defines the block name
  62146. */
  62147. constructor(name: string);
  62148. /**
  62149. * Gets the current class name
  62150. * @returns the class name
  62151. */
  62152. getClassName(): string;
  62153. /**
  62154. * Gets the value operand input component
  62155. */
  62156. get value(): NodeMaterialConnectionPoint;
  62157. /**
  62158. * Gets the first edge operand input component
  62159. */
  62160. get edge0(): NodeMaterialConnectionPoint;
  62161. /**
  62162. * Gets the second edge operand input component
  62163. */
  62164. get edge1(): NodeMaterialConnectionPoint;
  62165. /**
  62166. * Gets the output component
  62167. */
  62168. get output(): NodeMaterialConnectionPoint;
  62169. protected _buildBlock(state: NodeMaterialBuildState): this;
  62170. }
  62171. }
  62172. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62176. /**
  62177. * Block used to get the reciprocal (1 / x) of a value
  62178. */
  62179. export class ReciprocalBlock extends NodeMaterialBlock {
  62180. /**
  62181. * Creates a new ReciprocalBlock
  62182. * @param name defines the block name
  62183. */
  62184. constructor(name: string);
  62185. /**
  62186. * Gets the current class name
  62187. * @returns the class name
  62188. */
  62189. getClassName(): string;
  62190. /**
  62191. * Gets the input component
  62192. */
  62193. get input(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the output component
  62196. */
  62197. get output(): NodeMaterialConnectionPoint;
  62198. protected _buildBlock(state: NodeMaterialBuildState): this;
  62199. }
  62200. }
  62201. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62205. /**
  62206. * Block used to replace a color by another one
  62207. */
  62208. export class ReplaceColorBlock extends NodeMaterialBlock {
  62209. /**
  62210. * Creates a new ReplaceColorBlock
  62211. * @param name defines the block name
  62212. */
  62213. constructor(name: string);
  62214. /**
  62215. * Gets the current class name
  62216. * @returns the class name
  62217. */
  62218. getClassName(): string;
  62219. /**
  62220. * Gets the value input component
  62221. */
  62222. get value(): NodeMaterialConnectionPoint;
  62223. /**
  62224. * Gets the reference input component
  62225. */
  62226. get reference(): NodeMaterialConnectionPoint;
  62227. /**
  62228. * Gets the distance input component
  62229. */
  62230. get distance(): NodeMaterialConnectionPoint;
  62231. /**
  62232. * Gets the replacement input component
  62233. */
  62234. get replacement(): NodeMaterialConnectionPoint;
  62235. /**
  62236. * Gets the output component
  62237. */
  62238. get output(): NodeMaterialConnectionPoint;
  62239. protected _buildBlock(state: NodeMaterialBuildState): this;
  62240. }
  62241. }
  62242. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62246. /**
  62247. * Block used to posterize a value
  62248. * @see https://en.wikipedia.org/wiki/Posterization
  62249. */
  62250. export class PosterizeBlock extends NodeMaterialBlock {
  62251. /**
  62252. * Creates a new PosterizeBlock
  62253. * @param name defines the block name
  62254. */
  62255. constructor(name: string);
  62256. /**
  62257. * Gets the current class name
  62258. * @returns the class name
  62259. */
  62260. getClassName(): string;
  62261. /**
  62262. * Gets the value input component
  62263. */
  62264. get value(): NodeMaterialConnectionPoint;
  62265. /**
  62266. * Gets the steps input component
  62267. */
  62268. get steps(): NodeMaterialConnectionPoint;
  62269. /**
  62270. * Gets the output component
  62271. */
  62272. get output(): NodeMaterialConnectionPoint;
  62273. protected _buildBlock(state: NodeMaterialBuildState): this;
  62274. }
  62275. }
  62276. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62280. import { Scene } from "babylonjs/scene";
  62281. /**
  62282. * Operations supported by the Wave block
  62283. */
  62284. export enum WaveBlockKind {
  62285. /** SawTooth */
  62286. SawTooth = 0,
  62287. /** Square */
  62288. Square = 1,
  62289. /** Triangle */
  62290. Triangle = 2
  62291. }
  62292. /**
  62293. * Block used to apply wave operation to floats
  62294. */
  62295. export class WaveBlock extends NodeMaterialBlock {
  62296. /**
  62297. * Gets or sets the kibnd of wave to be applied by the block
  62298. */
  62299. kind: WaveBlockKind;
  62300. /**
  62301. * Creates a new WaveBlock
  62302. * @param name defines the block name
  62303. */
  62304. constructor(name: string);
  62305. /**
  62306. * Gets the current class name
  62307. * @returns the class name
  62308. */
  62309. getClassName(): string;
  62310. /**
  62311. * Gets the input component
  62312. */
  62313. get input(): NodeMaterialConnectionPoint;
  62314. /**
  62315. * Gets the output component
  62316. */
  62317. get output(): NodeMaterialConnectionPoint;
  62318. protected _buildBlock(state: NodeMaterialBuildState): this;
  62319. serialize(): any;
  62320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62321. }
  62322. }
  62323. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62327. import { Color3 } from "babylonjs/Maths/math.color";
  62328. import { Scene } from "babylonjs/scene";
  62329. /**
  62330. * Class used to store a color step for the GradientBlock
  62331. */
  62332. export class GradientBlockColorStep {
  62333. /**
  62334. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62335. */
  62336. step: number;
  62337. /**
  62338. * Gets or sets the color associated with this step
  62339. */
  62340. color: Color3;
  62341. /**
  62342. * Creates a new GradientBlockColorStep
  62343. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62344. * @param color defines the color associated with this step
  62345. */
  62346. constructor(
  62347. /**
  62348. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62349. */
  62350. step: number,
  62351. /**
  62352. * Gets or sets the color associated with this step
  62353. */
  62354. color: Color3);
  62355. }
  62356. /**
  62357. * Block used to return a color from a gradient based on an input value between 0 and 1
  62358. */
  62359. export class GradientBlock extends NodeMaterialBlock {
  62360. /**
  62361. * Gets or sets the list of color steps
  62362. */
  62363. colorSteps: GradientBlockColorStep[];
  62364. /**
  62365. * Creates a new GradientBlock
  62366. * @param name defines the block name
  62367. */
  62368. constructor(name: string);
  62369. /**
  62370. * Gets the current class name
  62371. * @returns the class name
  62372. */
  62373. getClassName(): string;
  62374. /**
  62375. * Gets the gradient input component
  62376. */
  62377. get gradient(): NodeMaterialConnectionPoint;
  62378. /**
  62379. * Gets the output component
  62380. */
  62381. get output(): NodeMaterialConnectionPoint;
  62382. private _writeColorConstant;
  62383. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62384. serialize(): any;
  62385. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62386. protected _dumpPropertiesCode(): string;
  62387. }
  62388. }
  62389. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62393. /**
  62394. * Block used to normalize lerp between 2 values
  62395. */
  62396. export class NLerpBlock extends NodeMaterialBlock {
  62397. /**
  62398. * Creates a new NLerpBlock
  62399. * @param name defines the block name
  62400. */
  62401. constructor(name: string);
  62402. /**
  62403. * Gets the current class name
  62404. * @returns the class name
  62405. */
  62406. getClassName(): string;
  62407. /**
  62408. * Gets the left operand input component
  62409. */
  62410. get left(): NodeMaterialConnectionPoint;
  62411. /**
  62412. * Gets the right operand input component
  62413. */
  62414. get right(): NodeMaterialConnectionPoint;
  62415. /**
  62416. * Gets the gradient operand input component
  62417. */
  62418. get gradient(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the output component
  62421. */
  62422. get output(): NodeMaterialConnectionPoint;
  62423. protected _buildBlock(state: NodeMaterialBuildState): this;
  62424. }
  62425. }
  62426. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62430. import { Scene } from "babylonjs/scene";
  62431. /**
  62432. * block used to Generate a Worley Noise 3D Noise Pattern
  62433. */
  62434. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62435. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62436. manhattanDistance: boolean;
  62437. /**
  62438. * Creates a new WorleyNoise3DBlock
  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 seed input component
  62449. */
  62450. get seed(): NodeMaterialConnectionPoint;
  62451. /**
  62452. * Gets the jitter input component
  62453. */
  62454. get jitter(): NodeMaterialConnectionPoint;
  62455. /**
  62456. * Gets the output component
  62457. */
  62458. get output(): NodeMaterialConnectionPoint;
  62459. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62460. /**
  62461. * Exposes the properties to the UI?
  62462. */
  62463. protected _dumpPropertiesCode(): string;
  62464. /**
  62465. * Exposes the properties to the Seralize?
  62466. */
  62467. serialize(): any;
  62468. /**
  62469. * Exposes the properties to the deseralize?
  62470. */
  62471. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62472. }
  62473. }
  62474. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62478. /**
  62479. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62480. */
  62481. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62482. /**
  62483. * Creates a new SimplexPerlin3DBlock
  62484. * @param name defines the block name
  62485. */
  62486. constructor(name: string);
  62487. /**
  62488. * Gets the current class name
  62489. * @returns the class name
  62490. */
  62491. getClassName(): string;
  62492. /**
  62493. * Gets the seed operand input component
  62494. */
  62495. get seed(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the output component
  62498. */
  62499. get output(): NodeMaterialConnectionPoint;
  62500. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62501. }
  62502. }
  62503. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62507. /**
  62508. * Block used to blend normals
  62509. */
  62510. export class NormalBlendBlock extends NodeMaterialBlock {
  62511. /**
  62512. * Creates a new NormalBlendBlock
  62513. * @param name defines the block name
  62514. */
  62515. constructor(name: string);
  62516. /**
  62517. * Gets the current class name
  62518. * @returns the class name
  62519. */
  62520. getClassName(): string;
  62521. /**
  62522. * Gets the first input component
  62523. */
  62524. get normalMap0(): NodeMaterialConnectionPoint;
  62525. /**
  62526. * Gets the second input component
  62527. */
  62528. get normalMap1(): NodeMaterialConnectionPoint;
  62529. /**
  62530. * Gets the output component
  62531. */
  62532. get output(): NodeMaterialConnectionPoint;
  62533. protected _buildBlock(state: NodeMaterialBuildState): this;
  62534. }
  62535. }
  62536. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62540. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62541. /**
  62542. * Block used to rotate a 2d vector by a given angle
  62543. */
  62544. export class Rotate2dBlock extends NodeMaterialBlock {
  62545. /**
  62546. * Creates a new Rotate2dBlock
  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 input vector
  62557. */
  62558. get input(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the input angle
  62561. */
  62562. get angle(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the output component
  62565. */
  62566. get output(): NodeMaterialConnectionPoint;
  62567. autoConfigure(material: NodeMaterial): void;
  62568. protected _buildBlock(state: NodeMaterialBuildState): this;
  62569. }
  62570. }
  62571. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62575. /**
  62576. * Block used to get the reflected vector from a direction and a normal
  62577. */
  62578. export class ReflectBlock extends NodeMaterialBlock {
  62579. /**
  62580. * Creates a new ReflectBlock
  62581. * @param name defines the block name
  62582. */
  62583. constructor(name: string);
  62584. /**
  62585. * Gets the current class name
  62586. * @returns the class name
  62587. */
  62588. getClassName(): string;
  62589. /**
  62590. * Gets the incident component
  62591. */
  62592. get incident(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the normal component
  62595. */
  62596. get normal(): NodeMaterialConnectionPoint;
  62597. /**
  62598. * Gets the output component
  62599. */
  62600. get output(): NodeMaterialConnectionPoint;
  62601. protected _buildBlock(state: NodeMaterialBuildState): this;
  62602. }
  62603. }
  62604. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62606. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62607. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62608. /**
  62609. * Block used to get the refracted vector from a direction and a normal
  62610. */
  62611. export class RefractBlock extends NodeMaterialBlock {
  62612. /**
  62613. * Creates a new RefractBlock
  62614. * @param name defines the block name
  62615. */
  62616. constructor(name: string);
  62617. /**
  62618. * Gets the current class name
  62619. * @returns the class name
  62620. */
  62621. getClassName(): string;
  62622. /**
  62623. * Gets the incident component
  62624. */
  62625. get incident(): NodeMaterialConnectionPoint;
  62626. /**
  62627. * Gets the normal component
  62628. */
  62629. get normal(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the index of refraction component
  62632. */
  62633. get ior(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the output component
  62636. */
  62637. get output(): NodeMaterialConnectionPoint;
  62638. protected _buildBlock(state: NodeMaterialBuildState): this;
  62639. }
  62640. }
  62641. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  62642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62645. /**
  62646. * Block used to desaturate a color
  62647. */
  62648. export class DesaturateBlock extends NodeMaterialBlock {
  62649. /**
  62650. * Creates a new DesaturateBlock
  62651. * @param name defines the block name
  62652. */
  62653. constructor(name: string);
  62654. /**
  62655. * Gets the current class name
  62656. * @returns the class name
  62657. */
  62658. getClassName(): string;
  62659. /**
  62660. * Gets the color operand input component
  62661. */
  62662. get color(): NodeMaterialConnectionPoint;
  62663. /**
  62664. * Gets the level operand input component
  62665. */
  62666. get level(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the output component
  62669. */
  62670. get output(): NodeMaterialConnectionPoint;
  62671. protected _buildBlock(state: NodeMaterialBuildState): this;
  62672. }
  62673. }
  62674. declare module "babylonjs/Materials/Node/Blocks/index" {
  62675. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  62676. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  62677. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  62678. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  62679. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  62680. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  62681. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  62682. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  62683. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  62684. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  62685. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  62686. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  62687. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  62688. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  62689. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  62690. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  62691. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  62692. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  62693. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  62694. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  62695. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  62696. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  62697. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  62698. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  62699. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  62700. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  62701. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  62702. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  62703. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  62704. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  62705. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  62706. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  62707. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  62708. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  62709. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  62710. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  62711. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  62712. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  62713. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  62714. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  62715. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  62716. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  62717. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  62718. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  62719. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  62720. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  62721. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  62722. }
  62723. declare module "babylonjs/Materials/Node/Optimizers/index" {
  62724. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  62725. }
  62726. declare module "babylonjs/Materials/Node/index" {
  62727. export * from "babylonjs/Materials/Node/Enums/index";
  62728. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62729. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  62730. export * from "babylonjs/Materials/Node/nodeMaterial";
  62731. export * from "babylonjs/Materials/Node/Blocks/index";
  62732. export * from "babylonjs/Materials/Node/Optimizers/index";
  62733. }
  62734. declare module "babylonjs/Materials/effectRenderer" {
  62735. import { Nullable } from "babylonjs/types";
  62736. import { Texture } from "babylonjs/Materials/Textures/texture";
  62737. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62738. import { Viewport } from "babylonjs/Maths/math.viewport";
  62739. import { Observable } from "babylonjs/Misc/observable";
  62740. import { Effect } from "babylonjs/Materials/effect";
  62741. import "babylonjs/Engines/Extensions/engine.renderTarget";
  62742. import "babylonjs/Shaders/postprocess.vertex";
  62743. /**
  62744. * Effect Render Options
  62745. */
  62746. export interface IEffectRendererOptions {
  62747. /**
  62748. * Defines the vertices positions.
  62749. */
  62750. positions?: number[];
  62751. /**
  62752. * Defines the indices.
  62753. */
  62754. indices?: number[];
  62755. }
  62756. /**
  62757. * Helper class to render one or more effects
  62758. */
  62759. export class EffectRenderer {
  62760. private engine;
  62761. private static _DefaultOptions;
  62762. private _vertexBuffers;
  62763. private _indexBuffer;
  62764. private _ringBufferIndex;
  62765. private _ringScreenBuffer;
  62766. private _fullscreenViewport;
  62767. private _getNextFrameBuffer;
  62768. /**
  62769. * Creates an effect renderer
  62770. * @param engine the engine to use for rendering
  62771. * @param options defines the options of the effect renderer
  62772. */
  62773. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62774. /**
  62775. * Sets the current viewport in normalized coordinates 0-1
  62776. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62777. */
  62778. setViewport(viewport?: Viewport): void;
  62779. /**
  62780. * Binds the embedded attributes buffer to the effect.
  62781. * @param effect Defines the effect to bind the attributes for
  62782. */
  62783. bindBuffers(effect: Effect): void;
  62784. /**
  62785. * Sets the current effect wrapper to use during draw.
  62786. * The effect needs to be ready before calling this api.
  62787. * This also sets the default full screen position attribute.
  62788. * @param effectWrapper Defines the effect to draw with
  62789. */
  62790. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62791. /**
  62792. * Draws a full screen quad.
  62793. */
  62794. draw(): void;
  62795. /**
  62796. * renders one or more effects to a specified texture
  62797. * @param effectWrappers list of effects to renderer
  62798. * @param outputTexture texture to draw to, if null it will render to the screen
  62799. */
  62800. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  62801. /**
  62802. * Disposes of the effect renderer
  62803. */
  62804. dispose(): void;
  62805. }
  62806. /**
  62807. * Options to create an EffectWrapper
  62808. */
  62809. interface EffectWrapperCreationOptions {
  62810. /**
  62811. * Engine to use to create the effect
  62812. */
  62813. engine: ThinEngine;
  62814. /**
  62815. * Fragment shader for the effect
  62816. */
  62817. fragmentShader: string;
  62818. /**
  62819. * Vertex shader for the effect
  62820. */
  62821. vertexShader?: string;
  62822. /**
  62823. * Attributes to use in the shader
  62824. */
  62825. attributeNames?: Array<string>;
  62826. /**
  62827. * Uniforms to use in the shader
  62828. */
  62829. uniformNames?: Array<string>;
  62830. /**
  62831. * Texture sampler names to use in the shader
  62832. */
  62833. samplerNames?: Array<string>;
  62834. /**
  62835. * The friendly name of the effect displayed in Spector.
  62836. */
  62837. name?: string;
  62838. }
  62839. /**
  62840. * Wraps an effect to be used for rendering
  62841. */
  62842. export class EffectWrapper {
  62843. /**
  62844. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62845. */
  62846. onApplyObservable: Observable<{}>;
  62847. /**
  62848. * The underlying effect
  62849. */
  62850. effect: Effect;
  62851. /**
  62852. * Creates an effect to be renderer
  62853. * @param creationOptions options to create the effect
  62854. */
  62855. constructor(creationOptions: EffectWrapperCreationOptions);
  62856. /**
  62857. * Disposes of the effect wrapper
  62858. */
  62859. dispose(): void;
  62860. }
  62861. }
  62862. declare module "babylonjs/Materials/index" {
  62863. export * from "babylonjs/Materials/Background/index";
  62864. export * from "babylonjs/Materials/colorCurves";
  62865. export * from "babylonjs/Materials/iEffectFallbacks";
  62866. export * from "babylonjs/Materials/effectFallbacks";
  62867. export * from "babylonjs/Materials/effect";
  62868. export * from "babylonjs/Materials/fresnelParameters";
  62869. export * from "babylonjs/Materials/imageProcessingConfiguration";
  62870. export * from "babylonjs/Materials/material";
  62871. export * from "babylonjs/Materials/materialDefines";
  62872. export * from "babylonjs/Materials/materialHelper";
  62873. export * from "babylonjs/Materials/multiMaterial";
  62874. export * from "babylonjs/Materials/PBR/index";
  62875. export * from "babylonjs/Materials/pushMaterial";
  62876. export * from "babylonjs/Materials/shaderMaterial";
  62877. export * from "babylonjs/Materials/standardMaterial";
  62878. export * from "babylonjs/Materials/Textures/index";
  62879. export * from "babylonjs/Materials/uniformBuffer";
  62880. export * from "babylonjs/Materials/materialFlags";
  62881. export * from "babylonjs/Materials/Node/index";
  62882. export * from "babylonjs/Materials/effectRenderer";
  62883. }
  62884. declare module "babylonjs/Maths/index" {
  62885. export * from "babylonjs/Maths/math.scalar";
  62886. export * from "babylonjs/Maths/math";
  62887. export * from "babylonjs/Maths/sphericalPolynomial";
  62888. }
  62889. declare module "babylonjs/Misc/workerPool" {
  62890. import { IDisposable } from "babylonjs/scene";
  62891. /**
  62892. * Helper class to push actions to a pool of workers.
  62893. */
  62894. export class WorkerPool implements IDisposable {
  62895. private _workerInfos;
  62896. private _pendingActions;
  62897. /**
  62898. * Constructor
  62899. * @param workers Array of workers to use for actions
  62900. */
  62901. constructor(workers: Array<Worker>);
  62902. /**
  62903. * Terminates all workers and clears any pending actions.
  62904. */
  62905. dispose(): void;
  62906. /**
  62907. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62908. * pended until a worker has completed its action.
  62909. * @param action The action to perform. Call onComplete when the action is complete.
  62910. */
  62911. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62912. private _execute;
  62913. }
  62914. }
  62915. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  62916. import { IDisposable } from "babylonjs/scene";
  62917. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  62918. /**
  62919. * Configuration for Draco compression
  62920. */
  62921. export interface IDracoCompressionConfiguration {
  62922. /**
  62923. * Configuration for the decoder.
  62924. */
  62925. decoder: {
  62926. /**
  62927. * The url to the WebAssembly module.
  62928. */
  62929. wasmUrl?: string;
  62930. /**
  62931. * The url to the WebAssembly binary.
  62932. */
  62933. wasmBinaryUrl?: string;
  62934. /**
  62935. * The url to the fallback JavaScript module.
  62936. */
  62937. fallbackUrl?: string;
  62938. };
  62939. }
  62940. /**
  62941. * Draco compression (https://google.github.io/draco/)
  62942. *
  62943. * This class wraps the Draco module.
  62944. *
  62945. * **Encoder**
  62946. *
  62947. * The encoder is not currently implemented.
  62948. *
  62949. * **Decoder**
  62950. *
  62951. * 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.
  62952. *
  62953. * To update the configuration, use the following code:
  62954. * ```javascript
  62955. * DracoCompression.Configuration = {
  62956. * decoder: {
  62957. * wasmUrl: "<url to the WebAssembly library>",
  62958. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62959. * fallbackUrl: "<url to the fallback JavaScript library>",
  62960. * }
  62961. * };
  62962. * ```
  62963. *
  62964. * 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.
  62965. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62966. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62967. *
  62968. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62969. * ```javascript
  62970. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62971. * ```
  62972. *
  62973. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62974. */
  62975. export class DracoCompression implements IDisposable {
  62976. private _workerPoolPromise?;
  62977. private _decoderModulePromise?;
  62978. /**
  62979. * The configuration. Defaults to the following urls:
  62980. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62981. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62982. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62983. */
  62984. static Configuration: IDracoCompressionConfiguration;
  62985. /**
  62986. * Returns true if the decoder configuration is available.
  62987. */
  62988. static get DecoderAvailable(): boolean;
  62989. /**
  62990. * Default number of workers to create when creating the draco compression object.
  62991. */
  62992. static DefaultNumWorkers: number;
  62993. private static GetDefaultNumWorkers;
  62994. private static _Default;
  62995. /**
  62996. * Default instance for the draco compression object.
  62997. */
  62998. static get Default(): DracoCompression;
  62999. /**
  63000. * Constructor
  63001. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63002. */
  63003. constructor(numWorkers?: number);
  63004. /**
  63005. * Stop all async operations and release resources.
  63006. */
  63007. dispose(): void;
  63008. /**
  63009. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63010. * @returns a promise that resolves when ready
  63011. */
  63012. whenReadyAsync(): Promise<void>;
  63013. /**
  63014. * Decode Draco compressed mesh data to vertex data.
  63015. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63016. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63017. * @returns A promise that resolves with the decoded vertex data
  63018. */
  63019. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63020. [kind: string]: number;
  63021. }): Promise<VertexData>;
  63022. }
  63023. }
  63024. declare module "babylonjs/Meshes/Compression/index" {
  63025. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63026. }
  63027. declare module "babylonjs/Meshes/csg" {
  63028. import { Nullable } from "babylonjs/types";
  63029. import { Scene } from "babylonjs/scene";
  63030. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63031. import { Mesh } from "babylonjs/Meshes/mesh";
  63032. import { Material } from "babylonjs/Materials/material";
  63033. /**
  63034. * Class for building Constructive Solid Geometry
  63035. */
  63036. export class CSG {
  63037. private polygons;
  63038. /**
  63039. * The world matrix
  63040. */
  63041. matrix: Matrix;
  63042. /**
  63043. * Stores the position
  63044. */
  63045. position: Vector3;
  63046. /**
  63047. * Stores the rotation
  63048. */
  63049. rotation: Vector3;
  63050. /**
  63051. * Stores the rotation quaternion
  63052. */
  63053. rotationQuaternion: Nullable<Quaternion>;
  63054. /**
  63055. * Stores the scaling vector
  63056. */
  63057. scaling: Vector3;
  63058. /**
  63059. * Convert the Mesh to CSG
  63060. * @param mesh The Mesh to convert to CSG
  63061. * @returns A new CSG from the Mesh
  63062. */
  63063. static FromMesh(mesh: Mesh): CSG;
  63064. /**
  63065. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63066. * @param polygons Polygons used to construct a CSG solid
  63067. */
  63068. private static FromPolygons;
  63069. /**
  63070. * Clones, or makes a deep copy, of the CSG
  63071. * @returns A new CSG
  63072. */
  63073. clone(): CSG;
  63074. /**
  63075. * Unions this CSG with another CSG
  63076. * @param csg The CSG to union against this CSG
  63077. * @returns The unioned CSG
  63078. */
  63079. union(csg: CSG): CSG;
  63080. /**
  63081. * Unions this CSG with another CSG in place
  63082. * @param csg The CSG to union against this CSG
  63083. */
  63084. unionInPlace(csg: CSG): void;
  63085. /**
  63086. * Subtracts this CSG with another CSG
  63087. * @param csg The CSG to subtract against this CSG
  63088. * @returns A new CSG
  63089. */
  63090. subtract(csg: CSG): CSG;
  63091. /**
  63092. * Subtracts this CSG with another CSG in place
  63093. * @param csg The CSG to subtact against this CSG
  63094. */
  63095. subtractInPlace(csg: CSG): void;
  63096. /**
  63097. * Intersect this CSG with another CSG
  63098. * @param csg The CSG to intersect against this CSG
  63099. * @returns A new CSG
  63100. */
  63101. intersect(csg: CSG): CSG;
  63102. /**
  63103. * Intersects this CSG with another CSG in place
  63104. * @param csg The CSG to intersect against this CSG
  63105. */
  63106. intersectInPlace(csg: CSG): void;
  63107. /**
  63108. * Return a new CSG solid with solid and empty space switched. This solid is
  63109. * not modified.
  63110. * @returns A new CSG solid with solid and empty space switched
  63111. */
  63112. inverse(): CSG;
  63113. /**
  63114. * Inverses the CSG in place
  63115. */
  63116. inverseInPlace(): void;
  63117. /**
  63118. * This is used to keep meshes transformations so they can be restored
  63119. * when we build back a Babylon Mesh
  63120. * NB : All CSG operations are performed in world coordinates
  63121. * @param csg The CSG to copy the transform attributes from
  63122. * @returns This CSG
  63123. */
  63124. copyTransformAttributes(csg: CSG): CSG;
  63125. /**
  63126. * Build Raw mesh from CSG
  63127. * Coordinates here are in world space
  63128. * @param name The name of the mesh geometry
  63129. * @param scene The Scene
  63130. * @param keepSubMeshes Specifies if the submeshes should be kept
  63131. * @returns A new Mesh
  63132. */
  63133. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63134. /**
  63135. * Build Mesh from CSG taking material and transforms into account
  63136. * @param name The name of the Mesh
  63137. * @param material The material of the Mesh
  63138. * @param scene The Scene
  63139. * @param keepSubMeshes Specifies if submeshes should be kept
  63140. * @returns The new Mesh
  63141. */
  63142. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63143. }
  63144. }
  63145. declare module "babylonjs/Meshes/trailMesh" {
  63146. import { Mesh } from "babylonjs/Meshes/mesh";
  63147. import { Scene } from "babylonjs/scene";
  63148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63149. /**
  63150. * Class used to create a trail following a mesh
  63151. */
  63152. export class TrailMesh extends Mesh {
  63153. private _generator;
  63154. private _autoStart;
  63155. private _running;
  63156. private _diameter;
  63157. private _length;
  63158. private _sectionPolygonPointsCount;
  63159. private _sectionVectors;
  63160. private _sectionNormalVectors;
  63161. private _beforeRenderObserver;
  63162. /**
  63163. * @constructor
  63164. * @param name The value used by scene.getMeshByName() to do a lookup.
  63165. * @param generator The mesh or transform node to generate a trail.
  63166. * @param scene The scene to add this mesh to.
  63167. * @param diameter Diameter of trailing mesh. Default is 1.
  63168. * @param length Length of trailing mesh. Default is 60.
  63169. * @param autoStart Automatically start trailing mesh. Default true.
  63170. */
  63171. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63172. /**
  63173. * "TrailMesh"
  63174. * @returns "TrailMesh"
  63175. */
  63176. getClassName(): string;
  63177. private _createMesh;
  63178. /**
  63179. * Start trailing mesh.
  63180. */
  63181. start(): void;
  63182. /**
  63183. * Stop trailing mesh.
  63184. */
  63185. stop(): void;
  63186. /**
  63187. * Update trailing mesh geometry.
  63188. */
  63189. update(): void;
  63190. /**
  63191. * Returns a new TrailMesh object.
  63192. * @param name is a string, the name given to the new mesh
  63193. * @param newGenerator use new generator object for cloned trail mesh
  63194. * @returns a new mesh
  63195. */
  63196. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63197. /**
  63198. * Serializes this trail mesh
  63199. * @param serializationObject object to write serialization to
  63200. */
  63201. serialize(serializationObject: any): void;
  63202. /**
  63203. * Parses a serialized trail mesh
  63204. * @param parsedMesh the serialized mesh
  63205. * @param scene the scene to create the trail mesh in
  63206. * @returns the created trail mesh
  63207. */
  63208. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63209. }
  63210. }
  63211. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63212. import { Nullable } from "babylonjs/types";
  63213. import { Scene } from "babylonjs/scene";
  63214. import { Vector4 } from "babylonjs/Maths/math.vector";
  63215. import { Color4 } from "babylonjs/Maths/math.color";
  63216. import { Mesh } from "babylonjs/Meshes/mesh";
  63217. /**
  63218. * Class containing static functions to help procedurally build meshes
  63219. */
  63220. export class TiledBoxBuilder {
  63221. /**
  63222. * Creates a box mesh
  63223. * 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)
  63224. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63228. * @param name defines the name of the mesh
  63229. * @param options defines the options used to create the mesh
  63230. * @param scene defines the hosting scene
  63231. * @returns the box mesh
  63232. */
  63233. static CreateTiledBox(name: string, options: {
  63234. pattern?: number;
  63235. width?: number;
  63236. height?: number;
  63237. depth?: number;
  63238. tileSize?: number;
  63239. tileWidth?: number;
  63240. tileHeight?: number;
  63241. alignHorizontal?: number;
  63242. alignVertical?: number;
  63243. faceUV?: Vector4[];
  63244. faceColors?: Color4[];
  63245. sideOrientation?: number;
  63246. updatable?: boolean;
  63247. }, scene?: Nullable<Scene>): Mesh;
  63248. }
  63249. }
  63250. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63251. import { Vector4 } from "babylonjs/Maths/math.vector";
  63252. import { Mesh } from "babylonjs/Meshes/mesh";
  63253. /**
  63254. * Class containing static functions to help procedurally build meshes
  63255. */
  63256. export class TorusKnotBuilder {
  63257. /**
  63258. * Creates a torus knot mesh
  63259. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63260. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63261. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63262. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63266. * @param name defines the name of the mesh
  63267. * @param options defines the options used to create the mesh
  63268. * @param scene defines the hosting scene
  63269. * @returns the torus knot mesh
  63270. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63271. */
  63272. static CreateTorusKnot(name: string, options: {
  63273. radius?: number;
  63274. tube?: number;
  63275. radialSegments?: number;
  63276. tubularSegments?: number;
  63277. p?: number;
  63278. q?: number;
  63279. updatable?: boolean;
  63280. sideOrientation?: number;
  63281. frontUVs?: Vector4;
  63282. backUVs?: Vector4;
  63283. }, scene: any): Mesh;
  63284. }
  63285. }
  63286. declare module "babylonjs/Meshes/polygonMesh" {
  63287. import { Scene } from "babylonjs/scene";
  63288. import { Vector2 } from "babylonjs/Maths/math.vector";
  63289. import { Mesh } from "babylonjs/Meshes/mesh";
  63290. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63291. import { Path2 } from "babylonjs/Maths/math.path";
  63292. /**
  63293. * Polygon
  63294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63295. */
  63296. export class Polygon {
  63297. /**
  63298. * Creates a rectangle
  63299. * @param xmin bottom X coord
  63300. * @param ymin bottom Y coord
  63301. * @param xmax top X coord
  63302. * @param ymax top Y coord
  63303. * @returns points that make the resulting rectation
  63304. */
  63305. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63306. /**
  63307. * Creates a circle
  63308. * @param radius radius of circle
  63309. * @param cx scale in x
  63310. * @param cy scale in y
  63311. * @param numberOfSides number of sides that make up the circle
  63312. * @returns points that make the resulting circle
  63313. */
  63314. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63315. /**
  63316. * Creates a polygon from input string
  63317. * @param input Input polygon data
  63318. * @returns the parsed points
  63319. */
  63320. static Parse(input: string): Vector2[];
  63321. /**
  63322. * Starts building a polygon from x and y coordinates
  63323. * @param x x coordinate
  63324. * @param y y coordinate
  63325. * @returns the started path2
  63326. */
  63327. static StartingAt(x: number, y: number): Path2;
  63328. }
  63329. /**
  63330. * Builds a polygon
  63331. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63332. */
  63333. export class PolygonMeshBuilder {
  63334. private _points;
  63335. private _outlinepoints;
  63336. private _holes;
  63337. private _name;
  63338. private _scene;
  63339. private _epoints;
  63340. private _eholes;
  63341. private _addToepoint;
  63342. /**
  63343. * Babylon reference to the earcut plugin.
  63344. */
  63345. bjsEarcut: any;
  63346. /**
  63347. * Creates a PolygonMeshBuilder
  63348. * @param name name of the builder
  63349. * @param contours Path of the polygon
  63350. * @param scene scene to add to when creating the mesh
  63351. * @param earcutInjection can be used to inject your own earcut reference
  63352. */
  63353. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63354. /**
  63355. * Adds a whole within the polygon
  63356. * @param hole Array of points defining the hole
  63357. * @returns this
  63358. */
  63359. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63360. /**
  63361. * Creates the polygon
  63362. * @param updatable If the mesh should be updatable
  63363. * @param depth The depth of the mesh created
  63364. * @returns the created mesh
  63365. */
  63366. build(updatable?: boolean, depth?: number): Mesh;
  63367. /**
  63368. * Creates the polygon
  63369. * @param depth The depth of the mesh created
  63370. * @returns the created VertexData
  63371. */
  63372. buildVertexData(depth?: number): VertexData;
  63373. /**
  63374. * Adds a side to the polygon
  63375. * @param positions points that make the polygon
  63376. * @param normals normals of the polygon
  63377. * @param uvs uvs of the polygon
  63378. * @param indices indices of the polygon
  63379. * @param bounds bounds of the polygon
  63380. * @param points points of the polygon
  63381. * @param depth depth of the polygon
  63382. * @param flip flip of the polygon
  63383. */
  63384. private addSide;
  63385. }
  63386. }
  63387. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63388. import { Scene } from "babylonjs/scene";
  63389. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63390. import { Color4 } from "babylonjs/Maths/math.color";
  63391. import { Mesh } from "babylonjs/Meshes/mesh";
  63392. import { Nullable } from "babylonjs/types";
  63393. /**
  63394. * Class containing static functions to help procedurally build meshes
  63395. */
  63396. export class PolygonBuilder {
  63397. /**
  63398. * Creates a polygon mesh
  63399. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63400. * * 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
  63401. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63404. * * Remember you can only change the shape positions, not their number when updating a polygon
  63405. * @param name defines the name of the mesh
  63406. * @param options defines the options used to create the mesh
  63407. * @param scene defines the hosting scene
  63408. * @param earcutInjection can be used to inject your own earcut reference
  63409. * @returns the polygon mesh
  63410. */
  63411. static CreatePolygon(name: string, options: {
  63412. shape: Vector3[];
  63413. holes?: Vector3[][];
  63414. depth?: number;
  63415. faceUV?: Vector4[];
  63416. faceColors?: Color4[];
  63417. updatable?: boolean;
  63418. sideOrientation?: number;
  63419. frontUVs?: Vector4;
  63420. backUVs?: Vector4;
  63421. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63422. /**
  63423. * Creates an extruded polygon mesh, with depth in the Y direction.
  63424. * * 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)
  63425. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63426. * @param name defines the name of the mesh
  63427. * @param options defines the options used to create the mesh
  63428. * @param scene defines the hosting scene
  63429. * @param earcutInjection can be used to inject your own earcut reference
  63430. * @returns the polygon mesh
  63431. */
  63432. static ExtrudePolygon(name: string, options: {
  63433. shape: Vector3[];
  63434. holes?: Vector3[][];
  63435. depth?: number;
  63436. faceUV?: Vector4[];
  63437. faceColors?: Color4[];
  63438. updatable?: boolean;
  63439. sideOrientation?: number;
  63440. frontUVs?: Vector4;
  63441. backUVs?: Vector4;
  63442. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63443. }
  63444. }
  63445. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63446. import { Scene } from "babylonjs/scene";
  63447. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63448. import { Mesh } from "babylonjs/Meshes/mesh";
  63449. import { Nullable } from "babylonjs/types";
  63450. /**
  63451. * Class containing static functions to help procedurally build meshes
  63452. */
  63453. export class LatheBuilder {
  63454. /**
  63455. * Creates lathe mesh.
  63456. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63457. * * 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
  63458. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63459. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63460. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63461. * * 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
  63462. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63463. * * 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
  63464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63468. * @param name defines the name of the mesh
  63469. * @param options defines the options used to create the mesh
  63470. * @param scene defines the hosting scene
  63471. * @returns the lathe mesh
  63472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63473. */
  63474. static CreateLathe(name: string, options: {
  63475. shape: Vector3[];
  63476. radius?: number;
  63477. tessellation?: number;
  63478. clip?: number;
  63479. arc?: number;
  63480. closed?: boolean;
  63481. updatable?: boolean;
  63482. sideOrientation?: number;
  63483. frontUVs?: Vector4;
  63484. backUVs?: Vector4;
  63485. cap?: number;
  63486. invertUV?: boolean;
  63487. }, scene?: Nullable<Scene>): Mesh;
  63488. }
  63489. }
  63490. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63491. import { Nullable } from "babylonjs/types";
  63492. import { Scene } from "babylonjs/scene";
  63493. import { Vector4 } from "babylonjs/Maths/math.vector";
  63494. import { Mesh } from "babylonjs/Meshes/mesh";
  63495. /**
  63496. * Class containing static functions to help procedurally build meshes
  63497. */
  63498. export class TiledPlaneBuilder {
  63499. /**
  63500. * Creates a tiled plane mesh
  63501. * * The parameter `pattern` will, depending on value, do nothing or
  63502. * * * flip (reflect about central vertical) alternate tiles across and up
  63503. * * * flip every tile on alternate rows
  63504. * * * rotate (180 degs) alternate tiles across and up
  63505. * * * rotate every tile on alternate rows
  63506. * * * flip and rotate alternate tiles across and up
  63507. * * * flip and rotate every tile on alternate rows
  63508. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63509. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63512. * * 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)
  63513. * * 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)
  63514. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63515. * @param name defines the name of the mesh
  63516. * @param options defines the options used to create the mesh
  63517. * @param scene defines the hosting scene
  63518. * @returns the box mesh
  63519. */
  63520. static CreateTiledPlane(name: string, options: {
  63521. pattern?: number;
  63522. tileSize?: number;
  63523. tileWidth?: number;
  63524. tileHeight?: number;
  63525. size?: number;
  63526. width?: number;
  63527. height?: number;
  63528. alignHorizontal?: number;
  63529. alignVertical?: number;
  63530. sideOrientation?: number;
  63531. frontUVs?: Vector4;
  63532. backUVs?: Vector4;
  63533. updatable?: boolean;
  63534. }, scene?: Nullable<Scene>): Mesh;
  63535. }
  63536. }
  63537. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63538. import { Nullable } from "babylonjs/types";
  63539. import { Scene } from "babylonjs/scene";
  63540. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63541. import { Mesh } from "babylonjs/Meshes/mesh";
  63542. /**
  63543. * Class containing static functions to help procedurally build meshes
  63544. */
  63545. export class TubeBuilder {
  63546. /**
  63547. * Creates a tube mesh.
  63548. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63549. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63550. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63551. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63552. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63553. * * 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)
  63554. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63555. * * 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
  63556. * * 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
  63557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63559. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63561. * @param name defines the name of the mesh
  63562. * @param options defines the options used to create the mesh
  63563. * @param scene defines the hosting scene
  63564. * @returns the tube mesh
  63565. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63566. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63567. */
  63568. static CreateTube(name: string, options: {
  63569. path: Vector3[];
  63570. radius?: number;
  63571. tessellation?: number;
  63572. radiusFunction?: {
  63573. (i: number, distance: number): number;
  63574. };
  63575. cap?: number;
  63576. arc?: number;
  63577. updatable?: boolean;
  63578. sideOrientation?: number;
  63579. frontUVs?: Vector4;
  63580. backUVs?: Vector4;
  63581. instance?: Mesh;
  63582. invertUV?: boolean;
  63583. }, scene?: Nullable<Scene>): Mesh;
  63584. }
  63585. }
  63586. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63587. import { Scene } from "babylonjs/scene";
  63588. import { Vector4 } from "babylonjs/Maths/math.vector";
  63589. import { Mesh } from "babylonjs/Meshes/mesh";
  63590. import { Nullable } from "babylonjs/types";
  63591. /**
  63592. * Class containing static functions to help procedurally build meshes
  63593. */
  63594. export class IcoSphereBuilder {
  63595. /**
  63596. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63597. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63598. * * 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`)
  63599. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63600. * * 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
  63601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63604. * @param name defines the name of the mesh
  63605. * @param options defines the options used to create the mesh
  63606. * @param scene defines the hosting scene
  63607. * @returns the icosahedron mesh
  63608. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63609. */
  63610. static CreateIcoSphere(name: string, options: {
  63611. radius?: number;
  63612. radiusX?: number;
  63613. radiusY?: number;
  63614. radiusZ?: number;
  63615. flat?: boolean;
  63616. subdivisions?: number;
  63617. sideOrientation?: number;
  63618. frontUVs?: Vector4;
  63619. backUVs?: Vector4;
  63620. updatable?: boolean;
  63621. }, scene?: Nullable<Scene>): Mesh;
  63622. }
  63623. }
  63624. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63625. import { Vector3 } from "babylonjs/Maths/math.vector";
  63626. import { Mesh } from "babylonjs/Meshes/mesh";
  63627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63628. /**
  63629. * Class containing static functions to help procedurally build meshes
  63630. */
  63631. export class DecalBuilder {
  63632. /**
  63633. * Creates a decal mesh.
  63634. * 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
  63635. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63636. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63637. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63638. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63639. * @param name defines the name of the mesh
  63640. * @param sourceMesh defines the mesh where the decal must be applied
  63641. * @param options defines the options used to create the mesh
  63642. * @param scene defines the hosting scene
  63643. * @returns the decal mesh
  63644. * @see https://doc.babylonjs.com/how_to/decals
  63645. */
  63646. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63647. position?: Vector3;
  63648. normal?: Vector3;
  63649. size?: Vector3;
  63650. angle?: number;
  63651. }): Mesh;
  63652. }
  63653. }
  63654. declare module "babylonjs/Meshes/meshBuilder" {
  63655. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63656. import { Nullable } from "babylonjs/types";
  63657. import { Scene } from "babylonjs/scene";
  63658. import { Mesh } from "babylonjs/Meshes/mesh";
  63659. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  63660. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  63661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63662. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63663. import { Plane } from "babylonjs/Maths/math.plane";
  63664. /**
  63665. * Class containing static functions to help procedurally build meshes
  63666. */
  63667. export class MeshBuilder {
  63668. /**
  63669. * Creates a box mesh
  63670. * * The parameter `size` sets the size (float) of each box side (default 1)
  63671. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63672. * * 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)
  63673. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63677. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63678. * @param name defines the name of the mesh
  63679. * @param options defines the options used to create the mesh
  63680. * @param scene defines the hosting scene
  63681. * @returns the box mesh
  63682. */
  63683. static CreateBox(name: string, options: {
  63684. size?: number;
  63685. width?: number;
  63686. height?: number;
  63687. depth?: number;
  63688. faceUV?: Vector4[];
  63689. faceColors?: Color4[];
  63690. sideOrientation?: number;
  63691. frontUVs?: Vector4;
  63692. backUVs?: Vector4;
  63693. updatable?: boolean;
  63694. }, scene?: Nullable<Scene>): Mesh;
  63695. /**
  63696. * Creates a tiled box mesh
  63697. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63699. * @param name defines the name of the mesh
  63700. * @param options defines the options used to create the mesh
  63701. * @param scene defines the hosting scene
  63702. * @returns the tiled box mesh
  63703. */
  63704. static CreateTiledBox(name: string, options: {
  63705. pattern?: number;
  63706. size?: number;
  63707. width?: number;
  63708. height?: number;
  63709. depth: number;
  63710. tileSize?: number;
  63711. tileWidth?: number;
  63712. tileHeight?: number;
  63713. faceUV?: Vector4[];
  63714. faceColors?: Color4[];
  63715. alignHorizontal?: number;
  63716. alignVertical?: number;
  63717. sideOrientation?: number;
  63718. updatable?: boolean;
  63719. }, scene?: Nullable<Scene>): Mesh;
  63720. /**
  63721. * Creates a sphere mesh
  63722. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63723. * * 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`)
  63724. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63725. * * 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
  63726. * * 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)
  63727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63730. * @param name defines the name of the mesh
  63731. * @param options defines the options used to create the mesh
  63732. * @param scene defines the hosting scene
  63733. * @returns the sphere mesh
  63734. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63735. */
  63736. static CreateSphere(name: string, options: {
  63737. segments?: number;
  63738. diameter?: number;
  63739. diameterX?: number;
  63740. diameterY?: number;
  63741. diameterZ?: number;
  63742. arc?: number;
  63743. slice?: number;
  63744. sideOrientation?: number;
  63745. frontUVs?: Vector4;
  63746. backUVs?: Vector4;
  63747. updatable?: boolean;
  63748. }, scene?: Nullable<Scene>): Mesh;
  63749. /**
  63750. * Creates a plane polygonal mesh. By default, this is a disc
  63751. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63752. * * 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
  63753. * * 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
  63754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63757. * @param name defines the name of the mesh
  63758. * @param options defines the options used to create the mesh
  63759. * @param scene defines the hosting scene
  63760. * @returns the plane polygonal mesh
  63761. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63762. */
  63763. static CreateDisc(name: string, options: {
  63764. radius?: number;
  63765. tessellation?: number;
  63766. arc?: number;
  63767. updatable?: boolean;
  63768. sideOrientation?: number;
  63769. frontUVs?: Vector4;
  63770. backUVs?: Vector4;
  63771. }, scene?: Nullable<Scene>): Mesh;
  63772. /**
  63773. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63774. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63775. * * 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`)
  63776. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63777. * * 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
  63778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63779. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63781. * @param name defines the name of the mesh
  63782. * @param options defines the options used to create the mesh
  63783. * @param scene defines the hosting scene
  63784. * @returns the icosahedron mesh
  63785. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63786. */
  63787. static CreateIcoSphere(name: string, options: {
  63788. radius?: number;
  63789. radiusX?: number;
  63790. radiusY?: number;
  63791. radiusZ?: number;
  63792. flat?: boolean;
  63793. subdivisions?: number;
  63794. sideOrientation?: number;
  63795. frontUVs?: Vector4;
  63796. backUVs?: Vector4;
  63797. updatable?: boolean;
  63798. }, scene?: Nullable<Scene>): Mesh;
  63799. /**
  63800. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63801. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63802. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63803. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63804. * * 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
  63805. * * 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
  63806. * * 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
  63807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63810. * * 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
  63811. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63812. * * 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
  63813. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63815. * @param name defines the name of the mesh
  63816. * @param options defines the options used to create the mesh
  63817. * @param scene defines the hosting scene
  63818. * @returns the ribbon mesh
  63819. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63820. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63821. */
  63822. static CreateRibbon(name: string, options: {
  63823. pathArray: Vector3[][];
  63824. closeArray?: boolean;
  63825. closePath?: boolean;
  63826. offset?: number;
  63827. updatable?: boolean;
  63828. sideOrientation?: number;
  63829. frontUVs?: Vector4;
  63830. backUVs?: Vector4;
  63831. instance?: Mesh;
  63832. invertUV?: boolean;
  63833. uvs?: Vector2[];
  63834. colors?: Color4[];
  63835. }, scene?: Nullable<Scene>): Mesh;
  63836. /**
  63837. * Creates a cylinder or a cone mesh
  63838. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63839. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63840. * * 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.
  63841. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63842. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63843. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63844. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63845. * * 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).
  63846. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63847. * * 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).
  63848. * * 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
  63849. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63850. * * 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
  63851. * * 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.
  63852. * * If `enclose` is false, a ring surface is one element.
  63853. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63854. * * 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
  63855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63858. * @param name defines the name of the mesh
  63859. * @param options defines the options used to create the mesh
  63860. * @param scene defines the hosting scene
  63861. * @returns the cylinder mesh
  63862. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63863. */
  63864. static CreateCylinder(name: string, options: {
  63865. height?: number;
  63866. diameterTop?: number;
  63867. diameterBottom?: number;
  63868. diameter?: number;
  63869. tessellation?: number;
  63870. subdivisions?: number;
  63871. arc?: number;
  63872. faceColors?: Color4[];
  63873. faceUV?: Vector4[];
  63874. updatable?: boolean;
  63875. hasRings?: boolean;
  63876. enclose?: boolean;
  63877. cap?: number;
  63878. sideOrientation?: number;
  63879. frontUVs?: Vector4;
  63880. backUVs?: Vector4;
  63881. }, scene?: Nullable<Scene>): Mesh;
  63882. /**
  63883. * Creates a torus mesh
  63884. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63885. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63886. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63890. * @param name defines the name of the mesh
  63891. * @param options defines the options used to create the mesh
  63892. * @param scene defines the hosting scene
  63893. * @returns the torus mesh
  63894. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63895. */
  63896. static CreateTorus(name: string, options: {
  63897. diameter?: number;
  63898. thickness?: number;
  63899. tessellation?: number;
  63900. updatable?: boolean;
  63901. sideOrientation?: number;
  63902. frontUVs?: Vector4;
  63903. backUVs?: Vector4;
  63904. }, scene?: Nullable<Scene>): Mesh;
  63905. /**
  63906. * Creates a torus knot mesh
  63907. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63908. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63909. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63910. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63914. * @param name defines the name of the mesh
  63915. * @param options defines the options used to create the mesh
  63916. * @param scene defines the hosting scene
  63917. * @returns the torus knot mesh
  63918. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63919. */
  63920. static CreateTorusKnot(name: string, options: {
  63921. radius?: number;
  63922. tube?: number;
  63923. radialSegments?: number;
  63924. tubularSegments?: number;
  63925. p?: number;
  63926. q?: number;
  63927. updatable?: boolean;
  63928. sideOrientation?: number;
  63929. frontUVs?: Vector4;
  63930. backUVs?: Vector4;
  63931. }, scene?: Nullable<Scene>): Mesh;
  63932. /**
  63933. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63934. * * 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
  63935. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63936. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63937. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63938. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63939. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63940. * * 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
  63941. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63944. * @param name defines the name of the new line system
  63945. * @param options defines the options used to create the line system
  63946. * @param scene defines the hosting scene
  63947. * @returns a new line system mesh
  63948. */
  63949. static CreateLineSystem(name: string, options: {
  63950. lines: Vector3[][];
  63951. updatable?: boolean;
  63952. instance?: Nullable<LinesMesh>;
  63953. colors?: Nullable<Color4[][]>;
  63954. useVertexAlpha?: boolean;
  63955. }, scene: Nullable<Scene>): LinesMesh;
  63956. /**
  63957. * Creates a line mesh
  63958. * 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
  63959. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63960. * * The parameter `points` is an array successive Vector3
  63961. * * 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
  63962. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63963. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63964. * * When updating an instance, remember that only point positions can change, not the number of points
  63965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63967. * @param name defines the name of the new line system
  63968. * @param options defines the options used to create the line system
  63969. * @param scene defines the hosting scene
  63970. * @returns a new line mesh
  63971. */
  63972. static CreateLines(name: string, options: {
  63973. points: Vector3[];
  63974. updatable?: boolean;
  63975. instance?: Nullable<LinesMesh>;
  63976. colors?: Color4[];
  63977. useVertexAlpha?: boolean;
  63978. }, scene?: Nullable<Scene>): LinesMesh;
  63979. /**
  63980. * Creates a dashed line mesh
  63981. * * 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
  63982. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63983. * * The parameter `points` is an array successive Vector3
  63984. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63985. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63986. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63987. * * 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
  63988. * * When updating an instance, remember that only point positions can change, not the number of points
  63989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63990. * @param name defines the name of the mesh
  63991. * @param options defines the options used to create the mesh
  63992. * @param scene defines the hosting scene
  63993. * @returns the dashed line mesh
  63994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63995. */
  63996. static CreateDashedLines(name: string, options: {
  63997. points: Vector3[];
  63998. dashSize?: number;
  63999. gapSize?: number;
  64000. dashNb?: number;
  64001. updatable?: boolean;
  64002. instance?: LinesMesh;
  64003. }, scene?: Nullable<Scene>): LinesMesh;
  64004. /**
  64005. * 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.
  64006. * * 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.
  64007. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64008. * * 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.
  64009. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64010. * * 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
  64011. * * 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
  64012. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64017. * @param name defines the name of the mesh
  64018. * @param options defines the options used to create the mesh
  64019. * @param scene defines the hosting scene
  64020. * @returns the extruded shape mesh
  64021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64023. */
  64024. static ExtrudeShape(name: string, options: {
  64025. shape: Vector3[];
  64026. path: Vector3[];
  64027. scale?: number;
  64028. rotation?: number;
  64029. cap?: number;
  64030. updatable?: boolean;
  64031. sideOrientation?: number;
  64032. frontUVs?: Vector4;
  64033. backUVs?: Vector4;
  64034. instance?: Mesh;
  64035. invertUV?: boolean;
  64036. }, scene?: Nullable<Scene>): Mesh;
  64037. /**
  64038. * Creates an custom extruded shape mesh.
  64039. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64040. * * 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.
  64041. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64042. * * 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
  64043. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64044. * * 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
  64045. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64046. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64047. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64048. * * 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
  64049. * * 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
  64050. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64053. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64055. * @param name defines the name of the mesh
  64056. * @param options defines the options used to create the mesh
  64057. * @param scene defines the hosting scene
  64058. * @returns the custom extruded shape mesh
  64059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64062. */
  64063. static ExtrudeShapeCustom(name: string, options: {
  64064. shape: Vector3[];
  64065. path: Vector3[];
  64066. scaleFunction?: any;
  64067. rotationFunction?: any;
  64068. ribbonCloseArray?: boolean;
  64069. ribbonClosePath?: boolean;
  64070. cap?: number;
  64071. updatable?: boolean;
  64072. sideOrientation?: number;
  64073. frontUVs?: Vector4;
  64074. backUVs?: Vector4;
  64075. instance?: Mesh;
  64076. invertUV?: boolean;
  64077. }, scene?: Nullable<Scene>): Mesh;
  64078. /**
  64079. * Creates lathe mesh.
  64080. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64081. * * 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
  64082. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64083. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64084. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64085. * * 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
  64086. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64087. * * 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
  64088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64092. * @param name defines the name of the mesh
  64093. * @param options defines the options used to create the mesh
  64094. * @param scene defines the hosting scene
  64095. * @returns the lathe mesh
  64096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64097. */
  64098. static CreateLathe(name: string, options: {
  64099. shape: Vector3[];
  64100. radius?: number;
  64101. tessellation?: number;
  64102. clip?: number;
  64103. arc?: number;
  64104. closed?: boolean;
  64105. updatable?: boolean;
  64106. sideOrientation?: number;
  64107. frontUVs?: Vector4;
  64108. backUVs?: Vector4;
  64109. cap?: number;
  64110. invertUV?: boolean;
  64111. }, scene?: Nullable<Scene>): Mesh;
  64112. /**
  64113. * Creates a tiled plane mesh
  64114. * * You can set a limited pattern arrangement with the tiles
  64115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64118. * @param name defines the name of the mesh
  64119. * @param options defines the options used to create the mesh
  64120. * @param scene defines the hosting scene
  64121. * @returns the plane mesh
  64122. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64123. */
  64124. static CreateTiledPlane(name: string, options: {
  64125. pattern?: number;
  64126. tileSize?: number;
  64127. tileWidth?: number;
  64128. tileHeight?: number;
  64129. size?: number;
  64130. width?: number;
  64131. height?: number;
  64132. alignHorizontal?: number;
  64133. alignVertical?: number;
  64134. sideOrientation?: number;
  64135. frontUVs?: Vector4;
  64136. backUVs?: Vector4;
  64137. updatable?: boolean;
  64138. }, scene?: Nullable<Scene>): Mesh;
  64139. /**
  64140. * Creates a plane mesh
  64141. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64142. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64143. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64147. * @param name defines the name of the mesh
  64148. * @param options defines the options used to create the mesh
  64149. * @param scene defines the hosting scene
  64150. * @returns the plane mesh
  64151. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64152. */
  64153. static CreatePlane(name: string, options: {
  64154. size?: number;
  64155. width?: number;
  64156. height?: number;
  64157. sideOrientation?: number;
  64158. frontUVs?: Vector4;
  64159. backUVs?: Vector4;
  64160. updatable?: boolean;
  64161. sourcePlane?: Plane;
  64162. }, scene?: Nullable<Scene>): Mesh;
  64163. /**
  64164. * Creates a ground mesh
  64165. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64166. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64168. * @param name defines the name of the mesh
  64169. * @param options defines the options used to create the mesh
  64170. * @param scene defines the hosting scene
  64171. * @returns the ground mesh
  64172. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64173. */
  64174. static CreateGround(name: string, options: {
  64175. width?: number;
  64176. height?: number;
  64177. subdivisions?: number;
  64178. subdivisionsX?: number;
  64179. subdivisionsY?: number;
  64180. updatable?: boolean;
  64181. }, scene?: Nullable<Scene>): Mesh;
  64182. /**
  64183. * Creates a tiled ground mesh
  64184. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64185. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64186. * * 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
  64187. * * 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
  64188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64189. * @param name defines the name of the mesh
  64190. * @param options defines the options used to create the mesh
  64191. * @param scene defines the hosting scene
  64192. * @returns the tiled ground mesh
  64193. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64194. */
  64195. static CreateTiledGround(name: string, options: {
  64196. xmin: number;
  64197. zmin: number;
  64198. xmax: number;
  64199. zmax: number;
  64200. subdivisions?: {
  64201. w: number;
  64202. h: number;
  64203. };
  64204. precision?: {
  64205. w: number;
  64206. h: number;
  64207. };
  64208. updatable?: boolean;
  64209. }, scene?: Nullable<Scene>): Mesh;
  64210. /**
  64211. * Creates a ground mesh from a height map
  64212. * * The parameter `url` sets the URL of the height map image resource.
  64213. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64214. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64215. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64216. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64217. * * 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.
  64218. * * 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).
  64219. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64221. * @param name defines the name of the mesh
  64222. * @param url defines the url to the height map
  64223. * @param options defines the options used to create the mesh
  64224. * @param scene defines the hosting scene
  64225. * @returns the ground mesh
  64226. * @see https://doc.babylonjs.com/babylon101/height_map
  64227. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64228. */
  64229. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64230. width?: number;
  64231. height?: number;
  64232. subdivisions?: number;
  64233. minHeight?: number;
  64234. maxHeight?: number;
  64235. colorFilter?: Color3;
  64236. alphaFilter?: number;
  64237. updatable?: boolean;
  64238. onReady?: (mesh: GroundMesh) => void;
  64239. }, scene?: Nullable<Scene>): GroundMesh;
  64240. /**
  64241. * Creates a polygon mesh
  64242. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64243. * * 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
  64244. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64247. * * Remember you can only change the shape positions, not their number when updating a polygon
  64248. * @param name defines the name of the mesh
  64249. * @param options defines the options used to create the mesh
  64250. * @param scene defines the hosting scene
  64251. * @param earcutInjection can be used to inject your own earcut reference
  64252. * @returns the polygon mesh
  64253. */
  64254. static CreatePolygon(name: string, options: {
  64255. shape: Vector3[];
  64256. holes?: Vector3[][];
  64257. depth?: number;
  64258. faceUV?: Vector4[];
  64259. faceColors?: Color4[];
  64260. updatable?: boolean;
  64261. sideOrientation?: number;
  64262. frontUVs?: Vector4;
  64263. backUVs?: Vector4;
  64264. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64265. /**
  64266. * Creates an extruded polygon mesh, with depth in the Y direction.
  64267. * * 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)
  64268. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64269. * @param name defines the name of the mesh
  64270. * @param options defines the options used to create the mesh
  64271. * @param scene defines the hosting scene
  64272. * @param earcutInjection can be used to inject your own earcut reference
  64273. * @returns the polygon mesh
  64274. */
  64275. static ExtrudePolygon(name: string, options: {
  64276. shape: Vector3[];
  64277. holes?: Vector3[][];
  64278. depth?: number;
  64279. faceUV?: Vector4[];
  64280. faceColors?: Color4[];
  64281. updatable?: boolean;
  64282. sideOrientation?: number;
  64283. frontUVs?: Vector4;
  64284. backUVs?: Vector4;
  64285. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64286. /**
  64287. * Creates a tube mesh.
  64288. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64289. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64290. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64291. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64292. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64293. * * 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)
  64294. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64295. * * 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
  64296. * * 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
  64297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64299. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64301. * @param name defines the name of the mesh
  64302. * @param options defines the options used to create the mesh
  64303. * @param scene defines the hosting scene
  64304. * @returns the tube mesh
  64305. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64306. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64307. */
  64308. static CreateTube(name: string, options: {
  64309. path: Vector3[];
  64310. radius?: number;
  64311. tessellation?: number;
  64312. radiusFunction?: {
  64313. (i: number, distance: number): number;
  64314. };
  64315. cap?: number;
  64316. arc?: number;
  64317. updatable?: boolean;
  64318. sideOrientation?: number;
  64319. frontUVs?: Vector4;
  64320. backUVs?: Vector4;
  64321. instance?: Mesh;
  64322. invertUV?: boolean;
  64323. }, scene?: Nullable<Scene>): Mesh;
  64324. /**
  64325. * Creates a polyhedron mesh
  64326. * * 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
  64327. * * The parameter `size` (positive float, default 1) sets the polygon size
  64328. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64329. * * 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`
  64330. * * 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
  64331. * * 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)`)
  64332. * * 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
  64333. * * 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
  64334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64337. * @param name defines the name of the mesh
  64338. * @param options defines the options used to create the mesh
  64339. * @param scene defines the hosting scene
  64340. * @returns the polyhedron mesh
  64341. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64342. */
  64343. static CreatePolyhedron(name: string, options: {
  64344. type?: number;
  64345. size?: number;
  64346. sizeX?: number;
  64347. sizeY?: number;
  64348. sizeZ?: number;
  64349. custom?: any;
  64350. faceUV?: Vector4[];
  64351. faceColors?: Color4[];
  64352. flat?: boolean;
  64353. updatable?: boolean;
  64354. sideOrientation?: number;
  64355. frontUVs?: Vector4;
  64356. backUVs?: Vector4;
  64357. }, scene?: Nullable<Scene>): Mesh;
  64358. /**
  64359. * Creates a decal mesh.
  64360. * 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
  64361. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64362. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64363. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64364. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64365. * @param name defines the name of the mesh
  64366. * @param sourceMesh defines the mesh where the decal must be applied
  64367. * @param options defines the options used to create the mesh
  64368. * @param scene defines the hosting scene
  64369. * @returns the decal mesh
  64370. * @see https://doc.babylonjs.com/how_to/decals
  64371. */
  64372. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64373. position?: Vector3;
  64374. normal?: Vector3;
  64375. size?: Vector3;
  64376. angle?: number;
  64377. }): Mesh;
  64378. }
  64379. }
  64380. declare module "babylonjs/Meshes/meshSimplification" {
  64381. import { Mesh } from "babylonjs/Meshes/mesh";
  64382. /**
  64383. * A simplifier interface for future simplification implementations
  64384. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64385. */
  64386. export interface ISimplifier {
  64387. /**
  64388. * Simplification of a given mesh according to the given settings.
  64389. * Since this requires computation, it is assumed that the function runs async.
  64390. * @param settings The settings of the simplification, including quality and distance
  64391. * @param successCallback A callback that will be called after the mesh was simplified.
  64392. * @param errorCallback in case of an error, this callback will be called. optional.
  64393. */
  64394. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64395. }
  64396. /**
  64397. * Expected simplification settings.
  64398. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64399. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64400. */
  64401. export interface ISimplificationSettings {
  64402. /**
  64403. * Gets or sets the expected quality
  64404. */
  64405. quality: number;
  64406. /**
  64407. * Gets or sets the distance when this optimized version should be used
  64408. */
  64409. distance: number;
  64410. /**
  64411. * Gets an already optimized mesh
  64412. */
  64413. optimizeMesh?: boolean;
  64414. }
  64415. /**
  64416. * Class used to specify simplification options
  64417. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64418. */
  64419. export class SimplificationSettings implements ISimplificationSettings {
  64420. /** expected quality */
  64421. quality: number;
  64422. /** distance when this optimized version should be used */
  64423. distance: number;
  64424. /** already optimized mesh */
  64425. optimizeMesh?: boolean | undefined;
  64426. /**
  64427. * Creates a SimplificationSettings
  64428. * @param quality expected quality
  64429. * @param distance distance when this optimized version should be used
  64430. * @param optimizeMesh already optimized mesh
  64431. */
  64432. constructor(
  64433. /** expected quality */
  64434. quality: number,
  64435. /** distance when this optimized version should be used */
  64436. distance: number,
  64437. /** already optimized mesh */
  64438. optimizeMesh?: boolean | undefined);
  64439. }
  64440. /**
  64441. * Interface used to define a simplification task
  64442. */
  64443. export interface ISimplificationTask {
  64444. /**
  64445. * Array of settings
  64446. */
  64447. settings: Array<ISimplificationSettings>;
  64448. /**
  64449. * Simplification type
  64450. */
  64451. simplificationType: SimplificationType;
  64452. /**
  64453. * Mesh to simplify
  64454. */
  64455. mesh: Mesh;
  64456. /**
  64457. * Callback called on success
  64458. */
  64459. successCallback?: () => void;
  64460. /**
  64461. * Defines if parallel processing can be used
  64462. */
  64463. parallelProcessing: boolean;
  64464. }
  64465. /**
  64466. * Queue used to order the simplification tasks
  64467. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64468. */
  64469. export class SimplificationQueue {
  64470. private _simplificationArray;
  64471. /**
  64472. * Gets a boolean indicating that the process is still running
  64473. */
  64474. running: boolean;
  64475. /**
  64476. * Creates a new queue
  64477. */
  64478. constructor();
  64479. /**
  64480. * Adds a new simplification task
  64481. * @param task defines a task to add
  64482. */
  64483. addTask(task: ISimplificationTask): void;
  64484. /**
  64485. * Execute next task
  64486. */
  64487. executeNext(): void;
  64488. /**
  64489. * Execute a simplification task
  64490. * @param task defines the task to run
  64491. */
  64492. runSimplification(task: ISimplificationTask): void;
  64493. private getSimplifier;
  64494. }
  64495. /**
  64496. * The implemented types of simplification
  64497. * At the moment only Quadratic Error Decimation is implemented
  64498. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64499. */
  64500. export enum SimplificationType {
  64501. /** Quadratic error decimation */
  64502. QUADRATIC = 0
  64503. }
  64504. }
  64505. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64506. import { Scene } from "babylonjs/scene";
  64507. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64508. import { ISceneComponent } from "babylonjs/sceneComponent";
  64509. module "babylonjs/scene" {
  64510. interface Scene {
  64511. /** @hidden (Backing field) */
  64512. _simplificationQueue: SimplificationQueue;
  64513. /**
  64514. * Gets or sets the simplification queue attached to the scene
  64515. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64516. */
  64517. simplificationQueue: SimplificationQueue;
  64518. }
  64519. }
  64520. module "babylonjs/Meshes/mesh" {
  64521. interface Mesh {
  64522. /**
  64523. * Simplify the mesh according to the given array of settings.
  64524. * Function will return immediately and will simplify async
  64525. * @param settings a collection of simplification settings
  64526. * @param parallelProcessing should all levels calculate parallel or one after the other
  64527. * @param simplificationType the type of simplification to run
  64528. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64529. * @returns the current mesh
  64530. */
  64531. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64532. }
  64533. }
  64534. /**
  64535. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64536. * created in a scene
  64537. */
  64538. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64539. /**
  64540. * The component name helpfull to identify the component in the list of scene components.
  64541. */
  64542. readonly name: string;
  64543. /**
  64544. * The scene the component belongs to.
  64545. */
  64546. scene: Scene;
  64547. /**
  64548. * Creates a new instance of the component for the given scene
  64549. * @param scene Defines the scene to register the component in
  64550. */
  64551. constructor(scene: Scene);
  64552. /**
  64553. * Registers the component in a given scene
  64554. */
  64555. register(): void;
  64556. /**
  64557. * Rebuilds the elements related to this component in case of
  64558. * context lost for instance.
  64559. */
  64560. rebuild(): void;
  64561. /**
  64562. * Disposes the component and the associated ressources
  64563. */
  64564. dispose(): void;
  64565. private _beforeCameraUpdate;
  64566. }
  64567. }
  64568. declare module "babylonjs/Meshes/Builders/index" {
  64569. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64570. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64571. export * from "babylonjs/Meshes/Builders/discBuilder";
  64572. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64573. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64574. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64575. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64576. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64577. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64578. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64579. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64580. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64581. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64582. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64583. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64584. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64585. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64586. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64587. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64588. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64589. }
  64590. declare module "babylonjs/Meshes/index" {
  64591. export * from "babylonjs/Meshes/abstractMesh";
  64592. export * from "babylonjs/Meshes/buffer";
  64593. export * from "babylonjs/Meshes/Compression/index";
  64594. export * from "babylonjs/Meshes/csg";
  64595. export * from "babylonjs/Meshes/geometry";
  64596. export * from "babylonjs/Meshes/groundMesh";
  64597. export * from "babylonjs/Meshes/trailMesh";
  64598. export * from "babylonjs/Meshes/instancedMesh";
  64599. export * from "babylonjs/Meshes/linesMesh";
  64600. export * from "babylonjs/Meshes/mesh";
  64601. export * from "babylonjs/Meshes/mesh.vertexData";
  64602. export * from "babylonjs/Meshes/meshBuilder";
  64603. export * from "babylonjs/Meshes/meshSimplification";
  64604. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64605. export * from "babylonjs/Meshes/polygonMesh";
  64606. export * from "babylonjs/Meshes/subMesh";
  64607. export * from "babylonjs/Meshes/meshLODLevel";
  64608. export * from "babylonjs/Meshes/transformNode";
  64609. export * from "babylonjs/Meshes/Builders/index";
  64610. export * from "babylonjs/Meshes/dataBuffer";
  64611. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64612. }
  64613. declare module "babylonjs/Morph/index" {
  64614. export * from "babylonjs/Morph/morphTarget";
  64615. export * from "babylonjs/Morph/morphTargetManager";
  64616. }
  64617. declare module "babylonjs/Navigation/INavigationEngine" {
  64618. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64619. import { Vector3 } from "babylonjs/Maths/math";
  64620. import { Mesh } from "babylonjs/Meshes/mesh";
  64621. import { Scene } from "babylonjs/scene";
  64622. /**
  64623. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64624. */
  64625. export interface INavigationEnginePlugin {
  64626. /**
  64627. * plugin name
  64628. */
  64629. name: string;
  64630. /**
  64631. * Creates a navigation mesh
  64632. * @param meshes array of all the geometry used to compute the navigatio mesh
  64633. * @param parameters bunch of parameters used to filter geometry
  64634. */
  64635. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64636. /**
  64637. * Create a navigation mesh debug mesh
  64638. * @param scene is where the mesh will be added
  64639. * @returns debug display mesh
  64640. */
  64641. createDebugNavMesh(scene: Scene): Mesh;
  64642. /**
  64643. * Get a navigation mesh constrained position, closest to the parameter position
  64644. * @param position world position
  64645. * @returns the closest point to position constrained by the navigation mesh
  64646. */
  64647. getClosestPoint(position: Vector3): Vector3;
  64648. /**
  64649. * Get a navigation mesh constrained position, within a particular radius
  64650. * @param position world position
  64651. * @param maxRadius the maximum distance to the constrained world position
  64652. * @returns the closest point to position constrained by the navigation mesh
  64653. */
  64654. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64655. /**
  64656. * Compute the final position from a segment made of destination-position
  64657. * @param position world position
  64658. * @param destination world position
  64659. * @returns the resulting point along the navmesh
  64660. */
  64661. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64662. /**
  64663. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64664. * @param start world position
  64665. * @param end world position
  64666. * @returns array containing world position composing the path
  64667. */
  64668. computePath(start: Vector3, end: Vector3): Vector3[];
  64669. /**
  64670. * If this plugin is supported
  64671. * @returns true if plugin is supported
  64672. */
  64673. isSupported(): boolean;
  64674. /**
  64675. * Create a new Crowd so you can add agents
  64676. * @param maxAgents the maximum agent count in the crowd
  64677. * @param maxAgentRadius the maximum radius an agent can have
  64678. * @param scene to attach the crowd to
  64679. * @returns the crowd you can add agents to
  64680. */
  64681. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64682. /**
  64683. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64684. * The queries will try to find a solution within those bounds
  64685. * default is (1,1,1)
  64686. * @param extent x,y,z value that define the extent around the queries point of reference
  64687. */
  64688. setDefaultQueryExtent(extent: Vector3): void;
  64689. /**
  64690. * Get the Bounding box extent specified by setDefaultQueryExtent
  64691. * @returns the box extent values
  64692. */
  64693. getDefaultQueryExtent(): Vector3;
  64694. /**
  64695. * Release all resources
  64696. */
  64697. dispose(): void;
  64698. }
  64699. /**
  64700. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64701. */
  64702. export interface ICrowd {
  64703. /**
  64704. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64705. * You can attach anything to that node. The node position is updated in the scene update tick.
  64706. * @param pos world position that will be constrained by the navigation mesh
  64707. * @param parameters agent parameters
  64708. * @param transform hooked to the agent that will be update by the scene
  64709. * @returns agent index
  64710. */
  64711. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64712. /**
  64713. * Returns the agent position in world space
  64714. * @param index agent index returned by addAgent
  64715. * @returns world space position
  64716. */
  64717. getAgentPosition(index: number): Vector3;
  64718. /**
  64719. * Gets the agent velocity in world space
  64720. * @param index agent index returned by addAgent
  64721. * @returns world space velocity
  64722. */
  64723. getAgentVelocity(index: number): Vector3;
  64724. /**
  64725. * remove a particular agent previously created
  64726. * @param index agent index returned by addAgent
  64727. */
  64728. removeAgent(index: number): void;
  64729. /**
  64730. * get the list of all agents attached to this crowd
  64731. * @returns list of agent indices
  64732. */
  64733. getAgents(): number[];
  64734. /**
  64735. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64736. * @param deltaTime in seconds
  64737. */
  64738. update(deltaTime: number): void;
  64739. /**
  64740. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64741. * @param index agent index returned by addAgent
  64742. * @param destination targeted world position
  64743. */
  64744. agentGoto(index: number, destination: Vector3): void;
  64745. /**
  64746. * Teleport the agent to a new position
  64747. * @param index agent index returned by addAgent
  64748. * @param destination targeted world position
  64749. */
  64750. agentTeleport(index: number, destination: Vector3): void;
  64751. /**
  64752. * Update agent parameters
  64753. * @param index agent index returned by addAgent
  64754. * @param parameters agent parameters
  64755. */
  64756. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64757. /**
  64758. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64759. * The queries will try to find a solution within those bounds
  64760. * default is (1,1,1)
  64761. * @param extent x,y,z value that define the extent around the queries point of reference
  64762. */
  64763. setDefaultQueryExtent(extent: Vector3): void;
  64764. /**
  64765. * Get the Bounding box extent specified by setDefaultQueryExtent
  64766. * @returns the box extent values
  64767. */
  64768. getDefaultQueryExtent(): Vector3;
  64769. /**
  64770. * Release all resources
  64771. */
  64772. dispose(): void;
  64773. }
  64774. /**
  64775. * Configures an agent
  64776. */
  64777. export interface IAgentParameters {
  64778. /**
  64779. * Agent radius. [Limit: >= 0]
  64780. */
  64781. radius: number;
  64782. /**
  64783. * Agent height. [Limit: > 0]
  64784. */
  64785. height: number;
  64786. /**
  64787. * Maximum allowed acceleration. [Limit: >= 0]
  64788. */
  64789. maxAcceleration: number;
  64790. /**
  64791. * Maximum allowed speed. [Limit: >= 0]
  64792. */
  64793. maxSpeed: number;
  64794. /**
  64795. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64796. */
  64797. collisionQueryRange: number;
  64798. /**
  64799. * The path visibility optimization range. [Limit: > 0]
  64800. */
  64801. pathOptimizationRange: number;
  64802. /**
  64803. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64804. */
  64805. separationWeight: number;
  64806. }
  64807. /**
  64808. * Configures the navigation mesh creation
  64809. */
  64810. export interface INavMeshParameters {
  64811. /**
  64812. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64813. */
  64814. cs: number;
  64815. /**
  64816. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64817. */
  64818. ch: number;
  64819. /**
  64820. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64821. */
  64822. walkableSlopeAngle: number;
  64823. /**
  64824. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64825. * be considered walkable. [Limit: >= 3] [Units: vx]
  64826. */
  64827. walkableHeight: number;
  64828. /**
  64829. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64830. */
  64831. walkableClimb: number;
  64832. /**
  64833. * The distance to erode/shrink the walkable area of the heightfield away from
  64834. * obstructions. [Limit: >=0] [Units: vx]
  64835. */
  64836. walkableRadius: number;
  64837. /**
  64838. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64839. */
  64840. maxEdgeLen: number;
  64841. /**
  64842. * The maximum distance a simplfied contour's border edges should deviate
  64843. * the original raw contour. [Limit: >=0] [Units: vx]
  64844. */
  64845. maxSimplificationError: number;
  64846. /**
  64847. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64848. */
  64849. minRegionArea: number;
  64850. /**
  64851. * Any regions with a span count smaller than this value will, if possible,
  64852. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64853. */
  64854. mergeRegionArea: number;
  64855. /**
  64856. * The maximum number of vertices allowed for polygons generated during the
  64857. * contour to polygon conversion process. [Limit: >= 3]
  64858. */
  64859. maxVertsPerPoly: number;
  64860. /**
  64861. * Sets the sampling distance to use when generating the detail mesh.
  64862. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64863. */
  64864. detailSampleDist: number;
  64865. /**
  64866. * The maximum distance the detail mesh surface should deviate from heightfield
  64867. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64868. */
  64869. detailSampleMaxError: number;
  64870. }
  64871. }
  64872. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  64873. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  64874. import { Mesh } from "babylonjs/Meshes/mesh";
  64875. import { Scene } from "babylonjs/scene";
  64876. import { Vector3 } from "babylonjs/Maths/math";
  64877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64878. /**
  64879. * RecastJS navigation plugin
  64880. */
  64881. export class RecastJSPlugin implements INavigationEnginePlugin {
  64882. /**
  64883. * Reference to the Recast library
  64884. */
  64885. bjsRECAST: any;
  64886. /**
  64887. * plugin name
  64888. */
  64889. name: string;
  64890. /**
  64891. * the first navmesh created. We might extend this to support multiple navmeshes
  64892. */
  64893. navMesh: any;
  64894. /**
  64895. * Initializes the recastJS plugin
  64896. * @param recastInjection can be used to inject your own recast reference
  64897. */
  64898. constructor(recastInjection?: any);
  64899. /**
  64900. * Creates a navigation mesh
  64901. * @param meshes array of all the geometry used to compute the navigatio mesh
  64902. * @param parameters bunch of parameters used to filter geometry
  64903. */
  64904. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64905. /**
  64906. * Create a navigation mesh debug mesh
  64907. * @param scene is where the mesh will be added
  64908. * @returns debug display mesh
  64909. */
  64910. createDebugNavMesh(scene: Scene): Mesh;
  64911. /**
  64912. * Get a navigation mesh constrained position, closest to the parameter position
  64913. * @param position world position
  64914. * @returns the closest point to position constrained by the navigation mesh
  64915. */
  64916. getClosestPoint(position: Vector3): Vector3;
  64917. /**
  64918. * Get a navigation mesh constrained position, within a particular radius
  64919. * @param position world position
  64920. * @param maxRadius the maximum distance to the constrained world position
  64921. * @returns the closest point to position constrained by the navigation mesh
  64922. */
  64923. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64924. /**
  64925. * Compute the final position from a segment made of destination-position
  64926. * @param position world position
  64927. * @param destination world position
  64928. * @returns the resulting point along the navmesh
  64929. */
  64930. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64931. /**
  64932. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64933. * @param start world position
  64934. * @param end world position
  64935. * @returns array containing world position composing the path
  64936. */
  64937. computePath(start: Vector3, end: Vector3): Vector3[];
  64938. /**
  64939. * Create a new Crowd so you can add agents
  64940. * @param maxAgents the maximum agent count in the crowd
  64941. * @param maxAgentRadius the maximum radius an agent can have
  64942. * @param scene to attach the crowd to
  64943. * @returns the crowd you can add agents to
  64944. */
  64945. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64946. /**
  64947. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64948. * The queries will try to find a solution within those bounds
  64949. * default is (1,1,1)
  64950. * @param extent x,y,z value that define the extent around the queries point of reference
  64951. */
  64952. setDefaultQueryExtent(extent: Vector3): void;
  64953. /**
  64954. * Get the Bounding box extent specified by setDefaultQueryExtent
  64955. * @returns the box extent values
  64956. */
  64957. getDefaultQueryExtent(): Vector3;
  64958. /**
  64959. * Disposes
  64960. */
  64961. dispose(): void;
  64962. /**
  64963. * If this plugin is supported
  64964. * @returns true if plugin is supported
  64965. */
  64966. isSupported(): boolean;
  64967. }
  64968. /**
  64969. * Recast detour crowd implementation
  64970. */
  64971. export class RecastJSCrowd implements ICrowd {
  64972. /**
  64973. * Recast/detour plugin
  64974. */
  64975. bjsRECASTPlugin: RecastJSPlugin;
  64976. /**
  64977. * Link to the detour crowd
  64978. */
  64979. recastCrowd: any;
  64980. /**
  64981. * One transform per agent
  64982. */
  64983. transforms: TransformNode[];
  64984. /**
  64985. * All agents created
  64986. */
  64987. agents: number[];
  64988. /**
  64989. * Link to the scene is kept to unregister the crowd from the scene
  64990. */
  64991. private _scene;
  64992. /**
  64993. * Observer for crowd updates
  64994. */
  64995. private _onBeforeAnimationsObserver;
  64996. /**
  64997. * Constructor
  64998. * @param plugin recastJS plugin
  64999. * @param maxAgents the maximum agent count in the crowd
  65000. * @param maxAgentRadius the maximum radius an agent can have
  65001. * @param scene to attach the crowd to
  65002. * @returns the crowd you can add agents to
  65003. */
  65004. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65005. /**
  65006. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65007. * You can attach anything to that node. The node position is updated in the scene update tick.
  65008. * @param pos world position that will be constrained by the navigation mesh
  65009. * @param parameters agent parameters
  65010. * @param transform hooked to the agent that will be update by the scene
  65011. * @returns agent index
  65012. */
  65013. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65014. /**
  65015. * Returns the agent position in world space
  65016. * @param index agent index returned by addAgent
  65017. * @returns world space position
  65018. */
  65019. getAgentPosition(index: number): Vector3;
  65020. /**
  65021. * Returns the agent velocity in world space
  65022. * @param index agent index returned by addAgent
  65023. * @returns world space velocity
  65024. */
  65025. getAgentVelocity(index: number): Vector3;
  65026. /**
  65027. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65028. * @param index agent index returned by addAgent
  65029. * @param destination targeted world position
  65030. */
  65031. agentGoto(index: number, destination: Vector3): void;
  65032. /**
  65033. * Teleport the agent to a new position
  65034. * @param index agent index returned by addAgent
  65035. * @param destination targeted world position
  65036. */
  65037. agentTeleport(index: number, destination: Vector3): void;
  65038. /**
  65039. * Update agent parameters
  65040. * @param index agent index returned by addAgent
  65041. * @param parameters agent parameters
  65042. */
  65043. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65044. /**
  65045. * remove a particular agent previously created
  65046. * @param index agent index returned by addAgent
  65047. */
  65048. removeAgent(index: number): void;
  65049. /**
  65050. * get the list of all agents attached to this crowd
  65051. * @returns list of agent indices
  65052. */
  65053. getAgents(): number[];
  65054. /**
  65055. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65056. * @param deltaTime in seconds
  65057. */
  65058. update(deltaTime: number): void;
  65059. /**
  65060. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65061. * The queries will try to find a solution within those bounds
  65062. * default is (1,1,1)
  65063. * @param extent x,y,z value that define the extent around the queries point of reference
  65064. */
  65065. setDefaultQueryExtent(extent: Vector3): void;
  65066. /**
  65067. * Get the Bounding box extent specified by setDefaultQueryExtent
  65068. * @returns the box extent values
  65069. */
  65070. getDefaultQueryExtent(): Vector3;
  65071. /**
  65072. * Release all resources
  65073. */
  65074. dispose(): void;
  65075. }
  65076. }
  65077. declare module "babylonjs/Navigation/Plugins/index" {
  65078. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65079. }
  65080. declare module "babylonjs/Navigation/index" {
  65081. export * from "babylonjs/Navigation/INavigationEngine";
  65082. export * from "babylonjs/Navigation/Plugins/index";
  65083. }
  65084. declare module "babylonjs/Offline/database" {
  65085. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65086. /**
  65087. * Class used to enable access to IndexedDB
  65088. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65089. */
  65090. export class Database implements IOfflineProvider {
  65091. private _callbackManifestChecked;
  65092. private _currentSceneUrl;
  65093. private _db;
  65094. private _enableSceneOffline;
  65095. private _enableTexturesOffline;
  65096. private _manifestVersionFound;
  65097. private _mustUpdateRessources;
  65098. private _hasReachedQuota;
  65099. private _isSupported;
  65100. private _idbFactory;
  65101. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65102. private static IsUASupportingBlobStorage;
  65103. /**
  65104. * Gets a boolean indicating if Database storate is enabled (off by default)
  65105. */
  65106. static IDBStorageEnabled: boolean;
  65107. /**
  65108. * Gets a boolean indicating if scene must be saved in the database
  65109. */
  65110. get enableSceneOffline(): boolean;
  65111. /**
  65112. * Gets a boolean indicating if textures must be saved in the database
  65113. */
  65114. get enableTexturesOffline(): boolean;
  65115. /**
  65116. * Creates a new Database
  65117. * @param urlToScene defines the url to load the scene
  65118. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65119. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65120. */
  65121. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65122. private static _ParseURL;
  65123. private static _ReturnFullUrlLocation;
  65124. private _checkManifestFile;
  65125. /**
  65126. * Open the database and make it available
  65127. * @param successCallback defines the callback to call on success
  65128. * @param errorCallback defines the callback to call on error
  65129. */
  65130. open(successCallback: () => void, errorCallback: () => void): void;
  65131. /**
  65132. * Loads an image from the database
  65133. * @param url defines the url to load from
  65134. * @param image defines the target DOM image
  65135. */
  65136. loadImage(url: string, image: HTMLImageElement): void;
  65137. private _loadImageFromDBAsync;
  65138. private _saveImageIntoDBAsync;
  65139. private _checkVersionFromDB;
  65140. private _loadVersionFromDBAsync;
  65141. private _saveVersionIntoDBAsync;
  65142. /**
  65143. * Loads a file from database
  65144. * @param url defines the URL to load from
  65145. * @param sceneLoaded defines a callback to call on success
  65146. * @param progressCallBack defines a callback to call when progress changed
  65147. * @param errorCallback defines a callback to call on error
  65148. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65149. */
  65150. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65151. private _loadFileAsync;
  65152. private _saveFileAsync;
  65153. /**
  65154. * Validates if xhr data is correct
  65155. * @param xhr defines the request to validate
  65156. * @param dataType defines the expected data type
  65157. * @returns true if data is correct
  65158. */
  65159. private static _ValidateXHRData;
  65160. }
  65161. }
  65162. declare module "babylonjs/Offline/index" {
  65163. export * from "babylonjs/Offline/database";
  65164. export * from "babylonjs/Offline/IOfflineProvider";
  65165. }
  65166. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65167. /** @hidden */
  65168. export var gpuUpdateParticlesPixelShader: {
  65169. name: string;
  65170. shader: string;
  65171. };
  65172. }
  65173. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65174. /** @hidden */
  65175. export var gpuUpdateParticlesVertexShader: {
  65176. name: string;
  65177. shader: string;
  65178. };
  65179. }
  65180. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65181. /** @hidden */
  65182. export var clipPlaneFragmentDeclaration2: {
  65183. name: string;
  65184. shader: string;
  65185. };
  65186. }
  65187. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65188. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65189. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65191. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65192. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65193. /** @hidden */
  65194. export var gpuRenderParticlesPixelShader: {
  65195. name: string;
  65196. shader: string;
  65197. };
  65198. }
  65199. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65200. /** @hidden */
  65201. export var clipPlaneVertexDeclaration2: {
  65202. name: string;
  65203. shader: string;
  65204. };
  65205. }
  65206. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65207. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65208. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65209. /** @hidden */
  65210. export var gpuRenderParticlesVertexShader: {
  65211. name: string;
  65212. shader: string;
  65213. };
  65214. }
  65215. declare module "babylonjs/Particles/gpuParticleSystem" {
  65216. import { Nullable } from "babylonjs/types";
  65217. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65218. import { Observable } from "babylonjs/Misc/observable";
  65219. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65220. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65221. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65222. import { Scene, IDisposable } from "babylonjs/scene";
  65223. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65224. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65225. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65226. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65227. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65228. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65229. /**
  65230. * This represents a GPU particle system in Babylon
  65231. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65232. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65233. */
  65234. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65235. /**
  65236. * The layer mask we are rendering the particles through.
  65237. */
  65238. layerMask: number;
  65239. private _capacity;
  65240. private _activeCount;
  65241. private _currentActiveCount;
  65242. private _accumulatedCount;
  65243. private _renderEffect;
  65244. private _updateEffect;
  65245. private _buffer0;
  65246. private _buffer1;
  65247. private _spriteBuffer;
  65248. private _updateVAO;
  65249. private _renderVAO;
  65250. private _targetIndex;
  65251. private _sourceBuffer;
  65252. private _targetBuffer;
  65253. private _engine;
  65254. private _currentRenderId;
  65255. private _started;
  65256. private _stopped;
  65257. private _timeDelta;
  65258. private _randomTexture;
  65259. private _randomTexture2;
  65260. private _attributesStrideSize;
  65261. private _updateEffectOptions;
  65262. private _randomTextureSize;
  65263. private _actualFrame;
  65264. private readonly _rawTextureWidth;
  65265. /**
  65266. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65267. */
  65268. static get IsSupported(): boolean;
  65269. /**
  65270. * An event triggered when the system is disposed.
  65271. */
  65272. onDisposeObservable: Observable<GPUParticleSystem>;
  65273. /**
  65274. * Gets the maximum number of particles active at the same time.
  65275. * @returns The max number of active particles.
  65276. */
  65277. getCapacity(): number;
  65278. /**
  65279. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65280. * to override the particles.
  65281. */
  65282. forceDepthWrite: boolean;
  65283. /**
  65284. * Gets or set the number of active particles
  65285. */
  65286. get activeParticleCount(): number;
  65287. set activeParticleCount(value: number);
  65288. private _preWarmDone;
  65289. /**
  65290. * Is this system ready to be used/rendered
  65291. * @return true if the system is ready
  65292. */
  65293. isReady(): boolean;
  65294. /**
  65295. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65296. * @returns True if it has been started, otherwise false.
  65297. */
  65298. isStarted(): boolean;
  65299. /**
  65300. * Starts the particle system and begins to emit
  65301. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65302. */
  65303. start(delay?: number): void;
  65304. /**
  65305. * Stops the particle system.
  65306. */
  65307. stop(): void;
  65308. /**
  65309. * Remove all active particles
  65310. */
  65311. reset(): void;
  65312. /**
  65313. * Returns the string "GPUParticleSystem"
  65314. * @returns a string containing the class name
  65315. */
  65316. getClassName(): string;
  65317. private _colorGradientsTexture;
  65318. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65319. /**
  65320. * Adds a new color gradient
  65321. * @param gradient defines the gradient to use (between 0 and 1)
  65322. * @param color1 defines the color to affect to the specified gradient
  65323. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65324. * @returns the current particle system
  65325. */
  65326. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65327. /**
  65328. * Remove a specific color gradient
  65329. * @param gradient defines the gradient to remove
  65330. * @returns the current particle system
  65331. */
  65332. removeColorGradient(gradient: number): GPUParticleSystem;
  65333. private _angularSpeedGradientsTexture;
  65334. private _sizeGradientsTexture;
  65335. private _velocityGradientsTexture;
  65336. private _limitVelocityGradientsTexture;
  65337. private _dragGradientsTexture;
  65338. private _addFactorGradient;
  65339. /**
  65340. * Adds a new size gradient
  65341. * @param gradient defines the gradient to use (between 0 and 1)
  65342. * @param factor defines the size factor to affect to the specified gradient
  65343. * @returns the current particle system
  65344. */
  65345. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65346. /**
  65347. * Remove a specific size gradient
  65348. * @param gradient defines the gradient to remove
  65349. * @returns the current particle system
  65350. */
  65351. removeSizeGradient(gradient: number): GPUParticleSystem;
  65352. /**
  65353. * Adds a new angular speed gradient
  65354. * @param gradient defines the gradient to use (between 0 and 1)
  65355. * @param factor defines the angular speed to affect to the specified gradient
  65356. * @returns the current particle system
  65357. */
  65358. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65359. /**
  65360. * Remove a specific angular speed gradient
  65361. * @param gradient defines the gradient to remove
  65362. * @returns the current particle system
  65363. */
  65364. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65365. /**
  65366. * Adds a new velocity gradient
  65367. * @param gradient defines the gradient to use (between 0 and 1)
  65368. * @param factor defines the velocity to affect to the specified gradient
  65369. * @returns the current particle system
  65370. */
  65371. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65372. /**
  65373. * Remove a specific velocity gradient
  65374. * @param gradient defines the gradient to remove
  65375. * @returns the current particle system
  65376. */
  65377. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65378. /**
  65379. * Adds a new limit velocity gradient
  65380. * @param gradient defines the gradient to use (between 0 and 1)
  65381. * @param factor defines the limit velocity value to affect to the specified gradient
  65382. * @returns the current particle system
  65383. */
  65384. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65385. /**
  65386. * Remove a specific limit velocity gradient
  65387. * @param gradient defines the gradient to remove
  65388. * @returns the current particle system
  65389. */
  65390. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65391. /**
  65392. * Adds a new drag gradient
  65393. * @param gradient defines the gradient to use (between 0 and 1)
  65394. * @param factor defines the drag value to affect to the specified gradient
  65395. * @returns the current particle system
  65396. */
  65397. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65398. /**
  65399. * Remove a specific drag gradient
  65400. * @param gradient defines the gradient to remove
  65401. * @returns the current particle system
  65402. */
  65403. removeDragGradient(gradient: number): GPUParticleSystem;
  65404. /**
  65405. * Not supported by GPUParticleSystem
  65406. * @param gradient defines the gradient to use (between 0 and 1)
  65407. * @param factor defines the emit rate value to affect to the specified gradient
  65408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65409. * @returns the current particle system
  65410. */
  65411. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65412. /**
  65413. * Not supported by GPUParticleSystem
  65414. * @param gradient defines the gradient to remove
  65415. * @returns the current particle system
  65416. */
  65417. removeEmitRateGradient(gradient: number): IParticleSystem;
  65418. /**
  65419. * Not supported by GPUParticleSystem
  65420. * @param gradient defines the gradient to use (between 0 and 1)
  65421. * @param factor defines the start size value to affect to the specified gradient
  65422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65423. * @returns the current particle system
  65424. */
  65425. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65426. /**
  65427. * Not supported by GPUParticleSystem
  65428. * @param gradient defines the gradient to remove
  65429. * @returns the current particle system
  65430. */
  65431. removeStartSizeGradient(gradient: number): IParticleSystem;
  65432. /**
  65433. * Not supported by GPUParticleSystem
  65434. * @param gradient defines the gradient to use (between 0 and 1)
  65435. * @param min defines the color remap minimal range
  65436. * @param max defines the color remap maximal range
  65437. * @returns the current particle system
  65438. */
  65439. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65440. /**
  65441. * Not supported by GPUParticleSystem
  65442. * @param gradient defines the gradient to remove
  65443. * @returns the current particle system
  65444. */
  65445. removeColorRemapGradient(): IParticleSystem;
  65446. /**
  65447. * Not supported by GPUParticleSystem
  65448. * @param gradient defines the gradient to use (between 0 and 1)
  65449. * @param min defines the alpha remap minimal range
  65450. * @param max defines the alpha remap maximal range
  65451. * @returns the current particle system
  65452. */
  65453. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65454. /**
  65455. * Not supported by GPUParticleSystem
  65456. * @param gradient defines the gradient to remove
  65457. * @returns the current particle system
  65458. */
  65459. removeAlphaRemapGradient(): IParticleSystem;
  65460. /**
  65461. * Not supported by GPUParticleSystem
  65462. * @param gradient defines the gradient to use (between 0 and 1)
  65463. * @param color defines the color to affect to the specified gradient
  65464. * @returns the current particle system
  65465. */
  65466. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65467. /**
  65468. * Not supported by GPUParticleSystem
  65469. * @param gradient defines the gradient to remove
  65470. * @returns the current particle system
  65471. */
  65472. removeRampGradient(): IParticleSystem;
  65473. /**
  65474. * Not supported by GPUParticleSystem
  65475. * @returns the list of ramp gradients
  65476. */
  65477. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65478. /**
  65479. * Not supported by GPUParticleSystem
  65480. * Gets or sets a boolean indicating that ramp gradients must be used
  65481. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65482. */
  65483. get useRampGradients(): boolean;
  65484. set useRampGradients(value: boolean);
  65485. /**
  65486. * Not supported by GPUParticleSystem
  65487. * @param gradient defines the gradient to use (between 0 and 1)
  65488. * @param factor defines the life time factor to affect to the specified gradient
  65489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65490. * @returns the current particle system
  65491. */
  65492. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65493. /**
  65494. * Not supported by GPUParticleSystem
  65495. * @param gradient defines the gradient to remove
  65496. * @returns the current particle system
  65497. */
  65498. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65499. /**
  65500. * Instantiates a GPU particle system.
  65501. * 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.
  65502. * @param name The name of the particle system
  65503. * @param options The options used to create the system
  65504. * @param scene The scene the particle system belongs to
  65505. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65506. */
  65507. constructor(name: string, options: Partial<{
  65508. capacity: number;
  65509. randomTextureSize: number;
  65510. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65511. protected _reset(): void;
  65512. private _createUpdateVAO;
  65513. private _createRenderVAO;
  65514. private _initialize;
  65515. /** @hidden */
  65516. _recreateUpdateEffect(): void;
  65517. /** @hidden */
  65518. _recreateRenderEffect(): void;
  65519. /**
  65520. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65521. * @param preWarm defines if we are in the pre-warmimg phase
  65522. */
  65523. animate(preWarm?: boolean): void;
  65524. private _createFactorGradientTexture;
  65525. private _createSizeGradientTexture;
  65526. private _createAngularSpeedGradientTexture;
  65527. private _createVelocityGradientTexture;
  65528. private _createLimitVelocityGradientTexture;
  65529. private _createDragGradientTexture;
  65530. private _createColorGradientTexture;
  65531. /**
  65532. * Renders the particle system in its current state
  65533. * @param preWarm defines if the system should only update the particles but not render them
  65534. * @returns the current number of particles
  65535. */
  65536. render(preWarm?: boolean): number;
  65537. /**
  65538. * Rebuilds the particle system
  65539. */
  65540. rebuild(): void;
  65541. private _releaseBuffers;
  65542. private _releaseVAOs;
  65543. /**
  65544. * Disposes the particle system and free the associated resources
  65545. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65546. */
  65547. dispose(disposeTexture?: boolean): void;
  65548. /**
  65549. * Clones the particle system.
  65550. * @param name The name of the cloned object
  65551. * @param newEmitter The new emitter to use
  65552. * @returns the cloned particle system
  65553. */
  65554. clone(name: string, newEmitter: any): GPUParticleSystem;
  65555. /**
  65556. * Serializes the particle system to a JSON object.
  65557. * @returns the JSON object
  65558. */
  65559. serialize(): any;
  65560. /**
  65561. * Parses a JSON object to create a GPU particle system.
  65562. * @param parsedParticleSystem The JSON object to parse
  65563. * @param scene The scene to create the particle system in
  65564. * @param rootUrl The root url to use to load external dependencies like texture
  65565. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65566. * @returns the parsed GPU particle system
  65567. */
  65568. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65569. }
  65570. }
  65571. declare module "babylonjs/Particles/particleSystemSet" {
  65572. import { Nullable } from "babylonjs/types";
  65573. import { Color3 } from "babylonjs/Maths/math.color";
  65574. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65576. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65577. import { Scene, IDisposable } from "babylonjs/scene";
  65578. /**
  65579. * Represents a set of particle systems working together to create a specific effect
  65580. */
  65581. export class ParticleSystemSet implements IDisposable {
  65582. /**
  65583. * Gets or sets base Assets URL
  65584. */
  65585. static BaseAssetsUrl: string;
  65586. private _emitterCreationOptions;
  65587. private _emitterNode;
  65588. /**
  65589. * Gets the particle system list
  65590. */
  65591. systems: IParticleSystem[];
  65592. /**
  65593. * Gets the emitter node used with this set
  65594. */
  65595. get emitterNode(): Nullable<TransformNode>;
  65596. /**
  65597. * Creates a new emitter mesh as a sphere
  65598. * @param options defines the options used to create the sphere
  65599. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65600. * @param scene defines the hosting scene
  65601. */
  65602. setEmitterAsSphere(options: {
  65603. diameter: number;
  65604. segments: number;
  65605. color: Color3;
  65606. }, renderingGroupId: number, scene: Scene): void;
  65607. /**
  65608. * Starts all particle systems of the set
  65609. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65610. */
  65611. start(emitter?: AbstractMesh): void;
  65612. /**
  65613. * Release all associated resources
  65614. */
  65615. dispose(): void;
  65616. /**
  65617. * Serialize the set into a JSON compatible object
  65618. * @returns a JSON compatible representation of the set
  65619. */
  65620. serialize(): any;
  65621. /**
  65622. * Parse a new ParticleSystemSet from a serialized source
  65623. * @param data defines a JSON compatible representation of the set
  65624. * @param scene defines the hosting scene
  65625. * @param gpu defines if we want GPU particles or CPU particles
  65626. * @returns a new ParticleSystemSet
  65627. */
  65628. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65629. }
  65630. }
  65631. declare module "babylonjs/Particles/particleHelper" {
  65632. import { Nullable } from "babylonjs/types";
  65633. import { Scene } from "babylonjs/scene";
  65634. import { Vector3 } from "babylonjs/Maths/math.vector";
  65635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65636. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65637. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  65638. /**
  65639. * This class is made for on one-liner static method to help creating particle system set.
  65640. */
  65641. export class ParticleHelper {
  65642. /**
  65643. * Gets or sets base Assets URL
  65644. */
  65645. static BaseAssetsUrl: string;
  65646. /**
  65647. * Create a default particle system that you can tweak
  65648. * @param emitter defines the emitter to use
  65649. * @param capacity defines the system capacity (default is 500 particles)
  65650. * @param scene defines the hosting scene
  65651. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65652. * @returns the new Particle system
  65653. */
  65654. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65655. /**
  65656. * This is the main static method (one-liner) of this helper to create different particle systems
  65657. * @param type This string represents the type to the particle system to create
  65658. * @param scene The scene where the particle system should live
  65659. * @param gpu If the system will use gpu
  65660. * @returns the ParticleSystemSet created
  65661. */
  65662. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65663. /**
  65664. * Static function used to export a particle system to a ParticleSystemSet variable.
  65665. * Please note that the emitter shape is not exported
  65666. * @param systems defines the particle systems to export
  65667. * @returns the created particle system set
  65668. */
  65669. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65670. }
  65671. }
  65672. declare module "babylonjs/Particles/particleSystemComponent" {
  65673. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65674. import { Effect } from "babylonjs/Materials/effect";
  65675. import "babylonjs/Shaders/particles.vertex";
  65676. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65677. module "babylonjs/Engines/engine" {
  65678. interface Engine {
  65679. /**
  65680. * Create an effect to use with particle systems.
  65681. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65682. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65683. * @param uniformsNames defines a list of attribute names
  65684. * @param samplers defines an array of string used to represent textures
  65685. * @param defines defines the string containing the defines to use to compile the shaders
  65686. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65687. * @param onCompiled defines a function to call when the effect creation is successful
  65688. * @param onError defines a function to call when the effect creation has failed
  65689. * @returns the new Effect
  65690. */
  65691. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65692. }
  65693. }
  65694. module "babylonjs/Meshes/mesh" {
  65695. interface Mesh {
  65696. /**
  65697. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65698. * @returns an array of IParticleSystem
  65699. */
  65700. getEmittedParticleSystems(): IParticleSystem[];
  65701. /**
  65702. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65703. * @returns an array of IParticleSystem
  65704. */
  65705. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65706. }
  65707. }
  65708. /**
  65709. * @hidden
  65710. */
  65711. export var _IDoNeedToBeInTheBuild: number;
  65712. }
  65713. declare module "babylonjs/Particles/pointsCloudSystem" {
  65714. import { Color4 } from "babylonjs/Maths/math";
  65715. import { Mesh } from "babylonjs/Meshes/mesh";
  65716. import { Scene, IDisposable } from "babylonjs/scene";
  65717. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  65718. /** Defines the 4 color options */
  65719. export enum PointColor {
  65720. /** color value */
  65721. Color = 2,
  65722. /** uv value */
  65723. UV = 1,
  65724. /** random value */
  65725. Random = 0,
  65726. /** stated value */
  65727. Stated = 3
  65728. }
  65729. /**
  65730. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65731. * 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.
  65732. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65733. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65734. *
  65735. * Full documentation here : TO BE ENTERED
  65736. */
  65737. export class PointsCloudSystem implements IDisposable {
  65738. /**
  65739. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65740. * Example : var p = SPS.particles[i];
  65741. */
  65742. particles: CloudPoint[];
  65743. /**
  65744. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65745. */
  65746. nbParticles: number;
  65747. /**
  65748. * This a counter for your own usage. It's not set by any SPS functions.
  65749. */
  65750. counter: number;
  65751. /**
  65752. * The PCS name. This name is also given to the underlying mesh.
  65753. */
  65754. name: string;
  65755. /**
  65756. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65757. */
  65758. mesh: Mesh;
  65759. /**
  65760. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65761. * Please read :
  65762. */
  65763. vars: any;
  65764. /**
  65765. * @hidden
  65766. */
  65767. _size: number;
  65768. private _scene;
  65769. private _promises;
  65770. private _positions;
  65771. private _indices;
  65772. private _normals;
  65773. private _colors;
  65774. private _uvs;
  65775. private _indices32;
  65776. private _positions32;
  65777. private _colors32;
  65778. private _uvs32;
  65779. private _updatable;
  65780. private _isVisibilityBoxLocked;
  65781. private _alwaysVisible;
  65782. private _groups;
  65783. private _groupCounter;
  65784. private _computeParticleColor;
  65785. private _computeParticleTexture;
  65786. private _computeParticleRotation;
  65787. private _computeBoundingBox;
  65788. private _isReady;
  65789. /**
  65790. * Creates a PCS (Points Cloud System) object
  65791. * @param name (String) is the PCS name, this will be the underlying mesh name
  65792. * @param pointSize (number) is the size for each point
  65793. * @param scene (Scene) is the scene in which the PCS is added
  65794. * @param options defines the options of the PCS e.g.
  65795. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65796. */
  65797. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65798. updatable?: boolean;
  65799. });
  65800. /**
  65801. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65802. * If no points were added to the PCS, the returned mesh is just a single point.
  65803. * @returns a promise for the created mesh
  65804. */
  65805. buildMeshAsync(): Promise<Mesh>;
  65806. /**
  65807. * @hidden
  65808. */
  65809. private _buildMesh;
  65810. private _addParticle;
  65811. private _randomUnitVector;
  65812. private _getColorIndicesForCoord;
  65813. private _setPointsColorOrUV;
  65814. private _colorFromTexture;
  65815. private _calculateDensity;
  65816. /**
  65817. * Adds points to the PCS in random positions within a unit sphere
  65818. * @param nb (positive integer) the number of particles to be created from this model
  65819. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65820. * @returns the number of groups in the system
  65821. */
  65822. addPoints(nb: number, pointFunction?: any): number;
  65823. /**
  65824. * Adds points to the PCS from the surface of the model shape
  65825. * @param mesh is any Mesh object that will be used as a surface model for the points
  65826. * @param nb (positive integer) the number of particles to be created from this model
  65827. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65828. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65829. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65830. * @returns the number of groups in the system
  65831. */
  65832. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65833. /**
  65834. * Adds points to the PCS inside the model shape
  65835. * @param mesh is any Mesh object that will be used as a surface model for the points
  65836. * @param nb (positive integer) the number of particles to be created from this model
  65837. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65838. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65839. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65840. * @returns the number of groups in the system
  65841. */
  65842. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65843. /**
  65844. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65845. * This method calls `updateParticle()` for each particle of the SPS.
  65846. * For an animated SPS, it is usually called within the render loop.
  65847. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65848. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65849. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65850. * @returns the PCS.
  65851. */
  65852. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65853. /**
  65854. * Disposes the PCS.
  65855. */
  65856. dispose(): void;
  65857. /**
  65858. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65859. * doc :
  65860. * @returns the PCS.
  65861. */
  65862. refreshVisibleSize(): PointsCloudSystem;
  65863. /**
  65864. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65865. * @param size the size (float) of the visibility box
  65866. * note : this doesn't lock the PCS mesh bounding box.
  65867. * doc :
  65868. */
  65869. setVisibilityBox(size: number): void;
  65870. /**
  65871. * Gets whether the PCS is always visible or not
  65872. * doc :
  65873. */
  65874. get isAlwaysVisible(): boolean;
  65875. /**
  65876. * Sets the PCS as always visible or not
  65877. * doc :
  65878. */
  65879. set isAlwaysVisible(val: boolean);
  65880. /**
  65881. * Tells to `setParticles()` to compute the particle rotations or not
  65882. * Default value : false. The PCS is faster when it's set to false
  65883. * Note : particle rotations are only applied to parent particles
  65884. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65885. */
  65886. set computeParticleRotation(val: boolean);
  65887. /**
  65888. * Tells to `setParticles()` to compute the particle colors or not.
  65889. * Default value : true. The PCS is faster when it's set to false.
  65890. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65891. */
  65892. set computeParticleColor(val: boolean);
  65893. set computeParticleTexture(val: boolean);
  65894. /**
  65895. * Gets if `setParticles()` computes the particle colors or not.
  65896. * Default value : false. The PCS is faster when it's set to false.
  65897. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65898. */
  65899. get computeParticleColor(): boolean;
  65900. /**
  65901. * Gets if `setParticles()` computes the particle textures or not.
  65902. * Default value : false. The PCS is faster when it's set to false.
  65903. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65904. */
  65905. get computeParticleTexture(): boolean;
  65906. /**
  65907. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65908. */
  65909. set computeBoundingBox(val: boolean);
  65910. /**
  65911. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65912. */
  65913. get computeBoundingBox(): boolean;
  65914. /**
  65915. * This function does nothing. It may be overwritten to set all the particle first values.
  65916. * The PCS doesn't call this function, you may have to call it by your own.
  65917. * doc :
  65918. */
  65919. initParticles(): void;
  65920. /**
  65921. * This function does nothing. It may be overwritten to recycle a particle
  65922. * The PCS doesn't call this function, you can to call it
  65923. * doc :
  65924. * @param particle The particle to recycle
  65925. * @returns the recycled particle
  65926. */
  65927. recycleParticle(particle: CloudPoint): CloudPoint;
  65928. /**
  65929. * Updates a particle : this function should be overwritten by the user.
  65930. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65931. * doc :
  65932. * @example : just set a particle position or velocity and recycle conditions
  65933. * @param particle The particle to update
  65934. * @returns the updated particle
  65935. */
  65936. updateParticle(particle: CloudPoint): CloudPoint;
  65937. /**
  65938. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65939. * This does nothing and may be overwritten by the user.
  65940. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65941. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65942. * @param update the boolean update value actually passed to setParticles()
  65943. */
  65944. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65945. /**
  65946. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65947. * This will be passed three parameters.
  65948. * This does nothing and may be overwritten by the user.
  65949. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65950. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65951. * @param update the boolean update value actually passed to setParticles()
  65952. */
  65953. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65954. }
  65955. }
  65956. declare module "babylonjs/Particles/cloudPoint" {
  65957. import { Nullable } from "babylonjs/types";
  65958. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  65959. import { Mesh } from "babylonjs/Meshes/mesh";
  65960. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  65961. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  65962. /**
  65963. * Represents one particle of a points cloud system.
  65964. */
  65965. export class CloudPoint {
  65966. /**
  65967. * particle global index
  65968. */
  65969. idx: number;
  65970. /**
  65971. * The color of the particle
  65972. */
  65973. color: Nullable<Color4>;
  65974. /**
  65975. * The world space position of the particle.
  65976. */
  65977. position: Vector3;
  65978. /**
  65979. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65980. */
  65981. rotation: Vector3;
  65982. /**
  65983. * The world space rotation quaternion of the particle.
  65984. */
  65985. rotationQuaternion: Nullable<Quaternion>;
  65986. /**
  65987. * The uv of the particle.
  65988. */
  65989. uv: Nullable<Vector2>;
  65990. /**
  65991. * The current speed of the particle.
  65992. */
  65993. velocity: Vector3;
  65994. /**
  65995. * The pivot point in the particle local space.
  65996. */
  65997. pivot: Vector3;
  65998. /**
  65999. * Must the particle be translated from its pivot point in its local space ?
  66000. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66001. * Default : false
  66002. */
  66003. translateFromPivot: boolean;
  66004. /**
  66005. * Index of this particle in the global "positions" array (Internal use)
  66006. * @hidden
  66007. */
  66008. _pos: number;
  66009. /**
  66010. * @hidden Index of this particle in the global "indices" array (Internal use)
  66011. */
  66012. _ind: number;
  66013. /**
  66014. * Group this particle belongs to
  66015. */
  66016. _group: PointsGroup;
  66017. /**
  66018. * Group id of this particle
  66019. */
  66020. groupId: number;
  66021. /**
  66022. * Index of the particle in its group id (Internal use)
  66023. */
  66024. idxInGroup: number;
  66025. /**
  66026. * @hidden Particle BoundingInfo object (Internal use)
  66027. */
  66028. _boundingInfo: BoundingInfo;
  66029. /**
  66030. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66031. */
  66032. _pcs: PointsCloudSystem;
  66033. /**
  66034. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66035. */
  66036. _stillInvisible: boolean;
  66037. /**
  66038. * @hidden Last computed particle rotation matrix
  66039. */
  66040. _rotationMatrix: number[];
  66041. /**
  66042. * Parent particle Id, if any.
  66043. * Default null.
  66044. */
  66045. parentId: Nullable<number>;
  66046. /**
  66047. * @hidden Internal global position in the PCS.
  66048. */
  66049. _globalPosition: Vector3;
  66050. /**
  66051. * Creates a Point Cloud object.
  66052. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66053. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66054. * @param group (PointsGroup) is the group the particle belongs to
  66055. * @param groupId (integer) is the group identifier in the PCS.
  66056. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66057. * @param pcs defines the PCS it is associated to
  66058. */
  66059. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66060. /**
  66061. * get point size
  66062. */
  66063. get size(): Vector3;
  66064. /**
  66065. * Set point size
  66066. */
  66067. set size(scale: Vector3);
  66068. /**
  66069. * Legacy support, changed quaternion to rotationQuaternion
  66070. */
  66071. get quaternion(): Nullable<Quaternion>;
  66072. /**
  66073. * Legacy support, changed quaternion to rotationQuaternion
  66074. */
  66075. set quaternion(q: Nullable<Quaternion>);
  66076. /**
  66077. * Returns a boolean. True if the particle intersects a mesh, else false
  66078. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66079. * @param target is the object (point or mesh) what the intersection is computed against
  66080. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66081. * @returns true if it intersects
  66082. */
  66083. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66084. /**
  66085. * get the rotation matrix of the particle
  66086. * @hidden
  66087. */
  66088. getRotationMatrix(m: Matrix): void;
  66089. }
  66090. /**
  66091. * Represents a group of points in a points cloud system
  66092. * * PCS internal tool, don't use it manually.
  66093. */
  66094. export class PointsGroup {
  66095. /**
  66096. * The group id
  66097. * @hidden
  66098. */
  66099. groupID: number;
  66100. /**
  66101. * image data for group (internal use)
  66102. * @hidden
  66103. */
  66104. _groupImageData: Nullable<ArrayBufferView>;
  66105. /**
  66106. * Image Width (internal use)
  66107. * @hidden
  66108. */
  66109. _groupImgWidth: number;
  66110. /**
  66111. * Image Height (internal use)
  66112. * @hidden
  66113. */
  66114. _groupImgHeight: number;
  66115. /**
  66116. * Custom position function (internal use)
  66117. * @hidden
  66118. */
  66119. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66120. /**
  66121. * density per facet for surface points
  66122. * @hidden
  66123. */
  66124. _groupDensity: number[];
  66125. /**
  66126. * Only when points are colored by texture carries pointer to texture list array
  66127. * @hidden
  66128. */
  66129. _textureNb: number;
  66130. /**
  66131. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66132. * PCS internal tool, don't use it manually.
  66133. * @hidden
  66134. */
  66135. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66136. }
  66137. }
  66138. declare module "babylonjs/Particles/index" {
  66139. export * from "babylonjs/Particles/baseParticleSystem";
  66140. export * from "babylonjs/Particles/EmitterTypes/index";
  66141. export * from "babylonjs/Particles/gpuParticleSystem";
  66142. export * from "babylonjs/Particles/IParticleSystem";
  66143. export * from "babylonjs/Particles/particle";
  66144. export * from "babylonjs/Particles/particleHelper";
  66145. export * from "babylonjs/Particles/particleSystem";
  66146. export * from "babylonjs/Particles/particleSystemComponent";
  66147. export * from "babylonjs/Particles/particleSystemSet";
  66148. export * from "babylonjs/Particles/solidParticle";
  66149. export * from "babylonjs/Particles/solidParticleSystem";
  66150. export * from "babylonjs/Particles/cloudPoint";
  66151. export * from "babylonjs/Particles/pointsCloudSystem";
  66152. export * from "babylonjs/Particles/subEmitter";
  66153. }
  66154. declare module "babylonjs/Physics/physicsEngineComponent" {
  66155. import { Nullable } from "babylonjs/types";
  66156. import { Observable, Observer } from "babylonjs/Misc/observable";
  66157. import { Vector3 } from "babylonjs/Maths/math.vector";
  66158. import { Mesh } from "babylonjs/Meshes/mesh";
  66159. import { ISceneComponent } from "babylonjs/sceneComponent";
  66160. import { Scene } from "babylonjs/scene";
  66161. import { Node } from "babylonjs/node";
  66162. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66163. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66164. module "babylonjs/scene" {
  66165. interface Scene {
  66166. /** @hidden (Backing field) */
  66167. _physicsEngine: Nullable<IPhysicsEngine>;
  66168. /** @hidden */
  66169. _physicsTimeAccumulator: number;
  66170. /**
  66171. * Gets the current physics engine
  66172. * @returns a IPhysicsEngine or null if none attached
  66173. */
  66174. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66175. /**
  66176. * Enables physics to the current scene
  66177. * @param gravity defines the scene's gravity for the physics engine
  66178. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66179. * @return a boolean indicating if the physics engine was initialized
  66180. */
  66181. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66182. /**
  66183. * Disables and disposes the physics engine associated with the scene
  66184. */
  66185. disablePhysicsEngine(): void;
  66186. /**
  66187. * Gets a boolean indicating if there is an active physics engine
  66188. * @returns a boolean indicating if there is an active physics engine
  66189. */
  66190. isPhysicsEnabled(): boolean;
  66191. /**
  66192. * Deletes a physics compound impostor
  66193. * @param compound defines the compound to delete
  66194. */
  66195. deleteCompoundImpostor(compound: any): void;
  66196. /**
  66197. * An event triggered when physic simulation is about to be run
  66198. */
  66199. onBeforePhysicsObservable: Observable<Scene>;
  66200. /**
  66201. * An event triggered when physic simulation has been done
  66202. */
  66203. onAfterPhysicsObservable: Observable<Scene>;
  66204. }
  66205. }
  66206. module "babylonjs/Meshes/abstractMesh" {
  66207. interface AbstractMesh {
  66208. /** @hidden */
  66209. _physicsImpostor: Nullable<PhysicsImpostor>;
  66210. /**
  66211. * Gets or sets impostor used for physic simulation
  66212. * @see http://doc.babylonjs.com/features/physics_engine
  66213. */
  66214. physicsImpostor: Nullable<PhysicsImpostor>;
  66215. /**
  66216. * Gets the current physics impostor
  66217. * @see http://doc.babylonjs.com/features/physics_engine
  66218. * @returns a physics impostor or null
  66219. */
  66220. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66221. /** Apply a physic impulse to the mesh
  66222. * @param force defines the force to apply
  66223. * @param contactPoint defines where to apply the force
  66224. * @returns the current mesh
  66225. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66226. */
  66227. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66228. /**
  66229. * Creates a physic joint between two meshes
  66230. * @param otherMesh defines the other mesh to use
  66231. * @param pivot1 defines the pivot to use on this mesh
  66232. * @param pivot2 defines the pivot to use on the other mesh
  66233. * @param options defines additional options (can be plugin dependent)
  66234. * @returns the current mesh
  66235. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66236. */
  66237. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66238. /** @hidden */
  66239. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66240. }
  66241. }
  66242. /**
  66243. * Defines the physics engine scene component responsible to manage a physics engine
  66244. */
  66245. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66246. /**
  66247. * The component name helpful to identify the component in the list of scene components.
  66248. */
  66249. readonly name: string;
  66250. /**
  66251. * The scene the component belongs to.
  66252. */
  66253. scene: Scene;
  66254. /**
  66255. * Creates a new instance of the component for the given scene
  66256. * @param scene Defines the scene to register the component in
  66257. */
  66258. constructor(scene: Scene);
  66259. /**
  66260. * Registers the component in a given scene
  66261. */
  66262. register(): void;
  66263. /**
  66264. * Rebuilds the elements related to this component in case of
  66265. * context lost for instance.
  66266. */
  66267. rebuild(): void;
  66268. /**
  66269. * Disposes the component and the associated ressources
  66270. */
  66271. dispose(): void;
  66272. }
  66273. }
  66274. declare module "babylonjs/Physics/physicsHelper" {
  66275. import { Nullable } from "babylonjs/types";
  66276. import { Vector3 } from "babylonjs/Maths/math.vector";
  66277. import { Mesh } from "babylonjs/Meshes/mesh";
  66278. import { Scene } from "babylonjs/scene";
  66279. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66280. /**
  66281. * A helper for physics simulations
  66282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66283. */
  66284. export class PhysicsHelper {
  66285. private _scene;
  66286. private _physicsEngine;
  66287. /**
  66288. * Initializes the Physics helper
  66289. * @param scene Babylon.js scene
  66290. */
  66291. constructor(scene: Scene);
  66292. /**
  66293. * Applies a radial explosion impulse
  66294. * @param origin the origin of the explosion
  66295. * @param radiusOrEventOptions the radius or the options of radial explosion
  66296. * @param strength the explosion strength
  66297. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66298. * @returns A physics radial explosion event, or null
  66299. */
  66300. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66301. /**
  66302. * Applies a radial explosion force
  66303. * @param origin the origin of the explosion
  66304. * @param radiusOrEventOptions the radius or the options of radial explosion
  66305. * @param strength the explosion strength
  66306. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66307. * @returns A physics radial explosion event, or null
  66308. */
  66309. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66310. /**
  66311. * Creates a gravitational field
  66312. * @param origin the origin of the explosion
  66313. * @param radiusOrEventOptions the radius or the options of radial explosion
  66314. * @param strength the explosion strength
  66315. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66316. * @returns A physics gravitational field event, or null
  66317. */
  66318. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66319. /**
  66320. * Creates a physics updraft event
  66321. * @param origin the origin of the updraft
  66322. * @param radiusOrEventOptions the radius or the options of the updraft
  66323. * @param strength the strength of the updraft
  66324. * @param height the height of the updraft
  66325. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66326. * @returns A physics updraft event, or null
  66327. */
  66328. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66329. /**
  66330. * Creates a physics vortex event
  66331. * @param origin the of the vortex
  66332. * @param radiusOrEventOptions the radius or the options of the vortex
  66333. * @param strength the strength of the vortex
  66334. * @param height the height of the vortex
  66335. * @returns a Physics vortex event, or null
  66336. * A physics vortex event or null
  66337. */
  66338. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66339. }
  66340. /**
  66341. * Represents a physics radial explosion event
  66342. */
  66343. class PhysicsRadialExplosionEvent {
  66344. private _scene;
  66345. private _options;
  66346. private _sphere;
  66347. private _dataFetched;
  66348. /**
  66349. * Initializes a radial explosioin event
  66350. * @param _scene BabylonJS scene
  66351. * @param _options The options for the vortex event
  66352. */
  66353. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66354. /**
  66355. * Returns the data related to the radial explosion event (sphere).
  66356. * @returns The radial explosion event data
  66357. */
  66358. getData(): PhysicsRadialExplosionEventData;
  66359. /**
  66360. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66361. * @param impostor A physics imposter
  66362. * @param origin the origin of the explosion
  66363. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66364. */
  66365. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66366. /**
  66367. * Triggers affecterd impostors callbacks
  66368. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66369. */
  66370. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66371. /**
  66372. * Disposes the sphere.
  66373. * @param force Specifies if the sphere should be disposed by force
  66374. */
  66375. dispose(force?: boolean): void;
  66376. /*** Helpers ***/
  66377. private _prepareSphere;
  66378. private _intersectsWithSphere;
  66379. }
  66380. /**
  66381. * Represents a gravitational field event
  66382. */
  66383. class PhysicsGravitationalFieldEvent {
  66384. private _physicsHelper;
  66385. private _scene;
  66386. private _origin;
  66387. private _options;
  66388. private _tickCallback;
  66389. private _sphere;
  66390. private _dataFetched;
  66391. /**
  66392. * Initializes the physics gravitational field event
  66393. * @param _physicsHelper A physics helper
  66394. * @param _scene BabylonJS scene
  66395. * @param _origin The origin position of the gravitational field event
  66396. * @param _options The options for the vortex event
  66397. */
  66398. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66399. /**
  66400. * Returns the data related to the gravitational field event (sphere).
  66401. * @returns A gravitational field event
  66402. */
  66403. getData(): PhysicsGravitationalFieldEventData;
  66404. /**
  66405. * Enables the gravitational field.
  66406. */
  66407. enable(): void;
  66408. /**
  66409. * Disables the gravitational field.
  66410. */
  66411. disable(): void;
  66412. /**
  66413. * Disposes the sphere.
  66414. * @param force The force to dispose from the gravitational field event
  66415. */
  66416. dispose(force?: boolean): void;
  66417. private _tick;
  66418. }
  66419. /**
  66420. * Represents a physics updraft event
  66421. */
  66422. class PhysicsUpdraftEvent {
  66423. private _scene;
  66424. private _origin;
  66425. private _options;
  66426. private _physicsEngine;
  66427. private _originTop;
  66428. private _originDirection;
  66429. private _tickCallback;
  66430. private _cylinder;
  66431. private _cylinderPosition;
  66432. private _dataFetched;
  66433. /**
  66434. * Initializes the physics updraft event
  66435. * @param _scene BabylonJS scene
  66436. * @param _origin The origin position of the updraft
  66437. * @param _options The options for the updraft event
  66438. */
  66439. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66440. /**
  66441. * Returns the data related to the updraft event (cylinder).
  66442. * @returns A physics updraft event
  66443. */
  66444. getData(): PhysicsUpdraftEventData;
  66445. /**
  66446. * Enables the updraft.
  66447. */
  66448. enable(): void;
  66449. /**
  66450. * Disables the updraft.
  66451. */
  66452. disable(): void;
  66453. /**
  66454. * Disposes the cylinder.
  66455. * @param force Specifies if the updraft should be disposed by force
  66456. */
  66457. dispose(force?: boolean): void;
  66458. private getImpostorHitData;
  66459. private _tick;
  66460. /*** Helpers ***/
  66461. private _prepareCylinder;
  66462. private _intersectsWithCylinder;
  66463. }
  66464. /**
  66465. * Represents a physics vortex event
  66466. */
  66467. class PhysicsVortexEvent {
  66468. private _scene;
  66469. private _origin;
  66470. private _options;
  66471. private _physicsEngine;
  66472. private _originTop;
  66473. private _tickCallback;
  66474. private _cylinder;
  66475. private _cylinderPosition;
  66476. private _dataFetched;
  66477. /**
  66478. * Initializes the physics vortex event
  66479. * @param _scene The BabylonJS scene
  66480. * @param _origin The origin position of the vortex
  66481. * @param _options The options for the vortex event
  66482. */
  66483. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66484. /**
  66485. * Returns the data related to the vortex event (cylinder).
  66486. * @returns The physics vortex event data
  66487. */
  66488. getData(): PhysicsVortexEventData;
  66489. /**
  66490. * Enables the vortex.
  66491. */
  66492. enable(): void;
  66493. /**
  66494. * Disables the cortex.
  66495. */
  66496. disable(): void;
  66497. /**
  66498. * Disposes the sphere.
  66499. * @param force
  66500. */
  66501. dispose(force?: boolean): void;
  66502. private getImpostorHitData;
  66503. private _tick;
  66504. /*** Helpers ***/
  66505. private _prepareCylinder;
  66506. private _intersectsWithCylinder;
  66507. }
  66508. /**
  66509. * Options fot the radial explosion event
  66510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66511. */
  66512. export class PhysicsRadialExplosionEventOptions {
  66513. /**
  66514. * The radius of the sphere for the radial explosion.
  66515. */
  66516. radius: number;
  66517. /**
  66518. * The strenth of the explosion.
  66519. */
  66520. strength: number;
  66521. /**
  66522. * The strenght of the force in correspondence to the distance of the affected object
  66523. */
  66524. falloff: PhysicsRadialImpulseFalloff;
  66525. /**
  66526. * Sphere options for the radial explosion.
  66527. */
  66528. sphere: {
  66529. segments: number;
  66530. diameter: number;
  66531. };
  66532. /**
  66533. * Sphere options for the radial explosion.
  66534. */
  66535. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66536. }
  66537. /**
  66538. * Options fot the updraft event
  66539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66540. */
  66541. export class PhysicsUpdraftEventOptions {
  66542. /**
  66543. * The radius of the cylinder for the vortex
  66544. */
  66545. radius: number;
  66546. /**
  66547. * The strenth of the updraft.
  66548. */
  66549. strength: number;
  66550. /**
  66551. * The height of the cylinder for the updraft.
  66552. */
  66553. height: number;
  66554. /**
  66555. * The mode for the the updraft.
  66556. */
  66557. updraftMode: PhysicsUpdraftMode;
  66558. }
  66559. /**
  66560. * Options fot the vortex event
  66561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66562. */
  66563. export class PhysicsVortexEventOptions {
  66564. /**
  66565. * The radius of the cylinder for the vortex
  66566. */
  66567. radius: number;
  66568. /**
  66569. * The strenth of the vortex.
  66570. */
  66571. strength: number;
  66572. /**
  66573. * The height of the cylinder for the vortex.
  66574. */
  66575. height: number;
  66576. /**
  66577. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66578. */
  66579. centripetalForceThreshold: number;
  66580. /**
  66581. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66582. */
  66583. centripetalForceMultiplier: number;
  66584. /**
  66585. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66586. */
  66587. centrifugalForceMultiplier: number;
  66588. /**
  66589. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66590. */
  66591. updraftForceMultiplier: number;
  66592. }
  66593. /**
  66594. * The strenght of the force in correspondence to the distance of the affected object
  66595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66596. */
  66597. export enum PhysicsRadialImpulseFalloff {
  66598. /** Defines that impulse is constant in strength across it's whole radius */
  66599. Constant = 0,
  66600. /** Defines that impulse gets weaker if it's further from the origin */
  66601. Linear = 1
  66602. }
  66603. /**
  66604. * The strength of the force in correspondence to the distance of the affected object
  66605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66606. */
  66607. export enum PhysicsUpdraftMode {
  66608. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66609. Center = 0,
  66610. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66611. Perpendicular = 1
  66612. }
  66613. /**
  66614. * Interface for a physics hit data
  66615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66616. */
  66617. export interface PhysicsHitData {
  66618. /**
  66619. * The force applied at the contact point
  66620. */
  66621. force: Vector3;
  66622. /**
  66623. * The contact point
  66624. */
  66625. contactPoint: Vector3;
  66626. /**
  66627. * The distance from the origin to the contact point
  66628. */
  66629. distanceFromOrigin: number;
  66630. }
  66631. /**
  66632. * Interface for radial explosion event data
  66633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66634. */
  66635. export interface PhysicsRadialExplosionEventData {
  66636. /**
  66637. * A sphere used for the radial explosion event
  66638. */
  66639. sphere: Mesh;
  66640. }
  66641. /**
  66642. * Interface for gravitational field event data
  66643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66644. */
  66645. export interface PhysicsGravitationalFieldEventData {
  66646. /**
  66647. * A sphere mesh used for the gravitational field event
  66648. */
  66649. sphere: Mesh;
  66650. }
  66651. /**
  66652. * Interface for updraft event data
  66653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66654. */
  66655. export interface PhysicsUpdraftEventData {
  66656. /**
  66657. * A cylinder used for the updraft event
  66658. */
  66659. cylinder: Mesh;
  66660. }
  66661. /**
  66662. * Interface for vortex event data
  66663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66664. */
  66665. export interface PhysicsVortexEventData {
  66666. /**
  66667. * A cylinder used for the vortex event
  66668. */
  66669. cylinder: Mesh;
  66670. }
  66671. /**
  66672. * Interface for an affected physics impostor
  66673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66674. */
  66675. export interface PhysicsAffectedImpostorWithData {
  66676. /**
  66677. * The impostor affected by the effect
  66678. */
  66679. impostor: PhysicsImpostor;
  66680. /**
  66681. * The data about the hit/horce from the explosion
  66682. */
  66683. hitData: PhysicsHitData;
  66684. }
  66685. }
  66686. declare module "babylonjs/Physics/Plugins/index" {
  66687. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  66688. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  66689. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  66690. }
  66691. declare module "babylonjs/Physics/index" {
  66692. export * from "babylonjs/Physics/IPhysicsEngine";
  66693. export * from "babylonjs/Physics/physicsEngine";
  66694. export * from "babylonjs/Physics/physicsEngineComponent";
  66695. export * from "babylonjs/Physics/physicsHelper";
  66696. export * from "babylonjs/Physics/physicsImpostor";
  66697. export * from "babylonjs/Physics/physicsJoint";
  66698. export * from "babylonjs/Physics/Plugins/index";
  66699. }
  66700. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  66701. /** @hidden */
  66702. export var blackAndWhitePixelShader: {
  66703. name: string;
  66704. shader: string;
  66705. };
  66706. }
  66707. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  66708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66709. import { Camera } from "babylonjs/Cameras/camera";
  66710. import { Engine } from "babylonjs/Engines/engine";
  66711. import "babylonjs/Shaders/blackAndWhite.fragment";
  66712. /**
  66713. * Post process used to render in black and white
  66714. */
  66715. export class BlackAndWhitePostProcess extends PostProcess {
  66716. /**
  66717. * Linear about to convert he result to black and white (default: 1)
  66718. */
  66719. degree: number;
  66720. /**
  66721. * Creates a black and white post process
  66722. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66723. * @param name The name of the effect.
  66724. * @param options The required width/height ratio to downsize to before computing the render pass.
  66725. * @param camera The camera to apply the render pass to.
  66726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66727. * @param engine The engine which the post process will be applied. (default: current engine)
  66728. * @param reusable If the post process can be reused on the same frame. (default: false)
  66729. */
  66730. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66731. }
  66732. }
  66733. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  66734. import { Nullable } from "babylonjs/types";
  66735. import { Camera } from "babylonjs/Cameras/camera";
  66736. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66737. import { Engine } from "babylonjs/Engines/engine";
  66738. /**
  66739. * This represents a set of one or more post processes in Babylon.
  66740. * A post process can be used to apply a shader to a texture after it is rendered.
  66741. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66742. */
  66743. export class PostProcessRenderEffect {
  66744. private _postProcesses;
  66745. private _getPostProcesses;
  66746. private _singleInstance;
  66747. private _cameras;
  66748. private _indicesForCamera;
  66749. /**
  66750. * Name of the effect
  66751. * @hidden
  66752. */
  66753. _name: string;
  66754. /**
  66755. * Instantiates a post process render effect.
  66756. * A post process can be used to apply a shader to a texture after it is rendered.
  66757. * @param engine The engine the effect is tied to
  66758. * @param name The name of the effect
  66759. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66760. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66761. */
  66762. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66763. /**
  66764. * Checks if all the post processes in the effect are supported.
  66765. */
  66766. get isSupported(): boolean;
  66767. /**
  66768. * Updates the current state of the effect
  66769. * @hidden
  66770. */
  66771. _update(): void;
  66772. /**
  66773. * Attaches the effect on cameras
  66774. * @param cameras The camera to attach to.
  66775. * @hidden
  66776. */
  66777. _attachCameras(cameras: Camera): void;
  66778. /**
  66779. * Attaches the effect on cameras
  66780. * @param cameras The camera to attach to.
  66781. * @hidden
  66782. */
  66783. _attachCameras(cameras: Camera[]): void;
  66784. /**
  66785. * Detaches the effect on cameras
  66786. * @param cameras The camera to detatch from.
  66787. * @hidden
  66788. */
  66789. _detachCameras(cameras: Camera): void;
  66790. /**
  66791. * Detatches the effect on cameras
  66792. * @param cameras The camera to detatch from.
  66793. * @hidden
  66794. */
  66795. _detachCameras(cameras: Camera[]): void;
  66796. /**
  66797. * Enables the effect on given cameras
  66798. * @param cameras The camera to enable.
  66799. * @hidden
  66800. */
  66801. _enable(cameras: Camera): void;
  66802. /**
  66803. * Enables the effect on given cameras
  66804. * @param cameras The camera to enable.
  66805. * @hidden
  66806. */
  66807. _enable(cameras: Nullable<Camera[]>): void;
  66808. /**
  66809. * Disables the effect on the given cameras
  66810. * @param cameras The camera to disable.
  66811. * @hidden
  66812. */
  66813. _disable(cameras: Camera): void;
  66814. /**
  66815. * Disables the effect on the given cameras
  66816. * @param cameras The camera to disable.
  66817. * @hidden
  66818. */
  66819. _disable(cameras: Nullable<Camera[]>): void;
  66820. /**
  66821. * Gets a list of the post processes contained in the effect.
  66822. * @param camera The camera to get the post processes on.
  66823. * @returns The list of the post processes in the effect.
  66824. */
  66825. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66826. }
  66827. }
  66828. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  66829. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66830. /** @hidden */
  66831. export var extractHighlightsPixelShader: {
  66832. name: string;
  66833. shader: string;
  66834. };
  66835. }
  66836. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  66837. import { Nullable } from "babylonjs/types";
  66838. import { Camera } from "babylonjs/Cameras/camera";
  66839. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66840. import { Engine } from "babylonjs/Engines/engine";
  66841. import "babylonjs/Shaders/extractHighlights.fragment";
  66842. /**
  66843. * 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.
  66844. */
  66845. export class ExtractHighlightsPostProcess extends PostProcess {
  66846. /**
  66847. * The luminance threshold, pixels below this value will be set to black.
  66848. */
  66849. threshold: number;
  66850. /** @hidden */
  66851. _exposure: number;
  66852. /**
  66853. * Post process which has the input texture to be used when performing highlight extraction
  66854. * @hidden
  66855. */
  66856. _inputPostProcess: Nullable<PostProcess>;
  66857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66858. }
  66859. }
  66860. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  66861. /** @hidden */
  66862. export var bloomMergePixelShader: {
  66863. name: string;
  66864. shader: string;
  66865. };
  66866. }
  66867. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  66868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66869. import { Nullable } from "babylonjs/types";
  66870. import { Engine } from "babylonjs/Engines/engine";
  66871. import { Camera } from "babylonjs/Cameras/camera";
  66872. import "babylonjs/Shaders/bloomMerge.fragment";
  66873. /**
  66874. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66875. */
  66876. export class BloomMergePostProcess extends PostProcess {
  66877. /** Weight of the bloom to be added to the original input. */
  66878. weight: number;
  66879. /**
  66880. * Creates a new instance of @see BloomMergePostProcess
  66881. * @param name The name of the effect.
  66882. * @param originalFromInput Post process which's input will be used for the merge.
  66883. * @param blurred Blurred highlights post process which's output will be used.
  66884. * @param weight Weight of the bloom to be added to the original input.
  66885. * @param options The required width/height ratio to downsize to before computing the render pass.
  66886. * @param camera The camera to apply the render pass to.
  66887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66888. * @param engine The engine which the post process will be applied. (default: current engine)
  66889. * @param reusable If the post process can be reused on the same frame. (default: false)
  66890. * @param textureType Type of textures used when performing the post process. (default: 0)
  66891. * @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)
  66892. */
  66893. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66894. /** Weight of the bloom to be added to the original input. */
  66895. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66896. }
  66897. }
  66898. declare module "babylonjs/PostProcesses/bloomEffect" {
  66899. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66900. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66901. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66902. import { Camera } from "babylonjs/Cameras/camera";
  66903. import { Scene } from "babylonjs/scene";
  66904. /**
  66905. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66906. */
  66907. export class BloomEffect extends PostProcessRenderEffect {
  66908. private bloomScale;
  66909. /**
  66910. * @hidden Internal
  66911. */
  66912. _effects: Array<PostProcess>;
  66913. /**
  66914. * @hidden Internal
  66915. */
  66916. _downscale: ExtractHighlightsPostProcess;
  66917. private _blurX;
  66918. private _blurY;
  66919. private _merge;
  66920. /**
  66921. * The luminance threshold to find bright areas of the image to bloom.
  66922. */
  66923. get threshold(): number;
  66924. set threshold(value: number);
  66925. /**
  66926. * The strength of the bloom.
  66927. */
  66928. get weight(): number;
  66929. set weight(value: number);
  66930. /**
  66931. * Specifies the size of the bloom blur kernel, relative to the final output size
  66932. */
  66933. get kernel(): number;
  66934. set kernel(value: number);
  66935. /**
  66936. * Creates a new instance of @see BloomEffect
  66937. * @param scene The scene the effect belongs to.
  66938. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66939. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66940. * @param bloomWeight The the strength of bloom.
  66941. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66942. * @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)
  66943. */
  66944. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66945. /**
  66946. * Disposes each of the internal effects for a given camera.
  66947. * @param camera The camera to dispose the effect on.
  66948. */
  66949. disposeEffects(camera: Camera): void;
  66950. /**
  66951. * @hidden Internal
  66952. */
  66953. _updateEffects(): void;
  66954. /**
  66955. * Internal
  66956. * @returns if all the contained post processes are ready.
  66957. * @hidden
  66958. */
  66959. _isReady(): boolean;
  66960. }
  66961. }
  66962. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  66963. /** @hidden */
  66964. export var chromaticAberrationPixelShader: {
  66965. name: string;
  66966. shader: string;
  66967. };
  66968. }
  66969. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  66970. import { Vector2 } from "babylonjs/Maths/math.vector";
  66971. import { Nullable } from "babylonjs/types";
  66972. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66973. import { Camera } from "babylonjs/Cameras/camera";
  66974. import { Engine } from "babylonjs/Engines/engine";
  66975. import "babylonjs/Shaders/chromaticAberration.fragment";
  66976. /**
  66977. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66978. */
  66979. export class ChromaticAberrationPostProcess extends PostProcess {
  66980. /**
  66981. * The amount of seperation of rgb channels (default: 30)
  66982. */
  66983. aberrationAmount: number;
  66984. /**
  66985. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66986. */
  66987. radialIntensity: number;
  66988. /**
  66989. * 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))
  66990. */
  66991. direction: Vector2;
  66992. /**
  66993. * 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))
  66994. */
  66995. centerPosition: Vector2;
  66996. /**
  66997. * Creates a new instance ChromaticAberrationPostProcess
  66998. * @param name The name of the effect.
  66999. * @param screenWidth The width of the screen to apply the effect on.
  67000. * @param screenHeight The height of the screen to apply the effect on.
  67001. * @param options The required width/height ratio to downsize to before computing the render pass.
  67002. * @param camera The camera to apply the render pass to.
  67003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67004. * @param engine The engine which the post process will be applied. (default: current engine)
  67005. * @param reusable If the post process can be reused on the same frame. (default: false)
  67006. * @param textureType Type of textures used when performing the post process. (default: 0)
  67007. * @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)
  67008. */
  67009. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67010. }
  67011. }
  67012. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67013. /** @hidden */
  67014. export var circleOfConfusionPixelShader: {
  67015. name: string;
  67016. shader: string;
  67017. };
  67018. }
  67019. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67020. import { Nullable } from "babylonjs/types";
  67021. import { Engine } from "babylonjs/Engines/engine";
  67022. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67024. import { Camera } from "babylonjs/Cameras/camera";
  67025. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67026. /**
  67027. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67028. */
  67029. export class CircleOfConfusionPostProcess extends PostProcess {
  67030. /**
  67031. * 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.
  67032. */
  67033. lensSize: number;
  67034. /**
  67035. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67036. */
  67037. fStop: number;
  67038. /**
  67039. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67040. */
  67041. focusDistance: number;
  67042. /**
  67043. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67044. */
  67045. focalLength: number;
  67046. private _depthTexture;
  67047. /**
  67048. * Creates a new instance CircleOfConfusionPostProcess
  67049. * @param name The name of the effect.
  67050. * @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.
  67051. * @param options The required width/height ratio to downsize to before computing the render pass.
  67052. * @param camera The camera to apply the render pass to.
  67053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67054. * @param engine The engine which the post process will be applied. (default: current engine)
  67055. * @param reusable If the post process can be reused on the same frame. (default: false)
  67056. * @param textureType Type of textures used when performing the post process. (default: 0)
  67057. * @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)
  67058. */
  67059. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67060. /**
  67061. * 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.
  67062. */
  67063. set depthTexture(value: RenderTargetTexture);
  67064. }
  67065. }
  67066. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67067. /** @hidden */
  67068. export var colorCorrectionPixelShader: {
  67069. name: string;
  67070. shader: string;
  67071. };
  67072. }
  67073. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67074. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67075. import { Engine } from "babylonjs/Engines/engine";
  67076. import { Camera } from "babylonjs/Cameras/camera";
  67077. import "babylonjs/Shaders/colorCorrection.fragment";
  67078. /**
  67079. *
  67080. * This post-process allows the modification of rendered colors by using
  67081. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67082. *
  67083. * The object needs to be provided an url to a texture containing the color
  67084. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67085. * Use an image editing software to tweak the LUT to match your needs.
  67086. *
  67087. * For an example of a color LUT, see here:
  67088. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67089. * For explanations on color grading, see here:
  67090. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67091. *
  67092. */
  67093. export class ColorCorrectionPostProcess extends PostProcess {
  67094. private _colorTableTexture;
  67095. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67096. }
  67097. }
  67098. declare module "babylonjs/Shaders/convolution.fragment" {
  67099. /** @hidden */
  67100. export var convolutionPixelShader: {
  67101. name: string;
  67102. shader: string;
  67103. };
  67104. }
  67105. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67106. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67107. import { Nullable } from "babylonjs/types";
  67108. import { Camera } from "babylonjs/Cameras/camera";
  67109. import { Engine } from "babylonjs/Engines/engine";
  67110. import "babylonjs/Shaders/convolution.fragment";
  67111. /**
  67112. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67113. * input texture to perform effects such as edge detection or sharpening
  67114. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67115. */
  67116. export class ConvolutionPostProcess extends PostProcess {
  67117. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67118. kernel: number[];
  67119. /**
  67120. * Creates a new instance ConvolutionPostProcess
  67121. * @param name The name of the effect.
  67122. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67123. * @param options The required width/height ratio to downsize to before computing the render pass.
  67124. * @param camera The camera to apply the render pass to.
  67125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67126. * @param engine The engine which the post process will be applied. (default: current engine)
  67127. * @param reusable If the post process can be reused on the same frame. (default: false)
  67128. * @param textureType Type of textures used when performing the post process. (default: 0)
  67129. */
  67130. constructor(name: string,
  67131. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67132. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67133. /**
  67134. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67135. */
  67136. static EdgeDetect0Kernel: number[];
  67137. /**
  67138. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67139. */
  67140. static EdgeDetect1Kernel: number[];
  67141. /**
  67142. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67143. */
  67144. static EdgeDetect2Kernel: number[];
  67145. /**
  67146. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67147. */
  67148. static SharpenKernel: number[];
  67149. /**
  67150. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67151. */
  67152. static EmbossKernel: number[];
  67153. /**
  67154. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67155. */
  67156. static GaussianKernel: number[];
  67157. }
  67158. }
  67159. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67160. import { Nullable } from "babylonjs/types";
  67161. import { Vector2 } from "babylonjs/Maths/math.vector";
  67162. import { Camera } from "babylonjs/Cameras/camera";
  67163. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67164. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67165. import { Engine } from "babylonjs/Engines/engine";
  67166. import { Scene } from "babylonjs/scene";
  67167. /**
  67168. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67169. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67170. * based on samples that have a large difference in distance than the center pixel.
  67171. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67172. */
  67173. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67174. direction: Vector2;
  67175. /**
  67176. * Creates a new instance CircleOfConfusionPostProcess
  67177. * @param name The name of the effect.
  67178. * @param scene The scene the effect belongs to.
  67179. * @param direction The direction the blur should be applied.
  67180. * @param kernel The size of the kernel used to blur.
  67181. * @param options The required width/height ratio to downsize to before computing the render pass.
  67182. * @param camera The camera to apply the render pass to.
  67183. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67184. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67186. * @param engine The engine which the post process will be applied. (default: current engine)
  67187. * @param reusable If the post process can be reused on the same frame. (default: false)
  67188. * @param textureType Type of textures used when performing the post process. (default: 0)
  67189. * @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)
  67190. */
  67191. 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);
  67192. }
  67193. }
  67194. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67195. /** @hidden */
  67196. export var depthOfFieldMergePixelShader: {
  67197. name: string;
  67198. shader: string;
  67199. };
  67200. }
  67201. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67202. import { Nullable } from "babylonjs/types";
  67203. import { Camera } from "babylonjs/Cameras/camera";
  67204. import { Effect } from "babylonjs/Materials/effect";
  67205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67206. import { Engine } from "babylonjs/Engines/engine";
  67207. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67208. /**
  67209. * Options to be set when merging outputs from the default pipeline.
  67210. */
  67211. export class DepthOfFieldMergePostProcessOptions {
  67212. /**
  67213. * The original image to merge on top of
  67214. */
  67215. originalFromInput: PostProcess;
  67216. /**
  67217. * Parameters to perform the merge of the depth of field effect
  67218. */
  67219. depthOfField?: {
  67220. circleOfConfusion: PostProcess;
  67221. blurSteps: Array<PostProcess>;
  67222. };
  67223. /**
  67224. * Parameters to perform the merge of bloom effect
  67225. */
  67226. bloom?: {
  67227. blurred: PostProcess;
  67228. weight: number;
  67229. };
  67230. }
  67231. /**
  67232. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67233. */
  67234. export class DepthOfFieldMergePostProcess extends PostProcess {
  67235. private blurSteps;
  67236. /**
  67237. * Creates a new instance of DepthOfFieldMergePostProcess
  67238. * @param name The name of the effect.
  67239. * @param originalFromInput Post process which's input will be used for the merge.
  67240. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67241. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67242. * @param options The required width/height ratio to downsize to before computing the render pass.
  67243. * @param camera The camera to apply the render pass to.
  67244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67245. * @param engine The engine which the post process will be applied. (default: current engine)
  67246. * @param reusable If the post process can be reused on the same frame. (default: false)
  67247. * @param textureType Type of textures used when performing the post process. (default: 0)
  67248. * @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)
  67249. */
  67250. 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);
  67251. /**
  67252. * Updates the effect with the current post process compile time values and recompiles the shader.
  67253. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67254. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67255. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67256. * @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
  67257. * @param onCompiled Called when the shader has been compiled.
  67258. * @param onError Called if there is an error when compiling a shader.
  67259. */
  67260. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67261. }
  67262. }
  67263. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67264. import { Nullable } from "babylonjs/types";
  67265. import { Camera } from "babylonjs/Cameras/camera";
  67266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67267. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67268. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67269. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67270. import { Scene } from "babylonjs/scene";
  67271. /**
  67272. * Specifies the level of max blur that should be applied when using the depth of field effect
  67273. */
  67274. export enum DepthOfFieldEffectBlurLevel {
  67275. /**
  67276. * Subtle blur
  67277. */
  67278. Low = 0,
  67279. /**
  67280. * Medium blur
  67281. */
  67282. Medium = 1,
  67283. /**
  67284. * Large blur
  67285. */
  67286. High = 2
  67287. }
  67288. /**
  67289. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67290. */
  67291. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67292. private _circleOfConfusion;
  67293. /**
  67294. * @hidden Internal, blurs from high to low
  67295. */
  67296. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67297. private _depthOfFieldBlurY;
  67298. private _dofMerge;
  67299. /**
  67300. * @hidden Internal post processes in depth of field effect
  67301. */
  67302. _effects: Array<PostProcess>;
  67303. /**
  67304. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67305. */
  67306. set focalLength(value: number);
  67307. get focalLength(): number;
  67308. /**
  67309. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67310. */
  67311. set fStop(value: number);
  67312. get fStop(): number;
  67313. /**
  67314. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67315. */
  67316. set focusDistance(value: number);
  67317. get focusDistance(): number;
  67318. /**
  67319. * 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.
  67320. */
  67321. set lensSize(value: number);
  67322. get lensSize(): number;
  67323. /**
  67324. * Creates a new instance DepthOfFieldEffect
  67325. * @param scene The scene the effect belongs to.
  67326. * @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.
  67327. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67328. * @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)
  67329. */
  67330. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67331. /**
  67332. * Get the current class name of the current effet
  67333. * @returns "DepthOfFieldEffect"
  67334. */
  67335. getClassName(): string;
  67336. /**
  67337. * 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.
  67338. */
  67339. set depthTexture(value: RenderTargetTexture);
  67340. /**
  67341. * Disposes each of the internal effects for a given camera.
  67342. * @param camera The camera to dispose the effect on.
  67343. */
  67344. disposeEffects(camera: Camera): void;
  67345. /**
  67346. * @hidden Internal
  67347. */
  67348. _updateEffects(): void;
  67349. /**
  67350. * Internal
  67351. * @returns if all the contained post processes are ready.
  67352. * @hidden
  67353. */
  67354. _isReady(): boolean;
  67355. }
  67356. }
  67357. declare module "babylonjs/Shaders/displayPass.fragment" {
  67358. /** @hidden */
  67359. export var displayPassPixelShader: {
  67360. name: string;
  67361. shader: string;
  67362. };
  67363. }
  67364. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67365. import { Nullable } from "babylonjs/types";
  67366. import { Camera } from "babylonjs/Cameras/camera";
  67367. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67368. import { Engine } from "babylonjs/Engines/engine";
  67369. import "babylonjs/Shaders/displayPass.fragment";
  67370. /**
  67371. * DisplayPassPostProcess which produces an output the same as it's input
  67372. */
  67373. export class DisplayPassPostProcess extends PostProcess {
  67374. /**
  67375. * Creates the DisplayPassPostProcess
  67376. * @param name The name of the effect.
  67377. * @param options The required width/height ratio to downsize to before computing the render pass.
  67378. * @param camera The camera to apply the render pass to.
  67379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67380. * @param engine The engine which the post process will be applied. (default: current engine)
  67381. * @param reusable If the post process can be reused on the same frame. (default: false)
  67382. */
  67383. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67384. }
  67385. }
  67386. declare module "babylonjs/Shaders/filter.fragment" {
  67387. /** @hidden */
  67388. export var filterPixelShader: {
  67389. name: string;
  67390. shader: string;
  67391. };
  67392. }
  67393. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67394. import { Nullable } from "babylonjs/types";
  67395. import { Matrix } from "babylonjs/Maths/math.vector";
  67396. import { Camera } from "babylonjs/Cameras/camera";
  67397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67398. import { Engine } from "babylonjs/Engines/engine";
  67399. import "babylonjs/Shaders/filter.fragment";
  67400. /**
  67401. * Applies a kernel filter to the image
  67402. */
  67403. export class FilterPostProcess extends PostProcess {
  67404. /** The matrix to be applied to the image */
  67405. kernelMatrix: Matrix;
  67406. /**
  67407. *
  67408. * @param name The name of the effect.
  67409. * @param kernelMatrix The matrix to be applied to the image
  67410. * @param options The required width/height ratio to downsize to before computing the render pass.
  67411. * @param camera The camera to apply the render pass to.
  67412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67413. * @param engine The engine which the post process will be applied. (default: current engine)
  67414. * @param reusable If the post process can be reused on the same frame. (default: false)
  67415. */
  67416. constructor(name: string,
  67417. /** The matrix to be applied to the image */
  67418. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67419. }
  67420. }
  67421. declare module "babylonjs/Shaders/fxaa.fragment" {
  67422. /** @hidden */
  67423. export var fxaaPixelShader: {
  67424. name: string;
  67425. shader: string;
  67426. };
  67427. }
  67428. declare module "babylonjs/Shaders/fxaa.vertex" {
  67429. /** @hidden */
  67430. export var fxaaVertexShader: {
  67431. name: string;
  67432. shader: string;
  67433. };
  67434. }
  67435. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67436. import { Nullable } from "babylonjs/types";
  67437. import { Camera } from "babylonjs/Cameras/camera";
  67438. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67439. import { Engine } from "babylonjs/Engines/engine";
  67440. import "babylonjs/Shaders/fxaa.fragment";
  67441. import "babylonjs/Shaders/fxaa.vertex";
  67442. /**
  67443. * Fxaa post process
  67444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67445. */
  67446. export class FxaaPostProcess extends PostProcess {
  67447. /** @hidden */
  67448. texelWidth: number;
  67449. /** @hidden */
  67450. texelHeight: number;
  67451. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67452. private _getDefines;
  67453. }
  67454. }
  67455. declare module "babylonjs/Shaders/grain.fragment" {
  67456. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67457. /** @hidden */
  67458. export var grainPixelShader: {
  67459. name: string;
  67460. shader: string;
  67461. };
  67462. }
  67463. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67464. import { Nullable } from "babylonjs/types";
  67465. import { Camera } from "babylonjs/Cameras/camera";
  67466. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67467. import { Engine } from "babylonjs/Engines/engine";
  67468. import "babylonjs/Shaders/grain.fragment";
  67469. /**
  67470. * The GrainPostProcess adds noise to the image at mid luminance levels
  67471. */
  67472. export class GrainPostProcess extends PostProcess {
  67473. /**
  67474. * The intensity of the grain added (default: 30)
  67475. */
  67476. intensity: number;
  67477. /**
  67478. * If the grain should be randomized on every frame
  67479. */
  67480. animated: boolean;
  67481. /**
  67482. * Creates a new instance of @see GrainPostProcess
  67483. * @param name The name of the effect.
  67484. * @param options The required width/height ratio to downsize to before computing the render pass.
  67485. * @param camera The camera to apply the render pass to.
  67486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67487. * @param engine The engine which the post process will be applied. (default: current engine)
  67488. * @param reusable If the post process can be reused on the same frame. (default: false)
  67489. * @param textureType Type of textures used when performing the post process. (default: 0)
  67490. * @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)
  67491. */
  67492. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67493. }
  67494. }
  67495. declare module "babylonjs/Shaders/highlights.fragment" {
  67496. /** @hidden */
  67497. export var highlightsPixelShader: {
  67498. name: string;
  67499. shader: string;
  67500. };
  67501. }
  67502. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67503. import { Nullable } from "babylonjs/types";
  67504. import { Camera } from "babylonjs/Cameras/camera";
  67505. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67506. import { Engine } from "babylonjs/Engines/engine";
  67507. import "babylonjs/Shaders/highlights.fragment";
  67508. /**
  67509. * Extracts highlights from the image
  67510. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67511. */
  67512. export class HighlightsPostProcess extends PostProcess {
  67513. /**
  67514. * Extracts highlights from the image
  67515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67516. * @param name The name of the effect.
  67517. * @param options The required width/height ratio to downsize to before computing the render pass.
  67518. * @param camera The camera to apply the render pass to.
  67519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67520. * @param engine The engine which the post process will be applied. (default: current engine)
  67521. * @param reusable If the post process can be reused on the same frame. (default: false)
  67522. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67523. */
  67524. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67525. }
  67526. }
  67527. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67528. /** @hidden */
  67529. export var mrtFragmentDeclaration: {
  67530. name: string;
  67531. shader: string;
  67532. };
  67533. }
  67534. declare module "babylonjs/Shaders/geometry.fragment" {
  67535. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67536. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67537. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67538. /** @hidden */
  67539. export var geometryPixelShader: {
  67540. name: string;
  67541. shader: string;
  67542. };
  67543. }
  67544. declare module "babylonjs/Shaders/geometry.vertex" {
  67545. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67548. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67550. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67551. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67552. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67553. /** @hidden */
  67554. export var geometryVertexShader: {
  67555. name: string;
  67556. shader: string;
  67557. };
  67558. }
  67559. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67560. import { Matrix } from "babylonjs/Maths/math.vector";
  67561. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67562. import { Mesh } from "babylonjs/Meshes/mesh";
  67563. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67564. import { Effect } from "babylonjs/Materials/effect";
  67565. import { Scene } from "babylonjs/scene";
  67566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67567. import "babylonjs/Shaders/geometry.fragment";
  67568. import "babylonjs/Shaders/geometry.vertex";
  67569. /** @hidden */
  67570. interface ISavedTransformationMatrix {
  67571. world: Matrix;
  67572. viewProjection: Matrix;
  67573. }
  67574. /**
  67575. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67576. */
  67577. export class GeometryBufferRenderer {
  67578. /**
  67579. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67580. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67581. */
  67582. static readonly POSITION_TEXTURE_TYPE: number;
  67583. /**
  67584. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67585. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67586. */
  67587. static readonly VELOCITY_TEXTURE_TYPE: number;
  67588. /**
  67589. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67590. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67591. */
  67592. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67593. /**
  67594. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67595. * in order to compute objects velocities when enableVelocity is set to "true"
  67596. * @hidden
  67597. */
  67598. _previousTransformationMatrices: {
  67599. [index: number]: ISavedTransformationMatrix;
  67600. };
  67601. /**
  67602. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67603. * in order to compute objects velocities when enableVelocity is set to "true"
  67604. * @hidden
  67605. */
  67606. _previousBonesTransformationMatrices: {
  67607. [index: number]: Float32Array;
  67608. };
  67609. /**
  67610. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67611. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67612. */
  67613. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67614. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67615. renderTransparentMeshes: boolean;
  67616. private _scene;
  67617. private _multiRenderTarget;
  67618. private _ratio;
  67619. private _enablePosition;
  67620. private _enableVelocity;
  67621. private _enableReflectivity;
  67622. private _positionIndex;
  67623. private _velocityIndex;
  67624. private _reflectivityIndex;
  67625. protected _effect: Effect;
  67626. protected _cachedDefines: string;
  67627. /**
  67628. * Set the render list (meshes to be rendered) used in the G buffer.
  67629. */
  67630. set renderList(meshes: Mesh[]);
  67631. /**
  67632. * Gets wether or not G buffer are supported by the running hardware.
  67633. * This requires draw buffer supports
  67634. */
  67635. get isSupported(): boolean;
  67636. /**
  67637. * Returns the index of the given texture type in the G-Buffer textures array
  67638. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67639. * @returns the index of the given texture type in the G-Buffer textures array
  67640. */
  67641. getTextureIndex(textureType: number): number;
  67642. /**
  67643. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67644. */
  67645. get enablePosition(): boolean;
  67646. /**
  67647. * Sets whether or not objects positions are enabled for the G buffer.
  67648. */
  67649. set enablePosition(enable: boolean);
  67650. /**
  67651. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67652. */
  67653. get enableVelocity(): boolean;
  67654. /**
  67655. * Sets wether or not objects velocities are enabled for the G buffer.
  67656. */
  67657. set enableVelocity(enable: boolean);
  67658. /**
  67659. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67660. */
  67661. get enableReflectivity(): boolean;
  67662. /**
  67663. * Sets wether or not objects roughness are enabled for the G buffer.
  67664. */
  67665. set enableReflectivity(enable: boolean);
  67666. /**
  67667. * Gets the scene associated with the buffer.
  67668. */
  67669. get scene(): Scene;
  67670. /**
  67671. * Gets the ratio used by the buffer during its creation.
  67672. * How big is the buffer related to the main canvas.
  67673. */
  67674. get ratio(): number;
  67675. /** @hidden */
  67676. static _SceneComponentInitialization: (scene: Scene) => void;
  67677. /**
  67678. * Creates a new G Buffer for the scene
  67679. * @param scene The scene the buffer belongs to
  67680. * @param ratio How big is the buffer related to the main canvas.
  67681. */
  67682. constructor(scene: Scene, ratio?: number);
  67683. /**
  67684. * Checks wether everything is ready to render a submesh to the G buffer.
  67685. * @param subMesh the submesh to check readiness for
  67686. * @param useInstances is the mesh drawn using instance or not
  67687. * @returns true if ready otherwise false
  67688. */
  67689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67690. /**
  67691. * Gets the current underlying G Buffer.
  67692. * @returns the buffer
  67693. */
  67694. getGBuffer(): MultiRenderTarget;
  67695. /**
  67696. * Gets the number of samples used to render the buffer (anti aliasing).
  67697. */
  67698. get samples(): number;
  67699. /**
  67700. * Sets the number of samples used to render the buffer (anti aliasing).
  67701. */
  67702. set samples(value: number);
  67703. /**
  67704. * Disposes the renderer and frees up associated resources.
  67705. */
  67706. dispose(): void;
  67707. protected _createRenderTargets(): void;
  67708. private _copyBonesTransformationMatrices;
  67709. }
  67710. }
  67711. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  67712. import { Nullable } from "babylonjs/types";
  67713. import { Scene } from "babylonjs/scene";
  67714. import { ISceneComponent } from "babylonjs/sceneComponent";
  67715. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  67716. module "babylonjs/scene" {
  67717. interface Scene {
  67718. /** @hidden (Backing field) */
  67719. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67720. /**
  67721. * Gets or Sets the current geometry buffer associated to the scene.
  67722. */
  67723. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67724. /**
  67725. * Enables a GeometryBufferRender and associates it with the scene
  67726. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67727. * @returns the GeometryBufferRenderer
  67728. */
  67729. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67730. /**
  67731. * Disables the GeometryBufferRender associated with the scene
  67732. */
  67733. disableGeometryBufferRenderer(): void;
  67734. }
  67735. }
  67736. /**
  67737. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67738. * in several rendering techniques.
  67739. */
  67740. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67741. /**
  67742. * The component name helpful to identify the component in the list of scene components.
  67743. */
  67744. readonly name: string;
  67745. /**
  67746. * The scene the component belongs to.
  67747. */
  67748. scene: Scene;
  67749. /**
  67750. * Creates a new instance of the component for the given scene
  67751. * @param scene Defines the scene to register the component in
  67752. */
  67753. constructor(scene: Scene);
  67754. /**
  67755. * Registers the component in a given scene
  67756. */
  67757. register(): void;
  67758. /**
  67759. * Rebuilds the elements related to this component in case of
  67760. * context lost for instance.
  67761. */
  67762. rebuild(): void;
  67763. /**
  67764. * Disposes the component and the associated ressources
  67765. */
  67766. dispose(): void;
  67767. private _gatherRenderTargets;
  67768. }
  67769. }
  67770. declare module "babylonjs/Shaders/motionBlur.fragment" {
  67771. /** @hidden */
  67772. export var motionBlurPixelShader: {
  67773. name: string;
  67774. shader: string;
  67775. };
  67776. }
  67777. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  67778. import { Nullable } from "babylonjs/types";
  67779. import { Camera } from "babylonjs/Cameras/camera";
  67780. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67781. import { Scene } from "babylonjs/scene";
  67782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67783. import "babylonjs/Animations/animatable";
  67784. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67785. import "babylonjs/Shaders/motionBlur.fragment";
  67786. import { Engine } from "babylonjs/Engines/engine";
  67787. /**
  67788. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67789. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67790. * As an example, all you have to do is to create the post-process:
  67791. * var mb = new BABYLON.MotionBlurPostProcess(
  67792. * 'mb', // The name of the effect.
  67793. * scene, // The scene containing the objects to blur according to their velocity.
  67794. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67795. * camera // The camera to apply the render pass to.
  67796. * );
  67797. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67798. */
  67799. export class MotionBlurPostProcess extends PostProcess {
  67800. /**
  67801. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67802. */
  67803. motionStrength: number;
  67804. /**
  67805. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67806. */
  67807. get motionBlurSamples(): number;
  67808. /**
  67809. * Sets the number of iterations to be used for motion blur quality
  67810. */
  67811. set motionBlurSamples(samples: number);
  67812. private _motionBlurSamples;
  67813. private _geometryBufferRenderer;
  67814. /**
  67815. * Creates a new instance MotionBlurPostProcess
  67816. * @param name The name of the effect.
  67817. * @param scene The scene containing the objects to blur according to their velocity.
  67818. * @param options The required width/height ratio to downsize to before computing the render pass.
  67819. * @param camera The camera to apply the render pass to.
  67820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67821. * @param engine The engine which the post process will be applied. (default: current engine)
  67822. * @param reusable If the post process can be reused on the same frame. (default: false)
  67823. * @param textureType Type of textures used when performing the post process. (default: 0)
  67824. * @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)
  67825. */
  67826. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67827. /**
  67828. * Excludes the given skinned mesh from computing bones velocities.
  67829. * 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.
  67830. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67831. */
  67832. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67833. /**
  67834. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67835. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67836. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67837. */
  67838. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67839. /**
  67840. * Disposes the post process.
  67841. * @param camera The camera to dispose the post process on.
  67842. */
  67843. dispose(camera?: Camera): void;
  67844. }
  67845. }
  67846. declare module "babylonjs/Shaders/refraction.fragment" {
  67847. /** @hidden */
  67848. export var refractionPixelShader: {
  67849. name: string;
  67850. shader: string;
  67851. };
  67852. }
  67853. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  67854. import { Color3 } from "babylonjs/Maths/math.color";
  67855. import { Camera } from "babylonjs/Cameras/camera";
  67856. import { Texture } from "babylonjs/Materials/Textures/texture";
  67857. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67858. import { Engine } from "babylonjs/Engines/engine";
  67859. import "babylonjs/Shaders/refraction.fragment";
  67860. /**
  67861. * Post process which applies a refractin texture
  67862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67863. */
  67864. export class RefractionPostProcess extends PostProcess {
  67865. /** the base color of the refraction (used to taint the rendering) */
  67866. color: Color3;
  67867. /** simulated refraction depth */
  67868. depth: number;
  67869. /** the coefficient of the base color (0 to remove base color tainting) */
  67870. colorLevel: number;
  67871. private _refTexture;
  67872. private _ownRefractionTexture;
  67873. /**
  67874. * Gets or sets the refraction texture
  67875. * Please note that you are responsible for disposing the texture if you set it manually
  67876. */
  67877. get refractionTexture(): Texture;
  67878. set refractionTexture(value: Texture);
  67879. /**
  67880. * Initializes the RefractionPostProcess
  67881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67882. * @param name The name of the effect.
  67883. * @param refractionTextureUrl Url of the refraction texture to use
  67884. * @param color the base color of the refraction (used to taint the rendering)
  67885. * @param depth simulated refraction depth
  67886. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67887. * @param camera The camera to apply the render pass to.
  67888. * @param options The required width/height ratio to downsize to before computing the render pass.
  67889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67890. * @param engine The engine which the post process will be applied. (default: current engine)
  67891. * @param reusable If the post process can be reused on the same frame. (default: false)
  67892. */
  67893. constructor(name: string, refractionTextureUrl: string,
  67894. /** the base color of the refraction (used to taint the rendering) */
  67895. color: Color3,
  67896. /** simulated refraction depth */
  67897. depth: number,
  67898. /** the coefficient of the base color (0 to remove base color tainting) */
  67899. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67900. /**
  67901. * Disposes of the post process
  67902. * @param camera Camera to dispose post process on
  67903. */
  67904. dispose(camera: Camera): void;
  67905. }
  67906. }
  67907. declare module "babylonjs/Shaders/sharpen.fragment" {
  67908. /** @hidden */
  67909. export var sharpenPixelShader: {
  67910. name: string;
  67911. shader: string;
  67912. };
  67913. }
  67914. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  67915. import { Nullable } from "babylonjs/types";
  67916. import { Camera } from "babylonjs/Cameras/camera";
  67917. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67918. import "babylonjs/Shaders/sharpen.fragment";
  67919. import { Engine } from "babylonjs/Engines/engine";
  67920. /**
  67921. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67922. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67923. */
  67924. export class SharpenPostProcess extends PostProcess {
  67925. /**
  67926. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67927. */
  67928. colorAmount: number;
  67929. /**
  67930. * How much sharpness should be applied (default: 0.3)
  67931. */
  67932. edgeAmount: number;
  67933. /**
  67934. * Creates a new instance ConvolutionPostProcess
  67935. * @param name The name of the effect.
  67936. * @param options The required width/height ratio to downsize to before computing the render pass.
  67937. * @param camera The camera to apply the render pass to.
  67938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67939. * @param engine The engine which the post process will be applied. (default: current engine)
  67940. * @param reusable If the post process can be reused on the same frame. (default: false)
  67941. * @param textureType Type of textures used when performing the post process. (default: 0)
  67942. * @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)
  67943. */
  67944. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67945. }
  67946. }
  67947. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  67948. import { Nullable } from "babylonjs/types";
  67949. import { Camera } from "babylonjs/Cameras/camera";
  67950. import { Engine } from "babylonjs/Engines/engine";
  67951. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67952. import { IInspectable } from "babylonjs/Misc/iInspectable";
  67953. /**
  67954. * PostProcessRenderPipeline
  67955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67956. */
  67957. export class PostProcessRenderPipeline {
  67958. private engine;
  67959. private _renderEffects;
  67960. private _renderEffectsForIsolatedPass;
  67961. /**
  67962. * List of inspectable custom properties (used by the Inspector)
  67963. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67964. */
  67965. inspectableCustomProperties: IInspectable[];
  67966. /**
  67967. * @hidden
  67968. */
  67969. protected _cameras: Camera[];
  67970. /** @hidden */
  67971. _name: string;
  67972. /**
  67973. * Gets pipeline name
  67974. */
  67975. get name(): string;
  67976. /** Gets the list of attached cameras */
  67977. get cameras(): Camera[];
  67978. /**
  67979. * Initializes a PostProcessRenderPipeline
  67980. * @param engine engine to add the pipeline to
  67981. * @param name name of the pipeline
  67982. */
  67983. constructor(engine: Engine, name: string);
  67984. /**
  67985. * Gets the class name
  67986. * @returns "PostProcessRenderPipeline"
  67987. */
  67988. getClassName(): string;
  67989. /**
  67990. * If all the render effects in the pipeline are supported
  67991. */
  67992. get isSupported(): boolean;
  67993. /**
  67994. * Adds an effect to the pipeline
  67995. * @param renderEffect the effect to add
  67996. */
  67997. addEffect(renderEffect: PostProcessRenderEffect): void;
  67998. /** @hidden */
  67999. _rebuild(): void;
  68000. /** @hidden */
  68001. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68002. /** @hidden */
  68003. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68004. /** @hidden */
  68005. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68006. /** @hidden */
  68007. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68008. /** @hidden */
  68009. _attachCameras(cameras: Camera, unique: boolean): void;
  68010. /** @hidden */
  68011. _attachCameras(cameras: Camera[], unique: boolean): void;
  68012. /** @hidden */
  68013. _detachCameras(cameras: Camera): void;
  68014. /** @hidden */
  68015. _detachCameras(cameras: Nullable<Camera[]>): void;
  68016. /** @hidden */
  68017. _update(): void;
  68018. /** @hidden */
  68019. _reset(): void;
  68020. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68021. /**
  68022. * Disposes of the pipeline
  68023. */
  68024. dispose(): void;
  68025. }
  68026. }
  68027. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68028. import { Camera } from "babylonjs/Cameras/camera";
  68029. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68030. /**
  68031. * PostProcessRenderPipelineManager class
  68032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68033. */
  68034. export class PostProcessRenderPipelineManager {
  68035. private _renderPipelines;
  68036. /**
  68037. * Initializes a PostProcessRenderPipelineManager
  68038. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68039. */
  68040. constructor();
  68041. /**
  68042. * Gets the list of supported render pipelines
  68043. */
  68044. get supportedPipelines(): PostProcessRenderPipeline[];
  68045. /**
  68046. * Adds a pipeline to the manager
  68047. * @param renderPipeline The pipeline to add
  68048. */
  68049. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68050. /**
  68051. * Attaches a camera to the pipeline
  68052. * @param renderPipelineName The name of the pipeline to attach to
  68053. * @param cameras the camera to attach
  68054. * @param unique if the camera can be attached multiple times to the pipeline
  68055. */
  68056. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68057. /**
  68058. * Detaches a camera from the pipeline
  68059. * @param renderPipelineName The name of the pipeline to detach from
  68060. * @param cameras the camera to detach
  68061. */
  68062. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68063. /**
  68064. * Enables an effect by name on a pipeline
  68065. * @param renderPipelineName the name of the pipeline to enable the effect in
  68066. * @param renderEffectName the name of the effect to enable
  68067. * @param cameras the cameras that the effect should be enabled on
  68068. */
  68069. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68070. /**
  68071. * Disables an effect by name on a pipeline
  68072. * @param renderPipelineName the name of the pipeline to disable the effect in
  68073. * @param renderEffectName the name of the effect to disable
  68074. * @param cameras the cameras that the effect should be disabled on
  68075. */
  68076. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68077. /**
  68078. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68079. */
  68080. update(): void;
  68081. /** @hidden */
  68082. _rebuild(): void;
  68083. /**
  68084. * Disposes of the manager and pipelines
  68085. */
  68086. dispose(): void;
  68087. }
  68088. }
  68089. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68090. import { ISceneComponent } from "babylonjs/sceneComponent";
  68091. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68092. import { Scene } from "babylonjs/scene";
  68093. module "babylonjs/scene" {
  68094. interface Scene {
  68095. /** @hidden (Backing field) */
  68096. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68097. /**
  68098. * Gets the postprocess render pipeline manager
  68099. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68100. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68101. */
  68102. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68103. }
  68104. }
  68105. /**
  68106. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68107. */
  68108. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68109. /**
  68110. * The component name helpfull to identify the component in the list of scene components.
  68111. */
  68112. readonly name: string;
  68113. /**
  68114. * The scene the component belongs to.
  68115. */
  68116. scene: Scene;
  68117. /**
  68118. * Creates a new instance of the component for the given scene
  68119. * @param scene Defines the scene to register the component in
  68120. */
  68121. constructor(scene: Scene);
  68122. /**
  68123. * Registers the component in a given scene
  68124. */
  68125. register(): void;
  68126. /**
  68127. * Rebuilds the elements related to this component in case of
  68128. * context lost for instance.
  68129. */
  68130. rebuild(): void;
  68131. /**
  68132. * Disposes the component and the associated ressources
  68133. */
  68134. dispose(): void;
  68135. private _gatherRenderTargets;
  68136. }
  68137. }
  68138. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68139. import { Nullable } from "babylonjs/types";
  68140. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68141. import { Camera } from "babylonjs/Cameras/camera";
  68142. import { IDisposable } from "babylonjs/scene";
  68143. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68144. import { Scene } from "babylonjs/scene";
  68145. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68146. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68147. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68148. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68149. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68150. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68151. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68152. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68153. import { Animation } from "babylonjs/Animations/animation";
  68154. /**
  68155. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68156. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68157. */
  68158. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68159. private _scene;
  68160. private _camerasToBeAttached;
  68161. /**
  68162. * ID of the sharpen post process,
  68163. */
  68164. private readonly SharpenPostProcessId;
  68165. /**
  68166. * @ignore
  68167. * ID of the image processing post process;
  68168. */
  68169. readonly ImageProcessingPostProcessId: string;
  68170. /**
  68171. * @ignore
  68172. * ID of the Fast Approximate Anti-Aliasing post process;
  68173. */
  68174. readonly FxaaPostProcessId: string;
  68175. /**
  68176. * ID of the chromatic aberration post process,
  68177. */
  68178. private readonly ChromaticAberrationPostProcessId;
  68179. /**
  68180. * ID of the grain post process
  68181. */
  68182. private readonly GrainPostProcessId;
  68183. /**
  68184. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68185. */
  68186. sharpen: SharpenPostProcess;
  68187. private _sharpenEffect;
  68188. private bloom;
  68189. /**
  68190. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68191. */
  68192. depthOfField: DepthOfFieldEffect;
  68193. /**
  68194. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68195. */
  68196. fxaa: FxaaPostProcess;
  68197. /**
  68198. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68199. */
  68200. imageProcessing: ImageProcessingPostProcess;
  68201. /**
  68202. * Chromatic aberration post process which will shift rgb colors in the image
  68203. */
  68204. chromaticAberration: ChromaticAberrationPostProcess;
  68205. private _chromaticAberrationEffect;
  68206. /**
  68207. * Grain post process which add noise to the image
  68208. */
  68209. grain: GrainPostProcess;
  68210. private _grainEffect;
  68211. /**
  68212. * Glow post process which adds a glow to emissive areas of the image
  68213. */
  68214. private _glowLayer;
  68215. /**
  68216. * Animations which can be used to tweak settings over a period of time
  68217. */
  68218. animations: Animation[];
  68219. private _imageProcessingConfigurationObserver;
  68220. private _sharpenEnabled;
  68221. private _bloomEnabled;
  68222. private _depthOfFieldEnabled;
  68223. private _depthOfFieldBlurLevel;
  68224. private _fxaaEnabled;
  68225. private _imageProcessingEnabled;
  68226. private _defaultPipelineTextureType;
  68227. private _bloomScale;
  68228. private _chromaticAberrationEnabled;
  68229. private _grainEnabled;
  68230. private _buildAllowed;
  68231. /**
  68232. * Gets active scene
  68233. */
  68234. get scene(): Scene;
  68235. /**
  68236. * Enable or disable the sharpen process from the pipeline
  68237. */
  68238. set sharpenEnabled(enabled: boolean);
  68239. get sharpenEnabled(): boolean;
  68240. private _resizeObserver;
  68241. private _hardwareScaleLevel;
  68242. private _bloomKernel;
  68243. /**
  68244. * Specifies the size of the bloom blur kernel, relative to the final output size
  68245. */
  68246. get bloomKernel(): number;
  68247. set bloomKernel(value: number);
  68248. /**
  68249. * Specifies the weight of the bloom in the final rendering
  68250. */
  68251. private _bloomWeight;
  68252. /**
  68253. * Specifies the luma threshold for the area that will be blurred by the bloom
  68254. */
  68255. private _bloomThreshold;
  68256. private _hdr;
  68257. /**
  68258. * The strength of the bloom.
  68259. */
  68260. set bloomWeight(value: number);
  68261. get bloomWeight(): number;
  68262. /**
  68263. * The strength of the bloom.
  68264. */
  68265. set bloomThreshold(value: number);
  68266. get bloomThreshold(): number;
  68267. /**
  68268. * The scale of the bloom, lower value will provide better performance.
  68269. */
  68270. set bloomScale(value: number);
  68271. get bloomScale(): number;
  68272. /**
  68273. * Enable or disable the bloom from the pipeline
  68274. */
  68275. set bloomEnabled(enabled: boolean);
  68276. get bloomEnabled(): boolean;
  68277. private _rebuildBloom;
  68278. /**
  68279. * If the depth of field is enabled.
  68280. */
  68281. get depthOfFieldEnabled(): boolean;
  68282. set depthOfFieldEnabled(enabled: boolean);
  68283. /**
  68284. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68285. */
  68286. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68287. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68288. /**
  68289. * If the anti aliasing is enabled.
  68290. */
  68291. set fxaaEnabled(enabled: boolean);
  68292. get fxaaEnabled(): boolean;
  68293. private _samples;
  68294. /**
  68295. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68296. */
  68297. set samples(sampleCount: number);
  68298. get samples(): number;
  68299. /**
  68300. * If image processing is enabled.
  68301. */
  68302. set imageProcessingEnabled(enabled: boolean);
  68303. get imageProcessingEnabled(): boolean;
  68304. /**
  68305. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68306. */
  68307. set glowLayerEnabled(enabled: boolean);
  68308. get glowLayerEnabled(): boolean;
  68309. /**
  68310. * Gets the glow layer (or null if not defined)
  68311. */
  68312. get glowLayer(): Nullable<GlowLayer>;
  68313. /**
  68314. * Enable or disable the chromaticAberration process from the pipeline
  68315. */
  68316. set chromaticAberrationEnabled(enabled: boolean);
  68317. get chromaticAberrationEnabled(): boolean;
  68318. /**
  68319. * Enable or disable the grain process from the pipeline
  68320. */
  68321. set grainEnabled(enabled: boolean);
  68322. get grainEnabled(): boolean;
  68323. /**
  68324. * @constructor
  68325. * @param name - The rendering pipeline name (default: "")
  68326. * @param hdr - If high dynamic range textures should be used (default: true)
  68327. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68328. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68329. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68330. */
  68331. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68332. /**
  68333. * Get the class name
  68334. * @returns "DefaultRenderingPipeline"
  68335. */
  68336. getClassName(): string;
  68337. /**
  68338. * Force the compilation of the entire pipeline.
  68339. */
  68340. prepare(): void;
  68341. private _hasCleared;
  68342. private _prevPostProcess;
  68343. private _prevPrevPostProcess;
  68344. private _setAutoClearAndTextureSharing;
  68345. private _depthOfFieldSceneObserver;
  68346. private _buildPipeline;
  68347. private _disposePostProcesses;
  68348. /**
  68349. * Adds a camera to the pipeline
  68350. * @param camera the camera to be added
  68351. */
  68352. addCamera(camera: Camera): void;
  68353. /**
  68354. * Removes a camera from the pipeline
  68355. * @param camera the camera to remove
  68356. */
  68357. removeCamera(camera: Camera): void;
  68358. /**
  68359. * Dispose of the pipeline and stop all post processes
  68360. */
  68361. dispose(): void;
  68362. /**
  68363. * Serialize the rendering pipeline (Used when exporting)
  68364. * @returns the serialized object
  68365. */
  68366. serialize(): any;
  68367. /**
  68368. * Parse the serialized pipeline
  68369. * @param source Source pipeline.
  68370. * @param scene The scene to load the pipeline to.
  68371. * @param rootUrl The URL of the serialized pipeline.
  68372. * @returns An instantiated pipeline from the serialized object.
  68373. */
  68374. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68375. }
  68376. }
  68377. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68378. /** @hidden */
  68379. export var lensHighlightsPixelShader: {
  68380. name: string;
  68381. shader: string;
  68382. };
  68383. }
  68384. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68385. /** @hidden */
  68386. export var depthOfFieldPixelShader: {
  68387. name: string;
  68388. shader: string;
  68389. };
  68390. }
  68391. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68392. import { Camera } from "babylonjs/Cameras/camera";
  68393. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68394. import { Scene } from "babylonjs/scene";
  68395. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68396. import "babylonjs/Shaders/chromaticAberration.fragment";
  68397. import "babylonjs/Shaders/lensHighlights.fragment";
  68398. import "babylonjs/Shaders/depthOfField.fragment";
  68399. /**
  68400. * BABYLON.JS Chromatic Aberration GLSL Shader
  68401. * Author: Olivier Guyot
  68402. * Separates very slightly R, G and B colors on the edges of the screen
  68403. * Inspired by Francois Tarlier & Martins Upitis
  68404. */
  68405. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68406. /**
  68407. * @ignore
  68408. * The chromatic aberration PostProcess id in the pipeline
  68409. */
  68410. LensChromaticAberrationEffect: string;
  68411. /**
  68412. * @ignore
  68413. * The highlights enhancing PostProcess id in the pipeline
  68414. */
  68415. HighlightsEnhancingEffect: string;
  68416. /**
  68417. * @ignore
  68418. * The depth-of-field PostProcess id in the pipeline
  68419. */
  68420. LensDepthOfFieldEffect: string;
  68421. private _scene;
  68422. private _depthTexture;
  68423. private _grainTexture;
  68424. private _chromaticAberrationPostProcess;
  68425. private _highlightsPostProcess;
  68426. private _depthOfFieldPostProcess;
  68427. private _edgeBlur;
  68428. private _grainAmount;
  68429. private _chromaticAberration;
  68430. private _distortion;
  68431. private _highlightsGain;
  68432. private _highlightsThreshold;
  68433. private _dofDistance;
  68434. private _dofAperture;
  68435. private _dofDarken;
  68436. private _dofPentagon;
  68437. private _blurNoise;
  68438. /**
  68439. * @constructor
  68440. *
  68441. * Effect parameters are as follow:
  68442. * {
  68443. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68444. * edge_blur: number; // from 0 to x (1 for realism)
  68445. * distortion: number; // from 0 to x (1 for realism)
  68446. * grain_amount: number; // from 0 to 1
  68447. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68448. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68449. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68450. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68451. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68452. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68453. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68454. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68455. * }
  68456. * Note: if an effect parameter is unset, effect is disabled
  68457. *
  68458. * @param name The rendering pipeline name
  68459. * @param parameters - An object containing all parameters (see above)
  68460. * @param scene The scene linked to this pipeline
  68461. * @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)
  68462. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68463. */
  68464. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68465. /**
  68466. * Get the class name
  68467. * @returns "LensRenderingPipeline"
  68468. */
  68469. getClassName(): string;
  68470. /**
  68471. * Gets associated scene
  68472. */
  68473. get scene(): Scene;
  68474. /**
  68475. * Gets or sets the edge blur
  68476. */
  68477. get edgeBlur(): number;
  68478. set edgeBlur(value: number);
  68479. /**
  68480. * Gets or sets the grain amount
  68481. */
  68482. get grainAmount(): number;
  68483. set grainAmount(value: number);
  68484. /**
  68485. * Gets or sets the chromatic aberration amount
  68486. */
  68487. get chromaticAberration(): number;
  68488. set chromaticAberration(value: number);
  68489. /**
  68490. * Gets or sets the depth of field aperture
  68491. */
  68492. get dofAperture(): number;
  68493. set dofAperture(value: number);
  68494. /**
  68495. * Gets or sets the edge distortion
  68496. */
  68497. get edgeDistortion(): number;
  68498. set edgeDistortion(value: number);
  68499. /**
  68500. * Gets or sets the depth of field distortion
  68501. */
  68502. get dofDistortion(): number;
  68503. set dofDistortion(value: number);
  68504. /**
  68505. * Gets or sets the darken out of focus amount
  68506. */
  68507. get darkenOutOfFocus(): number;
  68508. set darkenOutOfFocus(value: number);
  68509. /**
  68510. * Gets or sets a boolean indicating if blur noise is enabled
  68511. */
  68512. get blurNoise(): boolean;
  68513. set blurNoise(value: boolean);
  68514. /**
  68515. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68516. */
  68517. get pentagonBokeh(): boolean;
  68518. set pentagonBokeh(value: boolean);
  68519. /**
  68520. * Gets or sets the highlight grain amount
  68521. */
  68522. get highlightsGain(): number;
  68523. set highlightsGain(value: number);
  68524. /**
  68525. * Gets or sets the highlight threshold
  68526. */
  68527. get highlightsThreshold(): number;
  68528. set highlightsThreshold(value: number);
  68529. /**
  68530. * Sets the amount of blur at the edges
  68531. * @param amount blur amount
  68532. */
  68533. setEdgeBlur(amount: number): void;
  68534. /**
  68535. * Sets edge blur to 0
  68536. */
  68537. disableEdgeBlur(): void;
  68538. /**
  68539. * Sets the amout of grain
  68540. * @param amount Amount of grain
  68541. */
  68542. setGrainAmount(amount: number): void;
  68543. /**
  68544. * Set grain amount to 0
  68545. */
  68546. disableGrain(): void;
  68547. /**
  68548. * Sets the chromatic aberration amount
  68549. * @param amount amount of chromatic aberration
  68550. */
  68551. setChromaticAberration(amount: number): void;
  68552. /**
  68553. * Sets chromatic aberration amount to 0
  68554. */
  68555. disableChromaticAberration(): void;
  68556. /**
  68557. * Sets the EdgeDistortion amount
  68558. * @param amount amount of EdgeDistortion
  68559. */
  68560. setEdgeDistortion(amount: number): void;
  68561. /**
  68562. * Sets edge distortion to 0
  68563. */
  68564. disableEdgeDistortion(): void;
  68565. /**
  68566. * Sets the FocusDistance amount
  68567. * @param amount amount of FocusDistance
  68568. */
  68569. setFocusDistance(amount: number): void;
  68570. /**
  68571. * Disables depth of field
  68572. */
  68573. disableDepthOfField(): void;
  68574. /**
  68575. * Sets the Aperture amount
  68576. * @param amount amount of Aperture
  68577. */
  68578. setAperture(amount: number): void;
  68579. /**
  68580. * Sets the DarkenOutOfFocus amount
  68581. * @param amount amount of DarkenOutOfFocus
  68582. */
  68583. setDarkenOutOfFocus(amount: number): void;
  68584. private _pentagonBokehIsEnabled;
  68585. /**
  68586. * Creates a pentagon bokeh effect
  68587. */
  68588. enablePentagonBokeh(): void;
  68589. /**
  68590. * Disables the pentagon bokeh effect
  68591. */
  68592. disablePentagonBokeh(): void;
  68593. /**
  68594. * Enables noise blur
  68595. */
  68596. enableNoiseBlur(): void;
  68597. /**
  68598. * Disables noise blur
  68599. */
  68600. disableNoiseBlur(): void;
  68601. /**
  68602. * Sets the HighlightsGain amount
  68603. * @param amount amount of HighlightsGain
  68604. */
  68605. setHighlightsGain(amount: number): void;
  68606. /**
  68607. * Sets the HighlightsThreshold amount
  68608. * @param amount amount of HighlightsThreshold
  68609. */
  68610. setHighlightsThreshold(amount: number): void;
  68611. /**
  68612. * Disables highlights
  68613. */
  68614. disableHighlights(): void;
  68615. /**
  68616. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68617. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68618. */
  68619. dispose(disableDepthRender?: boolean): void;
  68620. private _createChromaticAberrationPostProcess;
  68621. private _createHighlightsPostProcess;
  68622. private _createDepthOfFieldPostProcess;
  68623. private _createGrainTexture;
  68624. }
  68625. }
  68626. declare module "babylonjs/Shaders/ssao2.fragment" {
  68627. /** @hidden */
  68628. export var ssao2PixelShader: {
  68629. name: string;
  68630. shader: string;
  68631. };
  68632. }
  68633. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  68634. /** @hidden */
  68635. export var ssaoCombinePixelShader: {
  68636. name: string;
  68637. shader: string;
  68638. };
  68639. }
  68640. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  68641. import { Camera } from "babylonjs/Cameras/camera";
  68642. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68643. import { Scene } from "babylonjs/scene";
  68644. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68645. import "babylonjs/Shaders/ssao2.fragment";
  68646. import "babylonjs/Shaders/ssaoCombine.fragment";
  68647. /**
  68648. * Render pipeline to produce ssao effect
  68649. */
  68650. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68651. /**
  68652. * @ignore
  68653. * The PassPostProcess id in the pipeline that contains the original scene color
  68654. */
  68655. SSAOOriginalSceneColorEffect: string;
  68656. /**
  68657. * @ignore
  68658. * The SSAO PostProcess id in the pipeline
  68659. */
  68660. SSAORenderEffect: string;
  68661. /**
  68662. * @ignore
  68663. * The horizontal blur PostProcess id in the pipeline
  68664. */
  68665. SSAOBlurHRenderEffect: string;
  68666. /**
  68667. * @ignore
  68668. * The vertical blur PostProcess id in the pipeline
  68669. */
  68670. SSAOBlurVRenderEffect: string;
  68671. /**
  68672. * @ignore
  68673. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68674. */
  68675. SSAOCombineRenderEffect: string;
  68676. /**
  68677. * The output strength of the SSAO post-process. Default value is 1.0.
  68678. */
  68679. totalStrength: number;
  68680. /**
  68681. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68682. */
  68683. maxZ: number;
  68684. /**
  68685. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68686. */
  68687. minZAspect: number;
  68688. private _samples;
  68689. /**
  68690. * Number of samples used for the SSAO calculations. Default value is 8
  68691. */
  68692. set samples(n: number);
  68693. get samples(): number;
  68694. private _textureSamples;
  68695. /**
  68696. * Number of samples to use for antialiasing
  68697. */
  68698. set textureSamples(n: number);
  68699. get textureSamples(): number;
  68700. /**
  68701. * Ratio object used for SSAO ratio and blur ratio
  68702. */
  68703. private _ratio;
  68704. /**
  68705. * Dynamically generated sphere sampler.
  68706. */
  68707. private _sampleSphere;
  68708. /**
  68709. * Blur filter offsets
  68710. */
  68711. private _samplerOffsets;
  68712. private _expensiveBlur;
  68713. /**
  68714. * If bilateral blur should be used
  68715. */
  68716. set expensiveBlur(b: boolean);
  68717. get expensiveBlur(): boolean;
  68718. /**
  68719. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68720. */
  68721. radius: number;
  68722. /**
  68723. * The base color of the SSAO post-process
  68724. * The final result is "base + ssao" between [0, 1]
  68725. */
  68726. base: number;
  68727. /**
  68728. * Support test.
  68729. */
  68730. static get IsSupported(): boolean;
  68731. private _scene;
  68732. private _depthTexture;
  68733. private _normalTexture;
  68734. private _randomTexture;
  68735. private _originalColorPostProcess;
  68736. private _ssaoPostProcess;
  68737. private _blurHPostProcess;
  68738. private _blurVPostProcess;
  68739. private _ssaoCombinePostProcess;
  68740. /**
  68741. * Gets active scene
  68742. */
  68743. get scene(): Scene;
  68744. /**
  68745. * @constructor
  68746. * @param name The rendering pipeline name
  68747. * @param scene The scene linked to this pipeline
  68748. * @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 }
  68749. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68750. */
  68751. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68752. /**
  68753. * Get the class name
  68754. * @returns "SSAO2RenderingPipeline"
  68755. */
  68756. getClassName(): string;
  68757. /**
  68758. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68759. */
  68760. dispose(disableGeometryBufferRenderer?: boolean): void;
  68761. private _createBlurPostProcess;
  68762. /** @hidden */
  68763. _rebuild(): void;
  68764. private _bits;
  68765. private _radicalInverse_VdC;
  68766. private _hammersley;
  68767. private _hemisphereSample_uniform;
  68768. private _generateHemisphere;
  68769. private _createSSAOPostProcess;
  68770. private _createSSAOCombinePostProcess;
  68771. private _createRandomTexture;
  68772. /**
  68773. * Serialize the rendering pipeline (Used when exporting)
  68774. * @returns the serialized object
  68775. */
  68776. serialize(): any;
  68777. /**
  68778. * Parse the serialized pipeline
  68779. * @param source Source pipeline.
  68780. * @param scene The scene to load the pipeline to.
  68781. * @param rootUrl The URL of the serialized pipeline.
  68782. * @returns An instantiated pipeline from the serialized object.
  68783. */
  68784. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68785. }
  68786. }
  68787. declare module "babylonjs/Shaders/ssao.fragment" {
  68788. /** @hidden */
  68789. export var ssaoPixelShader: {
  68790. name: string;
  68791. shader: string;
  68792. };
  68793. }
  68794. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  68795. import { Camera } from "babylonjs/Cameras/camera";
  68796. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68797. import { Scene } from "babylonjs/scene";
  68798. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68799. import "babylonjs/Shaders/ssao.fragment";
  68800. import "babylonjs/Shaders/ssaoCombine.fragment";
  68801. /**
  68802. * Render pipeline to produce ssao effect
  68803. */
  68804. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68805. /**
  68806. * @ignore
  68807. * The PassPostProcess id in the pipeline that contains the original scene color
  68808. */
  68809. SSAOOriginalSceneColorEffect: string;
  68810. /**
  68811. * @ignore
  68812. * The SSAO PostProcess id in the pipeline
  68813. */
  68814. SSAORenderEffect: string;
  68815. /**
  68816. * @ignore
  68817. * The horizontal blur PostProcess id in the pipeline
  68818. */
  68819. SSAOBlurHRenderEffect: string;
  68820. /**
  68821. * @ignore
  68822. * The vertical blur PostProcess id in the pipeline
  68823. */
  68824. SSAOBlurVRenderEffect: string;
  68825. /**
  68826. * @ignore
  68827. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68828. */
  68829. SSAOCombineRenderEffect: string;
  68830. /**
  68831. * The output strength of the SSAO post-process. Default value is 1.0.
  68832. */
  68833. totalStrength: number;
  68834. /**
  68835. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68836. */
  68837. radius: number;
  68838. /**
  68839. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68840. * Must not be equal to fallOff and superior to fallOff.
  68841. * Default value is 0.0075
  68842. */
  68843. area: number;
  68844. /**
  68845. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68846. * Must not be equal to area and inferior to area.
  68847. * Default value is 0.000001
  68848. */
  68849. fallOff: number;
  68850. /**
  68851. * The base color of the SSAO post-process
  68852. * The final result is "base + ssao" between [0, 1]
  68853. */
  68854. base: number;
  68855. private _scene;
  68856. private _depthTexture;
  68857. private _randomTexture;
  68858. private _originalColorPostProcess;
  68859. private _ssaoPostProcess;
  68860. private _blurHPostProcess;
  68861. private _blurVPostProcess;
  68862. private _ssaoCombinePostProcess;
  68863. private _firstUpdate;
  68864. /**
  68865. * Gets active scene
  68866. */
  68867. get scene(): Scene;
  68868. /**
  68869. * @constructor
  68870. * @param name - The rendering pipeline name
  68871. * @param scene - The scene linked to this pipeline
  68872. * @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 }
  68873. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68874. */
  68875. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68876. /**
  68877. * Get the class name
  68878. * @returns "SSAORenderingPipeline"
  68879. */
  68880. getClassName(): string;
  68881. /**
  68882. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68883. */
  68884. dispose(disableDepthRender?: boolean): void;
  68885. private _createBlurPostProcess;
  68886. /** @hidden */
  68887. _rebuild(): void;
  68888. private _createSSAOPostProcess;
  68889. private _createSSAOCombinePostProcess;
  68890. private _createRandomTexture;
  68891. }
  68892. }
  68893. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  68894. /** @hidden */
  68895. export var screenSpaceReflectionPixelShader: {
  68896. name: string;
  68897. shader: string;
  68898. };
  68899. }
  68900. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  68901. import { Nullable } from "babylonjs/types";
  68902. import { Camera } from "babylonjs/Cameras/camera";
  68903. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68904. import { Scene } from "babylonjs/scene";
  68905. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  68906. import { Engine } from "babylonjs/Engines/engine";
  68907. /**
  68908. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  68909. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  68910. */
  68911. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  68912. /**
  68913. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  68914. */
  68915. threshold: number;
  68916. /**
  68917. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68918. */
  68919. strength: number;
  68920. /**
  68921. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68922. */
  68923. reflectionSpecularFalloffExponent: number;
  68924. /**
  68925. * 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]
  68926. */
  68927. step: number;
  68928. /**
  68929. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68930. */
  68931. roughnessFactor: number;
  68932. private _geometryBufferRenderer;
  68933. private _enableSmoothReflections;
  68934. private _reflectionSamples;
  68935. private _smoothSteps;
  68936. /**
  68937. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68938. * @param name The name of the effect.
  68939. * @param scene The scene containing the objects to calculate reflections.
  68940. * @param options The required width/height ratio to downsize to before computing the render pass.
  68941. * @param camera The camera to apply the render pass to.
  68942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68943. * @param engine The engine which the post process will be applied. (default: current engine)
  68944. * @param reusable If the post process can be reused on the same frame. (default: false)
  68945. * @param textureType Type of textures used when performing the post process. (default: 0)
  68946. * @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)
  68947. */
  68948. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68949. /**
  68950. * Gets wether or not smoothing reflections is enabled.
  68951. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68952. */
  68953. get enableSmoothReflections(): boolean;
  68954. /**
  68955. * Sets wether or not smoothing reflections is enabled.
  68956. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68957. */
  68958. set enableSmoothReflections(enabled: boolean);
  68959. /**
  68960. * Gets the number of samples taken while computing reflections. More samples count is high,
  68961. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68962. */
  68963. get reflectionSamples(): number;
  68964. /**
  68965. * Sets the number of samples taken while computing reflections. More samples count is high,
  68966. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68967. */
  68968. set reflectionSamples(samples: number);
  68969. /**
  68970. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  68971. * more the post-process will require GPU power and can generate a drop in FPS.
  68972. * Default value (5.0) work pretty well in all cases but can be adjusted.
  68973. */
  68974. get smoothSteps(): number;
  68975. set smoothSteps(steps: number);
  68976. private _updateEffectDefines;
  68977. }
  68978. }
  68979. declare module "babylonjs/Shaders/standard.fragment" {
  68980. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68981. /** @hidden */
  68982. export var standardPixelShader: {
  68983. name: string;
  68984. shader: string;
  68985. };
  68986. }
  68987. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  68988. import { Nullable } from "babylonjs/types";
  68989. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68990. import { Camera } from "babylonjs/Cameras/camera";
  68991. import { Texture } from "babylonjs/Materials/Textures/texture";
  68992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68993. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68994. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68995. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68996. import { IDisposable } from "babylonjs/scene";
  68997. import { SpotLight } from "babylonjs/Lights/spotLight";
  68998. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  68999. import { Scene } from "babylonjs/scene";
  69000. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69001. import { Animation } from "babylonjs/Animations/animation";
  69002. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69003. import "babylonjs/Shaders/standard.fragment";
  69004. /**
  69005. * Standard rendering pipeline
  69006. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69007. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69008. */
  69009. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69010. /**
  69011. * Public members
  69012. */
  69013. /**
  69014. * Post-process which contains the original scene color before the pipeline applies all the effects
  69015. */
  69016. originalPostProcess: Nullable<PostProcess>;
  69017. /**
  69018. * Post-process used to down scale an image x4
  69019. */
  69020. downSampleX4PostProcess: Nullable<PostProcess>;
  69021. /**
  69022. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69023. */
  69024. brightPassPostProcess: Nullable<PostProcess>;
  69025. /**
  69026. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69027. */
  69028. blurHPostProcesses: PostProcess[];
  69029. /**
  69030. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69031. */
  69032. blurVPostProcesses: PostProcess[];
  69033. /**
  69034. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69035. */
  69036. textureAdderPostProcess: Nullable<PostProcess>;
  69037. /**
  69038. * Post-process used to create volumetric lighting effect
  69039. */
  69040. volumetricLightPostProcess: Nullable<PostProcess>;
  69041. /**
  69042. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69043. */
  69044. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69045. /**
  69046. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69047. */
  69048. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69049. /**
  69050. * Post-process used to merge the volumetric light effect and the real scene color
  69051. */
  69052. volumetricLightMergePostProces: Nullable<PostProcess>;
  69053. /**
  69054. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69055. */
  69056. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69057. /**
  69058. * Base post-process used to calculate the average luminance of the final image for HDR
  69059. */
  69060. luminancePostProcess: Nullable<PostProcess>;
  69061. /**
  69062. * Post-processes used to create down sample post-processes in order to get
  69063. * the average luminance of the final image for HDR
  69064. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69065. */
  69066. luminanceDownSamplePostProcesses: PostProcess[];
  69067. /**
  69068. * Post-process used to create a HDR effect (light adaptation)
  69069. */
  69070. hdrPostProcess: Nullable<PostProcess>;
  69071. /**
  69072. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69073. */
  69074. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69075. /**
  69076. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69077. */
  69078. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69079. /**
  69080. * Post-process used to merge the final HDR post-process and the real scene color
  69081. */
  69082. hdrFinalPostProcess: Nullable<PostProcess>;
  69083. /**
  69084. * Post-process used to create a lens flare effect
  69085. */
  69086. lensFlarePostProcess: Nullable<PostProcess>;
  69087. /**
  69088. * Post-process that merges the result of the lens flare post-process and the real scene color
  69089. */
  69090. lensFlareComposePostProcess: Nullable<PostProcess>;
  69091. /**
  69092. * Post-process used to create a motion blur effect
  69093. */
  69094. motionBlurPostProcess: Nullable<PostProcess>;
  69095. /**
  69096. * Post-process used to create a depth of field effect
  69097. */
  69098. depthOfFieldPostProcess: Nullable<PostProcess>;
  69099. /**
  69100. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69101. */
  69102. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69103. /**
  69104. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69105. */
  69106. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69107. /**
  69108. * Represents the brightness threshold in order to configure the illuminated surfaces
  69109. */
  69110. brightThreshold: number;
  69111. /**
  69112. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69113. */
  69114. blurWidth: number;
  69115. /**
  69116. * Sets if the blur for highlighted surfaces must be only horizontal
  69117. */
  69118. horizontalBlur: boolean;
  69119. /**
  69120. * Gets the overall exposure used by the pipeline
  69121. */
  69122. get exposure(): number;
  69123. /**
  69124. * Sets the overall exposure used by the pipeline
  69125. */
  69126. set exposure(value: number);
  69127. /**
  69128. * Texture used typically to simulate "dirty" on camera lens
  69129. */
  69130. lensTexture: Nullable<Texture>;
  69131. /**
  69132. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69133. */
  69134. volumetricLightCoefficient: number;
  69135. /**
  69136. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69137. */
  69138. volumetricLightPower: number;
  69139. /**
  69140. * Used the set the blur intensity to smooth the volumetric lights
  69141. */
  69142. volumetricLightBlurScale: number;
  69143. /**
  69144. * Light (spot or directional) used to generate the volumetric lights rays
  69145. * The source light must have a shadow generate so the pipeline can get its
  69146. * depth map
  69147. */
  69148. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69149. /**
  69150. * For eye adaptation, represents the minimum luminance the eye can see
  69151. */
  69152. hdrMinimumLuminance: number;
  69153. /**
  69154. * For eye adaptation, represents the decrease luminance speed
  69155. */
  69156. hdrDecreaseRate: number;
  69157. /**
  69158. * For eye adaptation, represents the increase luminance speed
  69159. */
  69160. hdrIncreaseRate: number;
  69161. /**
  69162. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69163. */
  69164. get hdrAutoExposure(): boolean;
  69165. /**
  69166. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69167. */
  69168. set hdrAutoExposure(value: boolean);
  69169. /**
  69170. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69171. */
  69172. lensColorTexture: Nullable<Texture>;
  69173. /**
  69174. * The overall strengh for the lens flare effect
  69175. */
  69176. lensFlareStrength: number;
  69177. /**
  69178. * Dispersion coefficient for lens flare ghosts
  69179. */
  69180. lensFlareGhostDispersal: number;
  69181. /**
  69182. * Main lens flare halo width
  69183. */
  69184. lensFlareHaloWidth: number;
  69185. /**
  69186. * Based on the lens distortion effect, defines how much the lens flare result
  69187. * is distorted
  69188. */
  69189. lensFlareDistortionStrength: number;
  69190. /**
  69191. * Configures the blur intensity used for for lens flare (halo)
  69192. */
  69193. lensFlareBlurWidth: number;
  69194. /**
  69195. * Lens star texture must be used to simulate rays on the flares and is available
  69196. * in the documentation
  69197. */
  69198. lensStarTexture: Nullable<Texture>;
  69199. /**
  69200. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69201. * flare effect by taking account of the dirt texture
  69202. */
  69203. lensFlareDirtTexture: Nullable<Texture>;
  69204. /**
  69205. * Represents the focal length for the depth of field effect
  69206. */
  69207. depthOfFieldDistance: number;
  69208. /**
  69209. * Represents the blur intensity for the blurred part of the depth of field effect
  69210. */
  69211. depthOfFieldBlurWidth: number;
  69212. /**
  69213. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69214. */
  69215. get motionStrength(): number;
  69216. /**
  69217. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69218. */
  69219. set motionStrength(strength: number);
  69220. /**
  69221. * Gets wether or not the motion blur post-process is object based or screen based.
  69222. */
  69223. get objectBasedMotionBlur(): boolean;
  69224. /**
  69225. * Sets wether or not the motion blur post-process should be object based or screen based
  69226. */
  69227. set objectBasedMotionBlur(value: boolean);
  69228. /**
  69229. * List of animations for the pipeline (IAnimatable implementation)
  69230. */
  69231. animations: Animation[];
  69232. /**
  69233. * Private members
  69234. */
  69235. private _scene;
  69236. private _currentDepthOfFieldSource;
  69237. private _basePostProcess;
  69238. private _fixedExposure;
  69239. private _currentExposure;
  69240. private _hdrAutoExposure;
  69241. private _hdrCurrentLuminance;
  69242. private _motionStrength;
  69243. private _isObjectBasedMotionBlur;
  69244. private _floatTextureType;
  69245. private _camerasToBeAttached;
  69246. private _ratio;
  69247. private _bloomEnabled;
  69248. private _depthOfFieldEnabled;
  69249. private _vlsEnabled;
  69250. private _lensFlareEnabled;
  69251. private _hdrEnabled;
  69252. private _motionBlurEnabled;
  69253. private _fxaaEnabled;
  69254. private _screenSpaceReflectionsEnabled;
  69255. private _motionBlurSamples;
  69256. private _volumetricLightStepsCount;
  69257. private _samples;
  69258. /**
  69259. * @ignore
  69260. * Specifies if the bloom pipeline is enabled
  69261. */
  69262. get BloomEnabled(): boolean;
  69263. set BloomEnabled(enabled: boolean);
  69264. /**
  69265. * @ignore
  69266. * Specifies if the depth of field pipeline is enabed
  69267. */
  69268. get DepthOfFieldEnabled(): boolean;
  69269. set DepthOfFieldEnabled(enabled: boolean);
  69270. /**
  69271. * @ignore
  69272. * Specifies if the lens flare pipeline is enabed
  69273. */
  69274. get LensFlareEnabled(): boolean;
  69275. set LensFlareEnabled(enabled: boolean);
  69276. /**
  69277. * @ignore
  69278. * Specifies if the HDR pipeline is enabled
  69279. */
  69280. get HDREnabled(): boolean;
  69281. set HDREnabled(enabled: boolean);
  69282. /**
  69283. * @ignore
  69284. * Specifies if the volumetric lights scattering effect is enabled
  69285. */
  69286. get VLSEnabled(): boolean;
  69287. set VLSEnabled(enabled: boolean);
  69288. /**
  69289. * @ignore
  69290. * Specifies if the motion blur effect is enabled
  69291. */
  69292. get MotionBlurEnabled(): boolean;
  69293. set MotionBlurEnabled(enabled: boolean);
  69294. /**
  69295. * Specifies if anti-aliasing is enabled
  69296. */
  69297. get fxaaEnabled(): boolean;
  69298. set fxaaEnabled(enabled: boolean);
  69299. /**
  69300. * Specifies if screen space reflections are enabled.
  69301. */
  69302. get screenSpaceReflectionsEnabled(): boolean;
  69303. set screenSpaceReflectionsEnabled(enabled: boolean);
  69304. /**
  69305. * Specifies the number of steps used to calculate the volumetric lights
  69306. * Typically in interval [50, 200]
  69307. */
  69308. get volumetricLightStepsCount(): number;
  69309. set volumetricLightStepsCount(count: number);
  69310. /**
  69311. * Specifies the number of samples used for the motion blur effect
  69312. * Typically in interval [16, 64]
  69313. */
  69314. get motionBlurSamples(): number;
  69315. set motionBlurSamples(samples: number);
  69316. /**
  69317. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69318. */
  69319. get samples(): number;
  69320. set samples(sampleCount: number);
  69321. /**
  69322. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69323. * @constructor
  69324. * @param name The rendering pipeline name
  69325. * @param scene The scene linked to this pipeline
  69326. * @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)
  69327. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69328. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69329. */
  69330. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69331. private _buildPipeline;
  69332. private _createDownSampleX4PostProcess;
  69333. private _createBrightPassPostProcess;
  69334. private _createBlurPostProcesses;
  69335. private _createTextureAdderPostProcess;
  69336. private _createVolumetricLightPostProcess;
  69337. private _createLuminancePostProcesses;
  69338. private _createHdrPostProcess;
  69339. private _createLensFlarePostProcess;
  69340. private _createDepthOfFieldPostProcess;
  69341. private _createMotionBlurPostProcess;
  69342. private _getDepthTexture;
  69343. private _disposePostProcesses;
  69344. /**
  69345. * Dispose of the pipeline and stop all post processes
  69346. */
  69347. dispose(): void;
  69348. /**
  69349. * Serialize the rendering pipeline (Used when exporting)
  69350. * @returns the serialized object
  69351. */
  69352. serialize(): any;
  69353. /**
  69354. * Parse the serialized pipeline
  69355. * @param source Source pipeline.
  69356. * @param scene The scene to load the pipeline to.
  69357. * @param rootUrl The URL of the serialized pipeline.
  69358. * @returns An instantiated pipeline from the serialized object.
  69359. */
  69360. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69361. /**
  69362. * Luminance steps
  69363. */
  69364. static LuminanceSteps: number;
  69365. }
  69366. }
  69367. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69368. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69369. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69370. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69371. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69372. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69373. }
  69374. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69375. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69376. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69377. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69378. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69379. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69380. }
  69381. declare module "babylonjs/Shaders/tonemap.fragment" {
  69382. /** @hidden */
  69383. export var tonemapPixelShader: {
  69384. name: string;
  69385. shader: string;
  69386. };
  69387. }
  69388. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69389. import { Camera } from "babylonjs/Cameras/camera";
  69390. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69391. import "babylonjs/Shaders/tonemap.fragment";
  69392. import { Engine } from "babylonjs/Engines/engine";
  69393. /** Defines operator used for tonemapping */
  69394. export enum TonemappingOperator {
  69395. /** Hable */
  69396. Hable = 0,
  69397. /** Reinhard */
  69398. Reinhard = 1,
  69399. /** HejiDawson */
  69400. HejiDawson = 2,
  69401. /** Photographic */
  69402. Photographic = 3
  69403. }
  69404. /**
  69405. * Defines a post process to apply tone mapping
  69406. */
  69407. export class TonemapPostProcess extends PostProcess {
  69408. private _operator;
  69409. /** Defines the required exposure adjustement */
  69410. exposureAdjustment: number;
  69411. /**
  69412. * Creates a new TonemapPostProcess
  69413. * @param name defines the name of the postprocess
  69414. * @param _operator defines the operator to use
  69415. * @param exposureAdjustment defines the required exposure adjustement
  69416. * @param camera defines the camera to use (can be null)
  69417. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69418. * @param engine defines the hosting engine (can be ignore if camera is set)
  69419. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69420. */
  69421. constructor(name: string, _operator: TonemappingOperator,
  69422. /** Defines the required exposure adjustement */
  69423. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69424. }
  69425. }
  69426. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69427. /** @hidden */
  69428. export var volumetricLightScatteringPixelShader: {
  69429. name: string;
  69430. shader: string;
  69431. };
  69432. }
  69433. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69434. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69435. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69437. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69438. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69439. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69440. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69441. /** @hidden */
  69442. export var volumetricLightScatteringPassVertexShader: {
  69443. name: string;
  69444. shader: string;
  69445. };
  69446. }
  69447. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69448. /** @hidden */
  69449. export var volumetricLightScatteringPassPixelShader: {
  69450. name: string;
  69451. shader: string;
  69452. };
  69453. }
  69454. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69455. import { Vector3 } from "babylonjs/Maths/math.vector";
  69456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69457. import { Mesh } from "babylonjs/Meshes/mesh";
  69458. import { Camera } from "babylonjs/Cameras/camera";
  69459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69460. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69461. import { Scene } from "babylonjs/scene";
  69462. import "babylonjs/Meshes/Builders/planeBuilder";
  69463. import "babylonjs/Shaders/depth.vertex";
  69464. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69465. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69466. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69467. import { Engine } from "babylonjs/Engines/engine";
  69468. /**
  69469. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69470. */
  69471. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69472. private _volumetricLightScatteringPass;
  69473. private _volumetricLightScatteringRTT;
  69474. private _viewPort;
  69475. private _screenCoordinates;
  69476. private _cachedDefines;
  69477. /**
  69478. * If not undefined, the mesh position is computed from the attached node position
  69479. */
  69480. attachedNode: {
  69481. position: Vector3;
  69482. };
  69483. /**
  69484. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69485. */
  69486. customMeshPosition: Vector3;
  69487. /**
  69488. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69489. */
  69490. useCustomMeshPosition: boolean;
  69491. /**
  69492. * If the post-process should inverse the light scattering direction
  69493. */
  69494. invert: boolean;
  69495. /**
  69496. * The internal mesh used by the post-process
  69497. */
  69498. mesh: Mesh;
  69499. /**
  69500. * @hidden
  69501. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69502. */
  69503. get useDiffuseColor(): boolean;
  69504. set useDiffuseColor(useDiffuseColor: boolean);
  69505. /**
  69506. * Array containing the excluded meshes not rendered in the internal pass
  69507. */
  69508. excludedMeshes: AbstractMesh[];
  69509. /**
  69510. * Controls the overall intensity of the post-process
  69511. */
  69512. exposure: number;
  69513. /**
  69514. * Dissipates each sample's contribution in range [0, 1]
  69515. */
  69516. decay: number;
  69517. /**
  69518. * Controls the overall intensity of each sample
  69519. */
  69520. weight: number;
  69521. /**
  69522. * Controls the density of each sample
  69523. */
  69524. density: number;
  69525. /**
  69526. * @constructor
  69527. * @param name The post-process name
  69528. * @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)
  69529. * @param camera The camera that the post-process will be attached to
  69530. * @param mesh The mesh used to create the light scattering
  69531. * @param samples The post-process quality, default 100
  69532. * @param samplingModeThe post-process filtering mode
  69533. * @param engine The babylon engine
  69534. * @param reusable If the post-process is reusable
  69535. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69536. */
  69537. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69538. /**
  69539. * Returns the string "VolumetricLightScatteringPostProcess"
  69540. * @returns "VolumetricLightScatteringPostProcess"
  69541. */
  69542. getClassName(): string;
  69543. private _isReady;
  69544. /**
  69545. * Sets the new light position for light scattering effect
  69546. * @param position The new custom light position
  69547. */
  69548. setCustomMeshPosition(position: Vector3): void;
  69549. /**
  69550. * Returns the light position for light scattering effect
  69551. * @return Vector3 The custom light position
  69552. */
  69553. getCustomMeshPosition(): Vector3;
  69554. /**
  69555. * Disposes the internal assets and detaches the post-process from the camera
  69556. */
  69557. dispose(camera: Camera): void;
  69558. /**
  69559. * Returns the render target texture used by the post-process
  69560. * @return the render target texture used by the post-process
  69561. */
  69562. getPass(): RenderTargetTexture;
  69563. private _meshExcluded;
  69564. private _createPass;
  69565. private _updateMeshScreenCoordinates;
  69566. /**
  69567. * Creates a default mesh for the Volumeric Light Scattering post-process
  69568. * @param name The mesh name
  69569. * @param scene The scene where to create the mesh
  69570. * @return the default mesh
  69571. */
  69572. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69573. }
  69574. }
  69575. declare module "babylonjs/PostProcesses/index" {
  69576. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69577. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69578. export * from "babylonjs/PostProcesses/bloomEffect";
  69579. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69580. export * from "babylonjs/PostProcesses/blurPostProcess";
  69581. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69582. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69583. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69584. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69585. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69586. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69587. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69588. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69589. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69590. export * from "babylonjs/PostProcesses/filterPostProcess";
  69591. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69592. export * from "babylonjs/PostProcesses/grainPostProcess";
  69593. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69594. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69595. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69596. export * from "babylonjs/PostProcesses/passPostProcess";
  69597. export * from "babylonjs/PostProcesses/postProcess";
  69598. export * from "babylonjs/PostProcesses/postProcessManager";
  69599. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69600. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69601. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69602. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69603. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69604. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69605. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69606. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69607. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69608. }
  69609. declare module "babylonjs/Probes/index" {
  69610. export * from "babylonjs/Probes/reflectionProbe";
  69611. }
  69612. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69613. import { Scene } from "babylonjs/scene";
  69614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69615. import { SmartArray } from "babylonjs/Misc/smartArray";
  69616. import { ISceneComponent } from "babylonjs/sceneComponent";
  69617. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69618. import "babylonjs/Meshes/Builders/boxBuilder";
  69619. import "babylonjs/Shaders/color.fragment";
  69620. import "babylonjs/Shaders/color.vertex";
  69621. import { Color3 } from "babylonjs/Maths/math.color";
  69622. module "babylonjs/scene" {
  69623. interface Scene {
  69624. /** @hidden (Backing field) */
  69625. _boundingBoxRenderer: BoundingBoxRenderer;
  69626. /** @hidden (Backing field) */
  69627. _forceShowBoundingBoxes: boolean;
  69628. /**
  69629. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69630. */
  69631. forceShowBoundingBoxes: boolean;
  69632. /**
  69633. * Gets the bounding box renderer associated with the scene
  69634. * @returns a BoundingBoxRenderer
  69635. */
  69636. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69637. }
  69638. }
  69639. module "babylonjs/Meshes/abstractMesh" {
  69640. interface AbstractMesh {
  69641. /** @hidden (Backing field) */
  69642. _showBoundingBox: boolean;
  69643. /**
  69644. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69645. */
  69646. showBoundingBox: boolean;
  69647. }
  69648. }
  69649. /**
  69650. * Component responsible of rendering the bounding box of the meshes in a scene.
  69651. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69652. */
  69653. export class BoundingBoxRenderer implements ISceneComponent {
  69654. /**
  69655. * The component name helpfull to identify the component in the list of scene components.
  69656. */
  69657. readonly name: string;
  69658. /**
  69659. * The scene the component belongs to.
  69660. */
  69661. scene: Scene;
  69662. /**
  69663. * Color of the bounding box lines placed in front of an object
  69664. */
  69665. frontColor: Color3;
  69666. /**
  69667. * Color of the bounding box lines placed behind an object
  69668. */
  69669. backColor: Color3;
  69670. /**
  69671. * Defines if the renderer should show the back lines or not
  69672. */
  69673. showBackLines: boolean;
  69674. /**
  69675. * @hidden
  69676. */
  69677. renderList: SmartArray<BoundingBox>;
  69678. private _colorShader;
  69679. private _vertexBuffers;
  69680. private _indexBuffer;
  69681. private _fillIndexBuffer;
  69682. private _fillIndexData;
  69683. /**
  69684. * Instantiates a new bounding box renderer in a scene.
  69685. * @param scene the scene the renderer renders in
  69686. */
  69687. constructor(scene: Scene);
  69688. /**
  69689. * Registers the component in a given scene
  69690. */
  69691. register(): void;
  69692. private _evaluateSubMesh;
  69693. private _activeMesh;
  69694. private _prepareRessources;
  69695. private _createIndexBuffer;
  69696. /**
  69697. * Rebuilds the elements related to this component in case of
  69698. * context lost for instance.
  69699. */
  69700. rebuild(): void;
  69701. /**
  69702. * @hidden
  69703. */
  69704. reset(): void;
  69705. /**
  69706. * Render the bounding boxes of a specific rendering group
  69707. * @param renderingGroupId defines the rendering group to render
  69708. */
  69709. render(renderingGroupId: number): void;
  69710. /**
  69711. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69712. * @param mesh Define the mesh to render the occlusion bounding box for
  69713. */
  69714. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69715. /**
  69716. * Dispose and release the resources attached to this renderer.
  69717. */
  69718. dispose(): void;
  69719. }
  69720. }
  69721. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  69722. import { Nullable } from "babylonjs/types";
  69723. import { Scene } from "babylonjs/scene";
  69724. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  69725. import { Camera } from "babylonjs/Cameras/camera";
  69726. import { ISceneComponent } from "babylonjs/sceneComponent";
  69727. module "babylonjs/scene" {
  69728. interface Scene {
  69729. /** @hidden (Backing field) */
  69730. _depthRenderer: {
  69731. [id: string]: DepthRenderer;
  69732. };
  69733. /**
  69734. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69735. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69736. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69737. * @returns the created depth renderer
  69738. */
  69739. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69740. /**
  69741. * Disables a depth renderer for a given camera
  69742. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69743. */
  69744. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69745. }
  69746. }
  69747. /**
  69748. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69749. * in several rendering techniques.
  69750. */
  69751. export class DepthRendererSceneComponent implements ISceneComponent {
  69752. /**
  69753. * The component name helpfull to identify the component in the list of scene components.
  69754. */
  69755. readonly name: string;
  69756. /**
  69757. * The scene the component belongs to.
  69758. */
  69759. scene: Scene;
  69760. /**
  69761. * Creates a new instance of the component for the given scene
  69762. * @param scene Defines the scene to register the component in
  69763. */
  69764. constructor(scene: Scene);
  69765. /**
  69766. * Registers the component in a given scene
  69767. */
  69768. register(): void;
  69769. /**
  69770. * Rebuilds the elements related to this component in case of
  69771. * context lost for instance.
  69772. */
  69773. rebuild(): void;
  69774. /**
  69775. * Disposes the component and the associated ressources
  69776. */
  69777. dispose(): void;
  69778. private _gatherRenderTargets;
  69779. private _gatherActiveCameraRenderTargets;
  69780. }
  69781. }
  69782. declare module "babylonjs/Shaders/outline.fragment" {
  69783. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69784. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  69785. /** @hidden */
  69786. export var outlinePixelShader: {
  69787. name: string;
  69788. shader: string;
  69789. };
  69790. }
  69791. declare module "babylonjs/Shaders/outline.vertex" {
  69792. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69793. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69794. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69795. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69796. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69797. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69798. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69799. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69800. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  69801. /** @hidden */
  69802. export var outlineVertexShader: {
  69803. name: string;
  69804. shader: string;
  69805. };
  69806. }
  69807. declare module "babylonjs/Rendering/outlineRenderer" {
  69808. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69809. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  69810. import { Scene } from "babylonjs/scene";
  69811. import { ISceneComponent } from "babylonjs/sceneComponent";
  69812. import "babylonjs/Shaders/outline.fragment";
  69813. import "babylonjs/Shaders/outline.vertex";
  69814. module "babylonjs/scene" {
  69815. interface Scene {
  69816. /** @hidden */
  69817. _outlineRenderer: OutlineRenderer;
  69818. /**
  69819. * Gets the outline renderer associated with the scene
  69820. * @returns a OutlineRenderer
  69821. */
  69822. getOutlineRenderer(): OutlineRenderer;
  69823. }
  69824. }
  69825. module "babylonjs/Meshes/abstractMesh" {
  69826. interface AbstractMesh {
  69827. /** @hidden (Backing field) */
  69828. _renderOutline: boolean;
  69829. /**
  69830. * Gets or sets a boolean indicating if the outline must be rendered as well
  69831. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69832. */
  69833. renderOutline: boolean;
  69834. /** @hidden (Backing field) */
  69835. _renderOverlay: boolean;
  69836. /**
  69837. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69838. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69839. */
  69840. renderOverlay: boolean;
  69841. }
  69842. }
  69843. /**
  69844. * This class is responsible to draw bothe outline/overlay of meshes.
  69845. * It should not be used directly but through the available method on mesh.
  69846. */
  69847. export class OutlineRenderer implements ISceneComponent {
  69848. /**
  69849. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69850. */
  69851. private static _StencilReference;
  69852. /**
  69853. * The name of the component. Each component must have a unique name.
  69854. */
  69855. name: string;
  69856. /**
  69857. * The scene the component belongs to.
  69858. */
  69859. scene: Scene;
  69860. /**
  69861. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69862. */
  69863. zOffset: number;
  69864. private _engine;
  69865. private _effect;
  69866. private _cachedDefines;
  69867. private _savedDepthWrite;
  69868. /**
  69869. * Instantiates a new outline renderer. (There could be only one per scene).
  69870. * @param scene Defines the scene it belongs to
  69871. */
  69872. constructor(scene: Scene);
  69873. /**
  69874. * Register the component to one instance of a scene.
  69875. */
  69876. register(): void;
  69877. /**
  69878. * Rebuilds the elements related to this component in case of
  69879. * context lost for instance.
  69880. */
  69881. rebuild(): void;
  69882. /**
  69883. * Disposes the component and the associated ressources.
  69884. */
  69885. dispose(): void;
  69886. /**
  69887. * Renders the outline in the canvas.
  69888. * @param subMesh Defines the sumesh to render
  69889. * @param batch Defines the batch of meshes in case of instances
  69890. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69891. */
  69892. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69893. /**
  69894. * Returns whether or not the outline renderer is ready for a given submesh.
  69895. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69896. * @param subMesh Defines the submesh to check readyness for
  69897. * @param useInstances Defines wheter wee are trying to render instances or not
  69898. * @returns true if ready otherwise false
  69899. */
  69900. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69901. private _beforeRenderingMesh;
  69902. private _afterRenderingMesh;
  69903. }
  69904. }
  69905. declare module "babylonjs/Rendering/index" {
  69906. export * from "babylonjs/Rendering/boundingBoxRenderer";
  69907. export * from "babylonjs/Rendering/depthRenderer";
  69908. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  69909. export * from "babylonjs/Rendering/edgesRenderer";
  69910. export * from "babylonjs/Rendering/geometryBufferRenderer";
  69911. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  69912. export * from "babylonjs/Rendering/outlineRenderer";
  69913. export * from "babylonjs/Rendering/renderingGroup";
  69914. export * from "babylonjs/Rendering/renderingManager";
  69915. export * from "babylonjs/Rendering/utilityLayerRenderer";
  69916. }
  69917. declare module "babylonjs/Sprites/ISprites" {
  69918. /**
  69919. * Defines the basic options interface of a Sprite Frame Source Size.
  69920. */
  69921. export interface ISpriteJSONSpriteSourceSize {
  69922. /**
  69923. * number of the original width of the Frame
  69924. */
  69925. w: number;
  69926. /**
  69927. * number of the original height of the Frame
  69928. */
  69929. h: number;
  69930. }
  69931. /**
  69932. * Defines the basic options interface of a Sprite Frame Data.
  69933. */
  69934. export interface ISpriteJSONSpriteFrameData {
  69935. /**
  69936. * number of the x offset of the Frame
  69937. */
  69938. x: number;
  69939. /**
  69940. * number of the y offset of the Frame
  69941. */
  69942. y: number;
  69943. /**
  69944. * number of the width of the Frame
  69945. */
  69946. w: number;
  69947. /**
  69948. * number of the height of the Frame
  69949. */
  69950. h: number;
  69951. }
  69952. /**
  69953. * Defines the basic options interface of a JSON Sprite.
  69954. */
  69955. export interface ISpriteJSONSprite {
  69956. /**
  69957. * string name of the Frame
  69958. */
  69959. filename: string;
  69960. /**
  69961. * ISpriteJSONSpriteFrame basic object of the frame data
  69962. */
  69963. frame: ISpriteJSONSpriteFrameData;
  69964. /**
  69965. * boolean to flag is the frame was rotated.
  69966. */
  69967. rotated: boolean;
  69968. /**
  69969. * boolean to flag is the frame was trimmed.
  69970. */
  69971. trimmed: boolean;
  69972. /**
  69973. * ISpriteJSONSpriteFrame basic object of the source data
  69974. */
  69975. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69976. /**
  69977. * ISpriteJSONSpriteFrame basic object of the source data
  69978. */
  69979. sourceSize: ISpriteJSONSpriteSourceSize;
  69980. }
  69981. /**
  69982. * Defines the basic options interface of a JSON atlas.
  69983. */
  69984. export interface ISpriteJSONAtlas {
  69985. /**
  69986. * Array of objects that contain the frame data.
  69987. */
  69988. frames: Array<ISpriteJSONSprite>;
  69989. /**
  69990. * object basic object containing the sprite meta data.
  69991. */
  69992. meta?: object;
  69993. }
  69994. }
  69995. declare module "babylonjs/Shaders/spriteMap.fragment" {
  69996. /** @hidden */
  69997. export var spriteMapPixelShader: {
  69998. name: string;
  69999. shader: string;
  70000. };
  70001. }
  70002. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70003. /** @hidden */
  70004. export var spriteMapVertexShader: {
  70005. name: string;
  70006. shader: string;
  70007. };
  70008. }
  70009. declare module "babylonjs/Sprites/spriteMap" {
  70010. import { IDisposable, Scene } from "babylonjs/scene";
  70011. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70012. import { Texture } from "babylonjs/Materials/Textures/texture";
  70013. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70014. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70015. import "babylonjs/Meshes/Builders/planeBuilder";
  70016. import "babylonjs/Shaders/spriteMap.fragment";
  70017. import "babylonjs/Shaders/spriteMap.vertex";
  70018. /**
  70019. * Defines the basic options interface of a SpriteMap
  70020. */
  70021. export interface ISpriteMapOptions {
  70022. /**
  70023. * Vector2 of the number of cells in the grid.
  70024. */
  70025. stageSize?: Vector2;
  70026. /**
  70027. * Vector2 of the size of the output plane in World Units.
  70028. */
  70029. outputSize?: Vector2;
  70030. /**
  70031. * Vector3 of the position of the output plane in World Units.
  70032. */
  70033. outputPosition?: Vector3;
  70034. /**
  70035. * Vector3 of the rotation of the output plane.
  70036. */
  70037. outputRotation?: Vector3;
  70038. /**
  70039. * number of layers that the system will reserve in resources.
  70040. */
  70041. layerCount?: number;
  70042. /**
  70043. * number of max animation frames a single cell will reserve in resources.
  70044. */
  70045. maxAnimationFrames?: number;
  70046. /**
  70047. * number cell index of the base tile when the system compiles.
  70048. */
  70049. baseTile?: number;
  70050. /**
  70051. * boolean flip the sprite after its been repositioned by the framing data.
  70052. */
  70053. flipU?: boolean;
  70054. /**
  70055. * Vector3 scalar of the global RGB values of the SpriteMap.
  70056. */
  70057. colorMultiply?: Vector3;
  70058. }
  70059. /**
  70060. * Defines the IDisposable interface in order to be cleanable from resources.
  70061. */
  70062. export interface ISpriteMap extends IDisposable {
  70063. /**
  70064. * String name of the SpriteMap.
  70065. */
  70066. name: string;
  70067. /**
  70068. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70069. */
  70070. atlasJSON: ISpriteJSONAtlas;
  70071. /**
  70072. * Texture of the SpriteMap.
  70073. */
  70074. spriteSheet: Texture;
  70075. /**
  70076. * The parameters to initialize the SpriteMap with.
  70077. */
  70078. options: ISpriteMapOptions;
  70079. }
  70080. /**
  70081. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70082. */
  70083. export class SpriteMap implements ISpriteMap {
  70084. /** The Name of the spriteMap */
  70085. name: string;
  70086. /** The JSON file with the frame and meta data */
  70087. atlasJSON: ISpriteJSONAtlas;
  70088. /** The systems Sprite Sheet Texture */
  70089. spriteSheet: Texture;
  70090. /** Arguments passed with the Constructor */
  70091. options: ISpriteMapOptions;
  70092. /** Public Sprite Storage array, parsed from atlasJSON */
  70093. sprites: Array<ISpriteJSONSprite>;
  70094. /** Returns the Number of Sprites in the System */
  70095. get spriteCount(): number;
  70096. /** Returns the Position of Output Plane*/
  70097. get position(): Vector3;
  70098. /** Returns the Position of Output Plane*/
  70099. set position(v: Vector3);
  70100. /** Returns the Rotation of Output Plane*/
  70101. get rotation(): Vector3;
  70102. /** Returns the Rotation of Output Plane*/
  70103. set rotation(v: Vector3);
  70104. /** Sets the AnimationMap*/
  70105. get animationMap(): RawTexture;
  70106. /** Sets the AnimationMap*/
  70107. set animationMap(v: RawTexture);
  70108. /** Scene that the SpriteMap was created in */
  70109. private _scene;
  70110. /** Texture Buffer of Float32 that holds tile frame data*/
  70111. private _frameMap;
  70112. /** Texture Buffers of Float32 that holds tileMap data*/
  70113. private _tileMaps;
  70114. /** Texture Buffer of Float32 that holds Animation Data*/
  70115. private _animationMap;
  70116. /** Custom ShaderMaterial Central to the System*/
  70117. private _material;
  70118. /** Custom ShaderMaterial Central to the System*/
  70119. private _output;
  70120. /** Systems Time Ticker*/
  70121. private _time;
  70122. /**
  70123. * Creates a new SpriteMap
  70124. * @param name defines the SpriteMaps Name
  70125. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70126. * @param spriteSheet is the Texture that the Sprites are on.
  70127. * @param options a basic deployment configuration
  70128. * @param scene The Scene that the map is deployed on
  70129. */
  70130. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70131. /**
  70132. * Returns tileID location
  70133. * @returns Vector2 the cell position ID
  70134. */
  70135. getTileID(): Vector2;
  70136. /**
  70137. * Gets the UV location of the mouse over the SpriteMap.
  70138. * @returns Vector2 the UV position of the mouse interaction
  70139. */
  70140. getMousePosition(): Vector2;
  70141. /**
  70142. * Creates the "frame" texture Buffer
  70143. * -------------------------------------
  70144. * Structure of frames
  70145. * "filename": "Falling-Water-2.png",
  70146. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70147. * "rotated": true,
  70148. * "trimmed": true,
  70149. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70150. * "sourceSize": {"w":32,"h":32}
  70151. * @returns RawTexture of the frameMap
  70152. */
  70153. private _createFrameBuffer;
  70154. /**
  70155. * Creates the tileMap texture Buffer
  70156. * @param buffer normally and array of numbers, or a false to generate from scratch
  70157. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70158. * @returns RawTexture of the tileMap
  70159. */
  70160. private _createTileBuffer;
  70161. /**
  70162. * Modifies the data of the tileMaps
  70163. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70164. * @param pos is the iVector2 Coordinates of the Tile
  70165. * @param tile The SpriteIndex of the new Tile
  70166. */
  70167. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70168. /**
  70169. * Creates the animationMap texture Buffer
  70170. * @param buffer normally and array of numbers, or a false to generate from scratch
  70171. * @returns RawTexture of the animationMap
  70172. */
  70173. private _createTileAnimationBuffer;
  70174. /**
  70175. * Modifies the data of the animationMap
  70176. * @param cellID is the Index of the Sprite
  70177. * @param _frame is the target Animation frame
  70178. * @param toCell is the Target Index of the next frame of the animation
  70179. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70180. * @param speed is a global scalar of the time variable on the map.
  70181. */
  70182. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70183. /**
  70184. * Exports the .tilemaps file
  70185. */
  70186. saveTileMaps(): void;
  70187. /**
  70188. * Imports the .tilemaps file
  70189. * @param url of the .tilemaps file
  70190. */
  70191. loadTileMaps(url: string): void;
  70192. /**
  70193. * Release associated resources
  70194. */
  70195. dispose(): void;
  70196. }
  70197. }
  70198. declare module "babylonjs/Sprites/spritePackedManager" {
  70199. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70200. import { Scene } from "babylonjs/scene";
  70201. /**
  70202. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70203. * @see http://doc.babylonjs.com/babylon101/sprites
  70204. */
  70205. export class SpritePackedManager extends SpriteManager {
  70206. /** defines the packed manager's name */
  70207. name: string;
  70208. /**
  70209. * Creates a new sprite manager from a packed sprite sheet
  70210. * @param name defines the manager's name
  70211. * @param imgUrl defines the sprite sheet url
  70212. * @param capacity defines the maximum allowed number of sprites
  70213. * @param scene defines the hosting scene
  70214. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70215. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70216. * @param samplingMode defines the smapling mode to use with spritesheet
  70217. * @param fromPacked set to true; do not alter
  70218. */
  70219. constructor(
  70220. /** defines the packed manager's name */
  70221. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70222. }
  70223. }
  70224. declare module "babylonjs/Sprites/index" {
  70225. export * from "babylonjs/Sprites/sprite";
  70226. export * from "babylonjs/Sprites/ISprites";
  70227. export * from "babylonjs/Sprites/spriteManager";
  70228. export * from "babylonjs/Sprites/spriteMap";
  70229. export * from "babylonjs/Sprites/spritePackedManager";
  70230. export * from "babylonjs/Sprites/spriteSceneComponent";
  70231. }
  70232. declare module "babylonjs/States/index" {
  70233. export * from "babylonjs/States/alphaCullingState";
  70234. export * from "babylonjs/States/depthCullingState";
  70235. export * from "babylonjs/States/stencilState";
  70236. }
  70237. declare module "babylonjs/Misc/assetsManager" {
  70238. import { Scene } from "babylonjs/scene";
  70239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70240. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70241. import { Skeleton } from "babylonjs/Bones/skeleton";
  70242. import { Observable } from "babylonjs/Misc/observable";
  70243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70244. import { Texture } from "babylonjs/Materials/Textures/texture";
  70245. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70246. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70247. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70248. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70249. /**
  70250. * Defines the list of states available for a task inside a AssetsManager
  70251. */
  70252. export enum AssetTaskState {
  70253. /**
  70254. * Initialization
  70255. */
  70256. INIT = 0,
  70257. /**
  70258. * Running
  70259. */
  70260. RUNNING = 1,
  70261. /**
  70262. * Done
  70263. */
  70264. DONE = 2,
  70265. /**
  70266. * Error
  70267. */
  70268. ERROR = 3
  70269. }
  70270. /**
  70271. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70272. */
  70273. export abstract class AbstractAssetTask {
  70274. /**
  70275. * Task name
  70276. */ name: string;
  70277. /**
  70278. * Callback called when the task is successful
  70279. */
  70280. onSuccess: (task: any) => void;
  70281. /**
  70282. * Callback called when the task is not successful
  70283. */
  70284. onError: (task: any, message?: string, exception?: any) => void;
  70285. /**
  70286. * Creates a new AssetsManager
  70287. * @param name defines the name of the task
  70288. */
  70289. constructor(
  70290. /**
  70291. * Task name
  70292. */ name: string);
  70293. private _isCompleted;
  70294. private _taskState;
  70295. private _errorObject;
  70296. /**
  70297. * Get if the task is completed
  70298. */
  70299. get isCompleted(): boolean;
  70300. /**
  70301. * Gets the current state of the task
  70302. */
  70303. get taskState(): AssetTaskState;
  70304. /**
  70305. * Gets the current error object (if task is in error)
  70306. */
  70307. get errorObject(): {
  70308. message?: string;
  70309. exception?: any;
  70310. };
  70311. /**
  70312. * Internal only
  70313. * @hidden
  70314. */
  70315. _setErrorObject(message?: string, exception?: any): void;
  70316. /**
  70317. * Execute the current task
  70318. * @param scene defines the scene where you want your assets to be loaded
  70319. * @param onSuccess is a callback called when the task is successfully executed
  70320. * @param onError is a callback called if an error occurs
  70321. */
  70322. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70323. /**
  70324. * Execute the current task
  70325. * @param scene defines the scene where you want your assets to be loaded
  70326. * @param onSuccess is a callback called when the task is successfully executed
  70327. * @param onError is a callback called if an error occurs
  70328. */
  70329. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70330. /**
  70331. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70332. * This can be used with failed tasks that have the reason for failure fixed.
  70333. */
  70334. reset(): void;
  70335. private onErrorCallback;
  70336. private onDoneCallback;
  70337. }
  70338. /**
  70339. * Define the interface used by progress events raised during assets loading
  70340. */
  70341. export interface IAssetsProgressEvent {
  70342. /**
  70343. * Defines the number of remaining tasks to process
  70344. */
  70345. remainingCount: number;
  70346. /**
  70347. * Defines the total number of tasks
  70348. */
  70349. totalCount: number;
  70350. /**
  70351. * Defines the task that was just processed
  70352. */
  70353. task: AbstractAssetTask;
  70354. }
  70355. /**
  70356. * Class used to share progress information about assets loading
  70357. */
  70358. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70359. /**
  70360. * Defines the number of remaining tasks to process
  70361. */
  70362. remainingCount: number;
  70363. /**
  70364. * Defines the total number of tasks
  70365. */
  70366. totalCount: number;
  70367. /**
  70368. * Defines the task that was just processed
  70369. */
  70370. task: AbstractAssetTask;
  70371. /**
  70372. * Creates a AssetsProgressEvent
  70373. * @param remainingCount defines the number of remaining tasks to process
  70374. * @param totalCount defines the total number of tasks
  70375. * @param task defines the task that was just processed
  70376. */
  70377. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70378. }
  70379. /**
  70380. * Define a task used by AssetsManager to load meshes
  70381. */
  70382. export class MeshAssetTask extends AbstractAssetTask {
  70383. /**
  70384. * Defines the name of the task
  70385. */
  70386. name: string;
  70387. /**
  70388. * Defines the list of mesh's names you want to load
  70389. */
  70390. meshesNames: any;
  70391. /**
  70392. * Defines the root url to use as a base to load your meshes and associated resources
  70393. */
  70394. rootUrl: string;
  70395. /**
  70396. * Defines the filename of the scene to load from
  70397. */
  70398. sceneFilename: string;
  70399. /**
  70400. * Gets the list of loaded meshes
  70401. */
  70402. loadedMeshes: Array<AbstractMesh>;
  70403. /**
  70404. * Gets the list of loaded particle systems
  70405. */
  70406. loadedParticleSystems: Array<IParticleSystem>;
  70407. /**
  70408. * Gets the list of loaded skeletons
  70409. */
  70410. loadedSkeletons: Array<Skeleton>;
  70411. /**
  70412. * Gets the list of loaded animation groups
  70413. */
  70414. loadedAnimationGroups: Array<AnimationGroup>;
  70415. /**
  70416. * Callback called when the task is successful
  70417. */
  70418. onSuccess: (task: MeshAssetTask) => void;
  70419. /**
  70420. * Callback called when the task is successful
  70421. */
  70422. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70423. /**
  70424. * Creates a new MeshAssetTask
  70425. * @param name defines the name of the task
  70426. * @param meshesNames defines the list of mesh's names you want to load
  70427. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70428. * @param sceneFilename defines the filename of the scene to load from
  70429. */
  70430. constructor(
  70431. /**
  70432. * Defines the name of the task
  70433. */
  70434. name: string,
  70435. /**
  70436. * Defines the list of mesh's names you want to load
  70437. */
  70438. meshesNames: any,
  70439. /**
  70440. * Defines the root url to use as a base to load your meshes and associated resources
  70441. */
  70442. rootUrl: string,
  70443. /**
  70444. * Defines the filename of the scene to load from
  70445. */
  70446. sceneFilename: string);
  70447. /**
  70448. * Execute the current task
  70449. * @param scene defines the scene where you want your assets to be loaded
  70450. * @param onSuccess is a callback called when the task is successfully executed
  70451. * @param onError is a callback called if an error occurs
  70452. */
  70453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70454. }
  70455. /**
  70456. * Define a task used by AssetsManager to load text content
  70457. */
  70458. export class TextFileAssetTask extends AbstractAssetTask {
  70459. /**
  70460. * Defines the name of the task
  70461. */
  70462. name: string;
  70463. /**
  70464. * Defines the location of the file to load
  70465. */
  70466. url: string;
  70467. /**
  70468. * Gets the loaded text string
  70469. */
  70470. text: string;
  70471. /**
  70472. * Callback called when the task is successful
  70473. */
  70474. onSuccess: (task: TextFileAssetTask) => void;
  70475. /**
  70476. * Callback called when the task is successful
  70477. */
  70478. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70479. /**
  70480. * Creates a new TextFileAssetTask object
  70481. * @param name defines the name of the task
  70482. * @param url defines the location of the file to load
  70483. */
  70484. constructor(
  70485. /**
  70486. * Defines the name of the task
  70487. */
  70488. name: string,
  70489. /**
  70490. * Defines the location of the file to load
  70491. */
  70492. url: string);
  70493. /**
  70494. * Execute the current task
  70495. * @param scene defines the scene where you want your assets to be loaded
  70496. * @param onSuccess is a callback called when the task is successfully executed
  70497. * @param onError is a callback called if an error occurs
  70498. */
  70499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70500. }
  70501. /**
  70502. * Define a task used by AssetsManager to load binary data
  70503. */
  70504. export class BinaryFileAssetTask extends AbstractAssetTask {
  70505. /**
  70506. * Defines the name of the task
  70507. */
  70508. name: string;
  70509. /**
  70510. * Defines the location of the file to load
  70511. */
  70512. url: string;
  70513. /**
  70514. * Gets the lodaded data (as an array buffer)
  70515. */
  70516. data: ArrayBuffer;
  70517. /**
  70518. * Callback called when the task is successful
  70519. */
  70520. onSuccess: (task: BinaryFileAssetTask) => void;
  70521. /**
  70522. * Callback called when the task is successful
  70523. */
  70524. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70525. /**
  70526. * Creates a new BinaryFileAssetTask object
  70527. * @param name defines the name of the new task
  70528. * @param url defines the location of the file to load
  70529. */
  70530. constructor(
  70531. /**
  70532. * Defines the name of the task
  70533. */
  70534. name: string,
  70535. /**
  70536. * Defines the location of the file to load
  70537. */
  70538. url: string);
  70539. /**
  70540. * Execute the current task
  70541. * @param scene defines the scene where you want your assets to be loaded
  70542. * @param onSuccess is a callback called when the task is successfully executed
  70543. * @param onError is a callback called if an error occurs
  70544. */
  70545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70546. }
  70547. /**
  70548. * Define a task used by AssetsManager to load images
  70549. */
  70550. export class ImageAssetTask extends AbstractAssetTask {
  70551. /**
  70552. * Defines the name of the task
  70553. */
  70554. name: string;
  70555. /**
  70556. * Defines the location of the image to load
  70557. */
  70558. url: string;
  70559. /**
  70560. * Gets the loaded images
  70561. */
  70562. image: HTMLImageElement;
  70563. /**
  70564. * Callback called when the task is successful
  70565. */
  70566. onSuccess: (task: ImageAssetTask) => void;
  70567. /**
  70568. * Callback called when the task is successful
  70569. */
  70570. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70571. /**
  70572. * Creates a new ImageAssetTask
  70573. * @param name defines the name of the task
  70574. * @param url defines the location of the image to load
  70575. */
  70576. constructor(
  70577. /**
  70578. * Defines the name of the task
  70579. */
  70580. name: string,
  70581. /**
  70582. * Defines the location of the image to load
  70583. */
  70584. url: string);
  70585. /**
  70586. * Execute the current task
  70587. * @param scene defines the scene where you want your assets to be loaded
  70588. * @param onSuccess is a callback called when the task is successfully executed
  70589. * @param onError is a callback called if an error occurs
  70590. */
  70591. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70592. }
  70593. /**
  70594. * Defines the interface used by texture loading tasks
  70595. */
  70596. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70597. /**
  70598. * Gets the loaded texture
  70599. */
  70600. texture: TEX;
  70601. }
  70602. /**
  70603. * Define a task used by AssetsManager to load 2D textures
  70604. */
  70605. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70606. /**
  70607. * Defines the name of the task
  70608. */
  70609. name: string;
  70610. /**
  70611. * Defines the location of the file to load
  70612. */
  70613. url: string;
  70614. /**
  70615. * Defines if mipmap should not be generated (default is false)
  70616. */
  70617. noMipmap?: boolean | undefined;
  70618. /**
  70619. * Defines if texture must be inverted on Y axis (default is false)
  70620. */
  70621. invertY?: boolean | undefined;
  70622. /**
  70623. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70624. */
  70625. samplingMode: number;
  70626. /**
  70627. * Gets the loaded texture
  70628. */
  70629. texture: Texture;
  70630. /**
  70631. * Callback called when the task is successful
  70632. */
  70633. onSuccess: (task: TextureAssetTask) => void;
  70634. /**
  70635. * Callback called when the task is successful
  70636. */
  70637. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70638. /**
  70639. * Creates a new TextureAssetTask object
  70640. * @param name defines the name of the task
  70641. * @param url defines the location of the file to load
  70642. * @param noMipmap defines if mipmap should not be generated (default is false)
  70643. * @param invertY defines if texture must be inverted on Y axis (default is false)
  70644. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70645. */
  70646. constructor(
  70647. /**
  70648. * Defines the name of the task
  70649. */
  70650. name: string,
  70651. /**
  70652. * Defines the location of the file to load
  70653. */
  70654. url: string,
  70655. /**
  70656. * Defines if mipmap should not be generated (default is false)
  70657. */
  70658. noMipmap?: boolean | undefined,
  70659. /**
  70660. * Defines if texture must be inverted on Y axis (default is false)
  70661. */
  70662. invertY?: boolean | undefined,
  70663. /**
  70664. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70665. */
  70666. samplingMode?: number);
  70667. /**
  70668. * Execute the current task
  70669. * @param scene defines the scene where you want your assets to be loaded
  70670. * @param onSuccess is a callback called when the task is successfully executed
  70671. * @param onError is a callback called if an error occurs
  70672. */
  70673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70674. }
  70675. /**
  70676. * Define a task used by AssetsManager to load cube textures
  70677. */
  70678. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70679. /**
  70680. * Defines the name of the task
  70681. */
  70682. name: string;
  70683. /**
  70684. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70685. */
  70686. url: string;
  70687. /**
  70688. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70689. */
  70690. extensions?: string[] | undefined;
  70691. /**
  70692. * Defines if mipmaps should not be generated (default is false)
  70693. */
  70694. noMipmap?: boolean | undefined;
  70695. /**
  70696. * Defines the explicit list of files (undefined by default)
  70697. */
  70698. files?: string[] | undefined;
  70699. /**
  70700. * Gets the loaded texture
  70701. */
  70702. texture: CubeTexture;
  70703. /**
  70704. * Callback called when the task is successful
  70705. */
  70706. onSuccess: (task: CubeTextureAssetTask) => void;
  70707. /**
  70708. * Callback called when the task is successful
  70709. */
  70710. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70711. /**
  70712. * Creates a new CubeTextureAssetTask
  70713. * @param name defines the name of the task
  70714. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70715. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70716. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70717. * @param files defines the explicit list of files (undefined by default)
  70718. */
  70719. constructor(
  70720. /**
  70721. * Defines the name of the task
  70722. */
  70723. name: string,
  70724. /**
  70725. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70726. */
  70727. url: string,
  70728. /**
  70729. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70730. */
  70731. extensions?: string[] | undefined,
  70732. /**
  70733. * Defines if mipmaps should not be generated (default is false)
  70734. */
  70735. noMipmap?: boolean | undefined,
  70736. /**
  70737. * Defines the explicit list of files (undefined by default)
  70738. */
  70739. files?: string[] | undefined);
  70740. /**
  70741. * Execute the current task
  70742. * @param scene defines the scene where you want your assets to be loaded
  70743. * @param onSuccess is a callback called when the task is successfully executed
  70744. * @param onError is a callback called if an error occurs
  70745. */
  70746. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70747. }
  70748. /**
  70749. * Define a task used by AssetsManager to load HDR cube textures
  70750. */
  70751. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70752. /**
  70753. * Defines the name of the task
  70754. */
  70755. name: string;
  70756. /**
  70757. * Defines the location of the file to load
  70758. */
  70759. url: string;
  70760. /**
  70761. * Defines the desired size (the more it increases the longer the generation will be)
  70762. */
  70763. size: number;
  70764. /**
  70765. * Defines if mipmaps should not be generated (default is false)
  70766. */
  70767. noMipmap: boolean;
  70768. /**
  70769. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70770. */
  70771. generateHarmonics: boolean;
  70772. /**
  70773. * 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)
  70774. */
  70775. gammaSpace: boolean;
  70776. /**
  70777. * Internal Use Only
  70778. */
  70779. reserved: boolean;
  70780. /**
  70781. * Gets the loaded texture
  70782. */
  70783. texture: HDRCubeTexture;
  70784. /**
  70785. * Callback called when the task is successful
  70786. */
  70787. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70788. /**
  70789. * Callback called when the task is successful
  70790. */
  70791. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70792. /**
  70793. * Creates a new HDRCubeTextureAssetTask object
  70794. * @param name defines the name of the task
  70795. * @param url defines the location of the file to load
  70796. * @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.
  70797. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70798. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70799. * @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)
  70800. * @param reserved Internal use only
  70801. */
  70802. constructor(
  70803. /**
  70804. * Defines the name of the task
  70805. */
  70806. name: string,
  70807. /**
  70808. * Defines the location of the file to load
  70809. */
  70810. url: string,
  70811. /**
  70812. * Defines the desired size (the more it increases the longer the generation will be)
  70813. */
  70814. size: number,
  70815. /**
  70816. * Defines if mipmaps should not be generated (default is false)
  70817. */
  70818. noMipmap?: boolean,
  70819. /**
  70820. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70821. */
  70822. generateHarmonics?: boolean,
  70823. /**
  70824. * 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)
  70825. */
  70826. gammaSpace?: boolean,
  70827. /**
  70828. * Internal Use Only
  70829. */
  70830. reserved?: boolean);
  70831. /**
  70832. * Execute the current task
  70833. * @param scene defines the scene where you want your assets to be loaded
  70834. * @param onSuccess is a callback called when the task is successfully executed
  70835. * @param onError is a callback called if an error occurs
  70836. */
  70837. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70838. }
  70839. /**
  70840. * Define a task used by AssetsManager to load Equirectangular cube textures
  70841. */
  70842. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70843. /**
  70844. * Defines the name of the task
  70845. */
  70846. name: string;
  70847. /**
  70848. * Defines the location of the file to load
  70849. */
  70850. url: string;
  70851. /**
  70852. * Defines the desired size (the more it increases the longer the generation will be)
  70853. */
  70854. size: number;
  70855. /**
  70856. * Defines if mipmaps should not be generated (default is false)
  70857. */
  70858. noMipmap: boolean;
  70859. /**
  70860. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70861. * but the standard material would require them in Gamma space) (default is true)
  70862. */
  70863. gammaSpace: boolean;
  70864. /**
  70865. * Gets the loaded texture
  70866. */
  70867. texture: EquiRectangularCubeTexture;
  70868. /**
  70869. * Callback called when the task is successful
  70870. */
  70871. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70872. /**
  70873. * Callback called when the task is successful
  70874. */
  70875. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70876. /**
  70877. * Creates a new EquiRectangularCubeTextureAssetTask object
  70878. * @param name defines the name of the task
  70879. * @param url defines the location of the file to load
  70880. * @param size defines the desired size (the more it increases the longer the generation will be)
  70881. * If the size is omitted this implies you are using a preprocessed cubemap.
  70882. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70883. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70884. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70885. * (default is true)
  70886. */
  70887. constructor(
  70888. /**
  70889. * Defines the name of the task
  70890. */
  70891. name: string,
  70892. /**
  70893. * Defines the location of the file to load
  70894. */
  70895. url: string,
  70896. /**
  70897. * Defines the desired size (the more it increases the longer the generation will be)
  70898. */
  70899. size: number,
  70900. /**
  70901. * Defines if mipmaps should not be generated (default is false)
  70902. */
  70903. noMipmap?: boolean,
  70904. /**
  70905. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70906. * but the standard material would require them in Gamma space) (default is true)
  70907. */
  70908. gammaSpace?: boolean);
  70909. /**
  70910. * Execute the current task
  70911. * @param scene defines the scene where you want your assets to be loaded
  70912. * @param onSuccess is a callback called when the task is successfully executed
  70913. * @param onError is a callback called if an error occurs
  70914. */
  70915. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70916. }
  70917. /**
  70918. * This class can be used to easily import assets into a scene
  70919. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70920. */
  70921. export class AssetsManager {
  70922. private _scene;
  70923. private _isLoading;
  70924. protected _tasks: AbstractAssetTask[];
  70925. protected _waitingTasksCount: number;
  70926. protected _totalTasksCount: number;
  70927. /**
  70928. * Callback called when all tasks are processed
  70929. */
  70930. onFinish: (tasks: AbstractAssetTask[]) => void;
  70931. /**
  70932. * Callback called when a task is successful
  70933. */
  70934. onTaskSuccess: (task: AbstractAssetTask) => void;
  70935. /**
  70936. * Callback called when a task had an error
  70937. */
  70938. onTaskError: (task: AbstractAssetTask) => void;
  70939. /**
  70940. * Callback called when a task is done (whatever the result is)
  70941. */
  70942. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70943. /**
  70944. * Observable called when all tasks are processed
  70945. */
  70946. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70947. /**
  70948. * Observable called when a task had an error
  70949. */
  70950. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70951. /**
  70952. * Observable called when all tasks were executed
  70953. */
  70954. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70955. /**
  70956. * Observable called when a task is done (whatever the result is)
  70957. */
  70958. onProgressObservable: Observable<IAssetsProgressEvent>;
  70959. /**
  70960. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70961. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70962. */
  70963. useDefaultLoadingScreen: boolean;
  70964. /**
  70965. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70966. * when all assets have been downloaded.
  70967. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70968. */
  70969. autoHideLoadingUI: boolean;
  70970. /**
  70971. * Creates a new AssetsManager
  70972. * @param scene defines the scene to work on
  70973. */
  70974. constructor(scene: Scene);
  70975. /**
  70976. * Add a MeshAssetTask to the list of active tasks
  70977. * @param taskName defines the name of the new task
  70978. * @param meshesNames defines the name of meshes to load
  70979. * @param rootUrl defines the root url to use to locate files
  70980. * @param sceneFilename defines the filename of the scene file
  70981. * @returns a new MeshAssetTask object
  70982. */
  70983. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70984. /**
  70985. * Add a TextFileAssetTask to the list of active tasks
  70986. * @param taskName defines the name of the new task
  70987. * @param url defines the url of the file to load
  70988. * @returns a new TextFileAssetTask object
  70989. */
  70990. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70991. /**
  70992. * Add a BinaryFileAssetTask to the list of active tasks
  70993. * @param taskName defines the name of the new task
  70994. * @param url defines the url of the file to load
  70995. * @returns a new BinaryFileAssetTask object
  70996. */
  70997. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70998. /**
  70999. * Add a ImageAssetTask to the list of active tasks
  71000. * @param taskName defines the name of the new task
  71001. * @param url defines the url of the file to load
  71002. * @returns a new ImageAssetTask object
  71003. */
  71004. addImageTask(taskName: string, url: string): ImageAssetTask;
  71005. /**
  71006. * Add a TextureAssetTask to the list of active tasks
  71007. * @param taskName defines the name of the new task
  71008. * @param url defines the url of the file to load
  71009. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71010. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71011. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71012. * @returns a new TextureAssetTask object
  71013. */
  71014. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71015. /**
  71016. * Add a CubeTextureAssetTask to the list of active tasks
  71017. * @param taskName defines the name of the new task
  71018. * @param url defines the url of the file to load
  71019. * @param extensions defines the extension to use to load the cube map (can be null)
  71020. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71021. * @param files defines the list of files to load (can be null)
  71022. * @returns a new CubeTextureAssetTask object
  71023. */
  71024. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71025. /**
  71026. *
  71027. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71028. * @param taskName defines the name of the new task
  71029. * @param url defines the url of the file to load
  71030. * @param size defines the size you want for the cubemap (can be null)
  71031. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71032. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71033. * @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)
  71034. * @param reserved Internal use only
  71035. * @returns a new HDRCubeTextureAssetTask object
  71036. */
  71037. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71038. /**
  71039. *
  71040. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71041. * @param taskName defines the name of the new task
  71042. * @param url defines the url of the file to load
  71043. * @param size defines the size you want for the cubemap (can be null)
  71044. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71045. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71046. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71047. * @returns a new EquiRectangularCubeTextureAssetTask object
  71048. */
  71049. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71050. /**
  71051. * Remove a task from the assets manager.
  71052. * @param task the task to remove
  71053. */
  71054. removeTask(task: AbstractAssetTask): void;
  71055. private _decreaseWaitingTasksCount;
  71056. private _runTask;
  71057. /**
  71058. * Reset the AssetsManager and remove all tasks
  71059. * @return the current instance of the AssetsManager
  71060. */
  71061. reset(): AssetsManager;
  71062. /**
  71063. * Start the loading process
  71064. * @return the current instance of the AssetsManager
  71065. */
  71066. load(): AssetsManager;
  71067. /**
  71068. * Start the loading process as an async operation
  71069. * @return a promise returning the list of failed tasks
  71070. */
  71071. loadAsync(): Promise<void>;
  71072. }
  71073. }
  71074. declare module "babylonjs/Misc/deferred" {
  71075. /**
  71076. * Wrapper class for promise with external resolve and reject.
  71077. */
  71078. export class Deferred<T> {
  71079. /**
  71080. * The promise associated with this deferred object.
  71081. */
  71082. readonly promise: Promise<T>;
  71083. private _resolve;
  71084. private _reject;
  71085. /**
  71086. * The resolve method of the promise associated with this deferred object.
  71087. */
  71088. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71089. /**
  71090. * The reject method of the promise associated with this deferred object.
  71091. */
  71092. get reject(): (reason?: any) => void;
  71093. /**
  71094. * Constructor for this deferred object.
  71095. */
  71096. constructor();
  71097. }
  71098. }
  71099. declare module "babylonjs/Misc/meshExploder" {
  71100. import { Mesh } from "babylonjs/Meshes/mesh";
  71101. /**
  71102. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71103. */
  71104. export class MeshExploder {
  71105. private _centerMesh;
  71106. private _meshes;
  71107. private _meshesOrigins;
  71108. private _toCenterVectors;
  71109. private _scaledDirection;
  71110. private _newPosition;
  71111. private _centerPosition;
  71112. /**
  71113. * Explodes meshes from a center mesh.
  71114. * @param meshes The meshes to explode.
  71115. * @param centerMesh The mesh to be center of explosion.
  71116. */
  71117. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71118. private _setCenterMesh;
  71119. /**
  71120. * Get class name
  71121. * @returns "MeshExploder"
  71122. */
  71123. getClassName(): string;
  71124. /**
  71125. * "Exploded meshes"
  71126. * @returns Array of meshes with the centerMesh at index 0.
  71127. */
  71128. getMeshes(): Array<Mesh>;
  71129. /**
  71130. * Explodes meshes giving a specific direction
  71131. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71132. */
  71133. explode(direction?: number): void;
  71134. }
  71135. }
  71136. declare module "babylonjs/Misc/filesInput" {
  71137. import { Engine } from "babylonjs/Engines/engine";
  71138. import { Scene } from "babylonjs/scene";
  71139. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71140. /**
  71141. * Class used to help managing file picking and drag'n'drop
  71142. */
  71143. export class FilesInput {
  71144. /**
  71145. * List of files ready to be loaded
  71146. */
  71147. static get FilesToLoad(): {
  71148. [key: string]: File;
  71149. };
  71150. /**
  71151. * Callback called when a file is processed
  71152. */
  71153. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71154. private _engine;
  71155. private _currentScene;
  71156. private _sceneLoadedCallback;
  71157. private _progressCallback;
  71158. private _additionalRenderLoopLogicCallback;
  71159. private _textureLoadingCallback;
  71160. private _startingProcessingFilesCallback;
  71161. private _onReloadCallback;
  71162. private _errorCallback;
  71163. private _elementToMonitor;
  71164. private _sceneFileToLoad;
  71165. private _filesToLoad;
  71166. /**
  71167. * Creates a new FilesInput
  71168. * @param engine defines the rendering engine
  71169. * @param scene defines the hosting scene
  71170. * @param sceneLoadedCallback callback called when scene is loaded
  71171. * @param progressCallback callback called to track progress
  71172. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71173. * @param textureLoadingCallback callback called when a texture is loading
  71174. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71175. * @param onReloadCallback callback called when a reload is requested
  71176. * @param errorCallback callback call if an error occurs
  71177. */
  71178. 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);
  71179. private _dragEnterHandler;
  71180. private _dragOverHandler;
  71181. private _dropHandler;
  71182. /**
  71183. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71184. * @param elementToMonitor defines the DOM element to track
  71185. */
  71186. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71187. /**
  71188. * Release all associated resources
  71189. */
  71190. dispose(): void;
  71191. private renderFunction;
  71192. private drag;
  71193. private drop;
  71194. private _traverseFolder;
  71195. private _processFiles;
  71196. /**
  71197. * Load files from a drop event
  71198. * @param event defines the drop event to use as source
  71199. */
  71200. loadFiles(event: any): void;
  71201. private _processReload;
  71202. /**
  71203. * Reload the current scene from the loaded files
  71204. */
  71205. reload(): void;
  71206. }
  71207. }
  71208. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71209. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71210. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71211. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71212. }
  71213. declare module "babylonjs/Misc/sceneOptimizer" {
  71214. import { Scene, IDisposable } from "babylonjs/scene";
  71215. import { Observable } from "babylonjs/Misc/observable";
  71216. /**
  71217. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71219. */
  71220. export class SceneOptimization {
  71221. /**
  71222. * Defines the priority of this optimization (0 by default which means first in the list)
  71223. */
  71224. priority: number;
  71225. /**
  71226. * Gets a string describing the action executed by the current optimization
  71227. * @returns description string
  71228. */
  71229. getDescription(): string;
  71230. /**
  71231. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71232. * @param scene defines the current scene where to apply this optimization
  71233. * @param optimizer defines the current optimizer
  71234. * @returns true if everything that can be done was applied
  71235. */
  71236. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71237. /**
  71238. * Creates the SceneOptimization object
  71239. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71240. * @param desc defines the description associated with the optimization
  71241. */
  71242. constructor(
  71243. /**
  71244. * Defines the priority of this optimization (0 by default which means first in the list)
  71245. */
  71246. priority?: number);
  71247. }
  71248. /**
  71249. * Defines an optimization used to reduce the size of render target textures
  71250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71251. */
  71252. export class TextureOptimization extends SceneOptimization {
  71253. /**
  71254. * Defines the priority of this optimization (0 by default which means first in the list)
  71255. */
  71256. priority: number;
  71257. /**
  71258. * 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
  71259. */
  71260. maximumSize: number;
  71261. /**
  71262. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71263. */
  71264. step: number;
  71265. /**
  71266. * Gets a string describing the action executed by the current optimization
  71267. * @returns description string
  71268. */
  71269. getDescription(): string;
  71270. /**
  71271. * Creates the TextureOptimization object
  71272. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71273. * @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
  71274. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71275. */
  71276. constructor(
  71277. /**
  71278. * Defines the priority of this optimization (0 by default which means first in the list)
  71279. */
  71280. priority?: number,
  71281. /**
  71282. * 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
  71283. */
  71284. maximumSize?: number,
  71285. /**
  71286. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71287. */
  71288. step?: number);
  71289. /**
  71290. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71291. * @param scene defines the current scene where to apply this optimization
  71292. * @param optimizer defines the current optimizer
  71293. * @returns true if everything that can be done was applied
  71294. */
  71295. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71296. }
  71297. /**
  71298. * Defines an optimization used to increase or decrease the rendering resolution
  71299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71300. */
  71301. export class HardwareScalingOptimization extends SceneOptimization {
  71302. /**
  71303. * Defines the priority of this optimization (0 by default which means first in the list)
  71304. */
  71305. priority: number;
  71306. /**
  71307. * Defines the maximum scale to use (2 by default)
  71308. */
  71309. maximumScale: number;
  71310. /**
  71311. * Defines the step to use between two passes (0.5 by default)
  71312. */
  71313. step: number;
  71314. private _currentScale;
  71315. private _directionOffset;
  71316. /**
  71317. * Gets a string describing the action executed by the current optimization
  71318. * @return description string
  71319. */
  71320. getDescription(): string;
  71321. /**
  71322. * Creates the HardwareScalingOptimization object
  71323. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71324. * @param maximumScale defines the maximum scale to use (2 by default)
  71325. * @param step defines the step to use between two passes (0.5 by default)
  71326. */
  71327. constructor(
  71328. /**
  71329. * Defines the priority of this optimization (0 by default which means first in the list)
  71330. */
  71331. priority?: number,
  71332. /**
  71333. * Defines the maximum scale to use (2 by default)
  71334. */
  71335. maximumScale?: number,
  71336. /**
  71337. * Defines the step to use between two passes (0.5 by default)
  71338. */
  71339. step?: number);
  71340. /**
  71341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71342. * @param scene defines the current scene where to apply this optimization
  71343. * @param optimizer defines the current optimizer
  71344. * @returns true if everything that can be done was applied
  71345. */
  71346. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71347. }
  71348. /**
  71349. * Defines an optimization used to remove shadows
  71350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71351. */
  71352. export class ShadowsOptimization extends SceneOptimization {
  71353. /**
  71354. * Gets a string describing the action executed by the current optimization
  71355. * @return description string
  71356. */
  71357. getDescription(): string;
  71358. /**
  71359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71360. * @param scene defines the current scene where to apply this optimization
  71361. * @param optimizer defines the current optimizer
  71362. * @returns true if everything that can be done was applied
  71363. */
  71364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71365. }
  71366. /**
  71367. * Defines an optimization used to turn post-processes off
  71368. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71369. */
  71370. export class PostProcessesOptimization extends SceneOptimization {
  71371. /**
  71372. * Gets a string describing the action executed by the current optimization
  71373. * @return description string
  71374. */
  71375. getDescription(): string;
  71376. /**
  71377. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71378. * @param scene defines the current scene where to apply this optimization
  71379. * @param optimizer defines the current optimizer
  71380. * @returns true if everything that can be done was applied
  71381. */
  71382. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71383. }
  71384. /**
  71385. * Defines an optimization used to turn lens flares off
  71386. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71387. */
  71388. export class LensFlaresOptimization extends SceneOptimization {
  71389. /**
  71390. * Gets a string describing the action executed by the current optimization
  71391. * @return description string
  71392. */
  71393. getDescription(): string;
  71394. /**
  71395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71396. * @param scene defines the current scene where to apply this optimization
  71397. * @param optimizer defines the current optimizer
  71398. * @returns true if everything that can be done was applied
  71399. */
  71400. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71401. }
  71402. /**
  71403. * Defines an optimization based on user defined callback.
  71404. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71405. */
  71406. export class CustomOptimization extends SceneOptimization {
  71407. /**
  71408. * Callback called to apply the custom optimization.
  71409. */
  71410. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71411. /**
  71412. * Callback called to get custom description
  71413. */
  71414. onGetDescription: () => string;
  71415. /**
  71416. * Gets a string describing the action executed by the current optimization
  71417. * @returns description string
  71418. */
  71419. getDescription(): string;
  71420. /**
  71421. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71422. * @param scene defines the current scene where to apply this optimization
  71423. * @param optimizer defines the current optimizer
  71424. * @returns true if everything that can be done was applied
  71425. */
  71426. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71427. }
  71428. /**
  71429. * Defines an optimization used to turn particles off
  71430. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71431. */
  71432. export class ParticlesOptimization extends SceneOptimization {
  71433. /**
  71434. * Gets a string describing the action executed by the current optimization
  71435. * @return description string
  71436. */
  71437. getDescription(): string;
  71438. /**
  71439. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71440. * @param scene defines the current scene where to apply this optimization
  71441. * @param optimizer defines the current optimizer
  71442. * @returns true if everything that can be done was applied
  71443. */
  71444. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71445. }
  71446. /**
  71447. * Defines an optimization used to turn render targets off
  71448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71449. */
  71450. export class RenderTargetsOptimization extends SceneOptimization {
  71451. /**
  71452. * Gets a string describing the action executed by the current optimization
  71453. * @return description string
  71454. */
  71455. getDescription(): string;
  71456. /**
  71457. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71458. * @param scene defines the current scene where to apply this optimization
  71459. * @param optimizer defines the current optimizer
  71460. * @returns true if everything that can be done was applied
  71461. */
  71462. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71463. }
  71464. /**
  71465. * Defines an optimization used to merge meshes with compatible materials
  71466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71467. */
  71468. export class MergeMeshesOptimization extends SceneOptimization {
  71469. private static _UpdateSelectionTree;
  71470. /**
  71471. * Gets or sets a boolean which defines if optimization octree has to be updated
  71472. */
  71473. static get UpdateSelectionTree(): boolean;
  71474. /**
  71475. * Gets or sets a boolean which defines if optimization octree has to be updated
  71476. */
  71477. static set UpdateSelectionTree(value: boolean);
  71478. /**
  71479. * Gets a string describing the action executed by the current optimization
  71480. * @return description string
  71481. */
  71482. getDescription(): string;
  71483. private _canBeMerged;
  71484. /**
  71485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71486. * @param scene defines the current scene where to apply this optimization
  71487. * @param optimizer defines the current optimizer
  71488. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71489. * @returns true if everything that can be done was applied
  71490. */
  71491. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71492. }
  71493. /**
  71494. * Defines a list of options used by SceneOptimizer
  71495. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71496. */
  71497. export class SceneOptimizerOptions {
  71498. /**
  71499. * Defines the target frame rate to reach (60 by default)
  71500. */
  71501. targetFrameRate: number;
  71502. /**
  71503. * Defines the interval between two checkes (2000ms by default)
  71504. */
  71505. trackerDuration: number;
  71506. /**
  71507. * Gets the list of optimizations to apply
  71508. */
  71509. optimizations: SceneOptimization[];
  71510. /**
  71511. * Creates a new list of options used by SceneOptimizer
  71512. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71513. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71514. */
  71515. constructor(
  71516. /**
  71517. * Defines the target frame rate to reach (60 by default)
  71518. */
  71519. targetFrameRate?: number,
  71520. /**
  71521. * Defines the interval between two checkes (2000ms by default)
  71522. */
  71523. trackerDuration?: number);
  71524. /**
  71525. * Add a new optimization
  71526. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71527. * @returns the current SceneOptimizerOptions
  71528. */
  71529. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71530. /**
  71531. * Add a new custom optimization
  71532. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71533. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71534. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71535. * @returns the current SceneOptimizerOptions
  71536. */
  71537. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71538. /**
  71539. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71540. * @param targetFrameRate defines the target frame rate (60 by default)
  71541. * @returns a SceneOptimizerOptions object
  71542. */
  71543. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71544. /**
  71545. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71546. * @param targetFrameRate defines the target frame rate (60 by default)
  71547. * @returns a SceneOptimizerOptions object
  71548. */
  71549. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71550. /**
  71551. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71552. * @param targetFrameRate defines the target frame rate (60 by default)
  71553. * @returns a SceneOptimizerOptions object
  71554. */
  71555. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71556. }
  71557. /**
  71558. * Class used to run optimizations in order to reach a target frame rate
  71559. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71560. */
  71561. export class SceneOptimizer implements IDisposable {
  71562. private _isRunning;
  71563. private _options;
  71564. private _scene;
  71565. private _currentPriorityLevel;
  71566. private _targetFrameRate;
  71567. private _trackerDuration;
  71568. private _currentFrameRate;
  71569. private _sceneDisposeObserver;
  71570. private _improvementMode;
  71571. /**
  71572. * Defines an observable called when the optimizer reaches the target frame rate
  71573. */
  71574. onSuccessObservable: Observable<SceneOptimizer>;
  71575. /**
  71576. * Defines an observable called when the optimizer enables an optimization
  71577. */
  71578. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71579. /**
  71580. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71581. */
  71582. onFailureObservable: Observable<SceneOptimizer>;
  71583. /**
  71584. * Gets a boolean indicating if the optimizer is in improvement mode
  71585. */
  71586. get isInImprovementMode(): boolean;
  71587. /**
  71588. * Gets the current priority level (0 at start)
  71589. */
  71590. get currentPriorityLevel(): number;
  71591. /**
  71592. * Gets the current frame rate checked by the SceneOptimizer
  71593. */
  71594. get currentFrameRate(): number;
  71595. /**
  71596. * Gets or sets the current target frame rate (60 by default)
  71597. */
  71598. get targetFrameRate(): number;
  71599. /**
  71600. * Gets or sets the current target frame rate (60 by default)
  71601. */
  71602. set targetFrameRate(value: number);
  71603. /**
  71604. * Gets or sets the current interval between two checks (every 2000ms by default)
  71605. */
  71606. get trackerDuration(): number;
  71607. /**
  71608. * Gets or sets the current interval between two checks (every 2000ms by default)
  71609. */
  71610. set trackerDuration(value: number);
  71611. /**
  71612. * Gets the list of active optimizations
  71613. */
  71614. get optimizations(): SceneOptimization[];
  71615. /**
  71616. * Creates a new SceneOptimizer
  71617. * @param scene defines the scene to work on
  71618. * @param options defines the options to use with the SceneOptimizer
  71619. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71620. * @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)
  71621. */
  71622. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71623. /**
  71624. * Stops the current optimizer
  71625. */
  71626. stop(): void;
  71627. /**
  71628. * Reset the optimizer to initial step (current priority level = 0)
  71629. */
  71630. reset(): void;
  71631. /**
  71632. * Start the optimizer. By default it will try to reach a specific framerate
  71633. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71634. */
  71635. start(): void;
  71636. private _checkCurrentState;
  71637. /**
  71638. * Release all resources
  71639. */
  71640. dispose(): void;
  71641. /**
  71642. * Helper function to create a SceneOptimizer with one single line of code
  71643. * @param scene defines the scene to work on
  71644. * @param options defines the options to use with the SceneOptimizer
  71645. * @param onSuccess defines a callback to call on success
  71646. * @param onFailure defines a callback to call on failure
  71647. * @returns the new SceneOptimizer object
  71648. */
  71649. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71650. }
  71651. }
  71652. declare module "babylonjs/Misc/sceneSerializer" {
  71653. import { Scene } from "babylonjs/scene";
  71654. /**
  71655. * Class used to serialize a scene into a string
  71656. */
  71657. export class SceneSerializer {
  71658. /**
  71659. * Clear cache used by a previous serialization
  71660. */
  71661. static ClearCache(): void;
  71662. /**
  71663. * Serialize a scene into a JSON compatible object
  71664. * @param scene defines the scene to serialize
  71665. * @returns a JSON compatible object
  71666. */
  71667. static Serialize(scene: Scene): any;
  71668. /**
  71669. * Serialize a mesh into a JSON compatible object
  71670. * @param toSerialize defines the mesh to serialize
  71671. * @param withParents defines if parents must be serialized as well
  71672. * @param withChildren defines if children must be serialized as well
  71673. * @returns a JSON compatible object
  71674. */
  71675. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71676. }
  71677. }
  71678. declare module "babylonjs/Misc/textureTools" {
  71679. import { Texture } from "babylonjs/Materials/Textures/texture";
  71680. /**
  71681. * Class used to host texture specific utilities
  71682. */
  71683. export class TextureTools {
  71684. /**
  71685. * Uses the GPU to create a copy texture rescaled at a given size
  71686. * @param texture Texture to copy from
  71687. * @param width defines the desired width
  71688. * @param height defines the desired height
  71689. * @param useBilinearMode defines if bilinear mode has to be used
  71690. * @return the generated texture
  71691. */
  71692. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71693. }
  71694. }
  71695. declare module "babylonjs/Misc/videoRecorder" {
  71696. import { Nullable } from "babylonjs/types";
  71697. import { Engine } from "babylonjs/Engines/engine";
  71698. /**
  71699. * This represents the different options available for the video capture.
  71700. */
  71701. export interface VideoRecorderOptions {
  71702. /** Defines the mime type of the video. */
  71703. mimeType: string;
  71704. /** Defines the FPS the video should be recorded at. */
  71705. fps: number;
  71706. /** Defines the chunk size for the recording data. */
  71707. recordChunckSize: number;
  71708. /** The audio tracks to attach to the recording. */
  71709. audioTracks?: MediaStreamTrack[];
  71710. }
  71711. /**
  71712. * This can help with recording videos from BabylonJS.
  71713. * This is based on the available WebRTC functionalities of the browser.
  71714. *
  71715. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71716. */
  71717. export class VideoRecorder {
  71718. private static readonly _defaultOptions;
  71719. /**
  71720. * Returns whether or not the VideoRecorder is available in your browser.
  71721. * @param engine Defines the Babylon Engine.
  71722. * @returns true if supported otherwise false.
  71723. */
  71724. static IsSupported(engine: Engine): boolean;
  71725. private readonly _options;
  71726. private _canvas;
  71727. private _mediaRecorder;
  71728. private _recordedChunks;
  71729. private _fileName;
  71730. private _resolve;
  71731. private _reject;
  71732. /**
  71733. * True when a recording is already in progress.
  71734. */
  71735. get isRecording(): boolean;
  71736. /**
  71737. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71738. * @param engine Defines the BabylonJS Engine you wish to record.
  71739. * @param options Defines options that can be used to customize the capture.
  71740. */
  71741. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71742. /**
  71743. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71744. */
  71745. stopRecording(): void;
  71746. /**
  71747. * Starts recording the canvas for a max duration specified in parameters.
  71748. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71749. * If null no automatic download will start and you can rely on the promise to get the data back.
  71750. * @param maxDuration Defines the maximum recording time in seconds.
  71751. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71752. * @return A promise callback at the end of the recording with the video data in Blob.
  71753. */
  71754. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71755. /**
  71756. * Releases internal resources used during the recording.
  71757. */
  71758. dispose(): void;
  71759. private _handleDataAvailable;
  71760. private _handleError;
  71761. private _handleStop;
  71762. }
  71763. }
  71764. declare module "babylonjs/Misc/screenshotTools" {
  71765. import { Camera } from "babylonjs/Cameras/camera";
  71766. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  71767. import { Engine } from "babylonjs/Engines/engine";
  71768. /**
  71769. * Class containing a set of static utilities functions for screenshots
  71770. */
  71771. export class ScreenshotTools {
  71772. /**
  71773. * Captures a screenshot of the current rendering
  71774. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71775. * @param engine defines the rendering engine
  71776. * @param camera defines the source camera
  71777. * @param size This parameter can be set to a single number or to an object with the
  71778. * following (optional) properties: precision, width, height. If a single number is passed,
  71779. * it will be used for both width and height. If an object is passed, the screenshot size
  71780. * will be derived from the parameters. The precision property is a multiplier allowing
  71781. * rendering at a higher or lower resolution
  71782. * @param successCallback defines the callback receives a single parameter which contains the
  71783. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71784. * src parameter of an <img> to display it
  71785. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71786. * Check your browser for supported MIME types
  71787. */
  71788. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71789. /**
  71790. * Captures a screenshot of the current rendering
  71791. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71792. * @param engine defines the rendering engine
  71793. * @param camera defines the source camera
  71794. * @param size This parameter can be set to a single number or to an object with the
  71795. * following (optional) properties: precision, width, height. If a single number is passed,
  71796. * it will be used for both width and height. If an object is passed, the screenshot size
  71797. * will be derived from the parameters. The precision property is a multiplier allowing
  71798. * rendering at a higher or lower resolution
  71799. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71800. * Check your browser for supported MIME types
  71801. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71802. * to the src parameter of an <img> to display it
  71803. */
  71804. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71805. /**
  71806. * Generates an image screenshot from the specified camera.
  71807. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71808. * @param engine The engine to use for rendering
  71809. * @param camera The camera to use for rendering
  71810. * @param size This parameter can be set to a single number or to an object with the
  71811. * following (optional) properties: precision, width, height. If a single number is passed,
  71812. * it will be used for both width and height. If an object is passed, the screenshot size
  71813. * will be derived from the parameters. The precision property is a multiplier allowing
  71814. * rendering at a higher or lower resolution
  71815. * @param successCallback The callback receives a single parameter which contains the
  71816. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71817. * src parameter of an <img> to display it
  71818. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71819. * Check your browser for supported MIME types
  71820. * @param samples Texture samples (default: 1)
  71821. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71822. * @param fileName A name for for the downloaded file.
  71823. */
  71824. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  71825. /**
  71826. * Generates an image screenshot from the specified camera.
  71827. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71828. * @param engine The engine to use for rendering
  71829. * @param camera The camera to use for rendering
  71830. * @param size This parameter can be set to a single number or to an object with the
  71831. * following (optional) properties: precision, width, height. If a single number is passed,
  71832. * it will be used for both width and height. If an object is passed, the screenshot size
  71833. * will be derived from the parameters. The precision property is a multiplier allowing
  71834. * rendering at a higher or lower resolution
  71835. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71836. * Check your browser for supported MIME types
  71837. * @param samples Texture samples (default: 1)
  71838. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71839. * @param fileName A name for for the downloaded file.
  71840. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71841. * to the src parameter of an <img> to display it
  71842. */
  71843. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  71844. /**
  71845. * Gets height and width for screenshot size
  71846. * @private
  71847. */
  71848. private static _getScreenshotSize;
  71849. }
  71850. }
  71851. declare module "babylonjs/Misc/dataReader" {
  71852. /**
  71853. * Interface for a data buffer
  71854. */
  71855. export interface IDataBuffer {
  71856. /**
  71857. * Reads bytes from the data buffer.
  71858. * @param byteOffset The byte offset to read
  71859. * @param byteLength The byte length to read
  71860. * @returns A promise that resolves when the bytes are read
  71861. */
  71862. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71863. /**
  71864. * The byte length of the buffer.
  71865. */
  71866. readonly byteLength: number;
  71867. }
  71868. /**
  71869. * Utility class for reading from a data buffer
  71870. */
  71871. export class DataReader {
  71872. /**
  71873. * The data buffer associated with this data reader.
  71874. */
  71875. readonly buffer: IDataBuffer;
  71876. /**
  71877. * The current byte offset from the beginning of the data buffer.
  71878. */
  71879. byteOffset: number;
  71880. private _dataView;
  71881. private _dataByteOffset;
  71882. /**
  71883. * Constructor
  71884. * @param buffer The buffer to read
  71885. */
  71886. constructor(buffer: IDataBuffer);
  71887. /**
  71888. * Loads the given byte length.
  71889. * @param byteLength The byte length to load
  71890. * @returns A promise that resolves when the load is complete
  71891. */
  71892. loadAsync(byteLength: number): Promise<void>;
  71893. /**
  71894. * Read a unsigned 32-bit integer from the currently loaded data range.
  71895. * @returns The 32-bit integer read
  71896. */
  71897. readUint32(): number;
  71898. /**
  71899. * Read a byte array from the currently loaded data range.
  71900. * @param byteLength The byte length to read
  71901. * @returns The byte array read
  71902. */
  71903. readUint8Array(byteLength: number): Uint8Array;
  71904. /**
  71905. * Read a string from the currently loaded data range.
  71906. * @param byteLength The byte length to read
  71907. * @returns The string read
  71908. */
  71909. readString(byteLength: number): string;
  71910. /**
  71911. * Skips the given byte length the currently loaded data range.
  71912. * @param byteLength The byte length to skip
  71913. */
  71914. skipBytes(byteLength: number): void;
  71915. }
  71916. }
  71917. declare module "babylonjs/Misc/index" {
  71918. export * from "babylonjs/Misc/andOrNotEvaluator";
  71919. export * from "babylonjs/Misc/assetsManager";
  71920. export * from "babylonjs/Misc/basis";
  71921. export * from "babylonjs/Misc/dds";
  71922. export * from "babylonjs/Misc/decorators";
  71923. export * from "babylonjs/Misc/deferred";
  71924. export * from "babylonjs/Misc/environmentTextureTools";
  71925. export * from "babylonjs/Misc/meshExploder";
  71926. export * from "babylonjs/Misc/filesInput";
  71927. export * from "babylonjs/Misc/HighDynamicRange/index";
  71928. export * from "babylonjs/Misc/khronosTextureContainer";
  71929. export * from "babylonjs/Misc/observable";
  71930. export * from "babylonjs/Misc/performanceMonitor";
  71931. export * from "babylonjs/Misc/promise";
  71932. export * from "babylonjs/Misc/sceneOptimizer";
  71933. export * from "babylonjs/Misc/sceneSerializer";
  71934. export * from "babylonjs/Misc/smartArray";
  71935. export * from "babylonjs/Misc/stringDictionary";
  71936. export * from "babylonjs/Misc/tags";
  71937. export * from "babylonjs/Misc/textureTools";
  71938. export * from "babylonjs/Misc/tga";
  71939. export * from "babylonjs/Misc/tools";
  71940. export * from "babylonjs/Misc/videoRecorder";
  71941. export * from "babylonjs/Misc/virtualJoystick";
  71942. export * from "babylonjs/Misc/workerPool";
  71943. export * from "babylonjs/Misc/logger";
  71944. export * from "babylonjs/Misc/typeStore";
  71945. export * from "babylonjs/Misc/filesInputStore";
  71946. export * from "babylonjs/Misc/deepCopier";
  71947. export * from "babylonjs/Misc/pivotTools";
  71948. export * from "babylonjs/Misc/precisionDate";
  71949. export * from "babylonjs/Misc/screenshotTools";
  71950. export * from "babylonjs/Misc/typeStore";
  71951. export * from "babylonjs/Misc/webRequest";
  71952. export * from "babylonjs/Misc/iInspectable";
  71953. export * from "babylonjs/Misc/brdfTextureTools";
  71954. export * from "babylonjs/Misc/rgbdTextureTools";
  71955. export * from "babylonjs/Misc/gradients";
  71956. export * from "babylonjs/Misc/perfCounter";
  71957. export * from "babylonjs/Misc/fileRequest";
  71958. export * from "babylonjs/Misc/customAnimationFrameRequester";
  71959. export * from "babylonjs/Misc/retryStrategy";
  71960. export * from "babylonjs/Misc/interfaces/screenshotSize";
  71961. export * from "babylonjs/Misc/canvasGenerator";
  71962. export * from "babylonjs/Misc/fileTools";
  71963. export * from "babylonjs/Misc/stringTools";
  71964. export * from "babylonjs/Misc/dataReader";
  71965. export * from "babylonjs/Misc/minMaxReducer";
  71966. export * from "babylonjs/Misc/depthReducer";
  71967. }
  71968. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  71969. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  71970. import { Observable } from "babylonjs/Misc/observable";
  71971. import { Matrix } from "babylonjs/Maths/math.vector";
  71972. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71973. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  71974. /**
  71975. * Options used for hit testing
  71976. */
  71977. export interface IWebXRHitTestOptions {
  71978. /**
  71979. * Only test when user interacted with the scene. Default - hit test every frame
  71980. */
  71981. testOnPointerDownOnly?: boolean;
  71982. /**
  71983. * The node to use to transform the local results to world coordinates
  71984. */
  71985. worldParentNode?: TransformNode;
  71986. }
  71987. /**
  71988. * Interface defining the babylon result of raycasting/hit-test
  71989. */
  71990. export interface IWebXRHitResult {
  71991. /**
  71992. * The native hit test result
  71993. */
  71994. xrHitResult: XRHitResult;
  71995. /**
  71996. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71997. */
  71998. transformationMatrix: Matrix;
  71999. }
  72000. /**
  72001. * The currently-working hit-test module.
  72002. * Hit test (or raycasting) is used to interact with the real world.
  72003. * For further information read here - https://github.com/immersive-web/hit-test
  72004. */
  72005. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72006. /**
  72007. * options to use when constructing this feature
  72008. */
  72009. readonly options: IWebXRHitTestOptions;
  72010. /**
  72011. * The module's name
  72012. */
  72013. static readonly Name: string;
  72014. /**
  72015. * The (Babylon) version of this module.
  72016. * This is an integer representing the implementation version.
  72017. * This number does not correspond to the webxr specs version
  72018. */
  72019. static readonly Version: number;
  72020. /**
  72021. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72022. * @param event the (select) event to use to select with
  72023. * @param referenceSpace the reference space to use for this hit test
  72024. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72025. */
  72026. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72027. /**
  72028. * execute a hit test with an XR Ray
  72029. *
  72030. * @param xrSession a native xrSession that will execute this hit test
  72031. * @param xrRay the ray (position and direction) to use for raycasting
  72032. * @param referenceSpace native XR reference space to use for the hit-test
  72033. * @param filter filter function that will filter the results
  72034. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72035. */
  72036. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72037. /**
  72038. * Triggered when new babylon (transformed) hit test results are available
  72039. */
  72040. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72041. private _onSelectEnabled;
  72042. /**
  72043. * Creates a new instance of the (legacy version) hit test feature
  72044. * @param _xrSessionManager an instance of WebXRSessionManager
  72045. * @param options options to use when constructing this feature
  72046. */
  72047. constructor(_xrSessionManager: WebXRSessionManager,
  72048. /**
  72049. * options to use when constructing this feature
  72050. */
  72051. options?: IWebXRHitTestOptions);
  72052. /**
  72053. * Populated with the last native XR Hit Results
  72054. */
  72055. lastNativeXRHitResults: XRHitResult[];
  72056. /**
  72057. * attach this feature
  72058. * Will usually be called by the features manager
  72059. *
  72060. * @returns true if successful.
  72061. */
  72062. attach(): boolean;
  72063. /**
  72064. * detach this feature.
  72065. * Will usually be called by the features manager
  72066. *
  72067. * @returns true if successful.
  72068. */
  72069. detach(): boolean;
  72070. private _onHitTestResults;
  72071. private _origin;
  72072. private _direction;
  72073. private _mat;
  72074. protected _onXRFrame(frame: XRFrame): void;
  72075. private _onSelect;
  72076. /**
  72077. * Dispose this feature and all of the resources attached
  72078. */
  72079. dispose(): void;
  72080. }
  72081. }
  72082. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72084. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72085. import { Observable } from "babylonjs/Misc/observable";
  72086. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72087. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72088. /**
  72089. * Options used in the plane detector module
  72090. */
  72091. export interface IWebXRPlaneDetectorOptions {
  72092. /**
  72093. * The node to use to transform the local results to world coordinates
  72094. */
  72095. worldParentNode?: TransformNode;
  72096. }
  72097. /**
  72098. * A babylon interface for a webxr plane.
  72099. * A Plane is actually a polygon, built from N points in space
  72100. *
  72101. * Supported in chrome 79, not supported in canary 81 ATM
  72102. */
  72103. export interface IWebXRPlane {
  72104. /**
  72105. * a babylon-assigned ID for this polygon
  72106. */
  72107. id: number;
  72108. /**
  72109. * the native xr-plane object
  72110. */
  72111. xrPlane: XRPlane;
  72112. /**
  72113. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72114. */
  72115. polygonDefinition: Array<Vector3>;
  72116. /**
  72117. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72118. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72119. */
  72120. transformationMatrix: Matrix;
  72121. }
  72122. /**
  72123. * The plane detector is used to detect planes in the real world when in AR
  72124. * For more information see https://github.com/immersive-web/real-world-geometry/
  72125. */
  72126. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72127. private _options;
  72128. /**
  72129. * The module's name
  72130. */
  72131. static readonly Name: string;
  72132. /**
  72133. * The (Babylon) version of this module.
  72134. * This is an integer representing the implementation version.
  72135. * This number does not correspond to the webxr specs version
  72136. */
  72137. static readonly Version: number;
  72138. /**
  72139. * Observers registered here will be executed when a new plane was added to the session
  72140. */
  72141. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72142. /**
  72143. * Observers registered here will be executed when a plane is no longer detected in the session
  72144. */
  72145. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72146. /**
  72147. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72148. * This can execute N times every frame
  72149. */
  72150. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72151. private _enabled;
  72152. private _detectedPlanes;
  72153. private _lastFrameDetected;
  72154. /**
  72155. * construct a new Plane Detector
  72156. * @param _xrSessionManager an instance of xr Session manager
  72157. * @param _options configuration to use when constructing this feature
  72158. */
  72159. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72160. private _init;
  72161. protected _onXRFrame(frame: XRFrame): void;
  72162. /**
  72163. * Dispose this feature and all of the resources attached
  72164. */
  72165. dispose(): void;
  72166. private _updatePlaneWithXRPlane;
  72167. /**
  72168. * avoiding using Array.find for global support.
  72169. * @param xrPlane the plane to find in the array
  72170. */
  72171. private findIndexInPlaneArray;
  72172. }
  72173. }
  72174. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72175. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72176. import { Observable } from "babylonjs/Misc/observable";
  72177. import { Matrix } from "babylonjs/Maths/math.vector";
  72178. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72179. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72180. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72181. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72182. /**
  72183. * Configuration options of the anchor system
  72184. */
  72185. export interface IWebXRAnchorSystemOptions {
  72186. /**
  72187. * a node that will be used to convert local to world coordinates
  72188. */
  72189. worldParentNode?: TransformNode;
  72190. /**
  72191. * should the anchor system use plane detection.
  72192. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72193. */
  72194. usePlaneDetection?: boolean;
  72195. /**
  72196. * Should a new anchor be added every time a select event is triggered
  72197. */
  72198. addAnchorOnSelect?: boolean;
  72199. }
  72200. /**
  72201. * A babylon container for an XR Anchor
  72202. */
  72203. export interface IWebXRAnchor {
  72204. /**
  72205. * A babylon-assigned ID for this anchor
  72206. */
  72207. id: number;
  72208. /**
  72209. * The native anchor object
  72210. */
  72211. xrAnchor: XRAnchor;
  72212. /**
  72213. * Transformation matrix to apply to an object attached to this anchor
  72214. */
  72215. transformationMatrix: Matrix;
  72216. }
  72217. /**
  72218. * An implementation of the anchor system of WebXR.
  72219. * Note that the current documented implementation is not available in any browser. Future implementations
  72220. * will use the frame to create an anchor and not the session or a detected plane
  72221. * For further information see https://github.com/immersive-web/anchors/
  72222. */
  72223. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72224. private _options;
  72225. /**
  72226. * The module's name
  72227. */
  72228. static readonly Name: string;
  72229. /**
  72230. * The (Babylon) version of this module.
  72231. * This is an integer representing the implementation version.
  72232. * This number does not correspond to the webxr specs version
  72233. */
  72234. static readonly Version: number;
  72235. /**
  72236. * Observers registered here will be executed when a new anchor was added to the session
  72237. */
  72238. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72239. /**
  72240. * Observers registered here will be executed when an existing anchor updates
  72241. * This can execute N times every frame
  72242. */
  72243. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72244. /**
  72245. * Observers registered here will be executed when an anchor was removed from the session
  72246. */
  72247. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72248. private _planeDetector;
  72249. private _hitTestModule;
  72250. private _enabled;
  72251. private _trackedAnchors;
  72252. private _lastFrameDetected;
  72253. /**
  72254. * constructs a new anchor system
  72255. * @param _xrSessionManager an instance of WebXRSessionManager
  72256. * @param _options configuration object for this feature
  72257. */
  72258. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72259. /**
  72260. * set the plane detector to use in order to create anchors from frames
  72261. * @param planeDetector the plane-detector module to use
  72262. * @param enable enable plane-anchors. default is true
  72263. */
  72264. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72265. /**
  72266. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72267. * @param hitTestModule the hit-test module to use.
  72268. */
  72269. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72270. /**
  72271. * attach this feature
  72272. * Will usually be called by the features manager
  72273. *
  72274. * @returns true if successful.
  72275. */
  72276. attach(): boolean;
  72277. /**
  72278. * detach this feature.
  72279. * Will usually be called by the features manager
  72280. *
  72281. * @returns true if successful.
  72282. */
  72283. detach(): boolean;
  72284. /**
  72285. * Dispose this feature and all of the resources attached
  72286. */
  72287. dispose(): void;
  72288. protected _onXRFrame(frame: XRFrame): void;
  72289. private _onSelect;
  72290. /**
  72291. * Add anchor at a specific XR point.
  72292. *
  72293. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72294. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72295. * @returns a promise the fulfills when the anchor was created
  72296. */
  72297. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72298. private _updateAnchorWithXRFrame;
  72299. /**
  72300. * avoiding using Array.find for global support.
  72301. * @param xrAnchor the plane to find in the array
  72302. */
  72303. private _findIndexInAnchorArray;
  72304. }
  72305. }
  72306. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72307. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72309. import { Observable } from "babylonjs/Misc/observable";
  72310. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72311. /**
  72312. * Options interface for the background remover plugin
  72313. */
  72314. export interface IWebXRBackgroundRemoverOptions {
  72315. /**
  72316. * don't disable the environment helper
  72317. */
  72318. ignoreEnvironmentHelper?: boolean;
  72319. /**
  72320. * flags to configure the removal of the environment helper.
  72321. * If not set, the entire background will be removed. If set, flags should be set as well.
  72322. */
  72323. environmentHelperRemovalFlags?: {
  72324. /**
  72325. * Should the skybox be removed (default false)
  72326. */
  72327. skyBox?: boolean;
  72328. /**
  72329. * Should the ground be removed (default false)
  72330. */
  72331. ground?: boolean;
  72332. };
  72333. /**
  72334. * Further background meshes to disable when entering AR
  72335. */
  72336. backgroundMeshes?: AbstractMesh[];
  72337. }
  72338. /**
  72339. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72340. */
  72341. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72342. /**
  72343. * read-only options to be used in this module
  72344. */
  72345. readonly options: IWebXRBackgroundRemoverOptions;
  72346. /**
  72347. * The module's name
  72348. */
  72349. static readonly Name: string;
  72350. /**
  72351. * The (Babylon) version of this module.
  72352. * This is an integer representing the implementation version.
  72353. * This number does not correspond to the webxr specs version
  72354. */
  72355. static readonly Version: number;
  72356. /**
  72357. * registered observers will be triggered when the background state changes
  72358. */
  72359. onBackgroundStateChangedObservable: Observable<boolean>;
  72360. /**
  72361. * constructs a new background remover module
  72362. * @param _xrSessionManager the session manager for this module
  72363. * @param options read-only options to be used in this module
  72364. */
  72365. constructor(_xrSessionManager: WebXRSessionManager,
  72366. /**
  72367. * read-only options to be used in this module
  72368. */
  72369. options?: IWebXRBackgroundRemoverOptions);
  72370. /**
  72371. * attach this feature
  72372. * Will usually be called by the features manager
  72373. *
  72374. * @returns true if successful.
  72375. */
  72376. attach(): boolean;
  72377. /**
  72378. * detach this feature.
  72379. * Will usually be called by the features manager
  72380. *
  72381. * @returns true if successful.
  72382. */
  72383. detach(): boolean;
  72384. private _setBackgroundState;
  72385. /**
  72386. * Dispose this feature and all of the resources attached
  72387. */
  72388. dispose(): void;
  72389. protected _onXRFrame(_xrFrame: XRFrame): void;
  72390. }
  72391. }
  72392. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72393. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72394. import { WebXRController } from "babylonjs/XR/webXRController";
  72395. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72396. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72397. /**
  72398. * Options for the controller physics feature
  72399. */
  72400. export class IWebXRControllerPhysicsOptions {
  72401. /**
  72402. * the xr input to use with this pointer selection
  72403. */
  72404. xrInput: WebXRInput;
  72405. /**
  72406. * The physics properties of the future impostors
  72407. */
  72408. physicsProperties?: {
  72409. /**
  72410. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72411. * Note that this requires a physics engine that supports mesh impostors!
  72412. */
  72413. useControllerMesh?: boolean;
  72414. /**
  72415. * The type of impostor to create. Default is sphere
  72416. */
  72417. impostorType?: number;
  72418. /**
  72419. * the size of the impostor. Defaults to 10cm
  72420. */
  72421. impostorSize?: number | {
  72422. width: number;
  72423. height: number;
  72424. depth: number;
  72425. };
  72426. /**
  72427. * Friction definitions
  72428. */
  72429. friction?: number;
  72430. /**
  72431. * Restitution
  72432. */
  72433. restitution?: number;
  72434. };
  72435. }
  72436. /**
  72437. * Add physics impostor to your webxr controllers,
  72438. * including naive calculation of their linear and angular velocity
  72439. */
  72440. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72441. private readonly _options;
  72442. /**
  72443. * The module's name
  72444. */
  72445. static readonly Name: string;
  72446. /**
  72447. * The (Babylon) version of this module.
  72448. * This is an integer representing the implementation version.
  72449. * This number does not correspond to the webxr specs version
  72450. */
  72451. static readonly Version: number;
  72452. private _lastTimestamp;
  72453. private _delta;
  72454. private _controllers;
  72455. private _tmpVector;
  72456. private _tmpQuaternion;
  72457. /**
  72458. * Construct a new Controller Physics Feature
  72459. * @param _xrSessionManager the corresponding xr session manager
  72460. * @param _options options to create this feature with
  72461. */
  72462. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72463. /**
  72464. * Update the physics properties provided in the constructor
  72465. * @param newProperties the new properties object
  72466. */
  72467. setPhysicsProperties(newProperties: {
  72468. impostorType?: number;
  72469. impostorSize?: number | {
  72470. width: number;
  72471. height: number;
  72472. depth: number;
  72473. };
  72474. friction?: number;
  72475. restitution?: number;
  72476. }): void;
  72477. /**
  72478. * attach this feature
  72479. * Will usually be called by the features manager
  72480. *
  72481. * @returns true if successful.
  72482. */
  72483. attach(): boolean;
  72484. /**
  72485. * detach this feature.
  72486. * Will usually be called by the features manager
  72487. *
  72488. * @returns true if successful.
  72489. */
  72490. detach(): boolean;
  72491. /**
  72492. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72493. * @param xrController the controller to add
  72494. */
  72495. addController(xrController: WebXRController): void;
  72496. private _debugMode;
  72497. /**
  72498. * @hidden
  72499. * enable debugging - will show console outputs and the impostor mesh
  72500. */
  72501. _enablePhysicsDebug(): void;
  72502. private _attachController;
  72503. private _detachController;
  72504. protected _onXRFrame(_xrFrame: any): void;
  72505. }
  72506. }
  72507. declare module "babylonjs/XR/features/index" {
  72508. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72509. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72510. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72511. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72512. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72513. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72514. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72515. }
  72516. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72517. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractController";
  72518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72519. import { Scene } from "babylonjs/scene";
  72520. /**
  72521. * The motion controller class for all microsoft mixed reality controllers
  72522. */
  72523. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72524. /**
  72525. * The base url used to load the left and right controller models
  72526. */
  72527. static MODEL_BASE_URL: string;
  72528. /**
  72529. * The name of the left controller model file
  72530. */
  72531. static MODEL_LEFT_FILENAME: string;
  72532. /**
  72533. * The name of the right controller model file
  72534. */
  72535. static MODEL_RIGHT_FILENAME: string;
  72536. profileId: string;
  72537. protected readonly _mapping: {
  72538. defaultButton: {
  72539. "valueNodeName": string;
  72540. "unpressedNodeName": string;
  72541. "pressedNodeName": string;
  72542. };
  72543. defaultAxis: {
  72544. "valueNodeName": string;
  72545. "minNodeName": string;
  72546. "maxNodeName": string;
  72547. };
  72548. buttons: {
  72549. "xr-standard-trigger": {
  72550. "rootNodeName": string;
  72551. "componentProperty": string;
  72552. "states": string[];
  72553. };
  72554. "xr-standard-squeeze": {
  72555. "rootNodeName": string;
  72556. "componentProperty": string;
  72557. "states": string[];
  72558. };
  72559. "xr-standard-touchpad": {
  72560. "rootNodeName": string;
  72561. "labelAnchorNodeName": string;
  72562. "touchPointNodeName": string;
  72563. };
  72564. "xr-standard-thumbstick": {
  72565. "rootNodeName": string;
  72566. "componentProperty": string;
  72567. "states": string[];
  72568. };
  72569. };
  72570. axes: {
  72571. "xr-standard-touchpad": {
  72572. "x-axis": {
  72573. "rootNodeName": string;
  72574. };
  72575. "y-axis": {
  72576. "rootNodeName": string;
  72577. };
  72578. };
  72579. "xr-standard-thumbstick": {
  72580. "x-axis": {
  72581. "rootNodeName": string;
  72582. };
  72583. "y-axis": {
  72584. "rootNodeName": string;
  72585. };
  72586. };
  72587. };
  72588. };
  72589. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72590. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72591. protected _getFilenameAndPath(): {
  72592. filename: string;
  72593. path: string;
  72594. };
  72595. protected _updateModel(): void;
  72596. protected _getModelLoadingConstraints(): boolean;
  72597. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72598. }
  72599. }
  72600. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  72601. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractController";
  72602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72603. import { Scene } from "babylonjs/scene";
  72604. /**
  72605. * The motion controller class for oculus touch (quest, rift).
  72606. * This class supports legacy mapping as well the standard xr mapping
  72607. */
  72608. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72609. private _forceLegacyControllers;
  72610. /**
  72611. * The base url used to load the left and right controller models
  72612. */
  72613. static MODEL_BASE_URL: string;
  72614. /**
  72615. * The name of the left controller model file
  72616. */
  72617. static MODEL_LEFT_FILENAME: string;
  72618. /**
  72619. * The name of the right controller model file
  72620. */
  72621. static MODEL_RIGHT_FILENAME: string;
  72622. /**
  72623. * Base Url for the Quest controller model.
  72624. */
  72625. static QUEST_MODEL_BASE_URL: string;
  72626. profileId: string;
  72627. private _modelRootNode;
  72628. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72629. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72630. protected _getFilenameAndPath(): {
  72631. filename: string;
  72632. path: string;
  72633. };
  72634. /**
  72635. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72636. * between the touch and touch 2.
  72637. */
  72638. private _isQuest;
  72639. protected _updateModel(): void;
  72640. protected _getModelLoadingConstraints(): boolean;
  72641. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72642. }
  72643. }
  72644. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  72645. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractController";
  72646. import { Scene } from "babylonjs/scene";
  72647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72648. /**
  72649. * The motion controller class for the standard HTC-Vive controllers
  72650. */
  72651. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72652. /**
  72653. * The base url used to load the left and right controller models
  72654. */
  72655. static MODEL_BASE_URL: string;
  72656. /**
  72657. * File name for the controller model.
  72658. */
  72659. static MODEL_FILENAME: string;
  72660. profileId: string;
  72661. private _modelRootNode;
  72662. /**
  72663. * Create a new Vive motion controller object
  72664. * @param scene the scene to use to create this controller
  72665. * @param gamepadObject the corresponding gamepad object
  72666. * @param handness the handness of the controller
  72667. */
  72668. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72669. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72670. protected _getFilenameAndPath(): {
  72671. filename: string;
  72672. path: string;
  72673. };
  72674. protected _updateModel(): void;
  72675. protected _getModelLoadingConstraints(): boolean;
  72676. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72677. }
  72678. }
  72679. declare module "babylonjs/XR/motionController/index" {
  72680. export * from "babylonjs/XR/motionController/webXRAbstractController";
  72681. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  72682. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  72683. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  72684. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  72685. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  72686. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  72687. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  72688. }
  72689. declare module "babylonjs/XR/index" {
  72690. export * from "babylonjs/XR/webXRCamera";
  72691. export * from "babylonjs/XR/webXREnterExitUI";
  72692. export * from "babylonjs/XR/webXRExperienceHelper";
  72693. export * from "babylonjs/XR/webXRInput";
  72694. export * from "babylonjs/XR/webXRController";
  72695. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  72696. export * from "babylonjs/XR/webXRTypes";
  72697. export * from "babylonjs/XR/webXRSessionManager";
  72698. export * from "babylonjs/XR/webXRDefaultExperience";
  72699. export * from "babylonjs/XR/webXRFeaturesManager";
  72700. export * from "babylonjs/XR/features/index";
  72701. export * from "babylonjs/XR/motionController/index";
  72702. }
  72703. declare module "babylonjs/index" {
  72704. export * from "babylonjs/abstractScene";
  72705. export * from "babylonjs/Actions/index";
  72706. export * from "babylonjs/Animations/index";
  72707. export * from "babylonjs/assetContainer";
  72708. export * from "babylonjs/Audio/index";
  72709. export * from "babylonjs/Behaviors/index";
  72710. export * from "babylonjs/Bones/index";
  72711. export * from "babylonjs/Cameras/index";
  72712. export * from "babylonjs/Collisions/index";
  72713. export * from "babylonjs/Culling/index";
  72714. export * from "babylonjs/Debug/index";
  72715. export * from "babylonjs/Engines/index";
  72716. export * from "babylonjs/Events/index";
  72717. export * from "babylonjs/Gamepads/index";
  72718. export * from "babylonjs/Gizmos/index";
  72719. export * from "babylonjs/Helpers/index";
  72720. export * from "babylonjs/Instrumentation/index";
  72721. export * from "babylonjs/Layers/index";
  72722. export * from "babylonjs/LensFlares/index";
  72723. export * from "babylonjs/Lights/index";
  72724. export * from "babylonjs/Loading/index";
  72725. export * from "babylonjs/Materials/index";
  72726. export * from "babylonjs/Maths/index";
  72727. export * from "babylonjs/Meshes/index";
  72728. export * from "babylonjs/Morph/index";
  72729. export * from "babylonjs/Navigation/index";
  72730. export * from "babylonjs/node";
  72731. export * from "babylonjs/Offline/index";
  72732. export * from "babylonjs/Particles/index";
  72733. export * from "babylonjs/Physics/index";
  72734. export * from "babylonjs/PostProcesses/index";
  72735. export * from "babylonjs/Probes/index";
  72736. export * from "babylonjs/Rendering/index";
  72737. export * from "babylonjs/scene";
  72738. export * from "babylonjs/sceneComponent";
  72739. export * from "babylonjs/Sprites/index";
  72740. export * from "babylonjs/States/index";
  72741. export * from "babylonjs/Misc/index";
  72742. export * from "babylonjs/XR/index";
  72743. export * from "babylonjs/types";
  72744. }
  72745. declare module "babylonjs/Animations/pathCursor" {
  72746. import { Vector3 } from "babylonjs/Maths/math.vector";
  72747. import { Path2 } from "babylonjs/Maths/math.path";
  72748. /**
  72749. * A cursor which tracks a point on a path
  72750. */
  72751. export class PathCursor {
  72752. private path;
  72753. /**
  72754. * Stores path cursor callbacks for when an onchange event is triggered
  72755. */
  72756. private _onchange;
  72757. /**
  72758. * The value of the path cursor
  72759. */
  72760. value: number;
  72761. /**
  72762. * The animation array of the path cursor
  72763. */
  72764. animations: Animation[];
  72765. /**
  72766. * Initializes the path cursor
  72767. * @param path The path to track
  72768. */
  72769. constructor(path: Path2);
  72770. /**
  72771. * Gets the cursor point on the path
  72772. * @returns A point on the path cursor at the cursor location
  72773. */
  72774. getPoint(): Vector3;
  72775. /**
  72776. * Moves the cursor ahead by the step amount
  72777. * @param step The amount to move the cursor forward
  72778. * @returns This path cursor
  72779. */
  72780. moveAhead(step?: number): PathCursor;
  72781. /**
  72782. * Moves the cursor behind by the step amount
  72783. * @param step The amount to move the cursor back
  72784. * @returns This path cursor
  72785. */
  72786. moveBack(step?: number): PathCursor;
  72787. /**
  72788. * Moves the cursor by the step amount
  72789. * If the step amount is greater than one, an exception is thrown
  72790. * @param step The amount to move the cursor
  72791. * @returns This path cursor
  72792. */
  72793. move(step: number): PathCursor;
  72794. /**
  72795. * Ensures that the value is limited between zero and one
  72796. * @returns This path cursor
  72797. */
  72798. private ensureLimits;
  72799. /**
  72800. * Runs onchange callbacks on change (used by the animation engine)
  72801. * @returns This path cursor
  72802. */
  72803. private raiseOnChange;
  72804. /**
  72805. * Executes a function on change
  72806. * @param f A path cursor onchange callback
  72807. * @returns This path cursor
  72808. */
  72809. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72810. }
  72811. }
  72812. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  72813. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  72814. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  72815. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  72816. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  72817. }
  72818. declare module "babylonjs/Engines/Processors/Expressions/index" {
  72819. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  72820. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  72821. }
  72822. declare module "babylonjs/Engines/Processors/index" {
  72823. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  72824. export * from "babylonjs/Engines/Processors/Expressions/index";
  72825. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  72826. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  72827. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  72828. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  72829. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  72830. export * from "babylonjs/Engines/Processors/shaderProcessor";
  72831. }
  72832. declare module "babylonjs/Legacy/legacy" {
  72833. import * as Babylon from "babylonjs/index";
  72834. export * from "babylonjs/index";
  72835. }
  72836. declare module "babylonjs/Shaders/blur.fragment" {
  72837. /** @hidden */
  72838. export var blurPixelShader: {
  72839. name: string;
  72840. shader: string;
  72841. };
  72842. }
  72843. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  72844. /** @hidden */
  72845. export var pointCloudVertexDeclaration: {
  72846. name: string;
  72847. shader: string;
  72848. };
  72849. }
  72850. declare module "babylonjs" {
  72851. export * from "babylonjs/Legacy/legacy";
  72852. }
  72853. declare module BABYLON {
  72854. /** Alias type for value that can be null */
  72855. export type Nullable<T> = T | null;
  72856. /**
  72857. * Alias type for number that are floats
  72858. * @ignorenaming
  72859. */
  72860. export type float = number;
  72861. /**
  72862. * Alias type for number that are doubles.
  72863. * @ignorenaming
  72864. */
  72865. export type double = number;
  72866. /**
  72867. * Alias type for number that are integer
  72868. * @ignorenaming
  72869. */
  72870. export type int = number;
  72871. /** Alias type for number array or Float32Array */
  72872. export type FloatArray = number[] | Float32Array;
  72873. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  72874. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  72875. /**
  72876. * Alias for types that can be used by a Buffer or VertexBuffer.
  72877. */
  72878. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  72879. /**
  72880. * Alias type for primitive types
  72881. * @ignorenaming
  72882. */
  72883. type Primitive = undefined | null | boolean | string | number | Function;
  72884. /**
  72885. * Type modifier to make all the properties of an object Readonly
  72886. */
  72887. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  72888. /**
  72889. * Type modifier to make all the properties of an object Readonly recursively
  72890. */
  72891. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  72892. /**
  72893. * Type modifier to make object properties readonly.
  72894. */
  72895. export type DeepImmutableObject<T> = {
  72896. readonly [K in keyof T]: DeepImmutable<T[K]>;
  72897. };
  72898. /** @hidden */
  72899. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  72900. }
  72901. }
  72902. declare module BABYLON {
  72903. /**
  72904. * A class serves as a medium between the observable and its observers
  72905. */
  72906. export class EventState {
  72907. /**
  72908. * Create a new EventState
  72909. * @param mask defines the mask associated with this state
  72910. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72911. * @param target defines the original target of the state
  72912. * @param currentTarget defines the current target of the state
  72913. */
  72914. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  72915. /**
  72916. * Initialize the current event state
  72917. * @param mask defines the mask associated with this state
  72918. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72919. * @param target defines the original target of the state
  72920. * @param currentTarget defines the current target of the state
  72921. * @returns the current event state
  72922. */
  72923. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72924. /**
  72925. * An Observer can set this property to true to prevent subsequent observers of being notified
  72926. */
  72927. skipNextObservers: boolean;
  72928. /**
  72929. * Get the mask value that were used to trigger the event corresponding to this EventState object
  72930. */
  72931. mask: number;
  72932. /**
  72933. * The object that originally notified the event
  72934. */
  72935. target?: any;
  72936. /**
  72937. * The current object in the bubbling phase
  72938. */
  72939. currentTarget?: any;
  72940. /**
  72941. * This will be populated with the return value of the last function that was executed.
  72942. * If it is the first function in the callback chain it will be the event data.
  72943. */
  72944. lastReturnValue?: any;
  72945. }
  72946. /**
  72947. * Represent an Observer registered to a given Observable object.
  72948. */
  72949. export class Observer<T> {
  72950. /**
  72951. * Defines the callback to call when the observer is notified
  72952. */
  72953. callback: (eventData: T, eventState: EventState) => void;
  72954. /**
  72955. * Defines the mask of the observer (used to filter notifications)
  72956. */
  72957. mask: number;
  72958. /**
  72959. * Defines the current scope used to restore the JS context
  72960. */
  72961. scope: any;
  72962. /** @hidden */
  72963. _willBeUnregistered: boolean;
  72964. /**
  72965. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  72966. */
  72967. unregisterOnNextCall: boolean;
  72968. /**
  72969. * Creates a new observer
  72970. * @param callback defines the callback to call when the observer is notified
  72971. * @param mask defines the mask of the observer (used to filter notifications)
  72972. * @param scope defines the current scope used to restore the JS context
  72973. */
  72974. constructor(
  72975. /**
  72976. * Defines the callback to call when the observer is notified
  72977. */
  72978. callback: (eventData: T, eventState: EventState) => void,
  72979. /**
  72980. * Defines the mask of the observer (used to filter notifications)
  72981. */
  72982. mask: number,
  72983. /**
  72984. * Defines the current scope used to restore the JS context
  72985. */
  72986. scope?: any);
  72987. }
  72988. /**
  72989. * Represent a list of observers registered to multiple Observables object.
  72990. */
  72991. export class MultiObserver<T> {
  72992. private _observers;
  72993. private _observables;
  72994. /**
  72995. * Release associated resources
  72996. */
  72997. dispose(): void;
  72998. /**
  72999. * Raise a callback when one of the observable will notify
  73000. * @param observables defines a list of observables to watch
  73001. * @param callback defines the callback to call on notification
  73002. * @param mask defines the mask used to filter notifications
  73003. * @param scope defines the current scope used to restore the JS context
  73004. * @returns the new MultiObserver
  73005. */
  73006. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73007. }
  73008. /**
  73009. * The Observable class is a simple implementation of the Observable pattern.
  73010. *
  73011. * 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.
  73012. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73013. * 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).
  73014. * 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.
  73015. */
  73016. export class Observable<T> {
  73017. private _observers;
  73018. private _eventState;
  73019. private _onObserverAdded;
  73020. /**
  73021. * Gets the list of observers
  73022. */
  73023. get observers(): Array<Observer<T>>;
  73024. /**
  73025. * Creates a new observable
  73026. * @param onObserverAdded defines a callback to call when a new observer is added
  73027. */
  73028. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73029. /**
  73030. * Create a new Observer with the specified callback
  73031. * @param callback the callback that will be executed for that Observer
  73032. * @param mask the mask used to filter observers
  73033. * @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.
  73034. * @param scope optional scope for the callback to be called from
  73035. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73036. * @returns the new observer created for the callback
  73037. */
  73038. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73039. /**
  73040. * Create a new Observer with the specified callback and unregisters after the next notification
  73041. * @param callback the callback that will be executed for that Observer
  73042. * @returns the new observer created for the callback
  73043. */
  73044. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73045. /**
  73046. * Remove an Observer from the Observable object
  73047. * @param observer the instance of the Observer to remove
  73048. * @returns false if it doesn't belong to this Observable
  73049. */
  73050. remove(observer: Nullable<Observer<T>>): boolean;
  73051. /**
  73052. * Remove a callback from the Observable object
  73053. * @param callback the callback to remove
  73054. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73055. * @returns false if it doesn't belong to this Observable
  73056. */
  73057. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73058. private _deferUnregister;
  73059. private _remove;
  73060. /**
  73061. * Moves the observable to the top of the observer list making it get called first when notified
  73062. * @param observer the observer to move
  73063. */
  73064. makeObserverTopPriority(observer: Observer<T>): void;
  73065. /**
  73066. * Moves the observable to the bottom of the observer list making it get called last when notified
  73067. * @param observer the observer to move
  73068. */
  73069. makeObserverBottomPriority(observer: Observer<T>): void;
  73070. /**
  73071. * Notify all Observers by calling their respective callback with the given data
  73072. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73073. * @param eventData defines the data to send to all observers
  73074. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73075. * @param target defines the original target of the state
  73076. * @param currentTarget defines the current target of the state
  73077. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73078. */
  73079. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73080. /**
  73081. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73082. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73083. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73084. * and it is crucial that all callbacks will be executed.
  73085. * The order of the callbacks is kept, callbacks are not executed parallel.
  73086. *
  73087. * @param eventData The data to be sent to each callback
  73088. * @param mask is used to filter observers defaults to -1
  73089. * @param target defines the callback target (see EventState)
  73090. * @param currentTarget defines he current object in the bubbling phase
  73091. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73092. */
  73093. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73094. /**
  73095. * Notify a specific observer
  73096. * @param observer defines the observer to notify
  73097. * @param eventData defines the data to be sent to each callback
  73098. * @param mask is used to filter observers defaults to -1
  73099. */
  73100. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73101. /**
  73102. * Gets a boolean indicating if the observable has at least one observer
  73103. * @returns true is the Observable has at least one Observer registered
  73104. */
  73105. hasObservers(): boolean;
  73106. /**
  73107. * Clear the list of observers
  73108. */
  73109. clear(): void;
  73110. /**
  73111. * Clone the current observable
  73112. * @returns a new observable
  73113. */
  73114. clone(): Observable<T>;
  73115. /**
  73116. * Does this observable handles observer registered with a given mask
  73117. * @param mask defines the mask to be tested
  73118. * @return whether or not one observer registered with the given mask is handeled
  73119. **/
  73120. hasSpecificMask(mask?: number): boolean;
  73121. }
  73122. }
  73123. declare module BABYLON {
  73124. /**
  73125. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73126. * Babylon.js
  73127. */
  73128. export class DomManagement {
  73129. /**
  73130. * Checks if the window object exists
  73131. * @returns true if the window object exists
  73132. */
  73133. static IsWindowObjectExist(): boolean;
  73134. /**
  73135. * Checks if the navigator object exists
  73136. * @returns true if the navigator object exists
  73137. */
  73138. static IsNavigatorAvailable(): boolean;
  73139. /**
  73140. * Extracts text content from a DOM element hierarchy
  73141. * @param element defines the root element
  73142. * @returns a string
  73143. */
  73144. static GetDOMTextContent(element: HTMLElement): string;
  73145. }
  73146. }
  73147. declare module BABYLON {
  73148. /**
  73149. * Logger used througouht the application to allow configuration of
  73150. * the log level required for the messages.
  73151. */
  73152. export class Logger {
  73153. /**
  73154. * No log
  73155. */
  73156. static readonly NoneLogLevel: number;
  73157. /**
  73158. * Only message logs
  73159. */
  73160. static readonly MessageLogLevel: number;
  73161. /**
  73162. * Only warning logs
  73163. */
  73164. static readonly WarningLogLevel: number;
  73165. /**
  73166. * Only error logs
  73167. */
  73168. static readonly ErrorLogLevel: number;
  73169. /**
  73170. * All logs
  73171. */
  73172. static readonly AllLogLevel: number;
  73173. private static _LogCache;
  73174. /**
  73175. * Gets a value indicating the number of loading errors
  73176. * @ignorenaming
  73177. */
  73178. static errorsCount: number;
  73179. /**
  73180. * Callback called when a new log is added
  73181. */
  73182. static OnNewCacheEntry: (entry: string) => void;
  73183. private static _AddLogEntry;
  73184. private static _FormatMessage;
  73185. private static _LogDisabled;
  73186. private static _LogEnabled;
  73187. private static _WarnDisabled;
  73188. private static _WarnEnabled;
  73189. private static _ErrorDisabled;
  73190. private static _ErrorEnabled;
  73191. /**
  73192. * Log a message to the console
  73193. */
  73194. static Log: (message: string) => void;
  73195. /**
  73196. * Write a warning message to the console
  73197. */
  73198. static Warn: (message: string) => void;
  73199. /**
  73200. * Write an error message to the console
  73201. */
  73202. static Error: (message: string) => void;
  73203. /**
  73204. * Gets current log cache (list of logs)
  73205. */
  73206. static get LogCache(): string;
  73207. /**
  73208. * Clears the log cache
  73209. */
  73210. static ClearLogCache(): void;
  73211. /**
  73212. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73213. */
  73214. static set LogLevels(level: number);
  73215. }
  73216. }
  73217. declare module BABYLON {
  73218. /** @hidden */
  73219. export class _TypeStore {
  73220. /** @hidden */
  73221. static RegisteredTypes: {
  73222. [key: string]: Object;
  73223. };
  73224. /** @hidden */
  73225. static GetClass(fqdn: string): any;
  73226. }
  73227. }
  73228. declare module BABYLON {
  73229. /**
  73230. * Helper to manipulate strings
  73231. */
  73232. export class StringTools {
  73233. /**
  73234. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73235. * @param str Source string
  73236. * @param suffix Suffix to search for in the source string
  73237. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73238. */
  73239. static EndsWith(str: string, suffix: string): boolean;
  73240. /**
  73241. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73242. * @param str Source string
  73243. * @param suffix Suffix to search for in the source string
  73244. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73245. */
  73246. static StartsWith(str: string, suffix: string): boolean;
  73247. /**
  73248. * Decodes a buffer into a string
  73249. * @param buffer The buffer to decode
  73250. * @returns The decoded string
  73251. */
  73252. static Decode(buffer: Uint8Array | Uint16Array): string;
  73253. /**
  73254. * Encode a buffer to a base64 string
  73255. * @param buffer defines the buffer to encode
  73256. * @returns the encoded string
  73257. */
  73258. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73259. }
  73260. }
  73261. declare module BABYLON {
  73262. /**
  73263. * Class containing a set of static utilities functions for deep copy.
  73264. */
  73265. export class DeepCopier {
  73266. /**
  73267. * Tries to copy an object by duplicating every property
  73268. * @param source defines the source object
  73269. * @param destination defines the target object
  73270. * @param doNotCopyList defines a list of properties to avoid
  73271. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73272. */
  73273. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73274. }
  73275. }
  73276. declare module BABYLON {
  73277. /**
  73278. * Class containing a set of static utilities functions for precision date
  73279. */
  73280. export class PrecisionDate {
  73281. /**
  73282. * Gets either window.performance.now() if supported or Date.now() else
  73283. */
  73284. static get Now(): number;
  73285. }
  73286. }
  73287. declare module BABYLON {
  73288. /** @hidden */
  73289. export class _DevTools {
  73290. static WarnImport(name: string): string;
  73291. }
  73292. }
  73293. declare module BABYLON {
  73294. /**
  73295. * Interface used to define the mechanism to get data from the network
  73296. */
  73297. export interface IWebRequest {
  73298. /**
  73299. * Returns client's response url
  73300. */
  73301. responseURL: string;
  73302. /**
  73303. * Returns client's status
  73304. */
  73305. status: number;
  73306. /**
  73307. * Returns client's status as a text
  73308. */
  73309. statusText: string;
  73310. }
  73311. }
  73312. declare module BABYLON {
  73313. /**
  73314. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73315. */
  73316. export class WebRequest implements IWebRequest {
  73317. private _xhr;
  73318. /**
  73319. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73320. * i.e. when loading files, where the server/service expects an Authorization header
  73321. */
  73322. static CustomRequestHeaders: {
  73323. [key: string]: string;
  73324. };
  73325. /**
  73326. * Add callback functions in this array to update all the requests before they get sent to the network
  73327. */
  73328. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73329. private _injectCustomRequestHeaders;
  73330. /**
  73331. * Gets or sets a function to be called when loading progress changes
  73332. */
  73333. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73334. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73335. /**
  73336. * Returns client's state
  73337. */
  73338. get readyState(): number;
  73339. /**
  73340. * Returns client's status
  73341. */
  73342. get status(): number;
  73343. /**
  73344. * Returns client's status as a text
  73345. */
  73346. get statusText(): string;
  73347. /**
  73348. * Returns client's response
  73349. */
  73350. get response(): any;
  73351. /**
  73352. * Returns client's response url
  73353. */
  73354. get responseURL(): string;
  73355. /**
  73356. * Returns client's response as text
  73357. */
  73358. get responseText(): string;
  73359. /**
  73360. * Gets or sets the expected response type
  73361. */
  73362. get responseType(): XMLHttpRequestResponseType;
  73363. set responseType(value: XMLHttpRequestResponseType);
  73364. /** @hidden */
  73365. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73366. /** @hidden */
  73367. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73368. /**
  73369. * Cancels any network activity
  73370. */
  73371. abort(): void;
  73372. /**
  73373. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73374. * @param body defines an optional request body
  73375. */
  73376. send(body?: Document | BodyInit | null): void;
  73377. /**
  73378. * Sets the request method, request URL
  73379. * @param method defines the method to use (GET, POST, etc..)
  73380. * @param url defines the url to connect with
  73381. */
  73382. open(method: string, url: string): void;
  73383. /**
  73384. * Sets the value of a request header.
  73385. * @param name The name of the header whose value is to be set
  73386. * @param value The value to set as the body of the header
  73387. */
  73388. setRequestHeader(name: string, value: string): void;
  73389. /**
  73390. * Get the string containing the text of a particular header's value.
  73391. * @param name The name of the header
  73392. * @returns The string containing the text of the given header name
  73393. */
  73394. getResponseHeader(name: string): Nullable<string>;
  73395. }
  73396. }
  73397. declare module BABYLON {
  73398. /**
  73399. * File request interface
  73400. */
  73401. export interface IFileRequest {
  73402. /**
  73403. * Raised when the request is complete (success or error).
  73404. */
  73405. onCompleteObservable: Observable<IFileRequest>;
  73406. /**
  73407. * Aborts the request for a file.
  73408. */
  73409. abort: () => void;
  73410. }
  73411. }
  73412. declare module BABYLON {
  73413. /**
  73414. * Define options used to create a render target texture
  73415. */
  73416. export class RenderTargetCreationOptions {
  73417. /**
  73418. * Specifies is mipmaps must be generated
  73419. */
  73420. generateMipMaps?: boolean;
  73421. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73422. generateDepthBuffer?: boolean;
  73423. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73424. generateStencilBuffer?: boolean;
  73425. /** Defines texture type (int by default) */
  73426. type?: number;
  73427. /** Defines sampling mode (trilinear by default) */
  73428. samplingMode?: number;
  73429. /** Defines format (RGBA by default) */
  73430. format?: number;
  73431. }
  73432. }
  73433. declare module BABYLON {
  73434. /**
  73435. * @hidden
  73436. **/
  73437. export class _TimeToken {
  73438. _startTimeQuery: Nullable<WebGLQuery>;
  73439. _endTimeQuery: Nullable<WebGLQuery>;
  73440. _timeElapsedQuery: Nullable<WebGLQuery>;
  73441. _timeElapsedQueryEnded: boolean;
  73442. }
  73443. }
  73444. declare module BABYLON {
  73445. /** Defines the cross module used constants to avoid circular dependncies */
  73446. export class Constants {
  73447. /** Defines that alpha blending is disabled */
  73448. static readonly ALPHA_DISABLE: number;
  73449. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73450. static readonly ALPHA_ADD: number;
  73451. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73452. static readonly ALPHA_COMBINE: number;
  73453. /** Defines that alpha blending is DEST - SRC * DEST */
  73454. static readonly ALPHA_SUBTRACT: number;
  73455. /** Defines that alpha blending is SRC * DEST */
  73456. static readonly ALPHA_MULTIPLY: number;
  73457. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73458. static readonly ALPHA_MAXIMIZED: number;
  73459. /** Defines that alpha blending is SRC + DEST */
  73460. static readonly ALPHA_ONEONE: number;
  73461. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73462. static readonly ALPHA_PREMULTIPLIED: number;
  73463. /**
  73464. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73465. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73466. */
  73467. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73468. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73469. static readonly ALPHA_INTERPOLATE: number;
  73470. /**
  73471. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73472. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73473. */
  73474. static readonly ALPHA_SCREENMODE: number;
  73475. /**
  73476. * Defines that alpha blending is SRC + DST
  73477. * Alpha will be set to SRC ALPHA + DST ALPHA
  73478. */
  73479. static readonly ALPHA_ONEONE_ONEONE: number;
  73480. /**
  73481. * Defines that alpha blending is SRC * DST ALPHA + DST
  73482. * Alpha will be set to 0
  73483. */
  73484. static readonly ALPHA_ALPHATOCOLOR: number;
  73485. /**
  73486. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73487. */
  73488. static readonly ALPHA_REVERSEONEMINUS: number;
  73489. /**
  73490. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73491. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73492. */
  73493. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73494. /**
  73495. * Defines that alpha blending is SRC + DST
  73496. * Alpha will be set to SRC ALPHA
  73497. */
  73498. static readonly ALPHA_ONEONE_ONEZERO: number;
  73499. /**
  73500. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73501. * Alpha will be set to DST ALPHA
  73502. */
  73503. static readonly ALPHA_EXCLUSION: number;
  73504. /** Defines that alpha blending equation a SUM */
  73505. static readonly ALPHA_EQUATION_ADD: number;
  73506. /** Defines that alpha blending equation a SUBSTRACTION */
  73507. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73508. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73509. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73510. /** Defines that alpha blending equation a MAX operation */
  73511. static readonly ALPHA_EQUATION_MAX: number;
  73512. /** Defines that alpha blending equation a MIN operation */
  73513. static readonly ALPHA_EQUATION_MIN: number;
  73514. /**
  73515. * Defines that alpha blending equation a DARKEN operation:
  73516. * It takes the min of the src and sums the alpha channels.
  73517. */
  73518. static readonly ALPHA_EQUATION_DARKEN: number;
  73519. /** Defines that the ressource is not delayed*/
  73520. static readonly DELAYLOADSTATE_NONE: number;
  73521. /** Defines that the ressource was successfully delay loaded */
  73522. static readonly DELAYLOADSTATE_LOADED: number;
  73523. /** Defines that the ressource is currently delay loading */
  73524. static readonly DELAYLOADSTATE_LOADING: number;
  73525. /** Defines that the ressource is delayed and has not started loading */
  73526. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73527. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73528. static readonly NEVER: number;
  73529. /** 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 */
  73530. static readonly ALWAYS: number;
  73531. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73532. static readonly LESS: number;
  73533. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73534. static readonly EQUAL: number;
  73535. /** 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 */
  73536. static readonly LEQUAL: number;
  73537. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73538. static readonly GREATER: number;
  73539. /** 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 */
  73540. static readonly GEQUAL: number;
  73541. /** 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 */
  73542. static readonly NOTEQUAL: number;
  73543. /** Passed to stencilOperation to specify that stencil value must be kept */
  73544. static readonly KEEP: number;
  73545. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73546. static readonly REPLACE: number;
  73547. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73548. static readonly INCR: number;
  73549. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73550. static readonly DECR: number;
  73551. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73552. static readonly INVERT: number;
  73553. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73554. static readonly INCR_WRAP: number;
  73555. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73556. static readonly DECR_WRAP: number;
  73557. /** Texture is not repeating outside of 0..1 UVs */
  73558. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73559. /** Texture is repeating outside of 0..1 UVs */
  73560. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73561. /** Texture is repeating and mirrored */
  73562. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73563. /** ALPHA */
  73564. static readonly TEXTUREFORMAT_ALPHA: number;
  73565. /** LUMINANCE */
  73566. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73567. /** LUMINANCE_ALPHA */
  73568. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73569. /** RGB */
  73570. static readonly TEXTUREFORMAT_RGB: number;
  73571. /** RGBA */
  73572. static readonly TEXTUREFORMAT_RGBA: number;
  73573. /** RED */
  73574. static readonly TEXTUREFORMAT_RED: number;
  73575. /** RED (2nd reference) */
  73576. static readonly TEXTUREFORMAT_R: number;
  73577. /** RG */
  73578. static readonly TEXTUREFORMAT_RG: number;
  73579. /** RED_INTEGER */
  73580. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73581. /** RED_INTEGER (2nd reference) */
  73582. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73583. /** RG_INTEGER */
  73584. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73585. /** RGB_INTEGER */
  73586. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73587. /** RGBA_INTEGER */
  73588. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73589. /** UNSIGNED_BYTE */
  73590. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73591. /** UNSIGNED_BYTE (2nd reference) */
  73592. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73593. /** FLOAT */
  73594. static readonly TEXTURETYPE_FLOAT: number;
  73595. /** HALF_FLOAT */
  73596. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73597. /** BYTE */
  73598. static readonly TEXTURETYPE_BYTE: number;
  73599. /** SHORT */
  73600. static readonly TEXTURETYPE_SHORT: number;
  73601. /** UNSIGNED_SHORT */
  73602. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73603. /** INT */
  73604. static readonly TEXTURETYPE_INT: number;
  73605. /** UNSIGNED_INT */
  73606. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73607. /** UNSIGNED_SHORT_4_4_4_4 */
  73608. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73609. /** UNSIGNED_SHORT_5_5_5_1 */
  73610. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73611. /** UNSIGNED_SHORT_5_6_5 */
  73612. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73613. /** UNSIGNED_INT_2_10_10_10_REV */
  73614. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73615. /** UNSIGNED_INT_24_8 */
  73616. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73617. /** UNSIGNED_INT_10F_11F_11F_REV */
  73618. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73619. /** UNSIGNED_INT_5_9_9_9_REV */
  73620. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73621. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73622. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73623. /** nearest is mag = nearest and min = nearest and no mip */
  73624. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73625. /** mag = nearest and min = nearest and mip = none */
  73626. static readonly TEXTURE_NEAREST_NEAREST: number;
  73627. /** Bilinear is mag = linear and min = linear and no mip */
  73628. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73629. /** mag = linear and min = linear and mip = none */
  73630. static readonly TEXTURE_LINEAR_LINEAR: number;
  73631. /** Trilinear is mag = linear and min = linear and mip = linear */
  73632. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73633. /** Trilinear is mag = linear and min = linear and mip = linear */
  73634. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73635. /** mag = nearest and min = nearest and mip = nearest */
  73636. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  73637. /** mag = nearest and min = linear and mip = nearest */
  73638. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  73639. /** mag = nearest and min = linear and mip = linear */
  73640. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  73641. /** mag = nearest and min = linear and mip = none */
  73642. static readonly TEXTURE_NEAREST_LINEAR: number;
  73643. /** nearest is mag = nearest and min = nearest and mip = linear */
  73644. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  73645. /** mag = linear and min = nearest and mip = nearest */
  73646. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  73647. /** mag = linear and min = nearest and mip = linear */
  73648. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  73649. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73650. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  73651. /** mag = linear and min = nearest and mip = none */
  73652. static readonly TEXTURE_LINEAR_NEAREST: number;
  73653. /** Explicit coordinates mode */
  73654. static readonly TEXTURE_EXPLICIT_MODE: number;
  73655. /** Spherical coordinates mode */
  73656. static readonly TEXTURE_SPHERICAL_MODE: number;
  73657. /** Planar coordinates mode */
  73658. static readonly TEXTURE_PLANAR_MODE: number;
  73659. /** Cubic coordinates mode */
  73660. static readonly TEXTURE_CUBIC_MODE: number;
  73661. /** Projection coordinates mode */
  73662. static readonly TEXTURE_PROJECTION_MODE: number;
  73663. /** Skybox coordinates mode */
  73664. static readonly TEXTURE_SKYBOX_MODE: number;
  73665. /** Inverse Cubic coordinates mode */
  73666. static readonly TEXTURE_INVCUBIC_MODE: number;
  73667. /** Equirectangular coordinates mode */
  73668. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  73669. /** Equirectangular Fixed coordinates mode */
  73670. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  73671. /** Equirectangular Fixed Mirrored coordinates mode */
  73672. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73673. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  73674. static readonly SCALEMODE_FLOOR: number;
  73675. /** Defines that texture rescaling will look for the nearest power of 2 size */
  73676. static readonly SCALEMODE_NEAREST: number;
  73677. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  73678. static readonly SCALEMODE_CEILING: number;
  73679. /**
  73680. * The dirty texture flag value
  73681. */
  73682. static readonly MATERIAL_TextureDirtyFlag: number;
  73683. /**
  73684. * The dirty light flag value
  73685. */
  73686. static readonly MATERIAL_LightDirtyFlag: number;
  73687. /**
  73688. * The dirty fresnel flag value
  73689. */
  73690. static readonly MATERIAL_FresnelDirtyFlag: number;
  73691. /**
  73692. * The dirty attribute flag value
  73693. */
  73694. static readonly MATERIAL_AttributesDirtyFlag: number;
  73695. /**
  73696. * The dirty misc flag value
  73697. */
  73698. static readonly MATERIAL_MiscDirtyFlag: number;
  73699. /**
  73700. * The all dirty flag value
  73701. */
  73702. static readonly MATERIAL_AllDirtyFlag: number;
  73703. /**
  73704. * Returns the triangle fill mode
  73705. */
  73706. static readonly MATERIAL_TriangleFillMode: number;
  73707. /**
  73708. * Returns the wireframe mode
  73709. */
  73710. static readonly MATERIAL_WireFrameFillMode: number;
  73711. /**
  73712. * Returns the point fill mode
  73713. */
  73714. static readonly MATERIAL_PointFillMode: number;
  73715. /**
  73716. * Returns the point list draw mode
  73717. */
  73718. static readonly MATERIAL_PointListDrawMode: number;
  73719. /**
  73720. * Returns the line list draw mode
  73721. */
  73722. static readonly MATERIAL_LineListDrawMode: number;
  73723. /**
  73724. * Returns the line loop draw mode
  73725. */
  73726. static readonly MATERIAL_LineLoopDrawMode: number;
  73727. /**
  73728. * Returns the line strip draw mode
  73729. */
  73730. static readonly MATERIAL_LineStripDrawMode: number;
  73731. /**
  73732. * Returns the triangle strip draw mode
  73733. */
  73734. static readonly MATERIAL_TriangleStripDrawMode: number;
  73735. /**
  73736. * Returns the triangle fan draw mode
  73737. */
  73738. static readonly MATERIAL_TriangleFanDrawMode: number;
  73739. /**
  73740. * Stores the clock-wise side orientation
  73741. */
  73742. static readonly MATERIAL_ClockWiseSideOrientation: number;
  73743. /**
  73744. * Stores the counter clock-wise side orientation
  73745. */
  73746. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  73747. /**
  73748. * Nothing
  73749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73750. */
  73751. static readonly ACTION_NothingTrigger: number;
  73752. /**
  73753. * On pick
  73754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73755. */
  73756. static readonly ACTION_OnPickTrigger: number;
  73757. /**
  73758. * On left pick
  73759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73760. */
  73761. static readonly ACTION_OnLeftPickTrigger: number;
  73762. /**
  73763. * On right pick
  73764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73765. */
  73766. static readonly ACTION_OnRightPickTrigger: number;
  73767. /**
  73768. * On center pick
  73769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73770. */
  73771. static readonly ACTION_OnCenterPickTrigger: number;
  73772. /**
  73773. * On pick down
  73774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73775. */
  73776. static readonly ACTION_OnPickDownTrigger: number;
  73777. /**
  73778. * On double pick
  73779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73780. */
  73781. static readonly ACTION_OnDoublePickTrigger: number;
  73782. /**
  73783. * On pick up
  73784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73785. */
  73786. static readonly ACTION_OnPickUpTrigger: number;
  73787. /**
  73788. * On pick out.
  73789. * This trigger will only be raised if you also declared a OnPickDown
  73790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73791. */
  73792. static readonly ACTION_OnPickOutTrigger: number;
  73793. /**
  73794. * On long press
  73795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73796. */
  73797. static readonly ACTION_OnLongPressTrigger: number;
  73798. /**
  73799. * On pointer over
  73800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73801. */
  73802. static readonly ACTION_OnPointerOverTrigger: number;
  73803. /**
  73804. * On pointer out
  73805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73806. */
  73807. static readonly ACTION_OnPointerOutTrigger: number;
  73808. /**
  73809. * On every frame
  73810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73811. */
  73812. static readonly ACTION_OnEveryFrameTrigger: number;
  73813. /**
  73814. * On intersection enter
  73815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73816. */
  73817. static readonly ACTION_OnIntersectionEnterTrigger: number;
  73818. /**
  73819. * On intersection exit
  73820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73821. */
  73822. static readonly ACTION_OnIntersectionExitTrigger: number;
  73823. /**
  73824. * On key down
  73825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73826. */
  73827. static readonly ACTION_OnKeyDownTrigger: number;
  73828. /**
  73829. * On key up
  73830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73831. */
  73832. static readonly ACTION_OnKeyUpTrigger: number;
  73833. /**
  73834. * Billboard mode will only apply to Y axis
  73835. */
  73836. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  73837. /**
  73838. * Billboard mode will apply to all axes
  73839. */
  73840. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  73841. /**
  73842. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73843. */
  73844. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  73845. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  73846. * Test order :
  73847. * Is the bounding sphere outside the frustum ?
  73848. * If not, are the bounding box vertices outside the frustum ?
  73849. * It not, then the cullable object is in the frustum.
  73850. */
  73851. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  73852. /** Culling strategy : Bounding Sphere Only.
  73853. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  73854. * It's also less accurate than the standard because some not visible objects can still be selected.
  73855. * Test : is the bounding sphere outside the frustum ?
  73856. * If not, then the cullable object is in the frustum.
  73857. */
  73858. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  73859. /** Culling strategy : Optimistic Inclusion.
  73860. * This in an inclusion test first, then the standard exclusion test.
  73861. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  73862. * 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.
  73863. * Anyway, it's as accurate as the standard strategy.
  73864. * Test :
  73865. * Is the cullable object bounding sphere center in the frustum ?
  73866. * If not, apply the default culling strategy.
  73867. */
  73868. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  73869. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  73870. * This in an inclusion test first, then the bounding sphere only exclusion test.
  73871. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  73872. * 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.
  73873. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  73874. * Test :
  73875. * Is the cullable object bounding sphere center in the frustum ?
  73876. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  73877. */
  73878. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  73879. /**
  73880. * No logging while loading
  73881. */
  73882. static readonly SCENELOADER_NO_LOGGING: number;
  73883. /**
  73884. * Minimal logging while loading
  73885. */
  73886. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  73887. /**
  73888. * Summary logging while loading
  73889. */
  73890. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  73891. /**
  73892. * Detailled logging while loading
  73893. */
  73894. static readonly SCENELOADER_DETAILED_LOGGING: number;
  73895. }
  73896. }
  73897. declare module BABYLON {
  73898. /**
  73899. * This represents the required contract to create a new type of texture loader.
  73900. */
  73901. export interface IInternalTextureLoader {
  73902. /**
  73903. * Defines wether the loader supports cascade loading the different faces.
  73904. */
  73905. supportCascades: boolean;
  73906. /**
  73907. * This returns if the loader support the current file information.
  73908. * @param extension defines the file extension of the file being loaded
  73909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73910. * @param fallback defines the fallback internal texture if any
  73911. * @param isBase64 defines whether the texture is encoded as a base64
  73912. * @param isBuffer defines whether the texture data are stored as a buffer
  73913. * @returns true if the loader can load the specified file
  73914. */
  73915. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73916. /**
  73917. * Transform the url before loading if required.
  73918. * @param rootUrl the url of the texture
  73919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73920. * @returns the transformed texture
  73921. */
  73922. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73923. /**
  73924. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73925. * @param rootUrl the url of the texture
  73926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73927. * @returns the fallback texture
  73928. */
  73929. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73930. /**
  73931. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73932. * @param data contains the texture data
  73933. * @param texture defines the BabylonJS internal texture
  73934. * @param createPolynomials will be true if polynomials have been requested
  73935. * @param onLoad defines the callback to trigger once the texture is ready
  73936. * @param onError defines the callback to trigger in case of error
  73937. */
  73938. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73939. /**
  73940. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73941. * @param data contains the texture data
  73942. * @param texture defines the BabylonJS internal texture
  73943. * @param callback defines the method to call once ready to upload
  73944. */
  73945. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73946. }
  73947. }
  73948. declare module BABYLON {
  73949. /**
  73950. * Class used to store and describe the pipeline context associated with an effect
  73951. */
  73952. export interface IPipelineContext {
  73953. /**
  73954. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  73955. */
  73956. isAsync: boolean;
  73957. /**
  73958. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  73959. */
  73960. isReady: boolean;
  73961. /** @hidden */
  73962. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  73963. }
  73964. }
  73965. declare module BABYLON {
  73966. /**
  73967. * Class used to store gfx data (like WebGLBuffer)
  73968. */
  73969. export class DataBuffer {
  73970. /**
  73971. * Gets or sets the number of objects referencing this buffer
  73972. */
  73973. references: number;
  73974. /** Gets or sets the size of the underlying buffer */
  73975. capacity: number;
  73976. /**
  73977. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  73978. */
  73979. is32Bits: boolean;
  73980. /**
  73981. * Gets the underlying buffer
  73982. */
  73983. get underlyingResource(): any;
  73984. }
  73985. }
  73986. declare module BABYLON {
  73987. /** @hidden */
  73988. export interface IShaderProcessor {
  73989. attributeProcessor?: (attribute: string) => string;
  73990. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  73991. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  73992. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  73993. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  73994. lineProcessor?: (line: string, isFragment: boolean) => string;
  73995. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73996. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73997. }
  73998. }
  73999. declare module BABYLON {
  74000. /** @hidden */
  74001. export interface ProcessingOptions {
  74002. defines: string[];
  74003. indexParameters: any;
  74004. isFragment: boolean;
  74005. shouldUseHighPrecisionShader: boolean;
  74006. supportsUniformBuffers: boolean;
  74007. shadersRepository: string;
  74008. includesShadersStore: {
  74009. [key: string]: string;
  74010. };
  74011. processor?: IShaderProcessor;
  74012. version: string;
  74013. platformName: string;
  74014. lookForClosingBracketForUniformBuffer?: boolean;
  74015. }
  74016. }
  74017. declare module BABYLON {
  74018. /** @hidden */
  74019. export class ShaderCodeNode {
  74020. line: string;
  74021. children: ShaderCodeNode[];
  74022. additionalDefineKey?: string;
  74023. additionalDefineValue?: string;
  74024. isValid(preprocessors: {
  74025. [key: string]: string;
  74026. }): boolean;
  74027. process(preprocessors: {
  74028. [key: string]: string;
  74029. }, options: ProcessingOptions): string;
  74030. }
  74031. }
  74032. declare module BABYLON {
  74033. /** @hidden */
  74034. export class ShaderCodeCursor {
  74035. private _lines;
  74036. lineIndex: number;
  74037. get currentLine(): string;
  74038. get canRead(): boolean;
  74039. set lines(value: string[]);
  74040. }
  74041. }
  74042. declare module BABYLON {
  74043. /** @hidden */
  74044. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74045. process(preprocessors: {
  74046. [key: string]: string;
  74047. }, options: ProcessingOptions): string;
  74048. }
  74049. }
  74050. declare module BABYLON {
  74051. /** @hidden */
  74052. export class ShaderDefineExpression {
  74053. isTrue(preprocessors: {
  74054. [key: string]: string;
  74055. }): boolean;
  74056. }
  74057. }
  74058. declare module BABYLON {
  74059. /** @hidden */
  74060. export class ShaderCodeTestNode extends ShaderCodeNode {
  74061. testExpression: ShaderDefineExpression;
  74062. isValid(preprocessors: {
  74063. [key: string]: string;
  74064. }): boolean;
  74065. }
  74066. }
  74067. declare module BABYLON {
  74068. /** @hidden */
  74069. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74070. define: string;
  74071. not: boolean;
  74072. constructor(define: string, not?: boolean);
  74073. isTrue(preprocessors: {
  74074. [key: string]: string;
  74075. }): boolean;
  74076. }
  74077. }
  74078. declare module BABYLON {
  74079. /** @hidden */
  74080. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74081. leftOperand: ShaderDefineExpression;
  74082. rightOperand: ShaderDefineExpression;
  74083. isTrue(preprocessors: {
  74084. [key: string]: string;
  74085. }): boolean;
  74086. }
  74087. }
  74088. declare module BABYLON {
  74089. /** @hidden */
  74090. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74091. leftOperand: ShaderDefineExpression;
  74092. rightOperand: ShaderDefineExpression;
  74093. isTrue(preprocessors: {
  74094. [key: string]: string;
  74095. }): boolean;
  74096. }
  74097. }
  74098. declare module BABYLON {
  74099. /** @hidden */
  74100. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74101. define: string;
  74102. operand: string;
  74103. testValue: string;
  74104. constructor(define: string, operand: string, testValue: string);
  74105. isTrue(preprocessors: {
  74106. [key: string]: string;
  74107. }): boolean;
  74108. }
  74109. }
  74110. declare module BABYLON {
  74111. /**
  74112. * Class used to enable access to offline support
  74113. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74114. */
  74115. export interface IOfflineProvider {
  74116. /**
  74117. * Gets a boolean indicating if scene must be saved in the database
  74118. */
  74119. enableSceneOffline: boolean;
  74120. /**
  74121. * Gets a boolean indicating if textures must be saved in the database
  74122. */
  74123. enableTexturesOffline: boolean;
  74124. /**
  74125. * Open the offline support and make it available
  74126. * @param successCallback defines the callback to call on success
  74127. * @param errorCallback defines the callback to call on error
  74128. */
  74129. open(successCallback: () => void, errorCallback: () => void): void;
  74130. /**
  74131. * Loads an image from the offline support
  74132. * @param url defines the url to load from
  74133. * @param image defines the target DOM image
  74134. */
  74135. loadImage(url: string, image: HTMLImageElement): void;
  74136. /**
  74137. * Loads a file from offline support
  74138. * @param url defines the URL to load from
  74139. * @param sceneLoaded defines a callback to call on success
  74140. * @param progressCallBack defines a callback to call when progress changed
  74141. * @param errorCallback defines a callback to call on error
  74142. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74143. */
  74144. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74145. }
  74146. }
  74147. declare module BABYLON {
  74148. /**
  74149. * Class used to help managing file picking and drag'n'drop
  74150. * File Storage
  74151. */
  74152. export class FilesInputStore {
  74153. /**
  74154. * List of files ready to be loaded
  74155. */
  74156. static FilesToLoad: {
  74157. [key: string]: File;
  74158. };
  74159. }
  74160. }
  74161. declare module BABYLON {
  74162. /**
  74163. * Class used to define a retry strategy when error happens while loading assets
  74164. */
  74165. export class RetryStrategy {
  74166. /**
  74167. * Function used to defines an exponential back off strategy
  74168. * @param maxRetries defines the maximum number of retries (3 by default)
  74169. * @param baseInterval defines the interval between retries
  74170. * @returns the strategy function to use
  74171. */
  74172. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74173. }
  74174. }
  74175. declare module BABYLON {
  74176. /**
  74177. * @ignore
  74178. * Application error to support additional information when loading a file
  74179. */
  74180. export abstract class BaseError extends Error {
  74181. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74182. }
  74183. }
  74184. declare module BABYLON {
  74185. /** @ignore */
  74186. export class LoadFileError extends BaseError {
  74187. request?: WebRequest;
  74188. file?: File;
  74189. /**
  74190. * Creates a new LoadFileError
  74191. * @param message defines the message of the error
  74192. * @param request defines the optional web request
  74193. * @param file defines the optional file
  74194. */
  74195. constructor(message: string, object?: WebRequest | File);
  74196. }
  74197. /** @ignore */
  74198. export class RequestFileError extends BaseError {
  74199. request: WebRequest;
  74200. /**
  74201. * Creates a new LoadFileError
  74202. * @param message defines the message of the error
  74203. * @param request defines the optional web request
  74204. */
  74205. constructor(message: string, request: WebRequest);
  74206. }
  74207. /** @ignore */
  74208. export class ReadFileError extends BaseError {
  74209. file: File;
  74210. /**
  74211. * Creates a new ReadFileError
  74212. * @param message defines the message of the error
  74213. * @param file defines the optional file
  74214. */
  74215. constructor(message: string, file: File);
  74216. }
  74217. /**
  74218. * @hidden
  74219. */
  74220. export class FileTools {
  74221. /**
  74222. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74223. */
  74224. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74225. /**
  74226. * Gets or sets the base URL to use to load assets
  74227. */
  74228. static BaseUrl: string;
  74229. /**
  74230. * Default behaviour for cors in the application.
  74231. * It can be a string if the expected behavior is identical in the entire app.
  74232. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74233. */
  74234. static CorsBehavior: string | ((url: string | string[]) => string);
  74235. /**
  74236. * Gets or sets a function used to pre-process url before using them to load assets
  74237. */
  74238. static PreprocessUrl: (url: string) => string;
  74239. /**
  74240. * Removes unwanted characters from an url
  74241. * @param url defines the url to clean
  74242. * @returns the cleaned url
  74243. */
  74244. private static _CleanUrl;
  74245. /**
  74246. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74247. * @param url define the url we are trying
  74248. * @param element define the dom element where to configure the cors policy
  74249. */
  74250. static SetCorsBehavior(url: string | string[], element: {
  74251. crossOrigin: string | null;
  74252. }): void;
  74253. /**
  74254. * Loads an image as an HTMLImageElement.
  74255. * @param input url string, ArrayBuffer, or Blob to load
  74256. * @param onLoad callback called when the image successfully loads
  74257. * @param onError callback called when the image fails to load
  74258. * @param offlineProvider offline provider for caching
  74259. * @param mimeType optional mime type
  74260. * @returns the HTMLImageElement of the loaded image
  74261. */
  74262. 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>;
  74263. /**
  74264. * Reads a file from a File object
  74265. * @param file defines the file to load
  74266. * @param onSuccess defines the callback to call when data is loaded
  74267. * @param onProgress defines the callback to call during loading process
  74268. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74269. * @param onError defines the callback to call when an error occurs
  74270. * @returns a file request object
  74271. */
  74272. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74273. /**
  74274. * Loads a file from a url
  74275. * @param url url to load
  74276. * @param onSuccess callback called when the file successfully loads
  74277. * @param onProgress callback called while file is loading (if the server supports this mode)
  74278. * @param offlineProvider defines the offline provider for caching
  74279. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74280. * @param onError callback called when the file fails to load
  74281. * @returns a file request object
  74282. */
  74283. 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;
  74284. /**
  74285. * Loads a file
  74286. * @param url url to load
  74287. * @param onSuccess callback called when the file successfully loads
  74288. * @param onProgress callback called while file is loading (if the server supports this mode)
  74289. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74290. * @param onError callback called when the file fails to load
  74291. * @param onOpened callback called when the web request is opened
  74292. * @returns a file request object
  74293. */
  74294. 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;
  74295. /**
  74296. * Checks if the loaded document was accessed via `file:`-Protocol.
  74297. * @returns boolean
  74298. */
  74299. static IsFileURL(): boolean;
  74300. }
  74301. }
  74302. declare module BABYLON {
  74303. /** @hidden */
  74304. export class ShaderProcessor {
  74305. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74306. private static _ProcessPrecision;
  74307. private static _ExtractOperation;
  74308. private static _BuildSubExpression;
  74309. private static _BuildExpression;
  74310. private static _MoveCursorWithinIf;
  74311. private static _MoveCursor;
  74312. private static _EvaluatePreProcessors;
  74313. private static _PreparePreProcessors;
  74314. private static _ProcessShaderConversion;
  74315. private static _ProcessIncludes;
  74316. /**
  74317. * Loads a file from a url
  74318. * @param url url to load
  74319. * @param onSuccess callback called when the file successfully loads
  74320. * @param onProgress callback called while file is loading (if the server supports this mode)
  74321. * @param offlineProvider defines the offline provider for caching
  74322. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74323. * @param onError callback called when the file fails to load
  74324. * @returns a file request object
  74325. * @hidden
  74326. */
  74327. 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;
  74328. }
  74329. }
  74330. declare module BABYLON {
  74331. /**
  74332. * @hidden
  74333. */
  74334. export interface IColor4Like {
  74335. r: float;
  74336. g: float;
  74337. b: float;
  74338. a: float;
  74339. }
  74340. /**
  74341. * @hidden
  74342. */
  74343. export interface IColor3Like {
  74344. r: float;
  74345. g: float;
  74346. b: float;
  74347. }
  74348. /**
  74349. * @hidden
  74350. */
  74351. export interface IVector4Like {
  74352. x: float;
  74353. y: float;
  74354. z: float;
  74355. w: float;
  74356. }
  74357. /**
  74358. * @hidden
  74359. */
  74360. export interface IVector3Like {
  74361. x: float;
  74362. y: float;
  74363. z: float;
  74364. }
  74365. /**
  74366. * @hidden
  74367. */
  74368. export interface IVector2Like {
  74369. x: float;
  74370. y: float;
  74371. }
  74372. /**
  74373. * @hidden
  74374. */
  74375. export interface IMatrixLike {
  74376. toArray(): DeepImmutable<Float32Array>;
  74377. updateFlag: int;
  74378. }
  74379. /**
  74380. * @hidden
  74381. */
  74382. export interface IViewportLike {
  74383. x: float;
  74384. y: float;
  74385. width: float;
  74386. height: float;
  74387. }
  74388. /**
  74389. * @hidden
  74390. */
  74391. export interface IPlaneLike {
  74392. normal: IVector3Like;
  74393. d: float;
  74394. normalize(): void;
  74395. }
  74396. }
  74397. declare module BABYLON {
  74398. /**
  74399. * Interface used to define common properties for effect fallbacks
  74400. */
  74401. export interface IEffectFallbacks {
  74402. /**
  74403. * Removes the defines that should be removed when falling back.
  74404. * @param currentDefines defines the current define statements for the shader.
  74405. * @param effect defines the current effect we try to compile
  74406. * @returns The resulting defines with defines of the current rank removed.
  74407. */
  74408. reduce(currentDefines: string, effect: Effect): string;
  74409. /**
  74410. * Removes the fallback from the bound mesh.
  74411. */
  74412. unBindMesh(): void;
  74413. /**
  74414. * Checks to see if more fallbacks are still availible.
  74415. */
  74416. hasMoreFallbacks: boolean;
  74417. }
  74418. }
  74419. declare module BABYLON {
  74420. /**
  74421. * Class used to evalaute queries containing `and` and `or` operators
  74422. */
  74423. export class AndOrNotEvaluator {
  74424. /**
  74425. * Evaluate a query
  74426. * @param query defines the query to evaluate
  74427. * @param evaluateCallback defines the callback used to filter result
  74428. * @returns true if the query matches
  74429. */
  74430. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74431. private static _HandleParenthesisContent;
  74432. private static _SimplifyNegation;
  74433. }
  74434. }
  74435. declare module BABYLON {
  74436. /**
  74437. * Class used to store custom tags
  74438. */
  74439. export class Tags {
  74440. /**
  74441. * Adds support for tags on the given object
  74442. * @param obj defines the object to use
  74443. */
  74444. static EnableFor(obj: any): void;
  74445. /**
  74446. * Removes tags support
  74447. * @param obj defines the object to use
  74448. */
  74449. static DisableFor(obj: any): void;
  74450. /**
  74451. * Gets a boolean indicating if the given object has tags
  74452. * @param obj defines the object to use
  74453. * @returns a boolean
  74454. */
  74455. static HasTags(obj: any): boolean;
  74456. /**
  74457. * Gets the tags available on a given object
  74458. * @param obj defines the object to use
  74459. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74460. * @returns the tags
  74461. */
  74462. static GetTags(obj: any, asString?: boolean): any;
  74463. /**
  74464. * Adds tags to an object
  74465. * @param obj defines the object to use
  74466. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74467. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74468. */
  74469. static AddTagsTo(obj: any, tagsString: string): void;
  74470. /**
  74471. * @hidden
  74472. */
  74473. static _AddTagTo(obj: any, tag: string): void;
  74474. /**
  74475. * Removes specific tags from a specific object
  74476. * @param obj defines the object to use
  74477. * @param tagsString defines the tags to remove
  74478. */
  74479. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74480. /**
  74481. * @hidden
  74482. */
  74483. static _RemoveTagFrom(obj: any, tag: string): void;
  74484. /**
  74485. * Defines if tags hosted on an object match a given query
  74486. * @param obj defines the object to use
  74487. * @param tagsQuery defines the tag query
  74488. * @returns a boolean
  74489. */
  74490. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74491. }
  74492. }
  74493. declare module BABYLON {
  74494. /**
  74495. * Scalar computation library
  74496. */
  74497. export class Scalar {
  74498. /**
  74499. * Two pi constants convenient for computation.
  74500. */
  74501. static TwoPi: number;
  74502. /**
  74503. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74504. * @param a number
  74505. * @param b number
  74506. * @param epsilon (default = 1.401298E-45)
  74507. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74508. */
  74509. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74510. /**
  74511. * Returns a string : the upper case translation of the number i to hexadecimal.
  74512. * @param i number
  74513. * @returns the upper case translation of the number i to hexadecimal.
  74514. */
  74515. static ToHex(i: number): string;
  74516. /**
  74517. * Returns -1 if value is negative and +1 is value is positive.
  74518. * @param value the value
  74519. * @returns the value itself if it's equal to zero.
  74520. */
  74521. static Sign(value: number): number;
  74522. /**
  74523. * Returns the value itself if it's between min and max.
  74524. * Returns min if the value is lower than min.
  74525. * Returns max if the value is greater than max.
  74526. * @param value the value to clmap
  74527. * @param min the min value to clamp to (default: 0)
  74528. * @param max the max value to clamp to (default: 1)
  74529. * @returns the clamped value
  74530. */
  74531. static Clamp(value: number, min?: number, max?: number): number;
  74532. /**
  74533. * the log2 of value.
  74534. * @param value the value to compute log2 of
  74535. * @returns the log2 of value.
  74536. */
  74537. static Log2(value: number): number;
  74538. /**
  74539. * Loops the value, so that it is never larger than length and never smaller than 0.
  74540. *
  74541. * This is similar to the modulo operator but it works with floating point numbers.
  74542. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74543. * With t = 5 and length = 2.5, the result would be 0.0.
  74544. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74545. * @param value the value
  74546. * @param length the length
  74547. * @returns the looped value
  74548. */
  74549. static Repeat(value: number, length: number): number;
  74550. /**
  74551. * Normalize the value between 0.0 and 1.0 using min and max values
  74552. * @param value value to normalize
  74553. * @param min max to normalize between
  74554. * @param max min to normalize between
  74555. * @returns the normalized value
  74556. */
  74557. static Normalize(value: number, min: number, max: number): number;
  74558. /**
  74559. * Denormalize the value from 0.0 and 1.0 using min and max values
  74560. * @param normalized value to denormalize
  74561. * @param min max to denormalize between
  74562. * @param max min to denormalize between
  74563. * @returns the denormalized value
  74564. */
  74565. static Denormalize(normalized: number, min: number, max: number): number;
  74566. /**
  74567. * Calculates the shortest difference between two given angles given in degrees.
  74568. * @param current current angle in degrees
  74569. * @param target target angle in degrees
  74570. * @returns the delta
  74571. */
  74572. static DeltaAngle(current: number, target: number): number;
  74573. /**
  74574. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74575. * @param tx value
  74576. * @param length length
  74577. * @returns The returned value will move back and forth between 0 and length
  74578. */
  74579. static PingPong(tx: number, length: number): number;
  74580. /**
  74581. * Interpolates between min and max with smoothing at the limits.
  74582. *
  74583. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74584. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74585. * @param from from
  74586. * @param to to
  74587. * @param tx value
  74588. * @returns the smooth stepped value
  74589. */
  74590. static SmoothStep(from: number, to: number, tx: number): number;
  74591. /**
  74592. * Moves a value current towards target.
  74593. *
  74594. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74595. * Negative values of maxDelta pushes the value away from target.
  74596. * @param current current value
  74597. * @param target target value
  74598. * @param maxDelta max distance to move
  74599. * @returns resulting value
  74600. */
  74601. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74602. /**
  74603. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74604. *
  74605. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74606. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74607. * @param current current value
  74608. * @param target target value
  74609. * @param maxDelta max distance to move
  74610. * @returns resulting angle
  74611. */
  74612. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74613. /**
  74614. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74615. * @param start start value
  74616. * @param end target value
  74617. * @param amount amount to lerp between
  74618. * @returns the lerped value
  74619. */
  74620. static Lerp(start: number, end: number, amount: number): number;
  74621. /**
  74622. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74623. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74624. * @param start start value
  74625. * @param end target value
  74626. * @param amount amount to lerp between
  74627. * @returns the lerped value
  74628. */
  74629. static LerpAngle(start: number, end: number, amount: number): number;
  74630. /**
  74631. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74632. * @param a start value
  74633. * @param b target value
  74634. * @param value value between a and b
  74635. * @returns the inverseLerp value
  74636. */
  74637. static InverseLerp(a: number, b: number, value: number): number;
  74638. /**
  74639. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74640. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74641. * @param value1 spline value
  74642. * @param tangent1 spline value
  74643. * @param value2 spline value
  74644. * @param tangent2 spline value
  74645. * @param amount input value
  74646. * @returns hermite result
  74647. */
  74648. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74649. /**
  74650. * Returns a random float number between and min and max values
  74651. * @param min min value of random
  74652. * @param max max value of random
  74653. * @returns random value
  74654. */
  74655. static RandomRange(min: number, max: number): number;
  74656. /**
  74657. * This function returns percentage of a number in a given range.
  74658. *
  74659. * RangeToPercent(40,20,60) will return 0.5 (50%)
  74660. * RangeToPercent(34,0,100) will return 0.34 (34%)
  74661. * @param number to convert to percentage
  74662. * @param min min range
  74663. * @param max max range
  74664. * @returns the percentage
  74665. */
  74666. static RangeToPercent(number: number, min: number, max: number): number;
  74667. /**
  74668. * This function returns number that corresponds to the percentage in a given range.
  74669. *
  74670. * PercentToRange(0.34,0,100) will return 34.
  74671. * @param percent to convert to number
  74672. * @param min min range
  74673. * @param max max range
  74674. * @returns the number
  74675. */
  74676. static PercentToRange(percent: number, min: number, max: number): number;
  74677. /**
  74678. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  74679. * @param angle The angle to normalize in radian.
  74680. * @return The converted angle.
  74681. */
  74682. static NormalizeRadians(angle: number): number;
  74683. }
  74684. }
  74685. declare module BABYLON {
  74686. /**
  74687. * Constant used to convert a value to gamma space
  74688. * @ignorenaming
  74689. */
  74690. export const ToGammaSpace: number;
  74691. /**
  74692. * Constant used to convert a value to linear space
  74693. * @ignorenaming
  74694. */
  74695. export const ToLinearSpace = 2.2;
  74696. /**
  74697. * Constant used to define the minimal number value in Babylon.js
  74698. * @ignorenaming
  74699. */
  74700. let Epsilon: number;
  74701. }
  74702. declare module BABYLON {
  74703. /**
  74704. * Class used to represent a viewport on screen
  74705. */
  74706. export class Viewport {
  74707. /** viewport left coordinate */
  74708. x: number;
  74709. /** viewport top coordinate */
  74710. y: number;
  74711. /**viewport width */
  74712. width: number;
  74713. /** viewport height */
  74714. height: number;
  74715. /**
  74716. * Creates a Viewport object located at (x, y) and sized (width, height)
  74717. * @param x defines viewport left coordinate
  74718. * @param y defines viewport top coordinate
  74719. * @param width defines the viewport width
  74720. * @param height defines the viewport height
  74721. */
  74722. constructor(
  74723. /** viewport left coordinate */
  74724. x: number,
  74725. /** viewport top coordinate */
  74726. y: number,
  74727. /**viewport width */
  74728. width: number,
  74729. /** viewport height */
  74730. height: number);
  74731. /**
  74732. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  74733. * @param renderWidth defines the rendering width
  74734. * @param renderHeight defines the rendering height
  74735. * @returns a new Viewport
  74736. */
  74737. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  74738. /**
  74739. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  74740. * @param renderWidth defines the rendering width
  74741. * @param renderHeight defines the rendering height
  74742. * @param ref defines the target viewport
  74743. * @returns the current viewport
  74744. */
  74745. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  74746. /**
  74747. * Returns a new Viewport copied from the current one
  74748. * @returns a new Viewport
  74749. */
  74750. clone(): Viewport;
  74751. }
  74752. }
  74753. declare module BABYLON {
  74754. /**
  74755. * Class containing a set of static utilities functions for arrays.
  74756. */
  74757. export class ArrayTools {
  74758. /**
  74759. * Returns an array of the given size filled with element built from the given constructor and the paramters
  74760. * @param size the number of element to construct and put in the array
  74761. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  74762. * @returns a new array filled with new objects
  74763. */
  74764. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  74765. }
  74766. }
  74767. declare module BABYLON {
  74768. /**
  74769. * Class representing a vector containing 2 coordinates
  74770. */
  74771. export class Vector2 {
  74772. /** defines the first coordinate */
  74773. x: number;
  74774. /** defines the second coordinate */
  74775. y: number;
  74776. /**
  74777. * Creates a new Vector2 from the given x and y coordinates
  74778. * @param x defines the first coordinate
  74779. * @param y defines the second coordinate
  74780. */
  74781. constructor(
  74782. /** defines the first coordinate */
  74783. x?: number,
  74784. /** defines the second coordinate */
  74785. y?: number);
  74786. /**
  74787. * Gets a string with the Vector2 coordinates
  74788. * @returns a string with the Vector2 coordinates
  74789. */
  74790. toString(): string;
  74791. /**
  74792. * Gets class name
  74793. * @returns the string "Vector2"
  74794. */
  74795. getClassName(): string;
  74796. /**
  74797. * Gets current vector hash code
  74798. * @returns the Vector2 hash code as a number
  74799. */
  74800. getHashCode(): number;
  74801. /**
  74802. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  74803. * @param array defines the source array
  74804. * @param index defines the offset in source array
  74805. * @returns the current Vector2
  74806. */
  74807. toArray(array: FloatArray, index?: number): Vector2;
  74808. /**
  74809. * Copy the current vector to an array
  74810. * @returns a new array with 2 elements: the Vector2 coordinates.
  74811. */
  74812. asArray(): number[];
  74813. /**
  74814. * Sets the Vector2 coordinates with the given Vector2 coordinates
  74815. * @param source defines the source Vector2
  74816. * @returns the current updated Vector2
  74817. */
  74818. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  74819. /**
  74820. * Sets the Vector2 coordinates with the given floats
  74821. * @param x defines the first coordinate
  74822. * @param y defines the second coordinate
  74823. * @returns the current updated Vector2
  74824. */
  74825. copyFromFloats(x: number, y: number): Vector2;
  74826. /**
  74827. * Sets the Vector2 coordinates with the given floats
  74828. * @param x defines the first coordinate
  74829. * @param y defines the second coordinate
  74830. * @returns the current updated Vector2
  74831. */
  74832. set(x: number, y: number): Vector2;
  74833. /**
  74834. * Add another vector with the current one
  74835. * @param otherVector defines the other vector
  74836. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  74837. */
  74838. add(otherVector: DeepImmutable<Vector2>): Vector2;
  74839. /**
  74840. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  74841. * @param otherVector defines the other vector
  74842. * @param result defines the target vector
  74843. * @returns the unmodified current Vector2
  74844. */
  74845. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74846. /**
  74847. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  74848. * @param otherVector defines the other vector
  74849. * @returns the current updated Vector2
  74850. */
  74851. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74852. /**
  74853. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  74854. * @param otherVector defines the other vector
  74855. * @returns a new Vector2
  74856. */
  74857. addVector3(otherVector: Vector3): Vector2;
  74858. /**
  74859. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  74860. * @param otherVector defines the other vector
  74861. * @returns a new Vector2
  74862. */
  74863. subtract(otherVector: Vector2): Vector2;
  74864. /**
  74865. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  74866. * @param otherVector defines the other vector
  74867. * @param result defines the target vector
  74868. * @returns the unmodified current Vector2
  74869. */
  74870. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74871. /**
  74872. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  74873. * @param otherVector defines the other vector
  74874. * @returns the current updated Vector2
  74875. */
  74876. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74877. /**
  74878. * Multiplies in place the current Vector2 coordinates by the given ones
  74879. * @param otherVector defines the other vector
  74880. * @returns the current updated Vector2
  74881. */
  74882. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74883. /**
  74884. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  74885. * @param otherVector defines the other vector
  74886. * @returns a new Vector2
  74887. */
  74888. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  74889. /**
  74890. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  74891. * @param otherVector defines the other vector
  74892. * @param result defines the target vector
  74893. * @returns the unmodified current Vector2
  74894. */
  74895. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74896. /**
  74897. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  74898. * @param x defines the first coordinate
  74899. * @param y defines the second coordinate
  74900. * @returns a new Vector2
  74901. */
  74902. multiplyByFloats(x: number, y: number): Vector2;
  74903. /**
  74904. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  74905. * @param otherVector defines the other vector
  74906. * @returns a new Vector2
  74907. */
  74908. divide(otherVector: Vector2): Vector2;
  74909. /**
  74910. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  74911. * @param otherVector defines the other vector
  74912. * @param result defines the target vector
  74913. * @returns the unmodified current Vector2
  74914. */
  74915. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74916. /**
  74917. * Divides the current Vector2 coordinates by the given ones
  74918. * @param otherVector defines the other vector
  74919. * @returns the current updated Vector2
  74920. */
  74921. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74922. /**
  74923. * Gets a new Vector2 with current Vector2 negated coordinates
  74924. * @returns a new Vector2
  74925. */
  74926. negate(): Vector2;
  74927. /**
  74928. * Negate this vector in place
  74929. * @returns this
  74930. */
  74931. negateInPlace(): Vector2;
  74932. /**
  74933. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  74934. * @param result defines the Vector3 object where to store the result
  74935. * @returns the current Vector2
  74936. */
  74937. negateToRef(result: Vector2): Vector2;
  74938. /**
  74939. * Multiply the Vector2 coordinates by scale
  74940. * @param scale defines the scaling factor
  74941. * @returns the current updated Vector2
  74942. */
  74943. scaleInPlace(scale: number): Vector2;
  74944. /**
  74945. * Returns a new Vector2 scaled by "scale" from the current Vector2
  74946. * @param scale defines the scaling factor
  74947. * @returns a new Vector2
  74948. */
  74949. scale(scale: number): Vector2;
  74950. /**
  74951. * Scale the current Vector2 values by a factor to a given Vector2
  74952. * @param scale defines the scale factor
  74953. * @param result defines the Vector2 object where to store the result
  74954. * @returns the unmodified current Vector2
  74955. */
  74956. scaleToRef(scale: number, result: Vector2): Vector2;
  74957. /**
  74958. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  74959. * @param scale defines the scale factor
  74960. * @param result defines the Vector2 object where to store the result
  74961. * @returns the unmodified current Vector2
  74962. */
  74963. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  74964. /**
  74965. * Gets a boolean if two vectors are equals
  74966. * @param otherVector defines the other vector
  74967. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  74968. */
  74969. equals(otherVector: DeepImmutable<Vector2>): boolean;
  74970. /**
  74971. * Gets a boolean if two vectors are equals (using an epsilon value)
  74972. * @param otherVector defines the other vector
  74973. * @param epsilon defines the minimal distance to consider equality
  74974. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  74975. */
  74976. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  74977. /**
  74978. * Gets a new Vector2 from current Vector2 floored values
  74979. * @returns a new Vector2
  74980. */
  74981. floor(): Vector2;
  74982. /**
  74983. * Gets a new Vector2 from current Vector2 floored values
  74984. * @returns a new Vector2
  74985. */
  74986. fract(): Vector2;
  74987. /**
  74988. * Gets the length of the vector
  74989. * @returns the vector length (float)
  74990. */
  74991. length(): number;
  74992. /**
  74993. * Gets the vector squared length
  74994. * @returns the vector squared length (float)
  74995. */
  74996. lengthSquared(): number;
  74997. /**
  74998. * Normalize the vector
  74999. * @returns the current updated Vector2
  75000. */
  75001. normalize(): Vector2;
  75002. /**
  75003. * Gets a new Vector2 copied from the Vector2
  75004. * @returns a new Vector2
  75005. */
  75006. clone(): Vector2;
  75007. /**
  75008. * Gets a new Vector2(0, 0)
  75009. * @returns a new Vector2
  75010. */
  75011. static Zero(): Vector2;
  75012. /**
  75013. * Gets a new Vector2(1, 1)
  75014. * @returns a new Vector2
  75015. */
  75016. static One(): Vector2;
  75017. /**
  75018. * Gets a new Vector2 set from the given index element of the given array
  75019. * @param array defines the data source
  75020. * @param offset defines the offset in the data source
  75021. * @returns a new Vector2
  75022. */
  75023. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75024. /**
  75025. * Sets "result" from the given index element of the given array
  75026. * @param array defines the data source
  75027. * @param offset defines the offset in the data source
  75028. * @param result defines the target vector
  75029. */
  75030. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75031. /**
  75032. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75033. * @param value1 defines 1st point of control
  75034. * @param value2 defines 2nd point of control
  75035. * @param value3 defines 3rd point of control
  75036. * @param value4 defines 4th point of control
  75037. * @param amount defines the interpolation factor
  75038. * @returns a new Vector2
  75039. */
  75040. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75041. /**
  75042. * 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".
  75043. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75044. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75045. * @param value defines the value to clamp
  75046. * @param min defines the lower limit
  75047. * @param max defines the upper limit
  75048. * @returns a new Vector2
  75049. */
  75050. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75051. /**
  75052. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75053. * @param value1 defines the 1st control point
  75054. * @param tangent1 defines the outgoing tangent
  75055. * @param value2 defines the 2nd control point
  75056. * @param tangent2 defines the incoming tangent
  75057. * @param amount defines the interpolation factor
  75058. * @returns a new Vector2
  75059. */
  75060. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75061. /**
  75062. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75063. * @param start defines the start vector
  75064. * @param end defines the end vector
  75065. * @param amount defines the interpolation factor
  75066. * @returns a new Vector2
  75067. */
  75068. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75069. /**
  75070. * Gets the dot product of the vector "left" and the vector "right"
  75071. * @param left defines first vector
  75072. * @param right defines second vector
  75073. * @returns the dot product (float)
  75074. */
  75075. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75076. /**
  75077. * Returns a new Vector2 equal to the normalized given vector
  75078. * @param vector defines the vector to normalize
  75079. * @returns a new Vector2
  75080. */
  75081. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75082. /**
  75083. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75084. * @param left defines 1st vector
  75085. * @param right defines 2nd vector
  75086. * @returns a new Vector2
  75087. */
  75088. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75089. /**
  75090. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75091. * @param left defines 1st vector
  75092. * @param right defines 2nd vector
  75093. * @returns a new Vector2
  75094. */
  75095. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75096. /**
  75097. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75098. * @param vector defines the vector to transform
  75099. * @param transformation defines the matrix to apply
  75100. * @returns a new Vector2
  75101. */
  75102. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75103. /**
  75104. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75105. * @param vector defines the vector to transform
  75106. * @param transformation defines the matrix to apply
  75107. * @param result defines the target vector
  75108. */
  75109. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75110. /**
  75111. * Determines if a given vector is included in a triangle
  75112. * @param p defines the vector to test
  75113. * @param p0 defines 1st triangle point
  75114. * @param p1 defines 2nd triangle point
  75115. * @param p2 defines 3rd triangle point
  75116. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75117. */
  75118. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75119. /**
  75120. * Gets the distance between the vectors "value1" and "value2"
  75121. * @param value1 defines first vector
  75122. * @param value2 defines second vector
  75123. * @returns the distance between vectors
  75124. */
  75125. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75126. /**
  75127. * Returns the squared distance between the vectors "value1" and "value2"
  75128. * @param value1 defines first vector
  75129. * @param value2 defines second vector
  75130. * @returns the squared distance between vectors
  75131. */
  75132. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75133. /**
  75134. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75135. * @param value1 defines first vector
  75136. * @param value2 defines second vector
  75137. * @returns a new Vector2
  75138. */
  75139. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75140. /**
  75141. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75142. * @param p defines the middle point
  75143. * @param segA defines one point of the segment
  75144. * @param segB defines the other point of the segment
  75145. * @returns the shortest distance
  75146. */
  75147. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75148. }
  75149. /**
  75150. * Class used to store (x,y,z) vector representation
  75151. * A Vector3 is the main object used in 3D geometry
  75152. * It can represent etiher the coordinates of a point the space, either a direction
  75153. * Reminder: js uses a left handed forward facing system
  75154. */
  75155. export class Vector3 {
  75156. /**
  75157. * Defines the first coordinates (on X axis)
  75158. */
  75159. x: number;
  75160. /**
  75161. * Defines the second coordinates (on Y axis)
  75162. */
  75163. y: number;
  75164. /**
  75165. * Defines the third coordinates (on Z axis)
  75166. */
  75167. z: number;
  75168. private static _UpReadOnly;
  75169. private static _ZeroReadOnly;
  75170. /**
  75171. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75172. * @param x defines the first coordinates (on X axis)
  75173. * @param y defines the second coordinates (on Y axis)
  75174. * @param z defines the third coordinates (on Z axis)
  75175. */
  75176. constructor(
  75177. /**
  75178. * Defines the first coordinates (on X axis)
  75179. */
  75180. x?: number,
  75181. /**
  75182. * Defines the second coordinates (on Y axis)
  75183. */
  75184. y?: number,
  75185. /**
  75186. * Defines the third coordinates (on Z axis)
  75187. */
  75188. z?: number);
  75189. /**
  75190. * Creates a string representation of the Vector3
  75191. * @returns a string with the Vector3 coordinates.
  75192. */
  75193. toString(): string;
  75194. /**
  75195. * Gets the class name
  75196. * @returns the string "Vector3"
  75197. */
  75198. getClassName(): string;
  75199. /**
  75200. * Creates the Vector3 hash code
  75201. * @returns a number which tends to be unique between Vector3 instances
  75202. */
  75203. getHashCode(): number;
  75204. /**
  75205. * Creates an array containing three elements : the coordinates of the Vector3
  75206. * @returns a new array of numbers
  75207. */
  75208. asArray(): number[];
  75209. /**
  75210. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75211. * @param array defines the destination array
  75212. * @param index defines the offset in the destination array
  75213. * @returns the current Vector3
  75214. */
  75215. toArray(array: FloatArray, index?: number): Vector3;
  75216. /**
  75217. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75218. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75219. */
  75220. toQuaternion(): Quaternion;
  75221. /**
  75222. * Adds the given vector to the current Vector3
  75223. * @param otherVector defines the second operand
  75224. * @returns the current updated Vector3
  75225. */
  75226. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75227. /**
  75228. * Adds the given coordinates to the current Vector3
  75229. * @param x defines the x coordinate of the operand
  75230. * @param y defines the y coordinate of the operand
  75231. * @param z defines the z coordinate of the operand
  75232. * @returns the current updated Vector3
  75233. */
  75234. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75235. /**
  75236. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75237. * @param otherVector defines the second operand
  75238. * @returns the resulting Vector3
  75239. */
  75240. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75241. /**
  75242. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75243. * @param otherVector defines the second operand
  75244. * @param result defines the Vector3 object where to store the result
  75245. * @returns the current Vector3
  75246. */
  75247. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75248. /**
  75249. * Subtract the given vector from the current Vector3
  75250. * @param otherVector defines the second operand
  75251. * @returns the current updated Vector3
  75252. */
  75253. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75254. /**
  75255. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75256. * @param otherVector defines the second operand
  75257. * @returns the resulting Vector3
  75258. */
  75259. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75260. /**
  75261. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75262. * @param otherVector defines the second operand
  75263. * @param result defines the Vector3 object where to store the result
  75264. * @returns the current Vector3
  75265. */
  75266. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75267. /**
  75268. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75269. * @param x defines the x coordinate of the operand
  75270. * @param y defines the y coordinate of the operand
  75271. * @param z defines the z coordinate of the operand
  75272. * @returns the resulting Vector3
  75273. */
  75274. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75275. /**
  75276. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75277. * @param x defines the x coordinate of the operand
  75278. * @param y defines the y coordinate of the operand
  75279. * @param z defines the z coordinate of the operand
  75280. * @param result defines the Vector3 object where to store the result
  75281. * @returns the current Vector3
  75282. */
  75283. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75284. /**
  75285. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75286. * @returns a new Vector3
  75287. */
  75288. negate(): Vector3;
  75289. /**
  75290. * Negate this vector in place
  75291. * @returns this
  75292. */
  75293. negateInPlace(): Vector3;
  75294. /**
  75295. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75296. * @param result defines the Vector3 object where to store the result
  75297. * @returns the current Vector3
  75298. */
  75299. negateToRef(result: Vector3): Vector3;
  75300. /**
  75301. * Multiplies the Vector3 coordinates by the float "scale"
  75302. * @param scale defines the multiplier factor
  75303. * @returns the current updated Vector3
  75304. */
  75305. scaleInPlace(scale: number): Vector3;
  75306. /**
  75307. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75308. * @param scale defines the multiplier factor
  75309. * @returns a new Vector3
  75310. */
  75311. scale(scale: number): Vector3;
  75312. /**
  75313. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75314. * @param scale defines the multiplier factor
  75315. * @param result defines the Vector3 object where to store the result
  75316. * @returns the current Vector3
  75317. */
  75318. scaleToRef(scale: number, result: Vector3): Vector3;
  75319. /**
  75320. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75321. * @param scale defines the scale factor
  75322. * @param result defines the Vector3 object where to store the result
  75323. * @returns the unmodified current Vector3
  75324. */
  75325. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75326. /**
  75327. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75328. * @param otherVector defines the second operand
  75329. * @returns true if both vectors are equals
  75330. */
  75331. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75332. /**
  75333. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75334. * @param otherVector defines the second operand
  75335. * @param epsilon defines the minimal distance to define values as equals
  75336. * @returns true if both vectors are distant less than epsilon
  75337. */
  75338. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75339. /**
  75340. * Returns true if the current Vector3 coordinates equals the given floats
  75341. * @param x defines the x coordinate of the operand
  75342. * @param y defines the y coordinate of the operand
  75343. * @param z defines the z coordinate of the operand
  75344. * @returns true if both vectors are equals
  75345. */
  75346. equalsToFloats(x: number, y: number, z: number): boolean;
  75347. /**
  75348. * Multiplies the current Vector3 coordinates by the given ones
  75349. * @param otherVector defines the second operand
  75350. * @returns the current updated Vector3
  75351. */
  75352. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75353. /**
  75354. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75355. * @param otherVector defines the second operand
  75356. * @returns the new Vector3
  75357. */
  75358. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75359. /**
  75360. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75361. * @param otherVector defines the second operand
  75362. * @param result defines the Vector3 object where to store the result
  75363. * @returns the current Vector3
  75364. */
  75365. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75366. /**
  75367. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75368. * @param x defines the x coordinate of the operand
  75369. * @param y defines the y coordinate of the operand
  75370. * @param z defines the z coordinate of the operand
  75371. * @returns the new Vector3
  75372. */
  75373. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75374. /**
  75375. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75376. * @param otherVector defines the second operand
  75377. * @returns the new Vector3
  75378. */
  75379. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75380. /**
  75381. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75382. * @param otherVector defines the second operand
  75383. * @param result defines the Vector3 object where to store the result
  75384. * @returns the current Vector3
  75385. */
  75386. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75387. /**
  75388. * Divides the current Vector3 coordinates by the given ones.
  75389. * @param otherVector defines the second operand
  75390. * @returns the current updated Vector3
  75391. */
  75392. divideInPlace(otherVector: Vector3): Vector3;
  75393. /**
  75394. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75395. * @param other defines the second operand
  75396. * @returns the current updated Vector3
  75397. */
  75398. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75399. /**
  75400. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75401. * @param other defines the second operand
  75402. * @returns the current updated Vector3
  75403. */
  75404. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75405. /**
  75406. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75407. * @param x defines the x coordinate of the operand
  75408. * @param y defines the y coordinate of the operand
  75409. * @param z defines the z coordinate of the operand
  75410. * @returns the current updated Vector3
  75411. */
  75412. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75413. /**
  75414. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75415. * @param x defines the x coordinate of the operand
  75416. * @param y defines the y coordinate of the operand
  75417. * @param z defines the z coordinate of the operand
  75418. * @returns the current updated Vector3
  75419. */
  75420. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75421. /**
  75422. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75423. * Check if is non uniform within a certain amount of decimal places to account for this
  75424. * @param epsilon the amount the values can differ
  75425. * @returns if the the vector is non uniform to a certain number of decimal places
  75426. */
  75427. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75428. /**
  75429. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75430. */
  75431. get isNonUniform(): boolean;
  75432. /**
  75433. * Gets a new Vector3 from current Vector3 floored values
  75434. * @returns a new Vector3
  75435. */
  75436. floor(): Vector3;
  75437. /**
  75438. * Gets a new Vector3 from current Vector3 floored values
  75439. * @returns a new Vector3
  75440. */
  75441. fract(): Vector3;
  75442. /**
  75443. * Gets the length of the Vector3
  75444. * @returns the length of the Vector3
  75445. */
  75446. length(): number;
  75447. /**
  75448. * Gets the squared length of the Vector3
  75449. * @returns squared length of the Vector3
  75450. */
  75451. lengthSquared(): number;
  75452. /**
  75453. * Normalize the current Vector3.
  75454. * Please note that this is an in place operation.
  75455. * @returns the current updated Vector3
  75456. */
  75457. normalize(): Vector3;
  75458. /**
  75459. * Reorders the x y z properties of the vector in place
  75460. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75461. * @returns the current updated vector
  75462. */
  75463. reorderInPlace(order: string): this;
  75464. /**
  75465. * Rotates the vector around 0,0,0 by a quaternion
  75466. * @param quaternion the rotation quaternion
  75467. * @param result vector to store the result
  75468. * @returns the resulting vector
  75469. */
  75470. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75471. /**
  75472. * Rotates a vector around a given point
  75473. * @param quaternion the rotation quaternion
  75474. * @param point the point to rotate around
  75475. * @param result vector to store the result
  75476. * @returns the resulting vector
  75477. */
  75478. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75479. /**
  75480. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75481. * The cross product is then orthogonal to both current and "other"
  75482. * @param other defines the right operand
  75483. * @returns the cross product
  75484. */
  75485. cross(other: Vector3): Vector3;
  75486. /**
  75487. * Normalize the current Vector3 with the given input length.
  75488. * Please note that this is an in place operation.
  75489. * @param len the length of the vector
  75490. * @returns the current updated Vector3
  75491. */
  75492. normalizeFromLength(len: number): Vector3;
  75493. /**
  75494. * Normalize the current Vector3 to a new vector
  75495. * @returns the new Vector3
  75496. */
  75497. normalizeToNew(): Vector3;
  75498. /**
  75499. * Normalize the current Vector3 to the reference
  75500. * @param reference define the Vector3 to update
  75501. * @returns the updated Vector3
  75502. */
  75503. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75504. /**
  75505. * Creates a new Vector3 copied from the current Vector3
  75506. * @returns the new Vector3
  75507. */
  75508. clone(): Vector3;
  75509. /**
  75510. * Copies the given vector coordinates to the current Vector3 ones
  75511. * @param source defines the source Vector3
  75512. * @returns the current updated Vector3
  75513. */
  75514. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75515. /**
  75516. * Copies the given floats to the current Vector3 coordinates
  75517. * @param x defines the x coordinate of the operand
  75518. * @param y defines the y coordinate of the operand
  75519. * @param z defines the z coordinate of the operand
  75520. * @returns the current updated Vector3
  75521. */
  75522. copyFromFloats(x: number, y: number, z: number): Vector3;
  75523. /**
  75524. * Copies the given floats to the current Vector3 coordinates
  75525. * @param x defines the x coordinate of the operand
  75526. * @param y defines the y coordinate of the operand
  75527. * @param z defines the z coordinate of the operand
  75528. * @returns the current updated Vector3
  75529. */
  75530. set(x: number, y: number, z: number): Vector3;
  75531. /**
  75532. * Copies the given float to the current Vector3 coordinates
  75533. * @param v defines the x, y and z coordinates of the operand
  75534. * @returns the current updated Vector3
  75535. */
  75536. setAll(v: number): Vector3;
  75537. /**
  75538. * Get the clip factor between two vectors
  75539. * @param vector0 defines the first operand
  75540. * @param vector1 defines the second operand
  75541. * @param axis defines the axis to use
  75542. * @param size defines the size along the axis
  75543. * @returns the clip factor
  75544. */
  75545. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75546. /**
  75547. * Get angle between two vectors
  75548. * @param vector0 angle between vector0 and vector1
  75549. * @param vector1 angle between vector0 and vector1
  75550. * @param normal direction of the normal
  75551. * @return the angle between vector0 and vector1
  75552. */
  75553. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75554. /**
  75555. * Returns a new Vector3 set from the index "offset" of the given array
  75556. * @param array defines the source array
  75557. * @param offset defines the offset in the source array
  75558. * @returns the new Vector3
  75559. */
  75560. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75561. /**
  75562. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75563. * @param array defines the source array
  75564. * @param offset defines the offset in the source array
  75565. * @returns the new Vector3
  75566. * @deprecated Please use FromArray instead.
  75567. */
  75568. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75569. /**
  75570. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75571. * @param array defines the source array
  75572. * @param offset defines the offset in the source array
  75573. * @param result defines the Vector3 where to store the result
  75574. */
  75575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75576. /**
  75577. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75578. * @param array defines the source array
  75579. * @param offset defines the offset in the source array
  75580. * @param result defines the Vector3 where to store the result
  75581. * @deprecated Please use FromArrayToRef instead.
  75582. */
  75583. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75584. /**
  75585. * Sets the given vector "result" with the given floats.
  75586. * @param x defines the x coordinate of the source
  75587. * @param y defines the y coordinate of the source
  75588. * @param z defines the z coordinate of the source
  75589. * @param result defines the Vector3 where to store the result
  75590. */
  75591. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75592. /**
  75593. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75594. * @returns a new empty Vector3
  75595. */
  75596. static Zero(): Vector3;
  75597. /**
  75598. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75599. * @returns a new unit Vector3
  75600. */
  75601. static One(): Vector3;
  75602. /**
  75603. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75604. * @returns a new up Vector3
  75605. */
  75606. static Up(): Vector3;
  75607. /**
  75608. * Gets a up Vector3 that must not be updated
  75609. */
  75610. static get UpReadOnly(): DeepImmutable<Vector3>;
  75611. /**
  75612. * Gets a zero Vector3 that must not be updated
  75613. */
  75614. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75615. /**
  75616. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75617. * @returns a new down Vector3
  75618. */
  75619. static Down(): Vector3;
  75620. /**
  75621. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75622. * @returns a new forward Vector3
  75623. */
  75624. static Forward(): Vector3;
  75625. /**
  75626. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75627. * @returns a new forward Vector3
  75628. */
  75629. static Backward(): Vector3;
  75630. /**
  75631. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75632. * @returns a new right Vector3
  75633. */
  75634. static Right(): Vector3;
  75635. /**
  75636. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75637. * @returns a new left Vector3
  75638. */
  75639. static Left(): Vector3;
  75640. /**
  75641. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75642. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75643. * @param vector defines the Vector3 to transform
  75644. * @param transformation defines the transformation matrix
  75645. * @returns the transformed Vector3
  75646. */
  75647. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75648. /**
  75649. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75650. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75651. * @param vector defines the Vector3 to transform
  75652. * @param transformation defines the transformation matrix
  75653. * @param result defines the Vector3 where to store the result
  75654. */
  75655. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75656. /**
  75657. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  75658. * This method computes tranformed coordinates only, not transformed direction vectors
  75659. * @param x define the x coordinate of the source vector
  75660. * @param y define the y coordinate of the source vector
  75661. * @param z define the z coordinate of the source vector
  75662. * @param transformation defines the transformation matrix
  75663. * @param result defines the Vector3 where to store the result
  75664. */
  75665. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75666. /**
  75667. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  75668. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75669. * @param vector defines the Vector3 to transform
  75670. * @param transformation defines the transformation matrix
  75671. * @returns the new Vector3
  75672. */
  75673. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75674. /**
  75675. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  75676. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75677. * @param vector defines the Vector3 to transform
  75678. * @param transformation defines the transformation matrix
  75679. * @param result defines the Vector3 where to store the result
  75680. */
  75681. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75682. /**
  75683. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  75684. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75685. * @param x define the x coordinate of the source vector
  75686. * @param y define the y coordinate of the source vector
  75687. * @param z define the z coordinate of the source vector
  75688. * @param transformation defines the transformation matrix
  75689. * @param result defines the Vector3 where to store the result
  75690. */
  75691. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75692. /**
  75693. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  75694. * @param value1 defines the first control point
  75695. * @param value2 defines the second control point
  75696. * @param value3 defines the third control point
  75697. * @param value4 defines the fourth control point
  75698. * @param amount defines the amount on the spline to use
  75699. * @returns the new Vector3
  75700. */
  75701. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  75702. /**
  75703. * 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"
  75704. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75705. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75706. * @param value defines the current value
  75707. * @param min defines the lower range value
  75708. * @param max defines the upper range value
  75709. * @returns the new Vector3
  75710. */
  75711. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  75712. /**
  75713. * 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"
  75714. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75715. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75716. * @param value defines the current value
  75717. * @param min defines the lower range value
  75718. * @param max defines the upper range value
  75719. * @param result defines the Vector3 where to store the result
  75720. */
  75721. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  75722. /**
  75723. * Checks if a given vector is inside a specific range
  75724. * @param v defines the vector to test
  75725. * @param min defines the minimum range
  75726. * @param max defines the maximum range
  75727. */
  75728. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  75729. /**
  75730. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  75731. * @param value1 defines the first control point
  75732. * @param tangent1 defines the first tangent vector
  75733. * @param value2 defines the second control point
  75734. * @param tangent2 defines the second tangent vector
  75735. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  75736. * @returns the new Vector3
  75737. */
  75738. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  75739. /**
  75740. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  75741. * @param start defines the start value
  75742. * @param end defines the end value
  75743. * @param amount max defines amount between both (between 0 and 1)
  75744. * @returns the new Vector3
  75745. */
  75746. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  75747. /**
  75748. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  75749. * @param start defines the start value
  75750. * @param end defines the end value
  75751. * @param amount max defines amount between both (between 0 and 1)
  75752. * @param result defines the Vector3 where to store the result
  75753. */
  75754. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  75755. /**
  75756. * Returns the dot product (float) between the vectors "left" and "right"
  75757. * @param left defines the left operand
  75758. * @param right defines the right operand
  75759. * @returns the dot product
  75760. */
  75761. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  75762. /**
  75763. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  75764. * The cross product is then orthogonal to both "left" and "right"
  75765. * @param left defines the left operand
  75766. * @param right defines the right operand
  75767. * @returns the cross product
  75768. */
  75769. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75770. /**
  75771. * Sets the given vector "result" with the cross product of "left" and "right"
  75772. * The cross product is then orthogonal to both "left" and "right"
  75773. * @param left defines the left operand
  75774. * @param right defines the right operand
  75775. * @param result defines the Vector3 where to store the result
  75776. */
  75777. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  75778. /**
  75779. * Returns a new Vector3 as the normalization of the given vector
  75780. * @param vector defines the Vector3 to normalize
  75781. * @returns the new Vector3
  75782. */
  75783. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  75784. /**
  75785. * Sets the given vector "result" with the normalization of the given first vector
  75786. * @param vector defines the Vector3 to normalize
  75787. * @param result defines the Vector3 where to store the result
  75788. */
  75789. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  75790. /**
  75791. * Project a Vector3 onto screen space
  75792. * @param vector defines the Vector3 to project
  75793. * @param world defines the world matrix to use
  75794. * @param transform defines the transform (view x projection) matrix to use
  75795. * @param viewport defines the screen viewport to use
  75796. * @returns the new Vector3
  75797. */
  75798. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  75799. /** @hidden */
  75800. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  75801. /**
  75802. * Unproject from screen space to object space
  75803. * @param source defines the screen space Vector3 to use
  75804. * @param viewportWidth defines the current width of the viewport
  75805. * @param viewportHeight defines the current height of the viewport
  75806. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75807. * @param transform defines the transform (view x projection) matrix to use
  75808. * @returns the new Vector3
  75809. */
  75810. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  75811. /**
  75812. * Unproject from screen space to object space
  75813. * @param source defines the screen space Vector3 to use
  75814. * @param viewportWidth defines the current width of the viewport
  75815. * @param viewportHeight defines the current height of the viewport
  75816. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75817. * @param view defines the view matrix to use
  75818. * @param projection defines the projection matrix to use
  75819. * @returns the new Vector3
  75820. */
  75821. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  75822. /**
  75823. * Unproject from screen space to object space
  75824. * @param source defines the screen space Vector3 to use
  75825. * @param viewportWidth defines the current width of the viewport
  75826. * @param viewportHeight defines the current height of the viewport
  75827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75828. * @param view defines the view matrix to use
  75829. * @param projection defines the projection matrix to use
  75830. * @param result defines the Vector3 where to store the result
  75831. */
  75832. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75833. /**
  75834. * Unproject from screen space to object space
  75835. * @param sourceX defines the screen space x coordinate to use
  75836. * @param sourceY defines the screen space y coordinate to use
  75837. * @param sourceZ defines the screen space z coordinate to use
  75838. * @param viewportWidth defines the current width of the viewport
  75839. * @param viewportHeight defines the current height of the viewport
  75840. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75841. * @param view defines the view matrix to use
  75842. * @param projection defines the projection matrix to use
  75843. * @param result defines the Vector3 where to store the result
  75844. */
  75845. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75846. /**
  75847. * Gets the minimal coordinate values between two Vector3
  75848. * @param left defines the first operand
  75849. * @param right defines the second operand
  75850. * @returns the new Vector3
  75851. */
  75852. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75853. /**
  75854. * Gets the maximal coordinate values between two Vector3
  75855. * @param left defines the first operand
  75856. * @param right defines the second operand
  75857. * @returns the new Vector3
  75858. */
  75859. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75860. /**
  75861. * Returns the distance between the vectors "value1" and "value2"
  75862. * @param value1 defines the first operand
  75863. * @param value2 defines the second operand
  75864. * @returns the distance
  75865. */
  75866. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75867. /**
  75868. * Returns the squared distance between the vectors "value1" and "value2"
  75869. * @param value1 defines the first operand
  75870. * @param value2 defines the second operand
  75871. * @returns the squared distance
  75872. */
  75873. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75874. /**
  75875. * Returns a new Vector3 located at the center between "value1" and "value2"
  75876. * @param value1 defines the first operand
  75877. * @param value2 defines the second operand
  75878. * @returns the new Vector3
  75879. */
  75880. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  75881. /**
  75882. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  75883. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  75884. * to something in order to rotate it from its local system to the given target system
  75885. * Note: axis1, axis2 and axis3 are normalized during this operation
  75886. * @param axis1 defines the first axis
  75887. * @param axis2 defines the second axis
  75888. * @param axis3 defines the third axis
  75889. * @returns a new Vector3
  75890. */
  75891. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  75892. /**
  75893. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  75894. * @param axis1 defines the first axis
  75895. * @param axis2 defines the second axis
  75896. * @param axis3 defines the third axis
  75897. * @param ref defines the Vector3 where to store the result
  75898. */
  75899. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  75900. }
  75901. /**
  75902. * Vector4 class created for EulerAngle class conversion to Quaternion
  75903. */
  75904. export class Vector4 {
  75905. /** x value of the vector */
  75906. x: number;
  75907. /** y value of the vector */
  75908. y: number;
  75909. /** z value of the vector */
  75910. z: number;
  75911. /** w value of the vector */
  75912. w: number;
  75913. /**
  75914. * Creates a Vector4 object from the given floats.
  75915. * @param x x value of the vector
  75916. * @param y y value of the vector
  75917. * @param z z value of the vector
  75918. * @param w w value of the vector
  75919. */
  75920. constructor(
  75921. /** x value of the vector */
  75922. x: number,
  75923. /** y value of the vector */
  75924. y: number,
  75925. /** z value of the vector */
  75926. z: number,
  75927. /** w value of the vector */
  75928. w: number);
  75929. /**
  75930. * Returns the string with the Vector4 coordinates.
  75931. * @returns a string containing all the vector values
  75932. */
  75933. toString(): string;
  75934. /**
  75935. * Returns the string "Vector4".
  75936. * @returns "Vector4"
  75937. */
  75938. getClassName(): string;
  75939. /**
  75940. * Returns the Vector4 hash code.
  75941. * @returns a unique hash code
  75942. */
  75943. getHashCode(): number;
  75944. /**
  75945. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  75946. * @returns the resulting array
  75947. */
  75948. asArray(): number[];
  75949. /**
  75950. * Populates the given array from the given index with the Vector4 coordinates.
  75951. * @param array array to populate
  75952. * @param index index of the array to start at (default: 0)
  75953. * @returns the Vector4.
  75954. */
  75955. toArray(array: FloatArray, index?: number): Vector4;
  75956. /**
  75957. * Adds the given vector to the current Vector4.
  75958. * @param otherVector the vector to add
  75959. * @returns the updated Vector4.
  75960. */
  75961. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75962. /**
  75963. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  75964. * @param otherVector the vector to add
  75965. * @returns the resulting vector
  75966. */
  75967. add(otherVector: DeepImmutable<Vector4>): Vector4;
  75968. /**
  75969. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  75970. * @param otherVector the vector to add
  75971. * @param result the vector to store the result
  75972. * @returns the current Vector4.
  75973. */
  75974. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75975. /**
  75976. * Subtract in place the given vector from the current Vector4.
  75977. * @param otherVector the vector to subtract
  75978. * @returns the updated Vector4.
  75979. */
  75980. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75981. /**
  75982. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  75983. * @param otherVector the vector to add
  75984. * @returns the new vector with the result
  75985. */
  75986. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  75987. /**
  75988. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  75989. * @param otherVector the vector to subtract
  75990. * @param result the vector to store the result
  75991. * @returns the current Vector4.
  75992. */
  75993. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75994. /**
  75995. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75996. */
  75997. /**
  75998. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75999. * @param x value to subtract
  76000. * @param y value to subtract
  76001. * @param z value to subtract
  76002. * @param w value to subtract
  76003. * @returns new vector containing the result
  76004. */
  76005. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76006. /**
  76007. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76008. * @param x value to subtract
  76009. * @param y value to subtract
  76010. * @param z value to subtract
  76011. * @param w value to subtract
  76012. * @param result the vector to store the result in
  76013. * @returns the current Vector4.
  76014. */
  76015. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76016. /**
  76017. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76018. * @returns a new vector with the negated values
  76019. */
  76020. negate(): Vector4;
  76021. /**
  76022. * Negate this vector in place
  76023. * @returns this
  76024. */
  76025. negateInPlace(): Vector4;
  76026. /**
  76027. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76028. * @param result defines the Vector3 object where to store the result
  76029. * @returns the current Vector4
  76030. */
  76031. negateToRef(result: Vector4): Vector4;
  76032. /**
  76033. * Multiplies the current Vector4 coordinates by scale (float).
  76034. * @param scale the number to scale with
  76035. * @returns the updated Vector4.
  76036. */
  76037. scaleInPlace(scale: number): Vector4;
  76038. /**
  76039. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76040. * @param scale the number to scale with
  76041. * @returns a new vector with the result
  76042. */
  76043. scale(scale: number): Vector4;
  76044. /**
  76045. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76046. * @param scale the number to scale with
  76047. * @param result a vector to store the result in
  76048. * @returns the current Vector4.
  76049. */
  76050. scaleToRef(scale: number, result: Vector4): Vector4;
  76051. /**
  76052. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76053. * @param scale defines the scale factor
  76054. * @param result defines the Vector4 object where to store the result
  76055. * @returns the unmodified current Vector4
  76056. */
  76057. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76058. /**
  76059. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76060. * @param otherVector the vector to compare against
  76061. * @returns true if they are equal
  76062. */
  76063. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76064. /**
  76065. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76066. * @param otherVector vector to compare against
  76067. * @param epsilon (Default: very small number)
  76068. * @returns true if they are equal
  76069. */
  76070. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76071. /**
  76072. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76073. * @param x x value to compare against
  76074. * @param y y value to compare against
  76075. * @param z z value to compare against
  76076. * @param w w value to compare against
  76077. * @returns true if equal
  76078. */
  76079. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76080. /**
  76081. * Multiplies in place the current Vector4 by the given one.
  76082. * @param otherVector vector to multiple with
  76083. * @returns the updated Vector4.
  76084. */
  76085. multiplyInPlace(otherVector: Vector4): Vector4;
  76086. /**
  76087. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76088. * @param otherVector vector to multiple with
  76089. * @returns resulting new vector
  76090. */
  76091. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76092. /**
  76093. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76094. * @param otherVector vector to multiple with
  76095. * @param result vector to store the result
  76096. * @returns the current Vector4.
  76097. */
  76098. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76099. /**
  76100. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76101. * @param x x value multiply with
  76102. * @param y y value multiply with
  76103. * @param z z value multiply with
  76104. * @param w w value multiply with
  76105. * @returns resulting new vector
  76106. */
  76107. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76108. /**
  76109. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76110. * @param otherVector vector to devide with
  76111. * @returns resulting new vector
  76112. */
  76113. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76114. /**
  76115. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76116. * @param otherVector vector to devide with
  76117. * @param result vector to store the result
  76118. * @returns the current Vector4.
  76119. */
  76120. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76121. /**
  76122. * Divides the current Vector3 coordinates by the given ones.
  76123. * @param otherVector vector to devide with
  76124. * @returns the updated Vector3.
  76125. */
  76126. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76127. /**
  76128. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76129. * @param other defines the second operand
  76130. * @returns the current updated Vector4
  76131. */
  76132. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76133. /**
  76134. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76135. * @param other defines the second operand
  76136. * @returns the current updated Vector4
  76137. */
  76138. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76139. /**
  76140. * Gets a new Vector4 from current Vector4 floored values
  76141. * @returns a new Vector4
  76142. */
  76143. floor(): Vector4;
  76144. /**
  76145. * Gets a new Vector4 from current Vector3 floored values
  76146. * @returns a new Vector4
  76147. */
  76148. fract(): Vector4;
  76149. /**
  76150. * Returns the Vector4 length (float).
  76151. * @returns the length
  76152. */
  76153. length(): number;
  76154. /**
  76155. * Returns the Vector4 squared length (float).
  76156. * @returns the length squared
  76157. */
  76158. lengthSquared(): number;
  76159. /**
  76160. * Normalizes in place the Vector4.
  76161. * @returns the updated Vector4.
  76162. */
  76163. normalize(): Vector4;
  76164. /**
  76165. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76166. * @returns this converted to a new vector3
  76167. */
  76168. toVector3(): Vector3;
  76169. /**
  76170. * Returns a new Vector4 copied from the current one.
  76171. * @returns the new cloned vector
  76172. */
  76173. clone(): Vector4;
  76174. /**
  76175. * Updates the current Vector4 with the given one coordinates.
  76176. * @param source the source vector to copy from
  76177. * @returns the updated Vector4.
  76178. */
  76179. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76180. /**
  76181. * Updates the current Vector4 coordinates with the given floats.
  76182. * @param x float to copy from
  76183. * @param y float to copy from
  76184. * @param z float to copy from
  76185. * @param w float to copy from
  76186. * @returns the updated Vector4.
  76187. */
  76188. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76189. /**
  76190. * Updates the current Vector4 coordinates with the given floats.
  76191. * @param x float to set from
  76192. * @param y float to set from
  76193. * @param z float to set from
  76194. * @param w float to set from
  76195. * @returns the updated Vector4.
  76196. */
  76197. set(x: number, y: number, z: number, w: number): Vector4;
  76198. /**
  76199. * Copies the given float to the current Vector3 coordinates
  76200. * @param v defines the x, y, z and w coordinates of the operand
  76201. * @returns the current updated Vector3
  76202. */
  76203. setAll(v: number): Vector4;
  76204. /**
  76205. * Returns a new Vector4 set from the starting index of the given array.
  76206. * @param array the array to pull values from
  76207. * @param offset the offset into the array to start at
  76208. * @returns the new vector
  76209. */
  76210. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76211. /**
  76212. * Updates the given vector "result" from the starting index of the given array.
  76213. * @param array the array to pull values from
  76214. * @param offset the offset into the array to start at
  76215. * @param result the vector to store the result in
  76216. */
  76217. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76218. /**
  76219. * Updates the given vector "result" from the starting index of the given Float32Array.
  76220. * @param array the array to pull values from
  76221. * @param offset the offset into the array to start at
  76222. * @param result the vector to store the result in
  76223. */
  76224. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76225. /**
  76226. * Updates the given vector "result" coordinates from the given floats.
  76227. * @param x float to set from
  76228. * @param y float to set from
  76229. * @param z float to set from
  76230. * @param w float to set from
  76231. * @param result the vector to the floats in
  76232. */
  76233. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76234. /**
  76235. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76236. * @returns the new vector
  76237. */
  76238. static Zero(): Vector4;
  76239. /**
  76240. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76241. * @returns the new vector
  76242. */
  76243. static One(): Vector4;
  76244. /**
  76245. * Returns a new normalized Vector4 from the given one.
  76246. * @param vector the vector to normalize
  76247. * @returns the vector
  76248. */
  76249. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76250. /**
  76251. * Updates the given vector "result" from the normalization of the given one.
  76252. * @param vector the vector to normalize
  76253. * @param result the vector to store the result in
  76254. */
  76255. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76256. /**
  76257. * Returns a vector with the minimum values from the left and right vectors
  76258. * @param left left vector to minimize
  76259. * @param right right vector to minimize
  76260. * @returns a new vector with the minimum of the left and right vector values
  76261. */
  76262. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76263. /**
  76264. * Returns a vector with the maximum values from the left and right vectors
  76265. * @param left left vector to maximize
  76266. * @param right right vector to maximize
  76267. * @returns a new vector with the maximum of the left and right vector values
  76268. */
  76269. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76270. /**
  76271. * Returns the distance (float) between the vectors "value1" and "value2".
  76272. * @param value1 value to calulate the distance between
  76273. * @param value2 value to calulate the distance between
  76274. * @return the distance between the two vectors
  76275. */
  76276. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76277. /**
  76278. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76279. * @param value1 value to calulate the distance between
  76280. * @param value2 value to calulate the distance between
  76281. * @return the distance between the two vectors squared
  76282. */
  76283. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76284. /**
  76285. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76286. * @param value1 value to calulate the center between
  76287. * @param value2 value to calulate the center between
  76288. * @return the center between the two vectors
  76289. */
  76290. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76291. /**
  76292. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76293. * This methods computes transformed normalized direction vectors only.
  76294. * @param vector the vector to transform
  76295. * @param transformation the transformation matrix to apply
  76296. * @returns the new vector
  76297. */
  76298. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76299. /**
  76300. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76301. * This methods computes transformed normalized direction vectors only.
  76302. * @param vector the vector to transform
  76303. * @param transformation the transformation matrix to apply
  76304. * @param result the vector to store the result in
  76305. */
  76306. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76307. /**
  76308. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76309. * This methods computes transformed normalized direction vectors only.
  76310. * @param x value to transform
  76311. * @param y value to transform
  76312. * @param z value to transform
  76313. * @param w value to transform
  76314. * @param transformation the transformation matrix to apply
  76315. * @param result the vector to store the results in
  76316. */
  76317. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76318. /**
  76319. * Creates a new Vector4 from a Vector3
  76320. * @param source defines the source data
  76321. * @param w defines the 4th component (default is 0)
  76322. * @returns a new Vector4
  76323. */
  76324. static FromVector3(source: Vector3, w?: number): Vector4;
  76325. }
  76326. /**
  76327. * Class used to store quaternion data
  76328. * @see https://en.wikipedia.org/wiki/Quaternion
  76329. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76330. */
  76331. export class Quaternion {
  76332. /** defines the first component (0 by default) */
  76333. x: number;
  76334. /** defines the second component (0 by default) */
  76335. y: number;
  76336. /** defines the third component (0 by default) */
  76337. z: number;
  76338. /** defines the fourth component (1.0 by default) */
  76339. w: number;
  76340. /**
  76341. * Creates a new Quaternion from the given floats
  76342. * @param x defines the first component (0 by default)
  76343. * @param y defines the second component (0 by default)
  76344. * @param z defines the third component (0 by default)
  76345. * @param w defines the fourth component (1.0 by default)
  76346. */
  76347. constructor(
  76348. /** defines the first component (0 by default) */
  76349. x?: number,
  76350. /** defines the second component (0 by default) */
  76351. y?: number,
  76352. /** defines the third component (0 by default) */
  76353. z?: number,
  76354. /** defines the fourth component (1.0 by default) */
  76355. w?: number);
  76356. /**
  76357. * Gets a string representation for the current quaternion
  76358. * @returns a string with the Quaternion coordinates
  76359. */
  76360. toString(): string;
  76361. /**
  76362. * Gets the class name of the quaternion
  76363. * @returns the string "Quaternion"
  76364. */
  76365. getClassName(): string;
  76366. /**
  76367. * Gets a hash code for this quaternion
  76368. * @returns the quaternion hash code
  76369. */
  76370. getHashCode(): number;
  76371. /**
  76372. * Copy the quaternion to an array
  76373. * @returns a new array populated with 4 elements from the quaternion coordinates
  76374. */
  76375. asArray(): number[];
  76376. /**
  76377. * Check if two quaternions are equals
  76378. * @param otherQuaternion defines the second operand
  76379. * @return true if the current quaternion and the given one coordinates are strictly equals
  76380. */
  76381. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76382. /**
  76383. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76384. * @param otherQuaternion defines the other quaternion
  76385. * @param epsilon defines the minimal distance to consider equality
  76386. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76387. */
  76388. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76389. /**
  76390. * Clone the current quaternion
  76391. * @returns a new quaternion copied from the current one
  76392. */
  76393. clone(): Quaternion;
  76394. /**
  76395. * Copy a quaternion to the current one
  76396. * @param other defines the other quaternion
  76397. * @returns the updated current quaternion
  76398. */
  76399. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76400. /**
  76401. * Updates the current quaternion with the given float coordinates
  76402. * @param x defines the x coordinate
  76403. * @param y defines the y coordinate
  76404. * @param z defines the z coordinate
  76405. * @param w defines the w coordinate
  76406. * @returns the updated current quaternion
  76407. */
  76408. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76409. /**
  76410. * Updates the current quaternion from the given float coordinates
  76411. * @param x defines the x coordinate
  76412. * @param y defines the y coordinate
  76413. * @param z defines the z coordinate
  76414. * @param w defines the w coordinate
  76415. * @returns the updated current quaternion
  76416. */
  76417. set(x: number, y: number, z: number, w: number): Quaternion;
  76418. /**
  76419. * Adds two quaternions
  76420. * @param other defines the second operand
  76421. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76422. */
  76423. add(other: DeepImmutable<Quaternion>): Quaternion;
  76424. /**
  76425. * Add a quaternion to the current one
  76426. * @param other defines the quaternion to add
  76427. * @returns the current quaternion
  76428. */
  76429. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76430. /**
  76431. * Subtract two quaternions
  76432. * @param other defines the second operand
  76433. * @returns a new quaternion as the subtraction result of the given one from the current one
  76434. */
  76435. subtract(other: Quaternion): Quaternion;
  76436. /**
  76437. * Multiplies the current quaternion by a scale factor
  76438. * @param value defines the scale factor
  76439. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76440. */
  76441. scale(value: number): Quaternion;
  76442. /**
  76443. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76444. * @param scale defines the scale factor
  76445. * @param result defines the Quaternion object where to store the result
  76446. * @returns the unmodified current quaternion
  76447. */
  76448. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76449. /**
  76450. * Multiplies in place the current quaternion by a scale factor
  76451. * @param value defines the scale factor
  76452. * @returns the current modified quaternion
  76453. */
  76454. scaleInPlace(value: number): Quaternion;
  76455. /**
  76456. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76457. * @param scale defines the scale factor
  76458. * @param result defines the Quaternion object where to store the result
  76459. * @returns the unmodified current quaternion
  76460. */
  76461. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76462. /**
  76463. * Multiplies two quaternions
  76464. * @param q1 defines the second operand
  76465. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76466. */
  76467. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76468. /**
  76469. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76470. * @param q1 defines the second operand
  76471. * @param result defines the target quaternion
  76472. * @returns the current quaternion
  76473. */
  76474. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76475. /**
  76476. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76477. * @param q1 defines the second operand
  76478. * @returns the currentupdated quaternion
  76479. */
  76480. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76481. /**
  76482. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76483. * @param ref defines the target quaternion
  76484. * @returns the current quaternion
  76485. */
  76486. conjugateToRef(ref: Quaternion): Quaternion;
  76487. /**
  76488. * Conjugates in place (1-q) the current quaternion
  76489. * @returns the current updated quaternion
  76490. */
  76491. conjugateInPlace(): Quaternion;
  76492. /**
  76493. * Conjugates in place (1-q) the current quaternion
  76494. * @returns a new quaternion
  76495. */
  76496. conjugate(): Quaternion;
  76497. /**
  76498. * Gets length of current quaternion
  76499. * @returns the quaternion length (float)
  76500. */
  76501. length(): number;
  76502. /**
  76503. * Normalize in place the current quaternion
  76504. * @returns the current updated quaternion
  76505. */
  76506. normalize(): Quaternion;
  76507. /**
  76508. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76509. * @param order is a reserved parameter and is ignore for now
  76510. * @returns a new Vector3 containing the Euler angles
  76511. */
  76512. toEulerAngles(order?: string): Vector3;
  76513. /**
  76514. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76515. * @param result defines the vector which will be filled with the Euler angles
  76516. * @param order is a reserved parameter and is ignore for now
  76517. * @returns the current unchanged quaternion
  76518. */
  76519. toEulerAnglesToRef(result: Vector3): Quaternion;
  76520. /**
  76521. * Updates the given rotation matrix with the current quaternion values
  76522. * @param result defines the target matrix
  76523. * @returns the current unchanged quaternion
  76524. */
  76525. toRotationMatrix(result: Matrix): Quaternion;
  76526. /**
  76527. * Updates the current quaternion from the given rotation matrix values
  76528. * @param matrix defines the source matrix
  76529. * @returns the current updated quaternion
  76530. */
  76531. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76532. /**
  76533. * Creates a new quaternion from a rotation matrix
  76534. * @param matrix defines the source matrix
  76535. * @returns a new quaternion created from the given rotation matrix values
  76536. */
  76537. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76538. /**
  76539. * Updates the given quaternion with the given rotation matrix values
  76540. * @param matrix defines the source matrix
  76541. * @param result defines the target quaternion
  76542. */
  76543. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76544. /**
  76545. * Returns the dot product (float) between the quaternions "left" and "right"
  76546. * @param left defines the left operand
  76547. * @param right defines the right operand
  76548. * @returns the dot product
  76549. */
  76550. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76551. /**
  76552. * Checks if the two quaternions are close to each other
  76553. * @param quat0 defines the first quaternion to check
  76554. * @param quat1 defines the second quaternion to check
  76555. * @returns true if the two quaternions are close to each other
  76556. */
  76557. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76558. /**
  76559. * Creates an empty quaternion
  76560. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76561. */
  76562. static Zero(): Quaternion;
  76563. /**
  76564. * Inverse a given quaternion
  76565. * @param q defines the source quaternion
  76566. * @returns a new quaternion as the inverted current quaternion
  76567. */
  76568. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76569. /**
  76570. * Inverse a given quaternion
  76571. * @param q defines the source quaternion
  76572. * @param result the quaternion the result will be stored in
  76573. * @returns the result quaternion
  76574. */
  76575. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76576. /**
  76577. * Creates an identity quaternion
  76578. * @returns the identity quaternion
  76579. */
  76580. static Identity(): Quaternion;
  76581. /**
  76582. * Gets a boolean indicating if the given quaternion is identity
  76583. * @param quaternion defines the quaternion to check
  76584. * @returns true if the quaternion is identity
  76585. */
  76586. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76587. /**
  76588. * Creates a quaternion from a rotation around an axis
  76589. * @param axis defines the axis to use
  76590. * @param angle defines the angle to use
  76591. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76592. */
  76593. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76594. /**
  76595. * Creates a rotation around an axis and stores it into the given quaternion
  76596. * @param axis defines the axis to use
  76597. * @param angle defines the angle to use
  76598. * @param result defines the target quaternion
  76599. * @returns the target quaternion
  76600. */
  76601. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76602. /**
  76603. * Creates a new quaternion from data stored into an array
  76604. * @param array defines the data source
  76605. * @param offset defines the offset in the source array where the data starts
  76606. * @returns a new quaternion
  76607. */
  76608. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76609. /**
  76610. * Create a quaternion from Euler rotation angles
  76611. * @param x Pitch
  76612. * @param y Yaw
  76613. * @param z Roll
  76614. * @returns the new Quaternion
  76615. */
  76616. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76617. /**
  76618. * Updates a quaternion from Euler rotation angles
  76619. * @param x Pitch
  76620. * @param y Yaw
  76621. * @param z Roll
  76622. * @param result the quaternion to store the result
  76623. * @returns the updated quaternion
  76624. */
  76625. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76626. /**
  76627. * Create a quaternion from Euler rotation vector
  76628. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76629. * @returns the new Quaternion
  76630. */
  76631. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76632. /**
  76633. * Updates a quaternion from Euler rotation vector
  76634. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76635. * @param result the quaternion to store the result
  76636. * @returns the updated quaternion
  76637. */
  76638. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76639. /**
  76640. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76641. * @param yaw defines the rotation around Y axis
  76642. * @param pitch defines the rotation around X axis
  76643. * @param roll defines the rotation around Z axis
  76644. * @returns the new quaternion
  76645. */
  76646. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76647. /**
  76648. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76649. * @param yaw defines the rotation around Y axis
  76650. * @param pitch defines the rotation around X axis
  76651. * @param roll defines the rotation around Z axis
  76652. * @param result defines the target quaternion
  76653. */
  76654. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  76655. /**
  76656. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  76657. * @param alpha defines the rotation around first axis
  76658. * @param beta defines the rotation around second axis
  76659. * @param gamma defines the rotation around third axis
  76660. * @returns the new quaternion
  76661. */
  76662. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  76663. /**
  76664. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  76665. * @param alpha defines the rotation around first axis
  76666. * @param beta defines the rotation around second axis
  76667. * @param gamma defines the rotation around third axis
  76668. * @param result defines the target quaternion
  76669. */
  76670. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  76671. /**
  76672. * 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)
  76673. * @param axis1 defines the first axis
  76674. * @param axis2 defines the second axis
  76675. * @param axis3 defines the third axis
  76676. * @returns the new quaternion
  76677. */
  76678. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  76679. /**
  76680. * 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
  76681. * @param axis1 defines the first axis
  76682. * @param axis2 defines the second axis
  76683. * @param axis3 defines the third axis
  76684. * @param ref defines the target quaternion
  76685. */
  76686. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  76687. /**
  76688. * Interpolates between two quaternions
  76689. * @param left defines first quaternion
  76690. * @param right defines second quaternion
  76691. * @param amount defines the gradient to use
  76692. * @returns the new interpolated quaternion
  76693. */
  76694. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76695. /**
  76696. * Interpolates between two quaternions and stores it into a target quaternion
  76697. * @param left defines first quaternion
  76698. * @param right defines second quaternion
  76699. * @param amount defines the gradient to use
  76700. * @param result defines the target quaternion
  76701. */
  76702. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  76703. /**
  76704. * Interpolate between two quaternions using Hermite interpolation
  76705. * @param value1 defines first quaternion
  76706. * @param tangent1 defines the incoming tangent
  76707. * @param value2 defines second quaternion
  76708. * @param tangent2 defines the outgoing tangent
  76709. * @param amount defines the target quaternion
  76710. * @returns the new interpolated quaternion
  76711. */
  76712. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76713. }
  76714. /**
  76715. * Class used to store matrix data (4x4)
  76716. */
  76717. export class Matrix {
  76718. private static _updateFlagSeed;
  76719. private static _identityReadOnly;
  76720. private _isIdentity;
  76721. private _isIdentityDirty;
  76722. private _isIdentity3x2;
  76723. private _isIdentity3x2Dirty;
  76724. /**
  76725. * Gets the update flag of the matrix which is an unique number for the matrix.
  76726. * It will be incremented every time the matrix data change.
  76727. * You can use it to speed the comparison between two versions of the same matrix.
  76728. */
  76729. updateFlag: number;
  76730. private readonly _m;
  76731. /**
  76732. * Gets the internal data of the matrix
  76733. */
  76734. get m(): DeepImmutable<Float32Array>;
  76735. /** @hidden */
  76736. _markAsUpdated(): void;
  76737. /** @hidden */
  76738. private _updateIdentityStatus;
  76739. /**
  76740. * Creates an empty matrix (filled with zeros)
  76741. */
  76742. constructor();
  76743. /**
  76744. * Check if the current matrix is identity
  76745. * @returns true is the matrix is the identity matrix
  76746. */
  76747. isIdentity(): boolean;
  76748. /**
  76749. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  76750. * @returns true is the matrix is the identity matrix
  76751. */
  76752. isIdentityAs3x2(): boolean;
  76753. /**
  76754. * Gets the determinant of the matrix
  76755. * @returns the matrix determinant
  76756. */
  76757. determinant(): number;
  76758. /**
  76759. * Returns the matrix as a Float32Array
  76760. * @returns the matrix underlying array
  76761. */
  76762. toArray(): DeepImmutable<Float32Array>;
  76763. /**
  76764. * Returns the matrix as a Float32Array
  76765. * @returns the matrix underlying array.
  76766. */
  76767. asArray(): DeepImmutable<Float32Array>;
  76768. /**
  76769. * Inverts the current matrix in place
  76770. * @returns the current inverted matrix
  76771. */
  76772. invert(): Matrix;
  76773. /**
  76774. * Sets all the matrix elements to zero
  76775. * @returns the current matrix
  76776. */
  76777. reset(): Matrix;
  76778. /**
  76779. * Adds the current matrix with a second one
  76780. * @param other defines the matrix to add
  76781. * @returns a new matrix as the addition of the current matrix and the given one
  76782. */
  76783. add(other: DeepImmutable<Matrix>): Matrix;
  76784. /**
  76785. * Sets the given matrix "result" to the addition of the current matrix and the given one
  76786. * @param other defines the matrix to add
  76787. * @param result defines the target matrix
  76788. * @returns the current matrix
  76789. */
  76790. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76791. /**
  76792. * Adds in place the given matrix to the current matrix
  76793. * @param other defines the second operand
  76794. * @returns the current updated matrix
  76795. */
  76796. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  76797. /**
  76798. * Sets the given matrix to the current inverted Matrix
  76799. * @param other defines the target matrix
  76800. * @returns the unmodified current matrix
  76801. */
  76802. invertToRef(other: Matrix): Matrix;
  76803. /**
  76804. * add a value at the specified position in the current Matrix
  76805. * @param index the index of the value within the matrix. between 0 and 15.
  76806. * @param value the value to be added
  76807. * @returns the current updated matrix
  76808. */
  76809. addAtIndex(index: number, value: number): Matrix;
  76810. /**
  76811. * mutiply the specified position in the current Matrix by a value
  76812. * @param index the index of the value within the matrix. between 0 and 15.
  76813. * @param value the value to be added
  76814. * @returns the current updated matrix
  76815. */
  76816. multiplyAtIndex(index: number, value: number): Matrix;
  76817. /**
  76818. * Inserts the translation vector (using 3 floats) in the current matrix
  76819. * @param x defines the 1st component of the translation
  76820. * @param y defines the 2nd component of the translation
  76821. * @param z defines the 3rd component of the translation
  76822. * @returns the current updated matrix
  76823. */
  76824. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76825. /**
  76826. * Adds the translation vector (using 3 floats) in the current matrix
  76827. * @param x defines the 1st component of the translation
  76828. * @param y defines the 2nd component of the translation
  76829. * @param z defines the 3rd component of the translation
  76830. * @returns the current updated matrix
  76831. */
  76832. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76833. /**
  76834. * Inserts the translation vector in the current matrix
  76835. * @param vector3 defines the translation to insert
  76836. * @returns the current updated matrix
  76837. */
  76838. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  76839. /**
  76840. * Gets the translation value of the current matrix
  76841. * @returns a new Vector3 as the extracted translation from the matrix
  76842. */
  76843. getTranslation(): Vector3;
  76844. /**
  76845. * Fill a Vector3 with the extracted translation from the matrix
  76846. * @param result defines the Vector3 where to store the translation
  76847. * @returns the current matrix
  76848. */
  76849. getTranslationToRef(result: Vector3): Matrix;
  76850. /**
  76851. * Remove rotation and scaling part from the matrix
  76852. * @returns the updated matrix
  76853. */
  76854. removeRotationAndScaling(): Matrix;
  76855. /**
  76856. * Multiply two matrices
  76857. * @param other defines the second operand
  76858. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  76859. */
  76860. multiply(other: DeepImmutable<Matrix>): Matrix;
  76861. /**
  76862. * Copy the current matrix from the given one
  76863. * @param other defines the source matrix
  76864. * @returns the current updated matrix
  76865. */
  76866. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  76867. /**
  76868. * Populates the given array from the starting index with the current matrix values
  76869. * @param array defines the target array
  76870. * @param offset defines the offset in the target array where to start storing values
  76871. * @returns the current matrix
  76872. */
  76873. copyToArray(array: Float32Array, offset?: number): Matrix;
  76874. /**
  76875. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  76876. * @param other defines the second operand
  76877. * @param result defines the matrix where to store the multiplication
  76878. * @returns the current matrix
  76879. */
  76880. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76881. /**
  76882. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  76883. * @param other defines the second operand
  76884. * @param result defines the array where to store the multiplication
  76885. * @param offset defines the offset in the target array where to start storing values
  76886. * @returns the current matrix
  76887. */
  76888. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  76889. /**
  76890. * Check equality between this matrix and a second one
  76891. * @param value defines the second matrix to compare
  76892. * @returns true is the current matrix and the given one values are strictly equal
  76893. */
  76894. equals(value: DeepImmutable<Matrix>): boolean;
  76895. /**
  76896. * Clone the current matrix
  76897. * @returns a new matrix from the current matrix
  76898. */
  76899. clone(): Matrix;
  76900. /**
  76901. * Returns the name of the current matrix class
  76902. * @returns the string "Matrix"
  76903. */
  76904. getClassName(): string;
  76905. /**
  76906. * Gets the hash code of the current matrix
  76907. * @returns the hash code
  76908. */
  76909. getHashCode(): number;
  76910. /**
  76911. * Decomposes the current Matrix into a translation, rotation and scaling components
  76912. * @param scale defines the scale vector3 given as a reference to update
  76913. * @param rotation defines the rotation quaternion given as a reference to update
  76914. * @param translation defines the translation vector3 given as a reference to update
  76915. * @returns true if operation was successful
  76916. */
  76917. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  76918. /**
  76919. * Gets specific row of the matrix
  76920. * @param index defines the number of the row to get
  76921. * @returns the index-th row of the current matrix as a new Vector4
  76922. */
  76923. getRow(index: number): Nullable<Vector4>;
  76924. /**
  76925. * Sets the index-th row of the current matrix to the vector4 values
  76926. * @param index defines the number of the row to set
  76927. * @param row defines the target vector4
  76928. * @returns the updated current matrix
  76929. */
  76930. setRow(index: number, row: Vector4): Matrix;
  76931. /**
  76932. * Compute the transpose of the matrix
  76933. * @returns the new transposed matrix
  76934. */
  76935. transpose(): Matrix;
  76936. /**
  76937. * Compute the transpose of the matrix and store it in a given matrix
  76938. * @param result defines the target matrix
  76939. * @returns the current matrix
  76940. */
  76941. transposeToRef(result: Matrix): Matrix;
  76942. /**
  76943. * Sets the index-th row of the current matrix with the given 4 x float values
  76944. * @param index defines the row index
  76945. * @param x defines the x component to set
  76946. * @param y defines the y component to set
  76947. * @param z defines the z component to set
  76948. * @param w defines the w component to set
  76949. * @returns the updated current matrix
  76950. */
  76951. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  76952. /**
  76953. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  76954. * @param scale defines the scale factor
  76955. * @returns a new matrix
  76956. */
  76957. scale(scale: number): Matrix;
  76958. /**
  76959. * Scale the current matrix values by a factor to a given result matrix
  76960. * @param scale defines the scale factor
  76961. * @param result defines the matrix to store the result
  76962. * @returns the current matrix
  76963. */
  76964. scaleToRef(scale: number, result: Matrix): Matrix;
  76965. /**
  76966. * Scale the current matrix values by a factor and add the result to a given matrix
  76967. * @param scale defines the scale factor
  76968. * @param result defines the Matrix to store the result
  76969. * @returns the current matrix
  76970. */
  76971. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  76972. /**
  76973. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  76974. * @param ref matrix to store the result
  76975. */
  76976. toNormalMatrix(ref: Matrix): void;
  76977. /**
  76978. * Gets only rotation part of the current matrix
  76979. * @returns a new matrix sets to the extracted rotation matrix from the current one
  76980. */
  76981. getRotationMatrix(): Matrix;
  76982. /**
  76983. * Extracts the rotation matrix from the current one and sets it as the given "result"
  76984. * @param result defines the target matrix to store data to
  76985. * @returns the current matrix
  76986. */
  76987. getRotationMatrixToRef(result: Matrix): Matrix;
  76988. /**
  76989. * Toggles model matrix from being right handed to left handed in place and vice versa
  76990. */
  76991. toggleModelMatrixHandInPlace(): void;
  76992. /**
  76993. * Toggles projection matrix from being right handed to left handed in place and vice versa
  76994. */
  76995. toggleProjectionMatrixHandInPlace(): void;
  76996. /**
  76997. * Creates a matrix from an array
  76998. * @param array defines the source array
  76999. * @param offset defines an offset in the source array
  77000. * @returns a new Matrix set from the starting index of the given array
  77001. */
  77002. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77003. /**
  77004. * Copy the content of an array into a given matrix
  77005. * @param array defines the source array
  77006. * @param offset defines an offset in the source array
  77007. * @param result defines the target matrix
  77008. */
  77009. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77010. /**
  77011. * Stores an array into a matrix after having multiplied each component by a given factor
  77012. * @param array defines the source array
  77013. * @param offset defines the offset in the source array
  77014. * @param scale defines the scaling factor
  77015. * @param result defines the target matrix
  77016. */
  77017. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77018. /**
  77019. * Gets an identity matrix that must not be updated
  77020. */
  77021. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77022. /**
  77023. * Stores a list of values (16) inside a given matrix
  77024. * @param initialM11 defines 1st value of 1st row
  77025. * @param initialM12 defines 2nd value of 1st row
  77026. * @param initialM13 defines 3rd value of 1st row
  77027. * @param initialM14 defines 4th value of 1st row
  77028. * @param initialM21 defines 1st value of 2nd row
  77029. * @param initialM22 defines 2nd value of 2nd row
  77030. * @param initialM23 defines 3rd value of 2nd row
  77031. * @param initialM24 defines 4th value of 2nd row
  77032. * @param initialM31 defines 1st value of 3rd row
  77033. * @param initialM32 defines 2nd value of 3rd row
  77034. * @param initialM33 defines 3rd value of 3rd row
  77035. * @param initialM34 defines 4th value of 3rd row
  77036. * @param initialM41 defines 1st value of 4th row
  77037. * @param initialM42 defines 2nd value of 4th row
  77038. * @param initialM43 defines 3rd value of 4th row
  77039. * @param initialM44 defines 4th value of 4th row
  77040. * @param result defines the target matrix
  77041. */
  77042. 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;
  77043. /**
  77044. * Creates new matrix from a list of values (16)
  77045. * @param initialM11 defines 1st value of 1st row
  77046. * @param initialM12 defines 2nd value of 1st row
  77047. * @param initialM13 defines 3rd value of 1st row
  77048. * @param initialM14 defines 4th value of 1st row
  77049. * @param initialM21 defines 1st value of 2nd row
  77050. * @param initialM22 defines 2nd value of 2nd row
  77051. * @param initialM23 defines 3rd value of 2nd row
  77052. * @param initialM24 defines 4th value of 2nd row
  77053. * @param initialM31 defines 1st value of 3rd row
  77054. * @param initialM32 defines 2nd value of 3rd row
  77055. * @param initialM33 defines 3rd value of 3rd row
  77056. * @param initialM34 defines 4th value of 3rd row
  77057. * @param initialM41 defines 1st value of 4th row
  77058. * @param initialM42 defines 2nd value of 4th row
  77059. * @param initialM43 defines 3rd value of 4th row
  77060. * @param initialM44 defines 4th value of 4th row
  77061. * @returns the new matrix
  77062. */
  77063. 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;
  77064. /**
  77065. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77066. * @param scale defines the scale vector3
  77067. * @param rotation defines the rotation quaternion
  77068. * @param translation defines the translation vector3
  77069. * @returns a new matrix
  77070. */
  77071. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77072. /**
  77073. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77074. * @param scale defines the scale vector3
  77075. * @param rotation defines the rotation quaternion
  77076. * @param translation defines the translation vector3
  77077. * @param result defines the target matrix
  77078. */
  77079. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77080. /**
  77081. * Creates a new identity matrix
  77082. * @returns a new identity matrix
  77083. */
  77084. static Identity(): Matrix;
  77085. /**
  77086. * Creates a new identity matrix and stores the result in a given matrix
  77087. * @param result defines the target matrix
  77088. */
  77089. static IdentityToRef(result: Matrix): void;
  77090. /**
  77091. * Creates a new zero matrix
  77092. * @returns a new zero matrix
  77093. */
  77094. static Zero(): Matrix;
  77095. /**
  77096. * Creates a new rotation matrix for "angle" radians around the X axis
  77097. * @param angle defines the angle (in radians) to use
  77098. * @return the new matrix
  77099. */
  77100. static RotationX(angle: number): Matrix;
  77101. /**
  77102. * Creates a new matrix as the invert of a given matrix
  77103. * @param source defines the source matrix
  77104. * @returns the new matrix
  77105. */
  77106. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77107. /**
  77108. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77109. * @param angle defines the angle (in radians) to use
  77110. * @param result defines the target matrix
  77111. */
  77112. static RotationXToRef(angle: number, result: Matrix): void;
  77113. /**
  77114. * Creates a new rotation matrix for "angle" radians around the Y axis
  77115. * @param angle defines the angle (in radians) to use
  77116. * @return the new matrix
  77117. */
  77118. static RotationY(angle: number): Matrix;
  77119. /**
  77120. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77121. * @param angle defines the angle (in radians) to use
  77122. * @param result defines the target matrix
  77123. */
  77124. static RotationYToRef(angle: number, result: Matrix): void;
  77125. /**
  77126. * Creates a new rotation matrix for "angle" radians around the Z axis
  77127. * @param angle defines the angle (in radians) to use
  77128. * @return the new matrix
  77129. */
  77130. static RotationZ(angle: number): Matrix;
  77131. /**
  77132. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77133. * @param angle defines the angle (in radians) to use
  77134. * @param result defines the target matrix
  77135. */
  77136. static RotationZToRef(angle: number, result: Matrix): void;
  77137. /**
  77138. * Creates a new rotation matrix for "angle" radians around the given axis
  77139. * @param axis defines the axis to use
  77140. * @param angle defines the angle (in radians) to use
  77141. * @return the new matrix
  77142. */
  77143. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77144. /**
  77145. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77146. * @param axis defines the axis to use
  77147. * @param angle defines the angle (in radians) to use
  77148. * @param result defines the target matrix
  77149. */
  77150. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77151. /**
  77152. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77153. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77154. * @param from defines the vector to align
  77155. * @param to defines the vector to align to
  77156. * @param result defines the target matrix
  77157. */
  77158. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77159. /**
  77160. * Creates a rotation matrix
  77161. * @param yaw defines the yaw angle in radians (Y axis)
  77162. * @param pitch defines the pitch angle in radians (X axis)
  77163. * @param roll defines the roll angle in radians (X axis)
  77164. * @returns the new rotation matrix
  77165. */
  77166. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77167. /**
  77168. * Creates a rotation matrix and stores it in a given matrix
  77169. * @param yaw defines the yaw angle in radians (Y axis)
  77170. * @param pitch defines the pitch angle in radians (X axis)
  77171. * @param roll defines the roll angle in radians (X axis)
  77172. * @param result defines the target matrix
  77173. */
  77174. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77175. /**
  77176. * Creates a scaling matrix
  77177. * @param x defines the scale factor on X axis
  77178. * @param y defines the scale factor on Y axis
  77179. * @param z defines the scale factor on Z axis
  77180. * @returns the new matrix
  77181. */
  77182. static Scaling(x: number, y: number, z: number): Matrix;
  77183. /**
  77184. * Creates a scaling matrix and stores it in a given matrix
  77185. * @param x defines the scale factor on X axis
  77186. * @param y defines the scale factor on Y axis
  77187. * @param z defines the scale factor on Z axis
  77188. * @param result defines the target matrix
  77189. */
  77190. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77191. /**
  77192. * Creates a translation matrix
  77193. * @param x defines the translation on X axis
  77194. * @param y defines the translation on Y axis
  77195. * @param z defines the translationon Z axis
  77196. * @returns the new matrix
  77197. */
  77198. static Translation(x: number, y: number, z: number): Matrix;
  77199. /**
  77200. * Creates a translation matrix and stores it in a given matrix
  77201. * @param x defines the translation on X axis
  77202. * @param y defines the translation on Y axis
  77203. * @param z defines the translationon Z axis
  77204. * @param result defines the target matrix
  77205. */
  77206. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77207. /**
  77208. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77209. * @param startValue defines the start value
  77210. * @param endValue defines the end value
  77211. * @param gradient defines the gradient factor
  77212. * @returns the new matrix
  77213. */
  77214. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77215. /**
  77216. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77217. * @param startValue defines the start value
  77218. * @param endValue defines the end value
  77219. * @param gradient defines the gradient factor
  77220. * @param result defines the Matrix object where to store data
  77221. */
  77222. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77223. /**
  77224. * Builds a new matrix whose values are computed by:
  77225. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77226. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77227. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77228. * @param startValue defines the first matrix
  77229. * @param endValue defines the second matrix
  77230. * @param gradient defines the gradient between the two matrices
  77231. * @returns the new matrix
  77232. */
  77233. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77234. /**
  77235. * Update a matrix to values which are computed by:
  77236. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77237. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77238. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77239. * @param startValue defines the first matrix
  77240. * @param endValue defines the second matrix
  77241. * @param gradient defines the gradient between the two matrices
  77242. * @param result defines the target matrix
  77243. */
  77244. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77245. /**
  77246. * 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"
  77247. * This function works in left handed mode
  77248. * @param eye defines the final position of the entity
  77249. * @param target defines where the entity should look at
  77250. * @param up defines the up vector for the entity
  77251. * @returns the new matrix
  77252. */
  77253. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77254. /**
  77255. * 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".
  77256. * This function works in left handed mode
  77257. * @param eye defines the final position of the entity
  77258. * @param target defines where the entity should look at
  77259. * @param up defines the up vector for the entity
  77260. * @param result defines the target matrix
  77261. */
  77262. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77263. /**
  77264. * 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"
  77265. * This function works in right handed mode
  77266. * @param eye defines the final position of the entity
  77267. * @param target defines where the entity should look at
  77268. * @param up defines the up vector for the entity
  77269. * @returns the new matrix
  77270. */
  77271. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77272. /**
  77273. * 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".
  77274. * This function works in right handed mode
  77275. * @param eye defines the final position of the entity
  77276. * @param target defines where the entity should look at
  77277. * @param up defines the up vector for the entity
  77278. * @param result defines the target matrix
  77279. */
  77280. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77281. /**
  77282. * Create a left-handed orthographic projection matrix
  77283. * @param width defines the viewport width
  77284. * @param height defines the viewport height
  77285. * @param znear defines the near clip plane
  77286. * @param zfar defines the far clip plane
  77287. * @returns a new matrix as a left-handed orthographic projection matrix
  77288. */
  77289. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77290. /**
  77291. * Store a left-handed orthographic projection to a given matrix
  77292. * @param width defines the viewport width
  77293. * @param height defines the viewport height
  77294. * @param znear defines the near clip plane
  77295. * @param zfar defines the far clip plane
  77296. * @param result defines the target matrix
  77297. */
  77298. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77299. /**
  77300. * Create a left-handed orthographic projection matrix
  77301. * @param left defines the viewport left coordinate
  77302. * @param right defines the viewport right coordinate
  77303. * @param bottom defines the viewport bottom coordinate
  77304. * @param top defines the viewport top coordinate
  77305. * @param znear defines the near clip plane
  77306. * @param zfar defines the far clip plane
  77307. * @returns a new matrix as a left-handed orthographic projection matrix
  77308. */
  77309. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77310. /**
  77311. * Stores a left-handed orthographic projection into a given matrix
  77312. * @param left defines the viewport left coordinate
  77313. * @param right defines the viewport right coordinate
  77314. * @param bottom defines the viewport bottom coordinate
  77315. * @param top defines the viewport top coordinate
  77316. * @param znear defines the near clip plane
  77317. * @param zfar defines the far clip plane
  77318. * @param result defines the target matrix
  77319. */
  77320. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77321. /**
  77322. * Creates a right-handed orthographic projection matrix
  77323. * @param left defines the viewport left coordinate
  77324. * @param right defines the viewport right coordinate
  77325. * @param bottom defines the viewport bottom coordinate
  77326. * @param top defines the viewport top coordinate
  77327. * @param znear defines the near clip plane
  77328. * @param zfar defines the far clip plane
  77329. * @returns a new matrix as a right-handed orthographic projection matrix
  77330. */
  77331. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77332. /**
  77333. * Stores a right-handed orthographic projection into a given matrix
  77334. * @param left defines the viewport left coordinate
  77335. * @param right defines the viewport right coordinate
  77336. * @param bottom defines the viewport bottom coordinate
  77337. * @param top defines the viewport top coordinate
  77338. * @param znear defines the near clip plane
  77339. * @param zfar defines the far clip plane
  77340. * @param result defines the target matrix
  77341. */
  77342. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77343. /**
  77344. * Creates a left-handed perspective projection matrix
  77345. * @param width defines the viewport width
  77346. * @param height defines the viewport height
  77347. * @param znear defines the near clip plane
  77348. * @param zfar defines the far clip plane
  77349. * @returns a new matrix as a left-handed perspective projection matrix
  77350. */
  77351. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77352. /**
  77353. * Creates a left-handed perspective projection matrix
  77354. * @param fov defines the horizontal field of view
  77355. * @param aspect defines the aspect ratio
  77356. * @param znear defines the near clip plane
  77357. * @param zfar defines the far clip plane
  77358. * @returns a new matrix as a left-handed perspective projection matrix
  77359. */
  77360. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77361. /**
  77362. * Stores a left-handed perspective projection into a given matrix
  77363. * @param fov defines the horizontal field of view
  77364. * @param aspect defines the aspect ratio
  77365. * @param znear defines the near clip plane
  77366. * @param zfar defines the far clip plane
  77367. * @param result defines the target matrix
  77368. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77369. */
  77370. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77371. /**
  77372. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77373. * @param fov defines the horizontal field of view
  77374. * @param aspect defines the aspect ratio
  77375. * @param znear defines the near clip plane
  77376. * @param zfar not used as infinity is used as far clip
  77377. * @param result defines the target matrix
  77378. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77379. */
  77380. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77381. /**
  77382. * Creates a right-handed perspective projection matrix
  77383. * @param fov defines the horizontal field of view
  77384. * @param aspect defines the aspect ratio
  77385. * @param znear defines the near clip plane
  77386. * @param zfar defines the far clip plane
  77387. * @returns a new matrix as a right-handed perspective projection matrix
  77388. */
  77389. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77390. /**
  77391. * Stores a right-handed perspective projection into a given matrix
  77392. * @param fov defines the horizontal field of view
  77393. * @param aspect defines the aspect ratio
  77394. * @param znear defines the near clip plane
  77395. * @param zfar defines the far clip plane
  77396. * @param result defines the target matrix
  77397. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77398. */
  77399. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77400. /**
  77401. * Stores a right-handed perspective projection into a given matrix
  77402. * @param fov defines the horizontal field of view
  77403. * @param aspect defines the aspect ratio
  77404. * @param znear defines the near clip plane
  77405. * @param zfar not used as infinity is used as far clip
  77406. * @param result defines the target matrix
  77407. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77408. */
  77409. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77410. /**
  77411. * Stores a perspective projection for WebVR info a given matrix
  77412. * @param fov defines the field of view
  77413. * @param znear defines the near clip plane
  77414. * @param zfar defines the far clip plane
  77415. * @param result defines the target matrix
  77416. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77417. */
  77418. static PerspectiveFovWebVRToRef(fov: {
  77419. upDegrees: number;
  77420. downDegrees: number;
  77421. leftDegrees: number;
  77422. rightDegrees: number;
  77423. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77424. /**
  77425. * Computes a complete transformation matrix
  77426. * @param viewport defines the viewport to use
  77427. * @param world defines the world matrix
  77428. * @param view defines the view matrix
  77429. * @param projection defines the projection matrix
  77430. * @param zmin defines the near clip plane
  77431. * @param zmax defines the far clip plane
  77432. * @returns the transformation matrix
  77433. */
  77434. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77435. /**
  77436. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77437. * @param matrix defines the matrix to use
  77438. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77439. */
  77440. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77441. /**
  77442. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77443. * @param matrix defines the matrix to use
  77444. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77445. */
  77446. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77447. /**
  77448. * Compute the transpose of a given matrix
  77449. * @param matrix defines the matrix to transpose
  77450. * @returns the new matrix
  77451. */
  77452. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77453. /**
  77454. * Compute the transpose of a matrix and store it in a target matrix
  77455. * @param matrix defines the matrix to transpose
  77456. * @param result defines the target matrix
  77457. */
  77458. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77459. /**
  77460. * Computes a reflection matrix from a plane
  77461. * @param plane defines the reflection plane
  77462. * @returns a new matrix
  77463. */
  77464. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77465. /**
  77466. * Computes a reflection matrix from a plane
  77467. * @param plane defines the reflection plane
  77468. * @param result defines the target matrix
  77469. */
  77470. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77471. /**
  77472. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77473. * @param xaxis defines the value of the 1st axis
  77474. * @param yaxis defines the value of the 2nd axis
  77475. * @param zaxis defines the value of the 3rd axis
  77476. * @param result defines the target matrix
  77477. */
  77478. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77479. /**
  77480. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77481. * @param quat defines the quaternion to use
  77482. * @param result defines the target matrix
  77483. */
  77484. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77485. }
  77486. /**
  77487. * @hidden
  77488. */
  77489. export class TmpVectors {
  77490. static Vector2: Vector2[];
  77491. static Vector3: Vector3[];
  77492. static Vector4: Vector4[];
  77493. static Quaternion: Quaternion[];
  77494. static Matrix: Matrix[];
  77495. }
  77496. }
  77497. declare module BABYLON {
  77498. /**
  77499. * Defines potential orientation for back face culling
  77500. */
  77501. export enum Orientation {
  77502. /**
  77503. * Clockwise
  77504. */
  77505. CW = 0,
  77506. /** Counter clockwise */
  77507. CCW = 1
  77508. }
  77509. /** Class used to represent a Bezier curve */
  77510. export class BezierCurve {
  77511. /**
  77512. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77513. * @param t defines the time
  77514. * @param x1 defines the left coordinate on X axis
  77515. * @param y1 defines the left coordinate on Y axis
  77516. * @param x2 defines the right coordinate on X axis
  77517. * @param y2 defines the right coordinate on Y axis
  77518. * @returns the interpolated value
  77519. */
  77520. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77521. }
  77522. /**
  77523. * Defines angle representation
  77524. */
  77525. export class Angle {
  77526. private _radians;
  77527. /**
  77528. * Creates an Angle object of "radians" radians (float).
  77529. * @param radians the angle in radians
  77530. */
  77531. constructor(radians: number);
  77532. /**
  77533. * Get value in degrees
  77534. * @returns the Angle value in degrees (float)
  77535. */
  77536. degrees(): number;
  77537. /**
  77538. * Get value in radians
  77539. * @returns the Angle value in radians (float)
  77540. */
  77541. radians(): number;
  77542. /**
  77543. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77544. * @param a defines first vector
  77545. * @param b defines second vector
  77546. * @returns a new Angle
  77547. */
  77548. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77549. /**
  77550. * Gets a new Angle object from the given float in radians
  77551. * @param radians defines the angle value in radians
  77552. * @returns a new Angle
  77553. */
  77554. static FromRadians(radians: number): Angle;
  77555. /**
  77556. * Gets a new Angle object from the given float in degrees
  77557. * @param degrees defines the angle value in degrees
  77558. * @returns a new Angle
  77559. */
  77560. static FromDegrees(degrees: number): Angle;
  77561. }
  77562. /**
  77563. * This represents an arc in a 2d space.
  77564. */
  77565. export class Arc2 {
  77566. /** Defines the start point of the arc */
  77567. startPoint: Vector2;
  77568. /** Defines the mid point of the arc */
  77569. midPoint: Vector2;
  77570. /** Defines the end point of the arc */
  77571. endPoint: Vector2;
  77572. /**
  77573. * Defines the center point of the arc.
  77574. */
  77575. centerPoint: Vector2;
  77576. /**
  77577. * Defines the radius of the arc.
  77578. */
  77579. radius: number;
  77580. /**
  77581. * Defines the angle of the arc (from mid point to end point).
  77582. */
  77583. angle: Angle;
  77584. /**
  77585. * Defines the start angle of the arc (from start point to middle point).
  77586. */
  77587. startAngle: Angle;
  77588. /**
  77589. * Defines the orientation of the arc (clock wise/counter clock wise).
  77590. */
  77591. orientation: Orientation;
  77592. /**
  77593. * Creates an Arc object from the three given points : start, middle and end.
  77594. * @param startPoint Defines the start point of the arc
  77595. * @param midPoint Defines the midlle point of the arc
  77596. * @param endPoint Defines the end point of the arc
  77597. */
  77598. constructor(
  77599. /** Defines the start point of the arc */
  77600. startPoint: Vector2,
  77601. /** Defines the mid point of the arc */
  77602. midPoint: Vector2,
  77603. /** Defines the end point of the arc */
  77604. endPoint: Vector2);
  77605. }
  77606. /**
  77607. * Represents a 2D path made up of multiple 2D points
  77608. */
  77609. export class Path2 {
  77610. private _points;
  77611. private _length;
  77612. /**
  77613. * If the path start and end point are the same
  77614. */
  77615. closed: boolean;
  77616. /**
  77617. * Creates a Path2 object from the starting 2D coordinates x and y.
  77618. * @param x the starting points x value
  77619. * @param y the starting points y value
  77620. */
  77621. constructor(x: number, y: number);
  77622. /**
  77623. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77624. * @param x the added points x value
  77625. * @param y the added points y value
  77626. * @returns the updated Path2.
  77627. */
  77628. addLineTo(x: number, y: number): Path2;
  77629. /**
  77630. * 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.
  77631. * @param midX middle point x value
  77632. * @param midY middle point y value
  77633. * @param endX end point x value
  77634. * @param endY end point y value
  77635. * @param numberOfSegments (default: 36)
  77636. * @returns the updated Path2.
  77637. */
  77638. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77639. /**
  77640. * Closes the Path2.
  77641. * @returns the Path2.
  77642. */
  77643. close(): Path2;
  77644. /**
  77645. * Gets the sum of the distance between each sequential point in the path
  77646. * @returns the Path2 total length (float).
  77647. */
  77648. length(): number;
  77649. /**
  77650. * Gets the points which construct the path
  77651. * @returns the Path2 internal array of points.
  77652. */
  77653. getPoints(): Vector2[];
  77654. /**
  77655. * Retreives the point at the distance aways from the starting point
  77656. * @param normalizedLengthPosition the length along the path to retreive the point from
  77657. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77658. */
  77659. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  77660. /**
  77661. * Creates a new path starting from an x and y position
  77662. * @param x starting x value
  77663. * @param y starting y value
  77664. * @returns a new Path2 starting at the coordinates (x, y).
  77665. */
  77666. static StartingAt(x: number, y: number): Path2;
  77667. }
  77668. /**
  77669. * Represents a 3D path made up of multiple 3D points
  77670. */
  77671. export class Path3D {
  77672. /**
  77673. * an array of Vector3, the curve axis of the Path3D
  77674. */
  77675. path: Vector3[];
  77676. private _curve;
  77677. private _distances;
  77678. private _tangents;
  77679. private _normals;
  77680. private _binormals;
  77681. private _raw;
  77682. private _alignTangentsWithPath;
  77683. private readonly _pointAtData;
  77684. /**
  77685. * new Path3D(path, normal, raw)
  77686. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77687. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77688. * @param path an array of Vector3, the curve axis of the Path3D
  77689. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77690. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77691. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  77692. */
  77693. constructor(
  77694. /**
  77695. * an array of Vector3, the curve axis of the Path3D
  77696. */
  77697. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  77698. /**
  77699. * Returns the Path3D array of successive Vector3 designing its curve.
  77700. * @returns the Path3D array of successive Vector3 designing its curve.
  77701. */
  77702. getCurve(): Vector3[];
  77703. /**
  77704. * Returns the Path3D array of successive Vector3 designing its curve.
  77705. * @returns the Path3D array of successive Vector3 designing its curve.
  77706. */
  77707. getPoints(): Vector3[];
  77708. /**
  77709. * @returns the computed length (float) of the path.
  77710. */
  77711. length(): number;
  77712. /**
  77713. * Returns an array populated with tangent vectors on each Path3D curve point.
  77714. * @returns an array populated with tangent vectors on each Path3D curve point.
  77715. */
  77716. getTangents(): Vector3[];
  77717. /**
  77718. * Returns an array populated with normal vectors on each Path3D curve point.
  77719. * @returns an array populated with normal vectors on each Path3D curve point.
  77720. */
  77721. getNormals(): Vector3[];
  77722. /**
  77723. * Returns an array populated with binormal vectors on each Path3D curve point.
  77724. * @returns an array populated with binormal vectors on each Path3D curve point.
  77725. */
  77726. getBinormals(): Vector3[];
  77727. /**
  77728. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77729. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77730. */
  77731. getDistances(): number[];
  77732. /**
  77733. * Returns an interpolated point along this path
  77734. * @param position the position of the point along this path, from 0.0 to 1.0
  77735. * @returns a new Vector3 as the point
  77736. */
  77737. getPointAt(position: number): Vector3;
  77738. /**
  77739. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77740. * @param position the position of the point along this path, from 0.0 to 1.0
  77741. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  77742. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  77743. */
  77744. getTangentAt(position: number, interpolated?: boolean): Vector3;
  77745. /**
  77746. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77747. * @param position the position of the point along this path, from 0.0 to 1.0
  77748. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  77749. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  77750. */
  77751. getNormalAt(position: number, interpolated?: boolean): Vector3;
  77752. /**
  77753. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  77754. * @param position the position of the point along this path, from 0.0 to 1.0
  77755. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  77756. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  77757. */
  77758. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  77759. /**
  77760. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  77761. * @param position the position of the point along this path, from 0.0 to 1.0
  77762. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  77763. */
  77764. getDistanceAt(position: number): number;
  77765. /**
  77766. * Returns the array index of the previous point of an interpolated point along this path
  77767. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77768. * @returns the array index
  77769. */
  77770. getPreviousPointIndexAt(position: number): number;
  77771. /**
  77772. * 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)
  77773. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77774. * @returns the sub position
  77775. */
  77776. getSubPositionAt(position: number): number;
  77777. /**
  77778. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  77779. * @param target the vector of which to get the closest position to
  77780. * @returns the position of the closest virtual point on this path to the target vector
  77781. */
  77782. getClosestPositionTo(target: Vector3): number;
  77783. /**
  77784. * Returns a sub path (slice) of this path
  77785. * @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
  77786. * @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
  77787. * @returns a sub path (slice) of this path
  77788. */
  77789. slice(start?: number, end?: number): Path3D;
  77790. /**
  77791. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77792. * @param path path which all values are copied into the curves points
  77793. * @param firstNormal which should be projected onto the curve
  77794. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  77795. * @returns the same object updated.
  77796. */
  77797. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  77798. private _compute;
  77799. private _getFirstNonNullVector;
  77800. private _getLastNonNullVector;
  77801. private _normalVector;
  77802. /**
  77803. * Updates the point at data for an interpolated point along this curve
  77804. * @param position the position of the point along this curve, from 0.0 to 1.0
  77805. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  77806. * @returns the (updated) point at data
  77807. */
  77808. private _updatePointAtData;
  77809. /**
  77810. * Updates the point at data from the specified parameters
  77811. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  77812. * @param point the interpolated point
  77813. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  77814. */
  77815. private _setPointAtData;
  77816. /**
  77817. * Updates the point at interpolation matrix for the tangents, normals and binormals
  77818. */
  77819. private _updateInterpolationMatrix;
  77820. }
  77821. /**
  77822. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77823. * A Curve3 is designed from a series of successive Vector3.
  77824. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77825. */
  77826. export class Curve3 {
  77827. private _points;
  77828. private _length;
  77829. /**
  77830. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77831. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77832. * @param v1 (Vector3) the control point
  77833. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77834. * @param nbPoints (integer) the wanted number of points in the curve
  77835. * @returns the created Curve3
  77836. */
  77837. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77838. /**
  77839. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77840. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77841. * @param v1 (Vector3) the first control point
  77842. * @param v2 (Vector3) the second control point
  77843. * @param v3 (Vector3) the end point of the Cubic Bezier
  77844. * @param nbPoints (integer) the wanted number of points in the curve
  77845. * @returns the created Curve3
  77846. */
  77847. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77848. /**
  77849. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77850. * @param p1 (Vector3) the origin point of the Hermite Spline
  77851. * @param t1 (Vector3) the tangent vector at the origin point
  77852. * @param p2 (Vector3) the end point of the Hermite Spline
  77853. * @param t2 (Vector3) the tangent vector at the end point
  77854. * @param nbPoints (integer) the wanted number of points in the curve
  77855. * @returns the created Curve3
  77856. */
  77857. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77858. /**
  77859. * Returns a Curve3 object along a CatmullRom Spline curve :
  77860. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77861. * @param nbPoints (integer) the wanted number of points between each curve control points
  77862. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77863. * @returns the created Curve3
  77864. */
  77865. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  77866. /**
  77867. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77868. * A Curve3 is designed from a series of successive Vector3.
  77869. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77870. * @param points points which make up the curve
  77871. */
  77872. constructor(points: Vector3[]);
  77873. /**
  77874. * @returns the Curve3 stored array of successive Vector3
  77875. */
  77876. getPoints(): Vector3[];
  77877. /**
  77878. * @returns the computed length (float) of the curve.
  77879. */
  77880. length(): number;
  77881. /**
  77882. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77883. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77884. * curveA and curveB keep unchanged.
  77885. * @param curve the curve to continue from this curve
  77886. * @returns the newly constructed curve
  77887. */
  77888. continue(curve: DeepImmutable<Curve3>): Curve3;
  77889. private _computeLength;
  77890. }
  77891. }
  77892. declare module BABYLON {
  77893. /**
  77894. * This represents the main contract an easing function should follow.
  77895. * Easing functions are used throughout the animation system.
  77896. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77897. */
  77898. export interface IEasingFunction {
  77899. /**
  77900. * Given an input gradient between 0 and 1, this returns the corrseponding value
  77901. * of the easing function.
  77902. * The link below provides some of the most common examples of easing functions.
  77903. * @see https://easings.net/
  77904. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77905. * @returns the corresponding value on the curve defined by the easing function
  77906. */
  77907. ease(gradient: number): number;
  77908. }
  77909. /**
  77910. * Base class used for every default easing function.
  77911. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77912. */
  77913. export class EasingFunction implements IEasingFunction {
  77914. /**
  77915. * Interpolation follows the mathematical formula associated with the easing function.
  77916. */
  77917. static readonly EASINGMODE_EASEIN: number;
  77918. /**
  77919. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  77920. */
  77921. static readonly EASINGMODE_EASEOUT: number;
  77922. /**
  77923. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  77924. */
  77925. static readonly EASINGMODE_EASEINOUT: number;
  77926. private _easingMode;
  77927. /**
  77928. * Sets the easing mode of the current function.
  77929. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  77930. */
  77931. setEasingMode(easingMode: number): void;
  77932. /**
  77933. * Gets the current easing mode.
  77934. * @returns the easing mode
  77935. */
  77936. getEasingMode(): number;
  77937. /**
  77938. * @hidden
  77939. */
  77940. easeInCore(gradient: number): number;
  77941. /**
  77942. * Given an input gradient between 0 and 1, this returns the corresponding value
  77943. * of the easing function.
  77944. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77945. * @returns the corresponding value on the curve defined by the easing function
  77946. */
  77947. ease(gradient: number): number;
  77948. }
  77949. /**
  77950. * Easing function with a circle shape (see link below).
  77951. * @see https://easings.net/#easeInCirc
  77952. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77953. */
  77954. export class CircleEase extends EasingFunction implements IEasingFunction {
  77955. /** @hidden */
  77956. easeInCore(gradient: number): number;
  77957. }
  77958. /**
  77959. * Easing function with a ease back shape (see link below).
  77960. * @see https://easings.net/#easeInBack
  77961. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77962. */
  77963. export class BackEase extends EasingFunction implements IEasingFunction {
  77964. /** Defines the amplitude of the function */
  77965. amplitude: number;
  77966. /**
  77967. * Instantiates a back ease easing
  77968. * @see https://easings.net/#easeInBack
  77969. * @param amplitude Defines the amplitude of the function
  77970. */
  77971. constructor(
  77972. /** Defines the amplitude of the function */
  77973. amplitude?: number);
  77974. /** @hidden */
  77975. easeInCore(gradient: number): number;
  77976. }
  77977. /**
  77978. * Easing function with a bouncing shape (see link below).
  77979. * @see https://easings.net/#easeInBounce
  77980. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77981. */
  77982. export class BounceEase extends EasingFunction implements IEasingFunction {
  77983. /** Defines the number of bounces */
  77984. bounces: number;
  77985. /** Defines the amplitude of the bounce */
  77986. bounciness: number;
  77987. /**
  77988. * Instantiates a bounce easing
  77989. * @see https://easings.net/#easeInBounce
  77990. * @param bounces Defines the number of bounces
  77991. * @param bounciness Defines the amplitude of the bounce
  77992. */
  77993. constructor(
  77994. /** Defines the number of bounces */
  77995. bounces?: number,
  77996. /** Defines the amplitude of the bounce */
  77997. bounciness?: number);
  77998. /** @hidden */
  77999. easeInCore(gradient: number): number;
  78000. }
  78001. /**
  78002. * Easing function with a power of 3 shape (see link below).
  78003. * @see https://easings.net/#easeInCubic
  78004. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78005. */
  78006. export class CubicEase extends EasingFunction implements IEasingFunction {
  78007. /** @hidden */
  78008. easeInCore(gradient: number): number;
  78009. }
  78010. /**
  78011. * Easing function with an elastic shape (see link below).
  78012. * @see https://easings.net/#easeInElastic
  78013. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78014. */
  78015. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78016. /** Defines the number of oscillations*/
  78017. oscillations: number;
  78018. /** Defines the amplitude of the oscillations*/
  78019. springiness: number;
  78020. /**
  78021. * Instantiates an elastic easing function
  78022. * @see https://easings.net/#easeInElastic
  78023. * @param oscillations Defines the number of oscillations
  78024. * @param springiness Defines the amplitude of the oscillations
  78025. */
  78026. constructor(
  78027. /** Defines the number of oscillations*/
  78028. oscillations?: number,
  78029. /** Defines the amplitude of the oscillations*/
  78030. springiness?: number);
  78031. /** @hidden */
  78032. easeInCore(gradient: number): number;
  78033. }
  78034. /**
  78035. * Easing function with an exponential shape (see link below).
  78036. * @see https://easings.net/#easeInExpo
  78037. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78038. */
  78039. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78040. /** Defines the exponent of the function */
  78041. exponent: number;
  78042. /**
  78043. * Instantiates an exponential easing function
  78044. * @see https://easings.net/#easeInExpo
  78045. * @param exponent Defines the exponent of the function
  78046. */
  78047. constructor(
  78048. /** Defines the exponent of the function */
  78049. exponent?: number);
  78050. /** @hidden */
  78051. easeInCore(gradient: number): number;
  78052. }
  78053. /**
  78054. * Easing function with a power shape (see link below).
  78055. * @see https://easings.net/#easeInQuad
  78056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78057. */
  78058. export class PowerEase extends EasingFunction implements IEasingFunction {
  78059. /** Defines the power of the function */
  78060. power: number;
  78061. /**
  78062. * Instantiates an power base easing function
  78063. * @see https://easings.net/#easeInQuad
  78064. * @param power Defines the power of the function
  78065. */
  78066. constructor(
  78067. /** Defines the power of the function */
  78068. power?: number);
  78069. /** @hidden */
  78070. easeInCore(gradient: number): number;
  78071. }
  78072. /**
  78073. * Easing function with a power of 2 shape (see link below).
  78074. * @see https://easings.net/#easeInQuad
  78075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78076. */
  78077. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78078. /** @hidden */
  78079. easeInCore(gradient: number): number;
  78080. }
  78081. /**
  78082. * Easing function with a power of 4 shape (see link below).
  78083. * @see https://easings.net/#easeInQuart
  78084. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78085. */
  78086. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78087. /** @hidden */
  78088. easeInCore(gradient: number): number;
  78089. }
  78090. /**
  78091. * Easing function with a power of 5 shape (see link below).
  78092. * @see https://easings.net/#easeInQuint
  78093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78094. */
  78095. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78096. /** @hidden */
  78097. easeInCore(gradient: number): number;
  78098. }
  78099. /**
  78100. * Easing function with a sin shape (see link below).
  78101. * @see https://easings.net/#easeInSine
  78102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78103. */
  78104. export class SineEase extends EasingFunction implements IEasingFunction {
  78105. /** @hidden */
  78106. easeInCore(gradient: number): number;
  78107. }
  78108. /**
  78109. * Easing function with a bezier shape (see link below).
  78110. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78112. */
  78113. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78114. /** Defines the x component of the start tangent in the bezier curve */
  78115. x1: number;
  78116. /** Defines the y component of the start tangent in the bezier curve */
  78117. y1: number;
  78118. /** Defines the x component of the end tangent in the bezier curve */
  78119. x2: number;
  78120. /** Defines the y component of the end tangent in the bezier curve */
  78121. y2: number;
  78122. /**
  78123. * Instantiates a bezier function
  78124. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78125. * @param x1 Defines the x component of the start tangent in the bezier curve
  78126. * @param y1 Defines the y component of the start tangent in the bezier curve
  78127. * @param x2 Defines the x component of the end tangent in the bezier curve
  78128. * @param y2 Defines the y component of the end tangent in the bezier curve
  78129. */
  78130. constructor(
  78131. /** Defines the x component of the start tangent in the bezier curve */
  78132. x1?: number,
  78133. /** Defines the y component of the start tangent in the bezier curve */
  78134. y1?: number,
  78135. /** Defines the x component of the end tangent in the bezier curve */
  78136. x2?: number,
  78137. /** Defines the y component of the end tangent in the bezier curve */
  78138. y2?: number);
  78139. /** @hidden */
  78140. easeInCore(gradient: number): number;
  78141. }
  78142. }
  78143. declare module BABYLON {
  78144. /**
  78145. * Class used to hold a RBG color
  78146. */
  78147. export class Color3 {
  78148. /**
  78149. * Defines the red component (between 0 and 1, default is 0)
  78150. */
  78151. r: number;
  78152. /**
  78153. * Defines the green component (between 0 and 1, default is 0)
  78154. */
  78155. g: number;
  78156. /**
  78157. * Defines the blue component (between 0 and 1, default is 0)
  78158. */
  78159. b: number;
  78160. /**
  78161. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78162. * @param r defines the red component (between 0 and 1, default is 0)
  78163. * @param g defines the green component (between 0 and 1, default is 0)
  78164. * @param b defines the blue component (between 0 and 1, default is 0)
  78165. */
  78166. constructor(
  78167. /**
  78168. * Defines the red component (between 0 and 1, default is 0)
  78169. */
  78170. r?: number,
  78171. /**
  78172. * Defines the green component (between 0 and 1, default is 0)
  78173. */
  78174. g?: number,
  78175. /**
  78176. * Defines the blue component (between 0 and 1, default is 0)
  78177. */
  78178. b?: number);
  78179. /**
  78180. * Creates a string with the Color3 current values
  78181. * @returns the string representation of the Color3 object
  78182. */
  78183. toString(): string;
  78184. /**
  78185. * Returns the string "Color3"
  78186. * @returns "Color3"
  78187. */
  78188. getClassName(): string;
  78189. /**
  78190. * Compute the Color3 hash code
  78191. * @returns an unique number that can be used to hash Color3 objects
  78192. */
  78193. getHashCode(): number;
  78194. /**
  78195. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78196. * @param array defines the array where to store the r,g,b components
  78197. * @param index defines an optional index in the target array to define where to start storing values
  78198. * @returns the current Color3 object
  78199. */
  78200. toArray(array: FloatArray, index?: number): Color3;
  78201. /**
  78202. * Returns a new Color4 object from the current Color3 and the given alpha
  78203. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78204. * @returns a new Color4 object
  78205. */
  78206. toColor4(alpha?: number): Color4;
  78207. /**
  78208. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78209. * @returns the new array
  78210. */
  78211. asArray(): number[];
  78212. /**
  78213. * Returns the luminance value
  78214. * @returns a float value
  78215. */
  78216. toLuminance(): number;
  78217. /**
  78218. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78219. * @param otherColor defines the second operand
  78220. * @returns the new Color3 object
  78221. */
  78222. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78223. /**
  78224. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78225. * @param otherColor defines the second operand
  78226. * @param result defines the Color3 object where to store the result
  78227. * @returns the current Color3
  78228. */
  78229. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78230. /**
  78231. * Determines equality between Color3 objects
  78232. * @param otherColor defines the second operand
  78233. * @returns true if the rgb values are equal to the given ones
  78234. */
  78235. equals(otherColor: DeepImmutable<Color3>): boolean;
  78236. /**
  78237. * Determines equality between the current Color3 object and a set of r,b,g values
  78238. * @param r defines the red component to check
  78239. * @param g defines the green component to check
  78240. * @param b defines the blue component to check
  78241. * @returns true if the rgb values are equal to the given ones
  78242. */
  78243. equalsFloats(r: number, g: number, b: number): boolean;
  78244. /**
  78245. * Multiplies in place each rgb value by scale
  78246. * @param scale defines the scaling factor
  78247. * @returns the updated Color3
  78248. */
  78249. scale(scale: number): Color3;
  78250. /**
  78251. * Multiplies the rgb values by scale and stores the result into "result"
  78252. * @param scale defines the scaling factor
  78253. * @param result defines the Color3 object where to store the result
  78254. * @returns the unmodified current Color3
  78255. */
  78256. scaleToRef(scale: number, result: Color3): Color3;
  78257. /**
  78258. * Scale the current Color3 values by a factor and add the result to a given Color3
  78259. * @param scale defines the scale factor
  78260. * @param result defines color to store the result into
  78261. * @returns the unmodified current Color3
  78262. */
  78263. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78264. /**
  78265. * Clamps the rgb values by the min and max values and stores the result into "result"
  78266. * @param min defines minimum clamping value (default is 0)
  78267. * @param max defines maximum clamping value (default is 1)
  78268. * @param result defines color to store the result into
  78269. * @returns the original Color3
  78270. */
  78271. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78272. /**
  78273. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78274. * @param otherColor defines the second operand
  78275. * @returns the new Color3
  78276. */
  78277. add(otherColor: DeepImmutable<Color3>): Color3;
  78278. /**
  78279. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78280. * @param otherColor defines the second operand
  78281. * @param result defines Color3 object to store the result into
  78282. * @returns the unmodified current Color3
  78283. */
  78284. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78285. /**
  78286. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78287. * @param otherColor defines the second operand
  78288. * @returns the new Color3
  78289. */
  78290. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78291. /**
  78292. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78293. * @param otherColor defines the second operand
  78294. * @param result defines Color3 object to store the result into
  78295. * @returns the unmodified current Color3
  78296. */
  78297. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78298. /**
  78299. * Copy the current object
  78300. * @returns a new Color3 copied the current one
  78301. */
  78302. clone(): Color3;
  78303. /**
  78304. * Copies the rgb values from the source in the current Color3
  78305. * @param source defines the source Color3 object
  78306. * @returns the updated Color3 object
  78307. */
  78308. copyFrom(source: DeepImmutable<Color3>): Color3;
  78309. /**
  78310. * Updates the Color3 rgb values from the given floats
  78311. * @param r defines the red component to read from
  78312. * @param g defines the green component to read from
  78313. * @param b defines the blue component to read from
  78314. * @returns the current Color3 object
  78315. */
  78316. copyFromFloats(r: number, g: number, b: number): Color3;
  78317. /**
  78318. * Updates the Color3 rgb values from the given floats
  78319. * @param r defines the red component to read from
  78320. * @param g defines the green component to read from
  78321. * @param b defines the blue component to read from
  78322. * @returns the current Color3 object
  78323. */
  78324. set(r: number, g: number, b: number): Color3;
  78325. /**
  78326. * Compute the Color3 hexadecimal code as a string
  78327. * @returns a string containing the hexadecimal representation of the Color3 object
  78328. */
  78329. toHexString(): string;
  78330. /**
  78331. * Computes a new Color3 converted from the current one to linear space
  78332. * @returns a new Color3 object
  78333. */
  78334. toLinearSpace(): Color3;
  78335. /**
  78336. * Converts current color in rgb space to HSV values
  78337. * @returns a new color3 representing the HSV values
  78338. */
  78339. toHSV(): Color3;
  78340. /**
  78341. * Converts current color in rgb space to HSV values
  78342. * @param result defines the Color3 where to store the HSV values
  78343. */
  78344. toHSVToRef(result: Color3): void;
  78345. /**
  78346. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78347. * @param convertedColor defines the Color3 object where to store the linear space version
  78348. * @returns the unmodified Color3
  78349. */
  78350. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78351. /**
  78352. * Computes a new Color3 converted from the current one to gamma space
  78353. * @returns a new Color3 object
  78354. */
  78355. toGammaSpace(): Color3;
  78356. /**
  78357. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78358. * @param convertedColor defines the Color3 object where to store the gamma space version
  78359. * @returns the unmodified Color3
  78360. */
  78361. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78362. private static _BlackReadOnly;
  78363. /**
  78364. * Convert Hue, saturation and value to a Color3 (RGB)
  78365. * @param hue defines the hue
  78366. * @param saturation defines the saturation
  78367. * @param value defines the value
  78368. * @param result defines the Color3 where to store the RGB values
  78369. */
  78370. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78371. /**
  78372. * Creates a new Color3 from the string containing valid hexadecimal values
  78373. * @param hex defines a string containing valid hexadecimal values
  78374. * @returns a new Color3 object
  78375. */
  78376. static FromHexString(hex: string): Color3;
  78377. /**
  78378. * Creates a new Color3 from the starting index of the given array
  78379. * @param array defines the source array
  78380. * @param offset defines an offset in the source array
  78381. * @returns a new Color3 object
  78382. */
  78383. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78384. /**
  78385. * Creates a new Color3 from integer values (< 256)
  78386. * @param r defines the red component to read from (value between 0 and 255)
  78387. * @param g defines the green component to read from (value between 0 and 255)
  78388. * @param b defines the blue component to read from (value between 0 and 255)
  78389. * @returns a new Color3 object
  78390. */
  78391. static FromInts(r: number, g: number, b: number): Color3;
  78392. /**
  78393. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78394. * @param start defines the start Color3 value
  78395. * @param end defines the end Color3 value
  78396. * @param amount defines the gradient value between start and end
  78397. * @returns a new Color3 object
  78398. */
  78399. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78400. /**
  78401. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78402. * @param left defines the start value
  78403. * @param right defines the end value
  78404. * @param amount defines the gradient factor
  78405. * @param result defines the Color3 object where to store the result
  78406. */
  78407. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78408. /**
  78409. * Returns a Color3 value containing a red color
  78410. * @returns a new Color3 object
  78411. */
  78412. static Red(): Color3;
  78413. /**
  78414. * Returns a Color3 value containing a green color
  78415. * @returns a new Color3 object
  78416. */
  78417. static Green(): Color3;
  78418. /**
  78419. * Returns a Color3 value containing a blue color
  78420. * @returns a new Color3 object
  78421. */
  78422. static Blue(): Color3;
  78423. /**
  78424. * Returns a Color3 value containing a black color
  78425. * @returns a new Color3 object
  78426. */
  78427. static Black(): Color3;
  78428. /**
  78429. * Gets a Color3 value containing a black color that must not be updated
  78430. */
  78431. static get BlackReadOnly(): DeepImmutable<Color3>;
  78432. /**
  78433. * Returns a Color3 value containing a white color
  78434. * @returns a new Color3 object
  78435. */
  78436. static White(): Color3;
  78437. /**
  78438. * Returns a Color3 value containing a purple color
  78439. * @returns a new Color3 object
  78440. */
  78441. static Purple(): Color3;
  78442. /**
  78443. * Returns a Color3 value containing a magenta color
  78444. * @returns a new Color3 object
  78445. */
  78446. static Magenta(): Color3;
  78447. /**
  78448. * Returns a Color3 value containing a yellow color
  78449. * @returns a new Color3 object
  78450. */
  78451. static Yellow(): Color3;
  78452. /**
  78453. * Returns a Color3 value containing a gray color
  78454. * @returns a new Color3 object
  78455. */
  78456. static Gray(): Color3;
  78457. /**
  78458. * Returns a Color3 value containing a teal color
  78459. * @returns a new Color3 object
  78460. */
  78461. static Teal(): Color3;
  78462. /**
  78463. * Returns a Color3 value containing a random color
  78464. * @returns a new Color3 object
  78465. */
  78466. static Random(): Color3;
  78467. }
  78468. /**
  78469. * Class used to hold a RBGA color
  78470. */
  78471. export class Color4 {
  78472. /**
  78473. * Defines the red component (between 0 and 1, default is 0)
  78474. */
  78475. r: number;
  78476. /**
  78477. * Defines the green component (between 0 and 1, default is 0)
  78478. */
  78479. g: number;
  78480. /**
  78481. * Defines the blue component (between 0 and 1, default is 0)
  78482. */
  78483. b: number;
  78484. /**
  78485. * Defines the alpha component (between 0 and 1, default is 1)
  78486. */
  78487. a: number;
  78488. /**
  78489. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78490. * @param r defines the red component (between 0 and 1, default is 0)
  78491. * @param g defines the green component (between 0 and 1, default is 0)
  78492. * @param b defines the blue component (between 0 and 1, default is 0)
  78493. * @param a defines the alpha component (between 0 and 1, default is 1)
  78494. */
  78495. constructor(
  78496. /**
  78497. * Defines the red component (between 0 and 1, default is 0)
  78498. */
  78499. r?: number,
  78500. /**
  78501. * Defines the green component (between 0 and 1, default is 0)
  78502. */
  78503. g?: number,
  78504. /**
  78505. * Defines the blue component (between 0 and 1, default is 0)
  78506. */
  78507. b?: number,
  78508. /**
  78509. * Defines the alpha component (between 0 and 1, default is 1)
  78510. */
  78511. a?: number);
  78512. /**
  78513. * Adds in place the given Color4 values to the current Color4 object
  78514. * @param right defines the second operand
  78515. * @returns the current updated Color4 object
  78516. */
  78517. addInPlace(right: DeepImmutable<Color4>): Color4;
  78518. /**
  78519. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78520. * @returns the new array
  78521. */
  78522. asArray(): number[];
  78523. /**
  78524. * Stores from the starting index in the given array the Color4 successive values
  78525. * @param array defines the array where to store the r,g,b components
  78526. * @param index defines an optional index in the target array to define where to start storing values
  78527. * @returns the current Color4 object
  78528. */
  78529. toArray(array: number[], index?: number): Color4;
  78530. /**
  78531. * Determines equality between Color4 objects
  78532. * @param otherColor defines the second operand
  78533. * @returns true if the rgba values are equal to the given ones
  78534. */
  78535. equals(otherColor: DeepImmutable<Color4>): boolean;
  78536. /**
  78537. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78538. * @param right defines the second operand
  78539. * @returns a new Color4 object
  78540. */
  78541. add(right: DeepImmutable<Color4>): Color4;
  78542. /**
  78543. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78544. * @param right defines the second operand
  78545. * @returns a new Color4 object
  78546. */
  78547. subtract(right: DeepImmutable<Color4>): Color4;
  78548. /**
  78549. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78550. * @param right defines the second operand
  78551. * @param result defines the Color4 object where to store the result
  78552. * @returns the current Color4 object
  78553. */
  78554. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78555. /**
  78556. * Creates a new Color4 with the current Color4 values multiplied by scale
  78557. * @param scale defines the scaling factor to apply
  78558. * @returns a new Color4 object
  78559. */
  78560. scale(scale: number): Color4;
  78561. /**
  78562. * Multiplies the current Color4 values by scale and stores the result in "result"
  78563. * @param scale defines the scaling factor to apply
  78564. * @param result defines the Color4 object where to store the result
  78565. * @returns the current unmodified Color4
  78566. */
  78567. scaleToRef(scale: number, result: Color4): Color4;
  78568. /**
  78569. * Scale the current Color4 values by a factor and add the result to a given Color4
  78570. * @param scale defines the scale factor
  78571. * @param result defines the Color4 object where to store the result
  78572. * @returns the unmodified current Color4
  78573. */
  78574. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78575. /**
  78576. * Clamps the rgb values by the min and max values and stores the result into "result"
  78577. * @param min defines minimum clamping value (default is 0)
  78578. * @param max defines maximum clamping value (default is 1)
  78579. * @param result defines color to store the result into.
  78580. * @returns the cuurent Color4
  78581. */
  78582. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78583. /**
  78584. * Multipy an Color4 value by another and return a new Color4 object
  78585. * @param color defines the Color4 value to multiply by
  78586. * @returns a new Color4 object
  78587. */
  78588. multiply(color: Color4): Color4;
  78589. /**
  78590. * Multipy a Color4 value by another and push the result in a reference value
  78591. * @param color defines the Color4 value to multiply by
  78592. * @param result defines the Color4 to fill the result in
  78593. * @returns the result Color4
  78594. */
  78595. multiplyToRef(color: Color4, result: Color4): Color4;
  78596. /**
  78597. * Creates a string with the Color4 current values
  78598. * @returns the string representation of the Color4 object
  78599. */
  78600. toString(): string;
  78601. /**
  78602. * Returns the string "Color4"
  78603. * @returns "Color4"
  78604. */
  78605. getClassName(): string;
  78606. /**
  78607. * Compute the Color4 hash code
  78608. * @returns an unique number that can be used to hash Color4 objects
  78609. */
  78610. getHashCode(): number;
  78611. /**
  78612. * Creates a new Color4 copied from the current one
  78613. * @returns a new Color4 object
  78614. */
  78615. clone(): Color4;
  78616. /**
  78617. * Copies the given Color4 values into the current one
  78618. * @param source defines the source Color4 object
  78619. * @returns the current updated Color4 object
  78620. */
  78621. copyFrom(source: Color4): Color4;
  78622. /**
  78623. * Copies the given float values into the current one
  78624. * @param r defines the red component to read from
  78625. * @param g defines the green component to read from
  78626. * @param b defines the blue component to read from
  78627. * @param a defines the alpha component to read from
  78628. * @returns the current updated Color4 object
  78629. */
  78630. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78631. /**
  78632. * Copies the given float values into the current one
  78633. * @param r defines the red component to read from
  78634. * @param g defines the green component to read from
  78635. * @param b defines the blue component to read from
  78636. * @param a defines the alpha component to read from
  78637. * @returns the current updated Color4 object
  78638. */
  78639. set(r: number, g: number, b: number, a: number): Color4;
  78640. /**
  78641. * Compute the Color4 hexadecimal code as a string
  78642. * @returns a string containing the hexadecimal representation of the Color4 object
  78643. */
  78644. toHexString(): string;
  78645. /**
  78646. * Computes a new Color4 converted from the current one to linear space
  78647. * @returns a new Color4 object
  78648. */
  78649. toLinearSpace(): Color4;
  78650. /**
  78651. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  78652. * @param convertedColor defines the Color4 object where to store the linear space version
  78653. * @returns the unmodified Color4
  78654. */
  78655. toLinearSpaceToRef(convertedColor: Color4): Color4;
  78656. /**
  78657. * Computes a new Color4 converted from the current one to gamma space
  78658. * @returns a new Color4 object
  78659. */
  78660. toGammaSpace(): Color4;
  78661. /**
  78662. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  78663. * @param convertedColor defines the Color4 object where to store the gamma space version
  78664. * @returns the unmodified Color4
  78665. */
  78666. toGammaSpaceToRef(convertedColor: Color4): Color4;
  78667. /**
  78668. * Creates a new Color4 from the string containing valid hexadecimal values
  78669. * @param hex defines a string containing valid hexadecimal values
  78670. * @returns a new Color4 object
  78671. */
  78672. static FromHexString(hex: string): Color4;
  78673. /**
  78674. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78675. * @param left defines the start value
  78676. * @param right defines the end value
  78677. * @param amount defines the gradient factor
  78678. * @returns a new Color4 object
  78679. */
  78680. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  78681. /**
  78682. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78683. * @param left defines the start value
  78684. * @param right defines the end value
  78685. * @param amount defines the gradient factor
  78686. * @param result defines the Color4 object where to store data
  78687. */
  78688. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  78689. /**
  78690. * Creates a new Color4 from a Color3 and an alpha value
  78691. * @param color3 defines the source Color3 to read from
  78692. * @param alpha defines the alpha component (1.0 by default)
  78693. * @returns a new Color4 object
  78694. */
  78695. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  78696. /**
  78697. * Creates a new Color4 from the starting index element of the given array
  78698. * @param array defines the source array to read from
  78699. * @param offset defines the offset in the source array
  78700. * @returns a new Color4 object
  78701. */
  78702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  78703. /**
  78704. * Creates a new Color3 from integer values (< 256)
  78705. * @param r defines the red component to read from (value between 0 and 255)
  78706. * @param g defines the green component to read from (value between 0 and 255)
  78707. * @param b defines the blue component to read from (value between 0 and 255)
  78708. * @param a defines the alpha component to read from (value between 0 and 255)
  78709. * @returns a new Color3 object
  78710. */
  78711. static FromInts(r: number, g: number, b: number, a: number): Color4;
  78712. /**
  78713. * Check the content of a given array and convert it to an array containing RGBA data
  78714. * If the original array was already containing count * 4 values then it is returned directly
  78715. * @param colors defines the array to check
  78716. * @param count defines the number of RGBA data to expect
  78717. * @returns an array containing count * 4 values (RGBA)
  78718. */
  78719. static CheckColors4(colors: number[], count: number): number[];
  78720. }
  78721. /**
  78722. * @hidden
  78723. */
  78724. export class TmpColors {
  78725. static Color3: Color3[];
  78726. static Color4: Color4[];
  78727. }
  78728. }
  78729. declare module BABYLON {
  78730. /**
  78731. * Defines an interface which represents an animation key frame
  78732. */
  78733. export interface IAnimationKey {
  78734. /**
  78735. * Frame of the key frame
  78736. */
  78737. frame: number;
  78738. /**
  78739. * Value at the specifies key frame
  78740. */
  78741. value: any;
  78742. /**
  78743. * The input tangent for the cubic hermite spline
  78744. */
  78745. inTangent?: any;
  78746. /**
  78747. * The output tangent for the cubic hermite spline
  78748. */
  78749. outTangent?: any;
  78750. /**
  78751. * The animation interpolation type
  78752. */
  78753. interpolation?: AnimationKeyInterpolation;
  78754. }
  78755. /**
  78756. * Enum for the animation key frame interpolation type
  78757. */
  78758. export enum AnimationKeyInterpolation {
  78759. /**
  78760. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  78761. */
  78762. STEP = 1
  78763. }
  78764. }
  78765. declare module BABYLON {
  78766. /**
  78767. * Represents the range of an animation
  78768. */
  78769. export class AnimationRange {
  78770. /**The name of the animation range**/
  78771. name: string;
  78772. /**The starting frame of the animation */
  78773. from: number;
  78774. /**The ending frame of the animation*/
  78775. to: number;
  78776. /**
  78777. * Initializes the range of an animation
  78778. * @param name The name of the animation range
  78779. * @param from The starting frame of the animation
  78780. * @param to The ending frame of the animation
  78781. */
  78782. constructor(
  78783. /**The name of the animation range**/
  78784. name: string,
  78785. /**The starting frame of the animation */
  78786. from: number,
  78787. /**The ending frame of the animation*/
  78788. to: number);
  78789. /**
  78790. * Makes a copy of the animation range
  78791. * @returns A copy of the animation range
  78792. */
  78793. clone(): AnimationRange;
  78794. }
  78795. }
  78796. declare module BABYLON {
  78797. /**
  78798. * Composed of a frame, and an action function
  78799. */
  78800. export class AnimationEvent {
  78801. /** The frame for which the event is triggered **/
  78802. frame: number;
  78803. /** The event to perform when triggered **/
  78804. action: (currentFrame: number) => void;
  78805. /** Specifies if the event should be triggered only once**/
  78806. onlyOnce?: boolean | undefined;
  78807. /**
  78808. * Specifies if the animation event is done
  78809. */
  78810. isDone: boolean;
  78811. /**
  78812. * Initializes the animation event
  78813. * @param frame The frame for which the event is triggered
  78814. * @param action The event to perform when triggered
  78815. * @param onlyOnce Specifies if the event should be triggered only once
  78816. */
  78817. constructor(
  78818. /** The frame for which the event is triggered **/
  78819. frame: number,
  78820. /** The event to perform when triggered **/
  78821. action: (currentFrame: number) => void,
  78822. /** Specifies if the event should be triggered only once**/
  78823. onlyOnce?: boolean | undefined);
  78824. /** @hidden */
  78825. _clone(): AnimationEvent;
  78826. }
  78827. }
  78828. declare module BABYLON {
  78829. /**
  78830. * Interface used to define a behavior
  78831. */
  78832. export interface Behavior<T> {
  78833. /** gets or sets behavior's name */
  78834. name: string;
  78835. /**
  78836. * Function called when the behavior needs to be initialized (after attaching it to a target)
  78837. */
  78838. init(): void;
  78839. /**
  78840. * Called when the behavior is attached to a target
  78841. * @param target defines the target where the behavior is attached to
  78842. */
  78843. attach(target: T): void;
  78844. /**
  78845. * Called when the behavior is detached from its target
  78846. */
  78847. detach(): void;
  78848. }
  78849. /**
  78850. * Interface implemented by classes supporting behaviors
  78851. */
  78852. export interface IBehaviorAware<T> {
  78853. /**
  78854. * Attach a behavior
  78855. * @param behavior defines the behavior to attach
  78856. * @returns the current host
  78857. */
  78858. addBehavior(behavior: Behavior<T>): T;
  78859. /**
  78860. * Remove a behavior from the current object
  78861. * @param behavior defines the behavior to detach
  78862. * @returns the current host
  78863. */
  78864. removeBehavior(behavior: Behavior<T>): T;
  78865. /**
  78866. * Gets a behavior using its name to search
  78867. * @param name defines the name to search
  78868. * @returns the behavior or null if not found
  78869. */
  78870. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  78871. }
  78872. }
  78873. declare module BABYLON {
  78874. /**
  78875. * Defines an array and its length.
  78876. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  78877. */
  78878. export interface ISmartArrayLike<T> {
  78879. /**
  78880. * The data of the array.
  78881. */
  78882. data: Array<T>;
  78883. /**
  78884. * The active length of the array.
  78885. */
  78886. length: number;
  78887. }
  78888. /**
  78889. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78890. */
  78891. export class SmartArray<T> implements ISmartArrayLike<T> {
  78892. /**
  78893. * The full set of data from the array.
  78894. */
  78895. data: Array<T>;
  78896. /**
  78897. * The active length of the array.
  78898. */
  78899. length: number;
  78900. protected _id: number;
  78901. /**
  78902. * Instantiates a Smart Array.
  78903. * @param capacity defines the default capacity of the array.
  78904. */
  78905. constructor(capacity: number);
  78906. /**
  78907. * Pushes a value at the end of the active data.
  78908. * @param value defines the object to push in the array.
  78909. */
  78910. push(value: T): void;
  78911. /**
  78912. * Iterates over the active data and apply the lambda to them.
  78913. * @param func defines the action to apply on each value.
  78914. */
  78915. forEach(func: (content: T) => void): void;
  78916. /**
  78917. * Sorts the full sets of data.
  78918. * @param compareFn defines the comparison function to apply.
  78919. */
  78920. sort(compareFn: (a: T, b: T) => number): void;
  78921. /**
  78922. * Resets the active data to an empty array.
  78923. */
  78924. reset(): void;
  78925. /**
  78926. * Releases all the data from the array as well as the array.
  78927. */
  78928. dispose(): void;
  78929. /**
  78930. * Concats the active data with a given array.
  78931. * @param array defines the data to concatenate with.
  78932. */
  78933. concat(array: any): void;
  78934. /**
  78935. * Returns the position of a value in the active data.
  78936. * @param value defines the value to find the index for
  78937. * @returns the index if found in the active data otherwise -1
  78938. */
  78939. indexOf(value: T): number;
  78940. /**
  78941. * Returns whether an element is part of the active data.
  78942. * @param value defines the value to look for
  78943. * @returns true if found in the active data otherwise false
  78944. */
  78945. contains(value: T): boolean;
  78946. private static _GlobalId;
  78947. }
  78948. /**
  78949. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78950. * The data in this array can only be present once
  78951. */
  78952. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  78953. private _duplicateId;
  78954. /**
  78955. * Pushes a value at the end of the active data.
  78956. * THIS DOES NOT PREVENT DUPPLICATE DATA
  78957. * @param value defines the object to push in the array.
  78958. */
  78959. push(value: T): void;
  78960. /**
  78961. * Pushes a value at the end of the active data.
  78962. * If the data is already present, it won t be added again
  78963. * @param value defines the object to push in the array.
  78964. * @returns true if added false if it was already present
  78965. */
  78966. pushNoDuplicate(value: T): boolean;
  78967. /**
  78968. * Resets the active data to an empty array.
  78969. */
  78970. reset(): void;
  78971. /**
  78972. * Concats the active data with a given array.
  78973. * This ensures no dupplicate will be present in the result.
  78974. * @param array defines the data to concatenate with.
  78975. */
  78976. concatWithNoDuplicate(array: any): void;
  78977. }
  78978. }
  78979. declare module BABYLON {
  78980. /**
  78981. * @ignore
  78982. * This is a list of all the different input types that are available in the application.
  78983. * Fo instance: ArcRotateCameraGamepadInput...
  78984. */
  78985. export var CameraInputTypes: {};
  78986. /**
  78987. * This is the contract to implement in order to create a new input class.
  78988. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  78989. */
  78990. export interface ICameraInput<TCamera extends Camera> {
  78991. /**
  78992. * Defines the camera the input is attached to.
  78993. */
  78994. camera: Nullable<TCamera>;
  78995. /**
  78996. * Gets the class name of the current intput.
  78997. * @returns the class name
  78998. */
  78999. getClassName(): string;
  79000. /**
  79001. * Get the friendly name associated with the input class.
  79002. * @returns the input friendly name
  79003. */
  79004. getSimpleName(): string;
  79005. /**
  79006. * Attach the input controls to a specific dom element to get the input from.
  79007. * @param element Defines the element the controls should be listened from
  79008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79009. */
  79010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79011. /**
  79012. * Detach the current controls from the specified dom element.
  79013. * @param element Defines the element to stop listening the inputs from
  79014. */
  79015. detachControl(element: Nullable<HTMLElement>): void;
  79016. /**
  79017. * Update the current camera state depending on the inputs that have been used this frame.
  79018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79019. */
  79020. checkInputs?: () => void;
  79021. }
  79022. /**
  79023. * Represents a map of input types to input instance or input index to input instance.
  79024. */
  79025. export interface CameraInputsMap<TCamera extends Camera> {
  79026. /**
  79027. * Accessor to the input by input type.
  79028. */
  79029. [name: string]: ICameraInput<TCamera>;
  79030. /**
  79031. * Accessor to the input by input index.
  79032. */
  79033. [idx: number]: ICameraInput<TCamera>;
  79034. }
  79035. /**
  79036. * This represents the input manager used within a camera.
  79037. * It helps dealing with all the different kind of input attached to a camera.
  79038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79039. */
  79040. export class CameraInputsManager<TCamera extends Camera> {
  79041. /**
  79042. * Defines the list of inputs attahed to the camera.
  79043. */
  79044. attached: CameraInputsMap<TCamera>;
  79045. /**
  79046. * Defines the dom element the camera is collecting inputs from.
  79047. * This is null if the controls have not been attached.
  79048. */
  79049. attachedElement: Nullable<HTMLElement>;
  79050. /**
  79051. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79052. */
  79053. noPreventDefault: boolean;
  79054. /**
  79055. * Defined the camera the input manager belongs to.
  79056. */
  79057. camera: TCamera;
  79058. /**
  79059. * Update the current camera state depending on the inputs that have been used this frame.
  79060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79061. */
  79062. checkInputs: () => void;
  79063. /**
  79064. * Instantiate a new Camera Input Manager.
  79065. * @param camera Defines the camera the input manager blongs to
  79066. */
  79067. constructor(camera: TCamera);
  79068. /**
  79069. * Add an input method to a camera
  79070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79071. * @param input camera input method
  79072. */
  79073. add(input: ICameraInput<TCamera>): void;
  79074. /**
  79075. * Remove a specific input method from a camera
  79076. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79077. * @param inputToRemove camera input method
  79078. */
  79079. remove(inputToRemove: ICameraInput<TCamera>): void;
  79080. /**
  79081. * Remove a specific input type from a camera
  79082. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79083. * @param inputType the type of the input to remove
  79084. */
  79085. removeByType(inputType: string): void;
  79086. private _addCheckInputs;
  79087. /**
  79088. * Attach the input controls to the currently attached dom element to listen the events from.
  79089. * @param input Defines the input to attach
  79090. */
  79091. attachInput(input: ICameraInput<TCamera>): void;
  79092. /**
  79093. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79094. * @param element Defines the dom element to collect the events from
  79095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79096. */
  79097. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79098. /**
  79099. * Detach the current manager inputs controls from a specific dom element.
  79100. * @param element Defines the dom element to collect the events from
  79101. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79102. */
  79103. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79104. /**
  79105. * Rebuild the dynamic inputCheck function from the current list of
  79106. * defined inputs in the manager.
  79107. */
  79108. rebuildInputCheck(): void;
  79109. /**
  79110. * Remove all attached input methods from a camera
  79111. */
  79112. clear(): void;
  79113. /**
  79114. * Serialize the current input manager attached to a camera.
  79115. * This ensures than once parsed,
  79116. * the input associated to the camera will be identical to the current ones
  79117. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79118. */
  79119. serialize(serializedCamera: any): void;
  79120. /**
  79121. * Parses an input manager serialized JSON to restore the previous list of inputs
  79122. * and states associated to a camera.
  79123. * @param parsedCamera Defines the JSON to parse
  79124. */
  79125. parse(parsedCamera: any): void;
  79126. }
  79127. }
  79128. declare module BABYLON {
  79129. /**
  79130. * Class used to store data that will be store in GPU memory
  79131. */
  79132. export class Buffer {
  79133. private _engine;
  79134. private _buffer;
  79135. /** @hidden */
  79136. _data: Nullable<DataArray>;
  79137. private _updatable;
  79138. private _instanced;
  79139. private _divisor;
  79140. /**
  79141. * Gets the byte stride.
  79142. */
  79143. readonly byteStride: number;
  79144. /**
  79145. * Constructor
  79146. * @param engine the engine
  79147. * @param data the data to use for this buffer
  79148. * @param updatable whether the data is updatable
  79149. * @param stride the stride (optional)
  79150. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79151. * @param instanced whether the buffer is instanced (optional)
  79152. * @param useBytes set to true if the stride in in bytes (optional)
  79153. * @param divisor sets an optional divisor for instances (1 by default)
  79154. */
  79155. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79156. /**
  79157. * Create a new VertexBuffer based on the current buffer
  79158. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79159. * @param offset defines offset in the buffer (0 by default)
  79160. * @param size defines the size in floats of attributes (position is 3 for instance)
  79161. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79162. * @param instanced defines if the vertex buffer contains indexed data
  79163. * @param useBytes defines if the offset and stride are in bytes *
  79164. * @param divisor sets an optional divisor for instances (1 by default)
  79165. * @returns the new vertex buffer
  79166. */
  79167. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79168. /**
  79169. * Gets a boolean indicating if the Buffer is updatable?
  79170. * @returns true if the buffer is updatable
  79171. */
  79172. isUpdatable(): boolean;
  79173. /**
  79174. * Gets current buffer's data
  79175. * @returns a DataArray or null
  79176. */
  79177. getData(): Nullable<DataArray>;
  79178. /**
  79179. * Gets underlying native buffer
  79180. * @returns underlying native buffer
  79181. */
  79182. getBuffer(): Nullable<DataBuffer>;
  79183. /**
  79184. * Gets the stride in float32 units (i.e. byte stride / 4).
  79185. * May not be an integer if the byte stride is not divisible by 4.
  79186. * @returns the stride in float32 units
  79187. * @deprecated Please use byteStride instead.
  79188. */
  79189. getStrideSize(): number;
  79190. /**
  79191. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79192. * @param data defines the data to store
  79193. */
  79194. create(data?: Nullable<DataArray>): void;
  79195. /** @hidden */
  79196. _rebuild(): void;
  79197. /**
  79198. * Update current buffer data
  79199. * @param data defines the data to store
  79200. */
  79201. update(data: DataArray): void;
  79202. /**
  79203. * Updates the data directly.
  79204. * @param data the new data
  79205. * @param offset the new offset
  79206. * @param vertexCount the vertex count (optional)
  79207. * @param useBytes set to true if the offset is in bytes
  79208. */
  79209. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79210. /**
  79211. * Release all resources
  79212. */
  79213. dispose(): void;
  79214. }
  79215. /**
  79216. * Specialized buffer used to store vertex data
  79217. */
  79218. export class VertexBuffer {
  79219. /** @hidden */
  79220. _buffer: Buffer;
  79221. private _kind;
  79222. private _size;
  79223. private _ownsBuffer;
  79224. private _instanced;
  79225. private _instanceDivisor;
  79226. /**
  79227. * The byte type.
  79228. */
  79229. static readonly BYTE: number;
  79230. /**
  79231. * The unsigned byte type.
  79232. */
  79233. static readonly UNSIGNED_BYTE: number;
  79234. /**
  79235. * The short type.
  79236. */
  79237. static readonly SHORT: number;
  79238. /**
  79239. * The unsigned short type.
  79240. */
  79241. static readonly UNSIGNED_SHORT: number;
  79242. /**
  79243. * The integer type.
  79244. */
  79245. static readonly INT: number;
  79246. /**
  79247. * The unsigned integer type.
  79248. */
  79249. static readonly UNSIGNED_INT: number;
  79250. /**
  79251. * The float type.
  79252. */
  79253. static readonly FLOAT: number;
  79254. /**
  79255. * Gets or sets the instance divisor when in instanced mode
  79256. */
  79257. get instanceDivisor(): number;
  79258. set instanceDivisor(value: number);
  79259. /**
  79260. * Gets the byte stride.
  79261. */
  79262. readonly byteStride: number;
  79263. /**
  79264. * Gets the byte offset.
  79265. */
  79266. readonly byteOffset: number;
  79267. /**
  79268. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79269. */
  79270. readonly normalized: boolean;
  79271. /**
  79272. * Gets the data type of each component in the array.
  79273. */
  79274. readonly type: number;
  79275. /**
  79276. * Constructor
  79277. * @param engine the engine
  79278. * @param data the data to use for this vertex buffer
  79279. * @param kind the vertex buffer kind
  79280. * @param updatable whether the data is updatable
  79281. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79282. * @param stride the stride (optional)
  79283. * @param instanced whether the buffer is instanced (optional)
  79284. * @param offset the offset of the data (optional)
  79285. * @param size the number of components (optional)
  79286. * @param type the type of the component (optional)
  79287. * @param normalized whether the data contains normalized data (optional)
  79288. * @param useBytes set to true if stride and offset are in bytes (optional)
  79289. * @param divisor defines the instance divisor to use (1 by default)
  79290. */
  79291. 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);
  79292. /** @hidden */
  79293. _rebuild(): void;
  79294. /**
  79295. * Returns the kind of the VertexBuffer (string)
  79296. * @returns a string
  79297. */
  79298. getKind(): string;
  79299. /**
  79300. * Gets a boolean indicating if the VertexBuffer is updatable?
  79301. * @returns true if the buffer is updatable
  79302. */
  79303. isUpdatable(): boolean;
  79304. /**
  79305. * Gets current buffer's data
  79306. * @returns a DataArray or null
  79307. */
  79308. getData(): Nullable<DataArray>;
  79309. /**
  79310. * Gets underlying native buffer
  79311. * @returns underlying native buffer
  79312. */
  79313. getBuffer(): Nullable<DataBuffer>;
  79314. /**
  79315. * Gets the stride in float32 units (i.e. byte stride / 4).
  79316. * May not be an integer if the byte stride is not divisible by 4.
  79317. * @returns the stride in float32 units
  79318. * @deprecated Please use byteStride instead.
  79319. */
  79320. getStrideSize(): number;
  79321. /**
  79322. * Returns the offset as a multiple of the type byte length.
  79323. * @returns the offset in bytes
  79324. * @deprecated Please use byteOffset instead.
  79325. */
  79326. getOffset(): number;
  79327. /**
  79328. * Returns the number of components per vertex attribute (integer)
  79329. * @returns the size in float
  79330. */
  79331. getSize(): number;
  79332. /**
  79333. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79334. * @returns true if this buffer is instanced
  79335. */
  79336. getIsInstanced(): boolean;
  79337. /**
  79338. * Returns the instancing divisor, zero for non-instanced (integer).
  79339. * @returns a number
  79340. */
  79341. getInstanceDivisor(): number;
  79342. /**
  79343. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79344. * @param data defines the data to store
  79345. */
  79346. create(data?: DataArray): void;
  79347. /**
  79348. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79349. * This function will create a new buffer if the current one is not updatable
  79350. * @param data defines the data to store
  79351. */
  79352. update(data: DataArray): void;
  79353. /**
  79354. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79355. * Returns the directly updated WebGLBuffer.
  79356. * @param data the new data
  79357. * @param offset the new offset
  79358. * @param useBytes set to true if the offset is in bytes
  79359. */
  79360. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79361. /**
  79362. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79363. */
  79364. dispose(): void;
  79365. /**
  79366. * Enumerates each value of this vertex buffer as numbers.
  79367. * @param count the number of values to enumerate
  79368. * @param callback the callback function called for each value
  79369. */
  79370. forEach(count: number, callback: (value: number, index: number) => void): void;
  79371. /**
  79372. * Positions
  79373. */
  79374. static readonly PositionKind: string;
  79375. /**
  79376. * Normals
  79377. */
  79378. static readonly NormalKind: string;
  79379. /**
  79380. * Tangents
  79381. */
  79382. static readonly TangentKind: string;
  79383. /**
  79384. * Texture coordinates
  79385. */
  79386. static readonly UVKind: string;
  79387. /**
  79388. * Texture coordinates 2
  79389. */
  79390. static readonly UV2Kind: string;
  79391. /**
  79392. * Texture coordinates 3
  79393. */
  79394. static readonly UV3Kind: string;
  79395. /**
  79396. * Texture coordinates 4
  79397. */
  79398. static readonly UV4Kind: string;
  79399. /**
  79400. * Texture coordinates 5
  79401. */
  79402. static readonly UV5Kind: string;
  79403. /**
  79404. * Texture coordinates 6
  79405. */
  79406. static readonly UV6Kind: string;
  79407. /**
  79408. * Colors
  79409. */
  79410. static readonly ColorKind: string;
  79411. /**
  79412. * Matrix indices (for bones)
  79413. */
  79414. static readonly MatricesIndicesKind: string;
  79415. /**
  79416. * Matrix weights (for bones)
  79417. */
  79418. static readonly MatricesWeightsKind: string;
  79419. /**
  79420. * Additional matrix indices (for bones)
  79421. */
  79422. static readonly MatricesIndicesExtraKind: string;
  79423. /**
  79424. * Additional matrix weights (for bones)
  79425. */
  79426. static readonly MatricesWeightsExtraKind: string;
  79427. /**
  79428. * Deduces the stride given a kind.
  79429. * @param kind The kind string to deduce
  79430. * @returns The deduced stride
  79431. */
  79432. static DeduceStride(kind: string): number;
  79433. /**
  79434. * Gets the byte length of the given type.
  79435. * @param type the type
  79436. * @returns the number of bytes
  79437. */
  79438. static GetTypeByteLength(type: number): number;
  79439. /**
  79440. * Enumerates each value of the given parameters as numbers.
  79441. * @param data the data to enumerate
  79442. * @param byteOffset the byte offset of the data
  79443. * @param byteStride the byte stride of the data
  79444. * @param componentCount the number of components per element
  79445. * @param componentType the type of the component
  79446. * @param count the number of values to enumerate
  79447. * @param normalized whether the data is normalized
  79448. * @param callback the callback function called for each value
  79449. */
  79450. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79451. private static _GetFloatValue;
  79452. }
  79453. }
  79454. declare module BABYLON {
  79455. /**
  79456. * @hidden
  79457. */
  79458. export class IntersectionInfo {
  79459. bu: Nullable<number>;
  79460. bv: Nullable<number>;
  79461. distance: number;
  79462. faceId: number;
  79463. subMeshId: number;
  79464. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79465. }
  79466. }
  79467. declare module BABYLON {
  79468. /**
  79469. * Represens a plane by the equation ax + by + cz + d = 0
  79470. */
  79471. export class Plane {
  79472. private static _TmpMatrix;
  79473. /**
  79474. * Normal of the plane (a,b,c)
  79475. */
  79476. normal: Vector3;
  79477. /**
  79478. * d component of the plane
  79479. */
  79480. d: number;
  79481. /**
  79482. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79483. * @param a a component of the plane
  79484. * @param b b component of the plane
  79485. * @param c c component of the plane
  79486. * @param d d component of the plane
  79487. */
  79488. constructor(a: number, b: number, c: number, d: number);
  79489. /**
  79490. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79491. */
  79492. asArray(): number[];
  79493. /**
  79494. * @returns a new plane copied from the current Plane.
  79495. */
  79496. clone(): Plane;
  79497. /**
  79498. * @returns the string "Plane".
  79499. */
  79500. getClassName(): string;
  79501. /**
  79502. * @returns the Plane hash code.
  79503. */
  79504. getHashCode(): number;
  79505. /**
  79506. * Normalize the current Plane in place.
  79507. * @returns the updated Plane.
  79508. */
  79509. normalize(): Plane;
  79510. /**
  79511. * Applies a transformation the plane and returns the result
  79512. * @param transformation the transformation matrix to be applied to the plane
  79513. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79514. */
  79515. transform(transformation: DeepImmutable<Matrix>): Plane;
  79516. /**
  79517. * Calcualtte the dot product between the point and the plane normal
  79518. * @param point point to calculate the dot product with
  79519. * @returns the dot product (float) of the point coordinates and the plane normal.
  79520. */
  79521. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79522. /**
  79523. * Updates the current Plane from the plane defined by the three given points.
  79524. * @param point1 one of the points used to contruct the plane
  79525. * @param point2 one of the points used to contruct the plane
  79526. * @param point3 one of the points used to contruct the plane
  79527. * @returns the updated Plane.
  79528. */
  79529. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79530. /**
  79531. * Checks if the plane is facing a given direction
  79532. * @param direction the direction to check if the plane is facing
  79533. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79534. * @returns True is the vector "direction" is the same side than the plane normal.
  79535. */
  79536. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79537. /**
  79538. * Calculates the distance to a point
  79539. * @param point point to calculate distance to
  79540. * @returns the signed distance (float) from the given point to the Plane.
  79541. */
  79542. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79543. /**
  79544. * Creates a plane from an array
  79545. * @param array the array to create a plane from
  79546. * @returns a new Plane from the given array.
  79547. */
  79548. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79549. /**
  79550. * Creates a plane from three points
  79551. * @param point1 point used to create the plane
  79552. * @param point2 point used to create the plane
  79553. * @param point3 point used to create the plane
  79554. * @returns a new Plane defined by the three given points.
  79555. */
  79556. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79557. /**
  79558. * Creates a plane from an origin point and a normal
  79559. * @param origin origin of the plane to be constructed
  79560. * @param normal normal of the plane to be constructed
  79561. * @returns a new Plane the normal vector to this plane at the given origin point.
  79562. * Note : the vector "normal" is updated because normalized.
  79563. */
  79564. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79565. /**
  79566. * Calculates the distance from a plane and a point
  79567. * @param origin origin of the plane to be constructed
  79568. * @param normal normal of the plane to be constructed
  79569. * @param point point to calculate distance to
  79570. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79571. */
  79572. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79573. }
  79574. }
  79575. declare module BABYLON {
  79576. /**
  79577. * Class used to store bounding sphere information
  79578. */
  79579. export class BoundingSphere {
  79580. /**
  79581. * Gets the center of the bounding sphere in local space
  79582. */
  79583. readonly center: Vector3;
  79584. /**
  79585. * Radius of the bounding sphere in local space
  79586. */
  79587. radius: number;
  79588. /**
  79589. * Gets the center of the bounding sphere in world space
  79590. */
  79591. readonly centerWorld: Vector3;
  79592. /**
  79593. * Radius of the bounding sphere in world space
  79594. */
  79595. radiusWorld: number;
  79596. /**
  79597. * Gets the minimum vector in local space
  79598. */
  79599. readonly minimum: Vector3;
  79600. /**
  79601. * Gets the maximum vector in local space
  79602. */
  79603. readonly maximum: Vector3;
  79604. private _worldMatrix;
  79605. private static readonly TmpVector3;
  79606. /**
  79607. * Creates a new bounding sphere
  79608. * @param min defines the minimum vector (in local space)
  79609. * @param max defines the maximum vector (in local space)
  79610. * @param worldMatrix defines the new world matrix
  79611. */
  79612. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79613. /**
  79614. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79615. * @param min defines the new minimum vector (in local space)
  79616. * @param max defines the new maximum vector (in local space)
  79617. * @param worldMatrix defines the new world matrix
  79618. */
  79619. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79620. /**
  79621. * Scale the current bounding sphere by applying a scale factor
  79622. * @param factor defines the scale factor to apply
  79623. * @returns the current bounding box
  79624. */
  79625. scale(factor: number): BoundingSphere;
  79626. /**
  79627. * Gets the world matrix of the bounding box
  79628. * @returns a matrix
  79629. */
  79630. getWorldMatrix(): DeepImmutable<Matrix>;
  79631. /** @hidden */
  79632. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79633. /**
  79634. * Tests if the bounding sphere is intersecting the frustum planes
  79635. * @param frustumPlanes defines the frustum planes to test
  79636. * @returns true if there is an intersection
  79637. */
  79638. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79639. /**
  79640. * Tests if the bounding sphere center is in between the frustum planes.
  79641. * Used for optimistic fast inclusion.
  79642. * @param frustumPlanes defines the frustum planes to test
  79643. * @returns true if the sphere center is in between the frustum planes
  79644. */
  79645. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79646. /**
  79647. * Tests if a point is inside the bounding sphere
  79648. * @param point defines the point to test
  79649. * @returns true if the point is inside the bounding sphere
  79650. */
  79651. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79652. /**
  79653. * Checks if two sphere intersct
  79654. * @param sphere0 sphere 0
  79655. * @param sphere1 sphere 1
  79656. * @returns true if the speres intersect
  79657. */
  79658. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  79659. }
  79660. }
  79661. declare module BABYLON {
  79662. /**
  79663. * Class used to store bounding box information
  79664. */
  79665. export class BoundingBox implements ICullable {
  79666. /**
  79667. * Gets the 8 vectors representing the bounding box in local space
  79668. */
  79669. readonly vectors: Vector3[];
  79670. /**
  79671. * Gets the center of the bounding box in local space
  79672. */
  79673. readonly center: Vector3;
  79674. /**
  79675. * Gets the center of the bounding box in world space
  79676. */
  79677. readonly centerWorld: Vector3;
  79678. /**
  79679. * Gets the extend size in local space
  79680. */
  79681. readonly extendSize: Vector3;
  79682. /**
  79683. * Gets the extend size in world space
  79684. */
  79685. readonly extendSizeWorld: Vector3;
  79686. /**
  79687. * Gets the OBB (object bounding box) directions
  79688. */
  79689. readonly directions: Vector3[];
  79690. /**
  79691. * Gets the 8 vectors representing the bounding box in world space
  79692. */
  79693. readonly vectorsWorld: Vector3[];
  79694. /**
  79695. * Gets the minimum vector in world space
  79696. */
  79697. readonly minimumWorld: Vector3;
  79698. /**
  79699. * Gets the maximum vector in world space
  79700. */
  79701. readonly maximumWorld: Vector3;
  79702. /**
  79703. * Gets the minimum vector in local space
  79704. */
  79705. readonly minimum: Vector3;
  79706. /**
  79707. * Gets the maximum vector in local space
  79708. */
  79709. readonly maximum: Vector3;
  79710. private _worldMatrix;
  79711. private static readonly TmpVector3;
  79712. /**
  79713. * @hidden
  79714. */
  79715. _tag: number;
  79716. /**
  79717. * Creates a new bounding box
  79718. * @param min defines the minimum vector (in local space)
  79719. * @param max defines the maximum vector (in local space)
  79720. * @param worldMatrix defines the new world matrix
  79721. */
  79722. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79723. /**
  79724. * Recreates the entire bounding box from scratch as if we call the constructor in place
  79725. * @param min defines the new minimum vector (in local space)
  79726. * @param max defines the new maximum vector (in local space)
  79727. * @param worldMatrix defines the new world matrix
  79728. */
  79729. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79730. /**
  79731. * Scale the current bounding box by applying a scale factor
  79732. * @param factor defines the scale factor to apply
  79733. * @returns the current bounding box
  79734. */
  79735. scale(factor: number): BoundingBox;
  79736. /**
  79737. * Gets the world matrix of the bounding box
  79738. * @returns a matrix
  79739. */
  79740. getWorldMatrix(): DeepImmutable<Matrix>;
  79741. /** @hidden */
  79742. _update(world: DeepImmutable<Matrix>): void;
  79743. /**
  79744. * Tests if the bounding box is intersecting the frustum planes
  79745. * @param frustumPlanes defines the frustum planes to test
  79746. * @returns true if there is an intersection
  79747. */
  79748. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79749. /**
  79750. * Tests if the bounding box is entirely inside the frustum planes
  79751. * @param frustumPlanes defines the frustum planes to test
  79752. * @returns true if there is an inclusion
  79753. */
  79754. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79755. /**
  79756. * Tests if a point is inside the bounding box
  79757. * @param point defines the point to test
  79758. * @returns true if the point is inside the bounding box
  79759. */
  79760. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79761. /**
  79762. * Tests if the bounding box intersects with a bounding sphere
  79763. * @param sphere defines the sphere to test
  79764. * @returns true if there is an intersection
  79765. */
  79766. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  79767. /**
  79768. * Tests if the bounding box intersects with a box defined by a min and max vectors
  79769. * @param min defines the min vector to use
  79770. * @param max defines the max vector to use
  79771. * @returns true if there is an intersection
  79772. */
  79773. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  79774. /**
  79775. * Tests if two bounding boxes are intersections
  79776. * @param box0 defines the first box to test
  79777. * @param box1 defines the second box to test
  79778. * @returns true if there is an intersection
  79779. */
  79780. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  79781. /**
  79782. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  79783. * @param minPoint defines the minimum vector of the bounding box
  79784. * @param maxPoint defines the maximum vector of the bounding box
  79785. * @param sphereCenter defines the sphere center
  79786. * @param sphereRadius defines the sphere radius
  79787. * @returns true if there is an intersection
  79788. */
  79789. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  79790. /**
  79791. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  79792. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79793. * @param frustumPlanes defines the frustum planes to test
  79794. * @return true if there is an inclusion
  79795. */
  79796. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79797. /**
  79798. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  79799. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79800. * @param frustumPlanes defines the frustum planes to test
  79801. * @return true if there is an intersection
  79802. */
  79803. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79804. }
  79805. }
  79806. declare module BABYLON {
  79807. /** @hidden */
  79808. export class Collider {
  79809. /** Define if a collision was found */
  79810. collisionFound: boolean;
  79811. /**
  79812. * Define last intersection point in local space
  79813. */
  79814. intersectionPoint: Vector3;
  79815. /**
  79816. * Define last collided mesh
  79817. */
  79818. collidedMesh: Nullable<AbstractMesh>;
  79819. private _collisionPoint;
  79820. private _planeIntersectionPoint;
  79821. private _tempVector;
  79822. private _tempVector2;
  79823. private _tempVector3;
  79824. private _tempVector4;
  79825. private _edge;
  79826. private _baseToVertex;
  79827. private _destinationPoint;
  79828. private _slidePlaneNormal;
  79829. private _displacementVector;
  79830. /** @hidden */
  79831. _radius: Vector3;
  79832. /** @hidden */
  79833. _retry: number;
  79834. private _velocity;
  79835. private _basePoint;
  79836. private _epsilon;
  79837. /** @hidden */
  79838. _velocityWorldLength: number;
  79839. /** @hidden */
  79840. _basePointWorld: Vector3;
  79841. private _velocityWorld;
  79842. private _normalizedVelocity;
  79843. /** @hidden */
  79844. _initialVelocity: Vector3;
  79845. /** @hidden */
  79846. _initialPosition: Vector3;
  79847. private _nearestDistance;
  79848. private _collisionMask;
  79849. get collisionMask(): number;
  79850. set collisionMask(mask: number);
  79851. /**
  79852. * Gets the plane normal used to compute the sliding response (in local space)
  79853. */
  79854. get slidePlaneNormal(): Vector3;
  79855. /** @hidden */
  79856. _initialize(source: Vector3, dir: Vector3, e: number): void;
  79857. /** @hidden */
  79858. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  79859. /** @hidden */
  79860. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  79861. /** @hidden */
  79862. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79863. /** @hidden */
  79864. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79865. /** @hidden */
  79866. _getResponse(pos: Vector3, vel: Vector3): void;
  79867. }
  79868. }
  79869. declare module BABYLON {
  79870. /**
  79871. * Interface for cullable objects
  79872. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  79873. */
  79874. export interface ICullable {
  79875. /**
  79876. * Checks if the object or part of the object is in the frustum
  79877. * @param frustumPlanes Camera near/planes
  79878. * @returns true if the object is in frustum otherwise false
  79879. */
  79880. isInFrustum(frustumPlanes: Plane[]): boolean;
  79881. /**
  79882. * Checks if a cullable object (mesh...) is in the camera frustum
  79883. * Unlike isInFrustum this cheks the full bounding box
  79884. * @param frustumPlanes Camera near/planes
  79885. * @returns true if the object is in frustum otherwise false
  79886. */
  79887. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79888. }
  79889. /**
  79890. * Info for a bounding data of a mesh
  79891. */
  79892. export class BoundingInfo implements ICullable {
  79893. /**
  79894. * Bounding box for the mesh
  79895. */
  79896. readonly boundingBox: BoundingBox;
  79897. /**
  79898. * Bounding sphere for the mesh
  79899. */
  79900. readonly boundingSphere: BoundingSphere;
  79901. private _isLocked;
  79902. private static readonly TmpVector3;
  79903. /**
  79904. * Constructs bounding info
  79905. * @param minimum min vector of the bounding box/sphere
  79906. * @param maximum max vector of the bounding box/sphere
  79907. * @param worldMatrix defines the new world matrix
  79908. */
  79909. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79910. /**
  79911. * Recreates the entire bounding info from scratch as if we call the constructor in place
  79912. * @param min defines the new minimum vector (in local space)
  79913. * @param max defines the new maximum vector (in local space)
  79914. * @param worldMatrix defines the new world matrix
  79915. */
  79916. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79917. /**
  79918. * min vector of the bounding box/sphere
  79919. */
  79920. get minimum(): Vector3;
  79921. /**
  79922. * max vector of the bounding box/sphere
  79923. */
  79924. get maximum(): Vector3;
  79925. /**
  79926. * If the info is locked and won't be updated to avoid perf overhead
  79927. */
  79928. get isLocked(): boolean;
  79929. set isLocked(value: boolean);
  79930. /**
  79931. * Updates the bounding sphere and box
  79932. * @param world world matrix to be used to update
  79933. */
  79934. update(world: DeepImmutable<Matrix>): void;
  79935. /**
  79936. * Recreate the bounding info to be centered around a specific point given a specific extend.
  79937. * @param center New center of the bounding info
  79938. * @param extend New extend of the bounding info
  79939. * @returns the current bounding info
  79940. */
  79941. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  79942. /**
  79943. * Scale the current bounding info by applying a scale factor
  79944. * @param factor defines the scale factor to apply
  79945. * @returns the current bounding info
  79946. */
  79947. scale(factor: number): BoundingInfo;
  79948. /**
  79949. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  79950. * @param frustumPlanes defines the frustum to test
  79951. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  79952. * @returns true if the bounding info is in the frustum planes
  79953. */
  79954. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  79955. /**
  79956. * Gets the world distance between the min and max points of the bounding box
  79957. */
  79958. get diagonalLength(): number;
  79959. /**
  79960. * Checks if a cullable object (mesh...) is in the camera frustum
  79961. * Unlike isInFrustum this cheks the full bounding box
  79962. * @param frustumPlanes Camera near/planes
  79963. * @returns true if the object is in frustum otherwise false
  79964. */
  79965. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79966. /** @hidden */
  79967. _checkCollision(collider: Collider): boolean;
  79968. /**
  79969. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  79970. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79971. * @param point the point to check intersection with
  79972. * @returns if the point intersects
  79973. */
  79974. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79975. /**
  79976. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  79977. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79978. * @param boundingInfo the bounding info to check intersection with
  79979. * @param precise if the intersection should be done using OBB
  79980. * @returns if the bounding info intersects
  79981. */
  79982. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  79983. }
  79984. }
  79985. declare module BABYLON {
  79986. /**
  79987. * Extracts minimum and maximum values from a list of indexed positions
  79988. * @param positions defines the positions to use
  79989. * @param indices defines the indices to the positions
  79990. * @param indexStart defines the start index
  79991. * @param indexCount defines the end index
  79992. * @param bias defines bias value to add to the result
  79993. * @return minimum and maximum values
  79994. */
  79995. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  79996. minimum: Vector3;
  79997. maximum: Vector3;
  79998. };
  79999. /**
  80000. * Extracts minimum and maximum values from a list of positions
  80001. * @param positions defines the positions to use
  80002. * @param start defines the start index in the positions array
  80003. * @param count defines the number of positions to handle
  80004. * @param bias defines bias value to add to the result
  80005. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80006. * @return minimum and maximum values
  80007. */
  80008. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80009. minimum: Vector3;
  80010. maximum: Vector3;
  80011. };
  80012. }
  80013. declare module BABYLON {
  80014. /** @hidden */
  80015. export class WebGLDataBuffer extends DataBuffer {
  80016. private _buffer;
  80017. constructor(resource: WebGLBuffer);
  80018. get underlyingResource(): any;
  80019. }
  80020. }
  80021. declare module BABYLON {
  80022. /** @hidden */
  80023. export class WebGLPipelineContext implements IPipelineContext {
  80024. engine: ThinEngine;
  80025. program: Nullable<WebGLProgram>;
  80026. context?: WebGLRenderingContext;
  80027. vertexShader?: WebGLShader;
  80028. fragmentShader?: WebGLShader;
  80029. isParallelCompiled: boolean;
  80030. onCompiled?: () => void;
  80031. transformFeedback?: WebGLTransformFeedback | null;
  80032. vertexCompilationError: Nullable<string>;
  80033. fragmentCompilationError: Nullable<string>;
  80034. programLinkError: Nullable<string>;
  80035. programValidationError: Nullable<string>;
  80036. get isAsync(): boolean;
  80037. get isReady(): boolean;
  80038. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80039. }
  80040. }
  80041. declare module BABYLON {
  80042. interface ThinEngine {
  80043. /**
  80044. * Create an uniform buffer
  80045. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80046. * @param elements defines the content of the uniform buffer
  80047. * @returns the webGL uniform buffer
  80048. */
  80049. createUniformBuffer(elements: FloatArray): DataBuffer;
  80050. /**
  80051. * Create a dynamic uniform buffer
  80052. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80053. * @param elements defines the content of the uniform buffer
  80054. * @returns the webGL uniform buffer
  80055. */
  80056. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80057. /**
  80058. * Update an existing uniform buffer
  80059. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80060. * @param uniformBuffer defines the target uniform buffer
  80061. * @param elements defines the content to update
  80062. * @param offset defines the offset in the uniform buffer where update should start
  80063. * @param count defines the size of the data to update
  80064. */
  80065. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80066. /**
  80067. * Bind an uniform buffer to the current webGL context
  80068. * @param buffer defines the buffer to bind
  80069. */
  80070. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80071. /**
  80072. * Bind a buffer to the current webGL context at a given location
  80073. * @param buffer defines the buffer to bind
  80074. * @param location defines the index where to bind the buffer
  80075. */
  80076. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80077. /**
  80078. * Bind a specific block at a given index in a specific shader program
  80079. * @param pipelineContext defines the pipeline context to use
  80080. * @param blockName defines the block name
  80081. * @param index defines the index where to bind the block
  80082. */
  80083. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80084. }
  80085. }
  80086. declare module BABYLON {
  80087. /**
  80088. * Uniform buffer objects.
  80089. *
  80090. * Handles blocks of uniform on the GPU.
  80091. *
  80092. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80093. *
  80094. * For more information, please refer to :
  80095. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80096. */
  80097. export class UniformBuffer {
  80098. private _engine;
  80099. private _buffer;
  80100. private _data;
  80101. private _bufferData;
  80102. private _dynamic?;
  80103. private _uniformLocations;
  80104. private _uniformSizes;
  80105. private _uniformLocationPointer;
  80106. private _needSync;
  80107. private _noUBO;
  80108. private _currentEffect;
  80109. /** @hidden */
  80110. _alreadyBound: boolean;
  80111. private static _MAX_UNIFORM_SIZE;
  80112. private static _tempBuffer;
  80113. /**
  80114. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80115. * This is dynamic to allow compat with webgl 1 and 2.
  80116. * You will need to pass the name of the uniform as well as the value.
  80117. */
  80118. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80119. /**
  80120. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80121. * This is dynamic to allow compat with webgl 1 and 2.
  80122. * You will need to pass the name of the uniform as well as the value.
  80123. */
  80124. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80125. /**
  80126. * Lambda to Update a single float in a uniform buffer.
  80127. * This is dynamic to allow compat with webgl 1 and 2.
  80128. * You will need to pass the name of the uniform as well as the value.
  80129. */
  80130. updateFloat: (name: string, x: number) => void;
  80131. /**
  80132. * Lambda to Update a vec2 of float in a uniform buffer.
  80133. * This is dynamic to allow compat with webgl 1 and 2.
  80134. * You will need to pass the name of the uniform as well as the value.
  80135. */
  80136. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80137. /**
  80138. * Lambda to Update a vec3 of float in a uniform buffer.
  80139. * This is dynamic to allow compat with webgl 1 and 2.
  80140. * You will need to pass the name of the uniform as well as the value.
  80141. */
  80142. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80143. /**
  80144. * Lambda to Update a vec4 of float in a uniform buffer.
  80145. * This is dynamic to allow compat with webgl 1 and 2.
  80146. * You will need to pass the name of the uniform as well as the value.
  80147. */
  80148. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80149. /**
  80150. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80151. * This is dynamic to allow compat with webgl 1 and 2.
  80152. * You will need to pass the name of the uniform as well as the value.
  80153. */
  80154. updateMatrix: (name: string, mat: Matrix) => void;
  80155. /**
  80156. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80157. * This is dynamic to allow compat with webgl 1 and 2.
  80158. * You will need to pass the name of the uniform as well as the value.
  80159. */
  80160. updateVector3: (name: string, vector: Vector3) => void;
  80161. /**
  80162. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80163. * This is dynamic to allow compat with webgl 1 and 2.
  80164. * You will need to pass the name of the uniform as well as the value.
  80165. */
  80166. updateVector4: (name: string, vector: Vector4) => void;
  80167. /**
  80168. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80169. * This is dynamic to allow compat with webgl 1 and 2.
  80170. * You will need to pass the name of the uniform as well as the value.
  80171. */
  80172. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80173. /**
  80174. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80175. * This is dynamic to allow compat with webgl 1 and 2.
  80176. * You will need to pass the name of the uniform as well as the value.
  80177. */
  80178. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80179. /**
  80180. * Instantiates a new Uniform buffer objects.
  80181. *
  80182. * Handles blocks of uniform on the GPU.
  80183. *
  80184. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80185. *
  80186. * For more information, please refer to :
  80187. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80188. * @param engine Define the engine the buffer is associated with
  80189. * @param data Define the data contained in the buffer
  80190. * @param dynamic Define if the buffer is updatable
  80191. */
  80192. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80193. /**
  80194. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80195. * or just falling back on setUniformXXX calls.
  80196. */
  80197. get useUbo(): boolean;
  80198. /**
  80199. * Indicates if the WebGL underlying uniform buffer is in sync
  80200. * with the javascript cache data.
  80201. */
  80202. get isSync(): boolean;
  80203. /**
  80204. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80205. * Also, a dynamic UniformBuffer will disable cache verification and always
  80206. * update the underlying WebGL uniform buffer to the GPU.
  80207. * @returns if Dynamic, otherwise false
  80208. */
  80209. isDynamic(): boolean;
  80210. /**
  80211. * The data cache on JS side.
  80212. * @returns the underlying data as a float array
  80213. */
  80214. getData(): Float32Array;
  80215. /**
  80216. * The underlying WebGL Uniform buffer.
  80217. * @returns the webgl buffer
  80218. */
  80219. getBuffer(): Nullable<DataBuffer>;
  80220. /**
  80221. * std140 layout specifies how to align data within an UBO structure.
  80222. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80223. * for specs.
  80224. */
  80225. private _fillAlignment;
  80226. /**
  80227. * Adds an uniform in the buffer.
  80228. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80229. * for the layout to be correct !
  80230. * @param name Name of the uniform, as used in the uniform block in the shader.
  80231. * @param size Data size, or data directly.
  80232. */
  80233. addUniform(name: string, size: number | number[]): void;
  80234. /**
  80235. * Adds a Matrix 4x4 to the uniform buffer.
  80236. * @param name Name of the uniform, as used in the uniform block in the shader.
  80237. * @param mat A 4x4 matrix.
  80238. */
  80239. addMatrix(name: string, mat: Matrix): void;
  80240. /**
  80241. * Adds a vec2 to the uniform buffer.
  80242. * @param name Name of the uniform, as used in the uniform block in the shader.
  80243. * @param x Define the x component value of the vec2
  80244. * @param y Define the y component value of the vec2
  80245. */
  80246. addFloat2(name: string, x: number, y: number): void;
  80247. /**
  80248. * Adds a vec3 to the uniform buffer.
  80249. * @param name Name of the uniform, as used in the uniform block in the shader.
  80250. * @param x Define the x component value of the vec3
  80251. * @param y Define the y component value of the vec3
  80252. * @param z Define the z component value of the vec3
  80253. */
  80254. addFloat3(name: string, x: number, y: number, z: number): void;
  80255. /**
  80256. * Adds a vec3 to the uniform buffer.
  80257. * @param name Name of the uniform, as used in the uniform block in the shader.
  80258. * @param color Define the vec3 from a Color
  80259. */
  80260. addColor3(name: string, color: Color3): void;
  80261. /**
  80262. * Adds a vec4 to the uniform buffer.
  80263. * @param name Name of the uniform, as used in the uniform block in the shader.
  80264. * @param color Define the rgb components from a Color
  80265. * @param alpha Define the a component of the vec4
  80266. */
  80267. addColor4(name: string, color: Color3, alpha: number): void;
  80268. /**
  80269. * Adds a vec3 to the uniform buffer.
  80270. * @param name Name of the uniform, as used in the uniform block in the shader.
  80271. * @param vector Define the vec3 components from a Vector
  80272. */
  80273. addVector3(name: string, vector: Vector3): void;
  80274. /**
  80275. * Adds a Matrix 3x3 to the uniform buffer.
  80276. * @param name Name of the uniform, as used in the uniform block in the shader.
  80277. */
  80278. addMatrix3x3(name: string): void;
  80279. /**
  80280. * Adds a Matrix 2x2 to the uniform buffer.
  80281. * @param name Name of the uniform, as used in the uniform block in the shader.
  80282. */
  80283. addMatrix2x2(name: string): void;
  80284. /**
  80285. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80286. */
  80287. create(): void;
  80288. /** @hidden */
  80289. _rebuild(): void;
  80290. /**
  80291. * Updates the WebGL Uniform Buffer on the GPU.
  80292. * If the `dynamic` flag is set to true, no cache comparison is done.
  80293. * Otherwise, the buffer will be updated only if the cache differs.
  80294. */
  80295. update(): void;
  80296. /**
  80297. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80298. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80299. * @param data Define the flattened data
  80300. * @param size Define the size of the data.
  80301. */
  80302. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80303. private _valueCache;
  80304. private _cacheMatrix;
  80305. private _updateMatrix3x3ForUniform;
  80306. private _updateMatrix3x3ForEffect;
  80307. private _updateMatrix2x2ForEffect;
  80308. private _updateMatrix2x2ForUniform;
  80309. private _updateFloatForEffect;
  80310. private _updateFloatForUniform;
  80311. private _updateFloat2ForEffect;
  80312. private _updateFloat2ForUniform;
  80313. private _updateFloat3ForEffect;
  80314. private _updateFloat3ForUniform;
  80315. private _updateFloat4ForEffect;
  80316. private _updateFloat4ForUniform;
  80317. private _updateMatrixForEffect;
  80318. private _updateMatrixForUniform;
  80319. private _updateVector3ForEffect;
  80320. private _updateVector3ForUniform;
  80321. private _updateVector4ForEffect;
  80322. private _updateVector4ForUniform;
  80323. private _updateColor3ForEffect;
  80324. private _updateColor3ForUniform;
  80325. private _updateColor4ForEffect;
  80326. private _updateColor4ForUniform;
  80327. /**
  80328. * Sets a sampler uniform on the effect.
  80329. * @param name Define the name of the sampler.
  80330. * @param texture Define the texture to set in the sampler
  80331. */
  80332. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80333. /**
  80334. * Directly updates the value of the uniform in the cache AND on the GPU.
  80335. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80336. * @param data Define the flattened data
  80337. */
  80338. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80339. /**
  80340. * Binds this uniform buffer to an effect.
  80341. * @param effect Define the effect to bind the buffer to
  80342. * @param name Name of the uniform block in the shader.
  80343. */
  80344. bindToEffect(effect: Effect, name: string): void;
  80345. /**
  80346. * Disposes the uniform buffer.
  80347. */
  80348. dispose(): void;
  80349. }
  80350. }
  80351. declare module BABYLON {
  80352. /**
  80353. * Enum that determines the text-wrapping mode to use.
  80354. */
  80355. export enum InspectableType {
  80356. /**
  80357. * Checkbox for booleans
  80358. */
  80359. Checkbox = 0,
  80360. /**
  80361. * Sliders for numbers
  80362. */
  80363. Slider = 1,
  80364. /**
  80365. * Vector3
  80366. */
  80367. Vector3 = 2,
  80368. /**
  80369. * Quaternions
  80370. */
  80371. Quaternion = 3,
  80372. /**
  80373. * Color3
  80374. */
  80375. Color3 = 4,
  80376. /**
  80377. * String
  80378. */
  80379. String = 5
  80380. }
  80381. /**
  80382. * Interface used to define custom inspectable properties.
  80383. * This interface is used by the inspector to display custom property grids
  80384. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80385. */
  80386. export interface IInspectable {
  80387. /**
  80388. * Gets the label to display
  80389. */
  80390. label: string;
  80391. /**
  80392. * Gets the name of the property to edit
  80393. */
  80394. propertyName: string;
  80395. /**
  80396. * Gets the type of the editor to use
  80397. */
  80398. type: InspectableType;
  80399. /**
  80400. * Gets the minimum value of the property when using in "slider" mode
  80401. */
  80402. min?: number;
  80403. /**
  80404. * Gets the maximum value of the property when using in "slider" mode
  80405. */
  80406. max?: number;
  80407. /**
  80408. * Gets the setp to use when using in "slider" mode
  80409. */
  80410. step?: number;
  80411. }
  80412. }
  80413. declare module BABYLON {
  80414. /**
  80415. * Class used to provide helper for timing
  80416. */
  80417. export class TimingTools {
  80418. /**
  80419. * Polyfill for setImmediate
  80420. * @param action defines the action to execute after the current execution block
  80421. */
  80422. static SetImmediate(action: () => void): void;
  80423. }
  80424. }
  80425. declare module BABYLON {
  80426. /**
  80427. * Class used to enable instatition of objects by class name
  80428. */
  80429. export class InstantiationTools {
  80430. /**
  80431. * Use this object to register external classes like custom textures or material
  80432. * to allow the laoders to instantiate them
  80433. */
  80434. static RegisteredExternalClasses: {
  80435. [key: string]: Object;
  80436. };
  80437. /**
  80438. * Tries to instantiate a new object from a given class name
  80439. * @param className defines the class name to instantiate
  80440. * @returns the new object or null if the system was not able to do the instantiation
  80441. */
  80442. static Instantiate(className: string): any;
  80443. }
  80444. }
  80445. declare module BABYLON {
  80446. /**
  80447. * Define options used to create a depth texture
  80448. */
  80449. export class DepthTextureCreationOptions {
  80450. /** Specifies whether or not a stencil should be allocated in the texture */
  80451. generateStencil?: boolean;
  80452. /** Specifies whether or not bilinear filtering is enable on the texture */
  80453. bilinearFiltering?: boolean;
  80454. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80455. comparisonFunction?: number;
  80456. /** Specifies if the created texture is a cube texture */
  80457. isCube?: boolean;
  80458. }
  80459. }
  80460. declare module BABYLON {
  80461. interface ThinEngine {
  80462. /**
  80463. * Creates a depth stencil cube texture.
  80464. * This is only available in WebGL 2.
  80465. * @param size The size of face edge in the cube texture.
  80466. * @param options The options defining the cube texture.
  80467. * @returns The cube texture
  80468. */
  80469. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80470. /**
  80471. * Creates a cube texture
  80472. * @param rootUrl defines the url where the files to load is located
  80473. * @param scene defines the current scene
  80474. * @param files defines the list of files to load (1 per face)
  80475. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80476. * @param onLoad defines an optional callback raised when the texture is loaded
  80477. * @param onError defines an optional callback raised if there is an issue to load the texture
  80478. * @param format defines the format of the data
  80479. * @param forcedExtension defines the extension to use to pick the right loader
  80480. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80481. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80482. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80483. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80484. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80485. * @returns the cube texture as an InternalTexture
  80486. */
  80487. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  80488. /**
  80489. * Creates a cube texture
  80490. * @param rootUrl defines the url where the files to load is located
  80491. * @param scene defines the current scene
  80492. * @param files defines the list of files to load (1 per face)
  80493. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80494. * @param onLoad defines an optional callback raised when the texture is loaded
  80495. * @param onError defines an optional callback raised if there is an issue to load the texture
  80496. * @param format defines the format of the data
  80497. * @param forcedExtension defines the extension to use to pick the right loader
  80498. * @returns the cube texture as an InternalTexture
  80499. */
  80500. 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;
  80501. /**
  80502. * Creates a cube texture
  80503. * @param rootUrl defines the url where the files to load is located
  80504. * @param scene defines the current scene
  80505. * @param files defines the list of files to load (1 per face)
  80506. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80507. * @param onLoad defines an optional callback raised when the texture is loaded
  80508. * @param onError defines an optional callback raised if there is an issue to load the texture
  80509. * @param format defines the format of the data
  80510. * @param forcedExtension defines the extension to use to pick the right loader
  80511. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80512. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80513. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80514. * @returns the cube texture as an InternalTexture
  80515. */
  80516. 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;
  80517. /** @hidden */
  80518. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80519. /** @hidden */
  80520. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80521. /** @hidden */
  80522. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80523. /** @hidden */
  80524. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80525. /**
  80526. * @hidden
  80527. */
  80528. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80529. }
  80530. }
  80531. declare module BABYLON {
  80532. /**
  80533. * Class for creating a cube texture
  80534. */
  80535. export class CubeTexture extends BaseTexture {
  80536. private _delayedOnLoad;
  80537. /**
  80538. * The url of the texture
  80539. */
  80540. url: string;
  80541. /**
  80542. * Gets or sets the center of the bounding box associated with the cube texture.
  80543. * It must define where the camera used to render the texture was set
  80544. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80545. */
  80546. boundingBoxPosition: Vector3;
  80547. private _boundingBoxSize;
  80548. /**
  80549. * Gets or sets the size of the bounding box associated with the cube texture
  80550. * When defined, the cubemap will switch to local mode
  80551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80552. * @example https://www.babylonjs-playground.com/#RNASML
  80553. */
  80554. set boundingBoxSize(value: Vector3);
  80555. /**
  80556. * Returns the bounding box size
  80557. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80558. */
  80559. get boundingBoxSize(): Vector3;
  80560. protected _rotationY: number;
  80561. /**
  80562. * Sets texture matrix rotation angle around Y axis in radians.
  80563. */
  80564. set rotationY(value: number);
  80565. /**
  80566. * Gets texture matrix rotation angle around Y axis radians.
  80567. */
  80568. get rotationY(): number;
  80569. /**
  80570. * Are mip maps generated for this texture or not.
  80571. */
  80572. get noMipmap(): boolean;
  80573. private _noMipmap;
  80574. private _files;
  80575. protected _forcedExtension: Nullable<string>;
  80576. private _extensions;
  80577. private _textureMatrix;
  80578. private _format;
  80579. private _createPolynomials;
  80580. /** @hidden */
  80581. _prefiltered: boolean;
  80582. /**
  80583. * Creates a cube texture from an array of image urls
  80584. * @param files defines an array of image urls
  80585. * @param scene defines the hosting scene
  80586. * @param noMipmap specifies if mip maps are not used
  80587. * @returns a cube texture
  80588. */
  80589. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80590. /**
  80591. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80592. * @param url defines the url of the prefiltered texture
  80593. * @param scene defines the scene the texture is attached to
  80594. * @param forcedExtension defines the extension of the file if different from the url
  80595. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80596. * @return the prefiltered texture
  80597. */
  80598. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80599. /**
  80600. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80601. * as prefiltered data.
  80602. * @param rootUrl defines the url of the texture or the root name of the six images
  80603. * @param scene defines the scene the texture is attached to
  80604. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80605. * @param noMipmap defines if mipmaps should be created or not
  80606. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80607. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80608. * @param onError defines a callback triggered in case of error during load
  80609. * @param format defines the internal format to use for the texture once loaded
  80610. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80611. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80612. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80613. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80614. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80615. * @return the cube texture
  80616. */
  80617. 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);
  80618. /**
  80619. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80620. */
  80621. get isPrefiltered(): boolean;
  80622. /**
  80623. * Get the current class name of the texture useful for serialization or dynamic coding.
  80624. * @returns "CubeTexture"
  80625. */
  80626. getClassName(): string;
  80627. /**
  80628. * Update the url (and optional buffer) of this texture if url was null during construction.
  80629. * @param url the url of the texture
  80630. * @param forcedExtension defines the extension to use
  80631. * @param onLoad callback called when the texture is loaded (defaults to null)
  80632. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80633. */
  80634. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80635. /**
  80636. * Delays loading of the cube texture
  80637. * @param forcedExtension defines the extension to use
  80638. */
  80639. delayLoad(forcedExtension?: string): void;
  80640. /**
  80641. * Returns the reflection texture matrix
  80642. * @returns the reflection texture matrix
  80643. */
  80644. getReflectionTextureMatrix(): Matrix;
  80645. /**
  80646. * Sets the reflection texture matrix
  80647. * @param value Reflection texture matrix
  80648. */
  80649. setReflectionTextureMatrix(value: Matrix): void;
  80650. /**
  80651. * Parses text to create a cube texture
  80652. * @param parsedTexture define the serialized text to read from
  80653. * @param scene defines the hosting scene
  80654. * @param rootUrl defines the root url of the cube texture
  80655. * @returns a cube texture
  80656. */
  80657. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  80658. /**
  80659. * Makes a clone, or deep copy, of the cube texture
  80660. * @returns a new cube texture
  80661. */
  80662. clone(): CubeTexture;
  80663. }
  80664. }
  80665. declare module BABYLON {
  80666. /**
  80667. * Manages the defines for the Material
  80668. */
  80669. export class MaterialDefines {
  80670. /** @hidden */
  80671. protected _keys: string[];
  80672. private _isDirty;
  80673. /** @hidden */
  80674. _renderId: number;
  80675. /** @hidden */
  80676. _areLightsDirty: boolean;
  80677. /** @hidden */
  80678. _areLightsDisposed: boolean;
  80679. /** @hidden */
  80680. _areAttributesDirty: boolean;
  80681. /** @hidden */
  80682. _areTexturesDirty: boolean;
  80683. /** @hidden */
  80684. _areFresnelDirty: boolean;
  80685. /** @hidden */
  80686. _areMiscDirty: boolean;
  80687. /** @hidden */
  80688. _areImageProcessingDirty: boolean;
  80689. /** @hidden */
  80690. _normals: boolean;
  80691. /** @hidden */
  80692. _uvs: boolean;
  80693. /** @hidden */
  80694. _needNormals: boolean;
  80695. /** @hidden */
  80696. _needUVs: boolean;
  80697. [id: string]: any;
  80698. /**
  80699. * Specifies if the material needs to be re-calculated
  80700. */
  80701. get isDirty(): boolean;
  80702. /**
  80703. * Marks the material to indicate that it has been re-calculated
  80704. */
  80705. markAsProcessed(): void;
  80706. /**
  80707. * Marks the material to indicate that it needs to be re-calculated
  80708. */
  80709. markAsUnprocessed(): void;
  80710. /**
  80711. * Marks the material to indicate all of its defines need to be re-calculated
  80712. */
  80713. markAllAsDirty(): void;
  80714. /**
  80715. * Marks the material to indicate that image processing needs to be re-calculated
  80716. */
  80717. markAsImageProcessingDirty(): void;
  80718. /**
  80719. * Marks the material to indicate the lights need to be re-calculated
  80720. * @param disposed Defines whether the light is dirty due to dispose or not
  80721. */
  80722. markAsLightDirty(disposed?: boolean): void;
  80723. /**
  80724. * Marks the attribute state as changed
  80725. */
  80726. markAsAttributesDirty(): void;
  80727. /**
  80728. * Marks the texture state as changed
  80729. */
  80730. markAsTexturesDirty(): void;
  80731. /**
  80732. * Marks the fresnel state as changed
  80733. */
  80734. markAsFresnelDirty(): void;
  80735. /**
  80736. * Marks the misc state as changed
  80737. */
  80738. markAsMiscDirty(): void;
  80739. /**
  80740. * Rebuilds the material defines
  80741. */
  80742. rebuild(): void;
  80743. /**
  80744. * Specifies if two material defines are equal
  80745. * @param other - A material define instance to compare to
  80746. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  80747. */
  80748. isEqual(other: MaterialDefines): boolean;
  80749. /**
  80750. * Clones this instance's defines to another instance
  80751. * @param other - material defines to clone values to
  80752. */
  80753. cloneTo(other: MaterialDefines): void;
  80754. /**
  80755. * Resets the material define values
  80756. */
  80757. reset(): void;
  80758. /**
  80759. * Converts the material define values to a string
  80760. * @returns - String of material define information
  80761. */
  80762. toString(): string;
  80763. }
  80764. }
  80765. declare module BABYLON {
  80766. /**
  80767. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  80768. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  80769. * 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;
  80770. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  80771. */
  80772. export class ColorCurves {
  80773. private _dirty;
  80774. private _tempColor;
  80775. private _globalCurve;
  80776. private _highlightsCurve;
  80777. private _midtonesCurve;
  80778. private _shadowsCurve;
  80779. private _positiveCurve;
  80780. private _negativeCurve;
  80781. private _globalHue;
  80782. private _globalDensity;
  80783. private _globalSaturation;
  80784. private _globalExposure;
  80785. /**
  80786. * Gets the global Hue value.
  80787. * 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).
  80788. */
  80789. get globalHue(): number;
  80790. /**
  80791. * Sets the global Hue value.
  80792. * 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).
  80793. */
  80794. set globalHue(value: number);
  80795. /**
  80796. * Gets the global Density value.
  80797. * 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.
  80798. * Values less than zero provide a filter of opposite hue.
  80799. */
  80800. get globalDensity(): number;
  80801. /**
  80802. * Sets the global Density value.
  80803. * 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.
  80804. * Values less than zero provide a filter of opposite hue.
  80805. */
  80806. set globalDensity(value: number);
  80807. /**
  80808. * Gets the global Saturation value.
  80809. * 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.
  80810. */
  80811. get globalSaturation(): number;
  80812. /**
  80813. * Sets the global Saturation value.
  80814. * 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.
  80815. */
  80816. set globalSaturation(value: number);
  80817. /**
  80818. * Gets the global Exposure value.
  80819. * 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.
  80820. */
  80821. get globalExposure(): number;
  80822. /**
  80823. * Sets the global Exposure value.
  80824. * 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.
  80825. */
  80826. set globalExposure(value: number);
  80827. private _highlightsHue;
  80828. private _highlightsDensity;
  80829. private _highlightsSaturation;
  80830. private _highlightsExposure;
  80831. /**
  80832. * Gets the highlights Hue value.
  80833. * 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).
  80834. */
  80835. get highlightsHue(): number;
  80836. /**
  80837. * Sets the highlights Hue value.
  80838. * 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).
  80839. */
  80840. set highlightsHue(value: number);
  80841. /**
  80842. * Gets the highlights Density value.
  80843. * 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.
  80844. * Values less than zero provide a filter of opposite hue.
  80845. */
  80846. get highlightsDensity(): number;
  80847. /**
  80848. * Sets the highlights Density value.
  80849. * 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.
  80850. * Values less than zero provide a filter of opposite hue.
  80851. */
  80852. set highlightsDensity(value: number);
  80853. /**
  80854. * Gets the highlights Saturation value.
  80855. * 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.
  80856. */
  80857. get highlightsSaturation(): number;
  80858. /**
  80859. * Sets the highlights Saturation value.
  80860. * 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.
  80861. */
  80862. set highlightsSaturation(value: number);
  80863. /**
  80864. * Gets the highlights Exposure value.
  80865. * 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.
  80866. */
  80867. get highlightsExposure(): number;
  80868. /**
  80869. * Sets the highlights Exposure value.
  80870. * 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.
  80871. */
  80872. set highlightsExposure(value: number);
  80873. private _midtonesHue;
  80874. private _midtonesDensity;
  80875. private _midtonesSaturation;
  80876. private _midtonesExposure;
  80877. /**
  80878. * Gets the midtones Hue value.
  80879. * 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).
  80880. */
  80881. get midtonesHue(): number;
  80882. /**
  80883. * Sets the midtones Hue value.
  80884. * 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).
  80885. */
  80886. set midtonesHue(value: number);
  80887. /**
  80888. * Gets the midtones Density value.
  80889. * 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.
  80890. * Values less than zero provide a filter of opposite hue.
  80891. */
  80892. get midtonesDensity(): number;
  80893. /**
  80894. * Sets the midtones Density value.
  80895. * 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.
  80896. * Values less than zero provide a filter of opposite hue.
  80897. */
  80898. set midtonesDensity(value: number);
  80899. /**
  80900. * Gets the midtones Saturation value.
  80901. * 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.
  80902. */
  80903. get midtonesSaturation(): number;
  80904. /**
  80905. * Sets the midtones Saturation value.
  80906. * 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.
  80907. */
  80908. set midtonesSaturation(value: number);
  80909. /**
  80910. * Gets the midtones Exposure value.
  80911. * 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.
  80912. */
  80913. get midtonesExposure(): number;
  80914. /**
  80915. * Sets the midtones Exposure value.
  80916. * 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.
  80917. */
  80918. set midtonesExposure(value: number);
  80919. private _shadowsHue;
  80920. private _shadowsDensity;
  80921. private _shadowsSaturation;
  80922. private _shadowsExposure;
  80923. /**
  80924. * Gets the shadows Hue value.
  80925. * 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).
  80926. */
  80927. get shadowsHue(): number;
  80928. /**
  80929. * Sets the shadows Hue value.
  80930. * 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).
  80931. */
  80932. set shadowsHue(value: number);
  80933. /**
  80934. * Gets the shadows Density value.
  80935. * 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.
  80936. * Values less than zero provide a filter of opposite hue.
  80937. */
  80938. get shadowsDensity(): number;
  80939. /**
  80940. * Sets the shadows Density value.
  80941. * 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.
  80942. * Values less than zero provide a filter of opposite hue.
  80943. */
  80944. set shadowsDensity(value: number);
  80945. /**
  80946. * Gets the shadows Saturation value.
  80947. * 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.
  80948. */
  80949. get shadowsSaturation(): number;
  80950. /**
  80951. * Sets the shadows Saturation value.
  80952. * 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.
  80953. */
  80954. set shadowsSaturation(value: number);
  80955. /**
  80956. * Gets the shadows Exposure value.
  80957. * 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.
  80958. */
  80959. get shadowsExposure(): number;
  80960. /**
  80961. * Sets the shadows Exposure value.
  80962. * 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.
  80963. */
  80964. set shadowsExposure(value: number);
  80965. /**
  80966. * Returns the class name
  80967. * @returns The class name
  80968. */
  80969. getClassName(): string;
  80970. /**
  80971. * Binds the color curves to the shader.
  80972. * @param colorCurves The color curve to bind
  80973. * @param effect The effect to bind to
  80974. * @param positiveUniform The positive uniform shader parameter
  80975. * @param neutralUniform The neutral uniform shader parameter
  80976. * @param negativeUniform The negative uniform shader parameter
  80977. */
  80978. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  80979. /**
  80980. * Prepare the list of uniforms associated with the ColorCurves effects.
  80981. * @param uniformsList The list of uniforms used in the effect
  80982. */
  80983. static PrepareUniforms(uniformsList: string[]): void;
  80984. /**
  80985. * Returns color grading data based on a hue, density, saturation and exposure value.
  80986. * @param filterHue The hue of the color filter.
  80987. * @param filterDensity The density of the color filter.
  80988. * @param saturation The saturation.
  80989. * @param exposure The exposure.
  80990. * @param result The result data container.
  80991. */
  80992. private getColorGradingDataToRef;
  80993. /**
  80994. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  80995. * @param value The input slider value in range [-100,100].
  80996. * @returns Adjusted value.
  80997. */
  80998. private static applyColorGradingSliderNonlinear;
  80999. /**
  81000. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81001. * @param hue The hue (H) input.
  81002. * @param saturation The saturation (S) input.
  81003. * @param brightness The brightness (B) input.
  81004. * @result An RGBA color represented as Vector4.
  81005. */
  81006. private static fromHSBToRef;
  81007. /**
  81008. * Returns a value clamped between min and max
  81009. * @param value The value to clamp
  81010. * @param min The minimum of value
  81011. * @param max The maximum of value
  81012. * @returns The clamped value.
  81013. */
  81014. private static clamp;
  81015. /**
  81016. * Clones the current color curve instance.
  81017. * @return The cloned curves
  81018. */
  81019. clone(): ColorCurves;
  81020. /**
  81021. * Serializes the current color curve instance to a json representation.
  81022. * @return a JSON representation
  81023. */
  81024. serialize(): any;
  81025. /**
  81026. * Parses the color curve from a json representation.
  81027. * @param source the JSON source to parse
  81028. * @return The parsed curves
  81029. */
  81030. static Parse(source: any): ColorCurves;
  81031. }
  81032. }
  81033. declare module BABYLON {
  81034. /**
  81035. * Interface to follow in your material defines to integrate easily the
  81036. * Image proccessing functions.
  81037. * @hidden
  81038. */
  81039. export interface IImageProcessingConfigurationDefines {
  81040. IMAGEPROCESSING: boolean;
  81041. VIGNETTE: boolean;
  81042. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81043. VIGNETTEBLENDMODEOPAQUE: boolean;
  81044. TONEMAPPING: boolean;
  81045. TONEMAPPING_ACES: boolean;
  81046. CONTRAST: boolean;
  81047. EXPOSURE: boolean;
  81048. COLORCURVES: boolean;
  81049. COLORGRADING: boolean;
  81050. COLORGRADING3D: boolean;
  81051. SAMPLER3DGREENDEPTH: boolean;
  81052. SAMPLER3DBGRMAP: boolean;
  81053. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81054. }
  81055. /**
  81056. * @hidden
  81057. */
  81058. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81059. IMAGEPROCESSING: boolean;
  81060. VIGNETTE: boolean;
  81061. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81062. VIGNETTEBLENDMODEOPAQUE: boolean;
  81063. TONEMAPPING: boolean;
  81064. TONEMAPPING_ACES: boolean;
  81065. CONTRAST: boolean;
  81066. COLORCURVES: boolean;
  81067. COLORGRADING: boolean;
  81068. COLORGRADING3D: boolean;
  81069. SAMPLER3DGREENDEPTH: boolean;
  81070. SAMPLER3DBGRMAP: boolean;
  81071. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81072. EXPOSURE: boolean;
  81073. constructor();
  81074. }
  81075. /**
  81076. * This groups together the common properties used for image processing either in direct forward pass
  81077. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81078. * or not.
  81079. */
  81080. export class ImageProcessingConfiguration {
  81081. /**
  81082. * Default tone mapping applied in BabylonJS.
  81083. */
  81084. static readonly TONEMAPPING_STANDARD: number;
  81085. /**
  81086. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81087. * to other engines rendering to increase portability.
  81088. */
  81089. static readonly TONEMAPPING_ACES: number;
  81090. /**
  81091. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81092. */
  81093. colorCurves: Nullable<ColorCurves>;
  81094. private _colorCurvesEnabled;
  81095. /**
  81096. * Gets wether the color curves effect is enabled.
  81097. */
  81098. get colorCurvesEnabled(): boolean;
  81099. /**
  81100. * Sets wether the color curves effect is enabled.
  81101. */
  81102. set colorCurvesEnabled(value: boolean);
  81103. private _colorGradingTexture;
  81104. /**
  81105. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81106. */
  81107. get colorGradingTexture(): Nullable<BaseTexture>;
  81108. /**
  81109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81110. */
  81111. set colorGradingTexture(value: Nullable<BaseTexture>);
  81112. private _colorGradingEnabled;
  81113. /**
  81114. * Gets wether the color grading effect is enabled.
  81115. */
  81116. get colorGradingEnabled(): boolean;
  81117. /**
  81118. * Sets wether the color grading effect is enabled.
  81119. */
  81120. set colorGradingEnabled(value: boolean);
  81121. private _colorGradingWithGreenDepth;
  81122. /**
  81123. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81124. */
  81125. get colorGradingWithGreenDepth(): boolean;
  81126. /**
  81127. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81128. */
  81129. set colorGradingWithGreenDepth(value: boolean);
  81130. private _colorGradingBGR;
  81131. /**
  81132. * Gets wether the color grading texture contains BGR values.
  81133. */
  81134. get colorGradingBGR(): boolean;
  81135. /**
  81136. * Sets wether the color grading texture contains BGR values.
  81137. */
  81138. set colorGradingBGR(value: boolean);
  81139. /** @hidden */
  81140. _exposure: number;
  81141. /**
  81142. * Gets the Exposure used in the effect.
  81143. */
  81144. get exposure(): number;
  81145. /**
  81146. * Sets the Exposure used in the effect.
  81147. */
  81148. set exposure(value: number);
  81149. private _toneMappingEnabled;
  81150. /**
  81151. * Gets wether the tone mapping effect is enabled.
  81152. */
  81153. get toneMappingEnabled(): boolean;
  81154. /**
  81155. * Sets wether the tone mapping effect is enabled.
  81156. */
  81157. set toneMappingEnabled(value: boolean);
  81158. private _toneMappingType;
  81159. /**
  81160. * Gets the type of tone mapping effect.
  81161. */
  81162. get toneMappingType(): number;
  81163. /**
  81164. * Sets the type of tone mapping effect used in BabylonJS.
  81165. */
  81166. set toneMappingType(value: number);
  81167. protected _contrast: number;
  81168. /**
  81169. * Gets the contrast used in the effect.
  81170. */
  81171. get contrast(): number;
  81172. /**
  81173. * Sets the contrast used in the effect.
  81174. */
  81175. set contrast(value: number);
  81176. /**
  81177. * Vignette stretch size.
  81178. */
  81179. vignetteStretch: number;
  81180. /**
  81181. * Vignette centre X Offset.
  81182. */
  81183. vignetteCentreX: number;
  81184. /**
  81185. * Vignette centre Y Offset.
  81186. */
  81187. vignetteCentreY: number;
  81188. /**
  81189. * Vignette weight or intensity of the vignette effect.
  81190. */
  81191. vignetteWeight: number;
  81192. /**
  81193. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81194. * if vignetteEnabled is set to true.
  81195. */
  81196. vignetteColor: Color4;
  81197. /**
  81198. * Camera field of view used by the Vignette effect.
  81199. */
  81200. vignetteCameraFov: number;
  81201. private _vignetteBlendMode;
  81202. /**
  81203. * Gets the vignette blend mode allowing different kind of effect.
  81204. */
  81205. get vignetteBlendMode(): number;
  81206. /**
  81207. * Sets the vignette blend mode allowing different kind of effect.
  81208. */
  81209. set vignetteBlendMode(value: number);
  81210. private _vignetteEnabled;
  81211. /**
  81212. * Gets wether the vignette effect is enabled.
  81213. */
  81214. get vignetteEnabled(): boolean;
  81215. /**
  81216. * Sets wether the vignette effect is enabled.
  81217. */
  81218. set vignetteEnabled(value: boolean);
  81219. private _applyByPostProcess;
  81220. /**
  81221. * Gets wether the image processing is applied through a post process or not.
  81222. */
  81223. get applyByPostProcess(): boolean;
  81224. /**
  81225. * Sets wether the image processing is applied through a post process or not.
  81226. */
  81227. set applyByPostProcess(value: boolean);
  81228. private _isEnabled;
  81229. /**
  81230. * Gets wether the image processing is enabled or not.
  81231. */
  81232. get isEnabled(): boolean;
  81233. /**
  81234. * Sets wether the image processing is enabled or not.
  81235. */
  81236. set isEnabled(value: boolean);
  81237. /**
  81238. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81239. */
  81240. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81241. /**
  81242. * Method called each time the image processing information changes requires to recompile the effect.
  81243. */
  81244. protected _updateParameters(): void;
  81245. /**
  81246. * Gets the current class name.
  81247. * @return "ImageProcessingConfiguration"
  81248. */
  81249. getClassName(): string;
  81250. /**
  81251. * Prepare the list of uniforms associated with the Image Processing effects.
  81252. * @param uniforms The list of uniforms used in the effect
  81253. * @param defines the list of defines currently in use
  81254. */
  81255. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81256. /**
  81257. * Prepare the list of samplers associated with the Image Processing effects.
  81258. * @param samplersList The list of uniforms used in the effect
  81259. * @param defines the list of defines currently in use
  81260. */
  81261. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81262. /**
  81263. * Prepare the list of defines associated to the shader.
  81264. * @param defines the list of defines to complete
  81265. * @param forPostProcess Define if we are currently in post process mode or not
  81266. */
  81267. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81268. /**
  81269. * Returns true if all the image processing information are ready.
  81270. * @returns True if ready, otherwise, false
  81271. */
  81272. isReady(): boolean;
  81273. /**
  81274. * Binds the image processing to the shader.
  81275. * @param effect The effect to bind to
  81276. * @param overrideAspectRatio Override the aspect ratio of the effect
  81277. */
  81278. bind(effect: Effect, overrideAspectRatio?: number): void;
  81279. /**
  81280. * Clones the current image processing instance.
  81281. * @return The cloned image processing
  81282. */
  81283. clone(): ImageProcessingConfiguration;
  81284. /**
  81285. * Serializes the current image processing instance to a json representation.
  81286. * @return a JSON representation
  81287. */
  81288. serialize(): any;
  81289. /**
  81290. * Parses the image processing from a json representation.
  81291. * @param source the JSON source to parse
  81292. * @return The parsed image processing
  81293. */
  81294. static Parse(source: any): ImageProcessingConfiguration;
  81295. private static _VIGNETTEMODE_MULTIPLY;
  81296. private static _VIGNETTEMODE_OPAQUE;
  81297. /**
  81298. * Used to apply the vignette as a mix with the pixel color.
  81299. */
  81300. static get VIGNETTEMODE_MULTIPLY(): number;
  81301. /**
  81302. * Used to apply the vignette as a replacement of the pixel color.
  81303. */
  81304. static get VIGNETTEMODE_OPAQUE(): number;
  81305. }
  81306. }
  81307. declare module BABYLON {
  81308. /** @hidden */
  81309. export var postprocessVertexShader: {
  81310. name: string;
  81311. shader: string;
  81312. };
  81313. }
  81314. declare module BABYLON {
  81315. interface ThinEngine {
  81316. /**
  81317. * Creates a new render target texture
  81318. * @param size defines the size of the texture
  81319. * @param options defines the options used to create the texture
  81320. * @returns a new render target texture stored in an InternalTexture
  81321. */
  81322. createRenderTargetTexture(size: number | {
  81323. width: number;
  81324. height: number;
  81325. layers?: number;
  81326. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81327. /**
  81328. * Creates a depth stencil texture.
  81329. * This is only available in WebGL 2 or with the depth texture extension available.
  81330. * @param size The size of face edge in the texture.
  81331. * @param options The options defining the texture.
  81332. * @returns The texture
  81333. */
  81334. createDepthStencilTexture(size: number | {
  81335. width: number;
  81336. height: number;
  81337. layers?: number;
  81338. }, options: DepthTextureCreationOptions): InternalTexture;
  81339. /** @hidden */
  81340. _createDepthStencilTexture(size: number | {
  81341. width: number;
  81342. height: number;
  81343. layers?: number;
  81344. }, options: DepthTextureCreationOptions): InternalTexture;
  81345. }
  81346. }
  81347. declare module BABYLON {
  81348. /** Defines supported spaces */
  81349. export enum Space {
  81350. /** Local (object) space */
  81351. LOCAL = 0,
  81352. /** World space */
  81353. WORLD = 1,
  81354. /** Bone space */
  81355. BONE = 2
  81356. }
  81357. /** Defines the 3 main axes */
  81358. export class Axis {
  81359. /** X axis */
  81360. static X: Vector3;
  81361. /** Y axis */
  81362. static Y: Vector3;
  81363. /** Z axis */
  81364. static Z: Vector3;
  81365. }
  81366. }
  81367. declare module BABYLON {
  81368. /**
  81369. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81370. * This is the base of the follow, arc rotate cameras and Free camera
  81371. * @see http://doc.babylonjs.com/features/cameras
  81372. */
  81373. export class TargetCamera extends Camera {
  81374. private static _RigCamTransformMatrix;
  81375. private static _TargetTransformMatrix;
  81376. private static _TargetFocalPoint;
  81377. /**
  81378. * Define the current direction the camera is moving to
  81379. */
  81380. cameraDirection: Vector3;
  81381. /**
  81382. * Define the current rotation the camera is rotating to
  81383. */
  81384. cameraRotation: Vector2;
  81385. /**
  81386. * When set, the up vector of the camera will be updated by the rotation of the camera
  81387. */
  81388. updateUpVectorFromRotation: boolean;
  81389. private _tmpQuaternion;
  81390. /**
  81391. * Define the current rotation of the camera
  81392. */
  81393. rotation: Vector3;
  81394. /**
  81395. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81396. */
  81397. rotationQuaternion: Quaternion;
  81398. /**
  81399. * Define the current speed of the camera
  81400. */
  81401. speed: number;
  81402. /**
  81403. * Add constraint to the camera to prevent it to move freely in all directions and
  81404. * around all axis.
  81405. */
  81406. noRotationConstraint: boolean;
  81407. /**
  81408. * Define the current target of the camera as an object or a position.
  81409. */
  81410. lockedTarget: any;
  81411. /** @hidden */
  81412. _currentTarget: Vector3;
  81413. /** @hidden */
  81414. _initialFocalDistance: number;
  81415. /** @hidden */
  81416. _viewMatrix: Matrix;
  81417. /** @hidden */
  81418. _camMatrix: Matrix;
  81419. /** @hidden */
  81420. _cameraTransformMatrix: Matrix;
  81421. /** @hidden */
  81422. _cameraRotationMatrix: Matrix;
  81423. /** @hidden */
  81424. _referencePoint: Vector3;
  81425. /** @hidden */
  81426. _transformedReferencePoint: Vector3;
  81427. protected _globalCurrentTarget: Vector3;
  81428. protected _globalCurrentUpVector: Vector3;
  81429. /** @hidden */
  81430. _reset: () => void;
  81431. private _defaultUp;
  81432. /**
  81433. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81434. * This is the base of the follow, arc rotate cameras and Free camera
  81435. * @see http://doc.babylonjs.com/features/cameras
  81436. * @param name Defines the name of the camera in the scene
  81437. * @param position Defines the start position of the camera in the scene
  81438. * @param scene Defines the scene the camera belongs to
  81439. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81440. */
  81441. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81442. /**
  81443. * Gets the position in front of the camera at a given distance.
  81444. * @param distance The distance from the camera we want the position to be
  81445. * @returns the position
  81446. */
  81447. getFrontPosition(distance: number): Vector3;
  81448. /** @hidden */
  81449. _getLockedTargetPosition(): Nullable<Vector3>;
  81450. private _storedPosition;
  81451. private _storedRotation;
  81452. private _storedRotationQuaternion;
  81453. /**
  81454. * Store current camera state of the camera (fov, position, rotation, etc..)
  81455. * @returns the camera
  81456. */
  81457. storeState(): Camera;
  81458. /**
  81459. * Restored camera state. You must call storeState() first
  81460. * @returns whether it was successful or not
  81461. * @hidden
  81462. */
  81463. _restoreStateValues(): boolean;
  81464. /** @hidden */
  81465. _initCache(): void;
  81466. /** @hidden */
  81467. _updateCache(ignoreParentClass?: boolean): void;
  81468. /** @hidden */
  81469. _isSynchronizedViewMatrix(): boolean;
  81470. /** @hidden */
  81471. _computeLocalCameraSpeed(): number;
  81472. /**
  81473. * Defines the target the camera should look at.
  81474. * @param target Defines the new target as a Vector or a mesh
  81475. */
  81476. setTarget(target: Vector3): void;
  81477. /**
  81478. * Return the current target position of the camera. This value is expressed in local space.
  81479. * @returns the target position
  81480. */
  81481. getTarget(): Vector3;
  81482. /** @hidden */
  81483. _decideIfNeedsToMove(): boolean;
  81484. /** @hidden */
  81485. _updatePosition(): void;
  81486. /** @hidden */
  81487. _checkInputs(): void;
  81488. protected _updateCameraRotationMatrix(): void;
  81489. /**
  81490. * 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)
  81491. * @returns the current camera
  81492. */
  81493. private _rotateUpVectorWithCameraRotationMatrix;
  81494. private _cachedRotationZ;
  81495. private _cachedQuaternionRotationZ;
  81496. /** @hidden */
  81497. _getViewMatrix(): Matrix;
  81498. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81499. /**
  81500. * @hidden
  81501. */
  81502. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81503. /**
  81504. * @hidden
  81505. */
  81506. _updateRigCameras(): void;
  81507. private _getRigCamPositionAndTarget;
  81508. /**
  81509. * Gets the current object class name.
  81510. * @return the class name
  81511. */
  81512. getClassName(): string;
  81513. }
  81514. }
  81515. declare module BABYLON {
  81516. /**
  81517. * Gather the list of keyboard event types as constants.
  81518. */
  81519. export class KeyboardEventTypes {
  81520. /**
  81521. * The keydown event is fired when a key becomes active (pressed).
  81522. */
  81523. static readonly KEYDOWN: number;
  81524. /**
  81525. * The keyup event is fired when a key has been released.
  81526. */
  81527. static readonly KEYUP: number;
  81528. }
  81529. /**
  81530. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81531. */
  81532. export class KeyboardInfo {
  81533. /**
  81534. * Defines the type of event (KeyboardEventTypes)
  81535. */
  81536. type: number;
  81537. /**
  81538. * Defines the related dom event
  81539. */
  81540. event: KeyboardEvent;
  81541. /**
  81542. * Instantiates a new keyboard info.
  81543. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81544. * @param type Defines the type of event (KeyboardEventTypes)
  81545. * @param event Defines the related dom event
  81546. */
  81547. constructor(
  81548. /**
  81549. * Defines the type of event (KeyboardEventTypes)
  81550. */
  81551. type: number,
  81552. /**
  81553. * Defines the related dom event
  81554. */
  81555. event: KeyboardEvent);
  81556. }
  81557. /**
  81558. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81559. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81560. */
  81561. export class KeyboardInfoPre extends KeyboardInfo {
  81562. /**
  81563. * Defines the type of event (KeyboardEventTypes)
  81564. */
  81565. type: number;
  81566. /**
  81567. * Defines the related dom event
  81568. */
  81569. event: KeyboardEvent;
  81570. /**
  81571. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81572. */
  81573. skipOnPointerObservable: boolean;
  81574. /**
  81575. * Instantiates a new keyboard pre info.
  81576. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81577. * @param type Defines the type of event (KeyboardEventTypes)
  81578. * @param event Defines the related dom event
  81579. */
  81580. constructor(
  81581. /**
  81582. * Defines the type of event (KeyboardEventTypes)
  81583. */
  81584. type: number,
  81585. /**
  81586. * Defines the related dom event
  81587. */
  81588. event: KeyboardEvent);
  81589. }
  81590. }
  81591. declare module BABYLON {
  81592. /**
  81593. * Manage the keyboard inputs to control the movement of a free camera.
  81594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81595. */
  81596. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81597. /**
  81598. * Defines the camera the input is attached to.
  81599. */
  81600. camera: FreeCamera;
  81601. /**
  81602. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81603. */
  81604. keysUp: number[];
  81605. /**
  81606. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81607. */
  81608. keysDown: number[];
  81609. /**
  81610. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81611. */
  81612. keysLeft: number[];
  81613. /**
  81614. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81615. */
  81616. keysRight: number[];
  81617. private _keys;
  81618. private _onCanvasBlurObserver;
  81619. private _onKeyboardObserver;
  81620. private _engine;
  81621. private _scene;
  81622. /**
  81623. * Attach the input controls to a specific dom element to get the input from.
  81624. * @param element Defines the element the controls should be listened from
  81625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81626. */
  81627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81628. /**
  81629. * Detach the current controls from the specified dom element.
  81630. * @param element Defines the element to stop listening the inputs from
  81631. */
  81632. detachControl(element: Nullable<HTMLElement>): void;
  81633. /**
  81634. * Update the current camera state depending on the inputs that have been used this frame.
  81635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81636. */
  81637. checkInputs(): void;
  81638. /**
  81639. * Gets the class name of the current intput.
  81640. * @returns the class name
  81641. */
  81642. getClassName(): string;
  81643. /** @hidden */
  81644. _onLostFocus(): void;
  81645. /**
  81646. * Get the friendly name associated with the input class.
  81647. * @returns the input friendly name
  81648. */
  81649. getSimpleName(): string;
  81650. }
  81651. }
  81652. declare module BABYLON {
  81653. /**
  81654. * Interface describing all the common properties and methods a shadow light needs to implement.
  81655. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  81656. * as well as binding the different shadow properties to the effects.
  81657. */
  81658. export interface IShadowLight extends Light {
  81659. /**
  81660. * The light id in the scene (used in scene.findLighById for instance)
  81661. */
  81662. id: string;
  81663. /**
  81664. * The position the shdow will be casted from.
  81665. */
  81666. position: Vector3;
  81667. /**
  81668. * In 2d mode (needCube being false), the direction used to cast the shadow.
  81669. */
  81670. direction: Vector3;
  81671. /**
  81672. * The transformed position. Position of the light in world space taking parenting in account.
  81673. */
  81674. transformedPosition: Vector3;
  81675. /**
  81676. * The transformed direction. Direction of the light in world space taking parenting in account.
  81677. */
  81678. transformedDirection: Vector3;
  81679. /**
  81680. * The friendly name of the light in the scene.
  81681. */
  81682. name: string;
  81683. /**
  81684. * Defines the shadow projection clipping minimum z value.
  81685. */
  81686. shadowMinZ: number;
  81687. /**
  81688. * Defines the shadow projection clipping maximum z value.
  81689. */
  81690. shadowMaxZ: number;
  81691. /**
  81692. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81693. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81694. */
  81695. computeTransformedInformation(): boolean;
  81696. /**
  81697. * Gets the scene the light belongs to.
  81698. * @returns The scene
  81699. */
  81700. getScene(): Scene;
  81701. /**
  81702. * Callback defining a custom Projection Matrix Builder.
  81703. * This can be used to override the default projection matrix computation.
  81704. */
  81705. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81706. /**
  81707. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81708. * @param matrix The materix to updated with the projection information
  81709. * @param viewMatrix The transform matrix of the light
  81710. * @param renderList The list of mesh to render in the map
  81711. * @returns The current light
  81712. */
  81713. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81714. /**
  81715. * Gets the current depth scale used in ESM.
  81716. * @returns The scale
  81717. */
  81718. getDepthScale(): number;
  81719. /**
  81720. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81721. * @returns true if a cube texture needs to be use
  81722. */
  81723. needCube(): boolean;
  81724. /**
  81725. * Detects if the projection matrix requires to be recomputed this frame.
  81726. * @returns true if it requires to be recomputed otherwise, false.
  81727. */
  81728. needProjectionMatrixCompute(): boolean;
  81729. /**
  81730. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81731. */
  81732. forceProjectionMatrixCompute(): void;
  81733. /**
  81734. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81735. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81736. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81737. */
  81738. getShadowDirection(faceIndex?: number): Vector3;
  81739. /**
  81740. * Gets the minZ used for shadow according to both the scene and the light.
  81741. * @param activeCamera The camera we are returning the min for
  81742. * @returns the depth min z
  81743. */
  81744. getDepthMinZ(activeCamera: Camera): number;
  81745. /**
  81746. * Gets the maxZ used for shadow according to both the scene and the light.
  81747. * @param activeCamera The camera we are returning the max for
  81748. * @returns the depth max z
  81749. */
  81750. getDepthMaxZ(activeCamera: Camera): number;
  81751. }
  81752. /**
  81753. * Base implementation IShadowLight
  81754. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  81755. */
  81756. export abstract class ShadowLight extends Light implements IShadowLight {
  81757. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  81758. protected _position: Vector3;
  81759. protected _setPosition(value: Vector3): void;
  81760. /**
  81761. * Sets the position the shadow will be casted from. Also use as the light position for both
  81762. * point and spot lights.
  81763. */
  81764. get position(): Vector3;
  81765. /**
  81766. * Sets the position the shadow will be casted from. Also use as the light position for both
  81767. * point and spot lights.
  81768. */
  81769. set position(value: Vector3);
  81770. protected _direction: Vector3;
  81771. protected _setDirection(value: Vector3): void;
  81772. /**
  81773. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  81774. * Also use as the light direction on spot and directional lights.
  81775. */
  81776. get direction(): Vector3;
  81777. /**
  81778. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  81779. * Also use as the light direction on spot and directional lights.
  81780. */
  81781. set direction(value: Vector3);
  81782. protected _shadowMinZ: number;
  81783. /**
  81784. * Gets the shadow projection clipping minimum z value.
  81785. */
  81786. get shadowMinZ(): number;
  81787. /**
  81788. * Sets the shadow projection clipping minimum z value.
  81789. */
  81790. set shadowMinZ(value: number);
  81791. protected _shadowMaxZ: number;
  81792. /**
  81793. * Sets the shadow projection clipping maximum z value.
  81794. */
  81795. get shadowMaxZ(): number;
  81796. /**
  81797. * Gets the shadow projection clipping maximum z value.
  81798. */
  81799. set shadowMaxZ(value: number);
  81800. /**
  81801. * Callback defining a custom Projection Matrix Builder.
  81802. * This can be used to override the default projection matrix computation.
  81803. */
  81804. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81805. /**
  81806. * The transformed position. Position of the light in world space taking parenting in account.
  81807. */
  81808. transformedPosition: Vector3;
  81809. /**
  81810. * The transformed direction. Direction of the light in world space taking parenting in account.
  81811. */
  81812. transformedDirection: Vector3;
  81813. private _needProjectionMatrixCompute;
  81814. /**
  81815. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81816. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81817. */
  81818. computeTransformedInformation(): boolean;
  81819. /**
  81820. * Return the depth scale used for the shadow map.
  81821. * @returns the depth scale.
  81822. */
  81823. getDepthScale(): number;
  81824. /**
  81825. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81826. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81827. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81828. */
  81829. getShadowDirection(faceIndex?: number): Vector3;
  81830. /**
  81831. * Returns the ShadowLight absolute position in the World.
  81832. * @returns the position vector in world space
  81833. */
  81834. getAbsolutePosition(): Vector3;
  81835. /**
  81836. * Sets the ShadowLight direction toward the passed target.
  81837. * @param target The point to target in local space
  81838. * @returns the updated ShadowLight direction
  81839. */
  81840. setDirectionToTarget(target: Vector3): Vector3;
  81841. /**
  81842. * Returns the light rotation in euler definition.
  81843. * @returns the x y z rotation in local space.
  81844. */
  81845. getRotation(): Vector3;
  81846. /**
  81847. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81848. * @returns true if a cube texture needs to be use
  81849. */
  81850. needCube(): boolean;
  81851. /**
  81852. * Detects if the projection matrix requires to be recomputed this frame.
  81853. * @returns true if it requires to be recomputed otherwise, false.
  81854. */
  81855. needProjectionMatrixCompute(): boolean;
  81856. /**
  81857. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81858. */
  81859. forceProjectionMatrixCompute(): void;
  81860. /** @hidden */
  81861. _initCache(): void;
  81862. /** @hidden */
  81863. _isSynchronized(): boolean;
  81864. /**
  81865. * Computes the world matrix of the node
  81866. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81867. * @returns the world matrix
  81868. */
  81869. computeWorldMatrix(force?: boolean): Matrix;
  81870. /**
  81871. * Gets the minZ used for shadow according to both the scene and the light.
  81872. * @param activeCamera The camera we are returning the min for
  81873. * @returns the depth min z
  81874. */
  81875. getDepthMinZ(activeCamera: Camera): number;
  81876. /**
  81877. * Gets the maxZ used for shadow according to both the scene and the light.
  81878. * @param activeCamera The camera we are returning the max for
  81879. * @returns the depth max z
  81880. */
  81881. getDepthMaxZ(activeCamera: Camera): number;
  81882. /**
  81883. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81884. * @param matrix The materix to updated with the projection information
  81885. * @param viewMatrix The transform matrix of the light
  81886. * @param renderList The list of mesh to render in the map
  81887. * @returns The current light
  81888. */
  81889. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81890. }
  81891. }
  81892. declare module BABYLON {
  81893. /**
  81894. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  81895. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  81896. */
  81897. export class EffectFallbacks implements IEffectFallbacks {
  81898. private _defines;
  81899. private _currentRank;
  81900. private _maxRank;
  81901. private _mesh;
  81902. /**
  81903. * Removes the fallback from the bound mesh.
  81904. */
  81905. unBindMesh(): void;
  81906. /**
  81907. * Adds a fallback on the specified property.
  81908. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81909. * @param define The name of the define in the shader
  81910. */
  81911. addFallback(rank: number, define: string): void;
  81912. /**
  81913. * Sets the mesh to use CPU skinning when needing to fallback.
  81914. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81915. * @param mesh The mesh to use the fallbacks.
  81916. */
  81917. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  81918. /**
  81919. * Checks to see if more fallbacks are still availible.
  81920. */
  81921. get hasMoreFallbacks(): boolean;
  81922. /**
  81923. * Removes the defines that should be removed when falling back.
  81924. * @param currentDefines defines the current define statements for the shader.
  81925. * @param effect defines the current effect we try to compile
  81926. * @returns The resulting defines with defines of the current rank removed.
  81927. */
  81928. reduce(currentDefines: string, effect: Effect): string;
  81929. }
  81930. }
  81931. declare module BABYLON {
  81932. /**
  81933. * "Static Class" containing the most commonly used helper while dealing with material for
  81934. * rendering purpose.
  81935. *
  81936. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  81937. *
  81938. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  81939. */
  81940. export class MaterialHelper {
  81941. /**
  81942. * Bind the current view position to an effect.
  81943. * @param effect The effect to be bound
  81944. * @param scene The scene the eyes position is used from
  81945. */
  81946. static BindEyePosition(effect: Effect, scene: Scene): void;
  81947. /**
  81948. * Helps preparing the defines values about the UVs in used in the effect.
  81949. * UVs are shared as much as we can accross channels in the shaders.
  81950. * @param texture The texture we are preparing the UVs for
  81951. * @param defines The defines to update
  81952. * @param key The channel key "diffuse", "specular"... used in the shader
  81953. */
  81954. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  81955. /**
  81956. * Binds a texture matrix value to its corrsponding uniform
  81957. * @param texture The texture to bind the matrix for
  81958. * @param uniformBuffer The uniform buffer receivin the data
  81959. * @param key The channel key "diffuse", "specular"... used in the shader
  81960. */
  81961. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  81962. /**
  81963. * Gets the current status of the fog (should it be enabled?)
  81964. * @param mesh defines the mesh to evaluate for fog support
  81965. * @param scene defines the hosting scene
  81966. * @returns true if fog must be enabled
  81967. */
  81968. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  81969. /**
  81970. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  81971. * @param mesh defines the current mesh
  81972. * @param scene defines the current scene
  81973. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  81974. * @param pointsCloud defines if point cloud rendering has to be turned on
  81975. * @param fogEnabled defines if fog has to be turned on
  81976. * @param alphaTest defines if alpha testing has to be turned on
  81977. * @param defines defines the current list of defines
  81978. */
  81979. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  81980. /**
  81981. * Helper used to prepare the list of defines associated with frame values for shader compilation
  81982. * @param scene defines the current scene
  81983. * @param engine defines the current engine
  81984. * @param defines specifies the list of active defines
  81985. * @param useInstances defines if instances have to be turned on
  81986. * @param useClipPlane defines if clip plane have to be turned on
  81987. */
  81988. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  81989. /**
  81990. * Prepares the defines for bones
  81991. * @param mesh The mesh containing the geometry data we will draw
  81992. * @param defines The defines to update
  81993. */
  81994. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  81995. /**
  81996. * Prepares the defines for morph targets
  81997. * @param mesh The mesh containing the geometry data we will draw
  81998. * @param defines The defines to update
  81999. */
  82000. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82001. /**
  82002. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82003. * @param mesh The mesh containing the geometry data we will draw
  82004. * @param defines The defines to update
  82005. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82006. * @param useBones Precise whether bones should be used or not (override mesh info)
  82007. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82008. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82009. * @returns false if defines are considered not dirty and have not been checked
  82010. */
  82011. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82012. /**
  82013. * Prepares the defines related to multiview
  82014. * @param scene The scene we are intending to draw
  82015. * @param defines The defines to update
  82016. */
  82017. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82018. /**
  82019. * Prepares the defines related to the light information passed in parameter
  82020. * @param scene The scene we are intending to draw
  82021. * @param mesh The mesh the effect is compiling for
  82022. * @param light The light the effect is compiling for
  82023. * @param lightIndex The index of the light
  82024. * @param defines The defines to update
  82025. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82026. * @param state Defines the current state regarding what is needed (normals, etc...)
  82027. */
  82028. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82029. needNormals: boolean;
  82030. needRebuild: boolean;
  82031. shadowEnabled: boolean;
  82032. specularEnabled: boolean;
  82033. lightmapMode: boolean;
  82034. }): void;
  82035. /**
  82036. * Prepares the defines related to the light information passed in parameter
  82037. * @param scene The scene we are intending to draw
  82038. * @param mesh The mesh the effect is compiling for
  82039. * @param defines The defines to update
  82040. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82041. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82042. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82043. * @returns true if normals will be required for the rest of the effect
  82044. */
  82045. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82046. /**
  82047. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82048. * @param lightIndex defines the light index
  82049. * @param uniformsList The uniform list
  82050. * @param samplersList The sampler list
  82051. * @param projectedLightTexture defines if projected texture must be used
  82052. * @param uniformBuffersList defines an optional list of uniform buffers
  82053. */
  82054. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82055. /**
  82056. * Prepares the uniforms and samplers list to be used in the effect
  82057. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82058. * @param samplersList The sampler list
  82059. * @param defines The defines helping in the list generation
  82060. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82061. */
  82062. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82063. /**
  82064. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82065. * @param defines The defines to update while falling back
  82066. * @param fallbacks The authorized effect fallbacks
  82067. * @param maxSimultaneousLights The maximum number of lights allowed
  82068. * @param rank the current rank of the Effect
  82069. * @returns The newly affected rank
  82070. */
  82071. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82072. private static _TmpMorphInfluencers;
  82073. /**
  82074. * Prepares the list of attributes required for morph targets according to the effect defines.
  82075. * @param attribs The current list of supported attribs
  82076. * @param mesh The mesh to prepare the morph targets attributes for
  82077. * @param influencers The number of influencers
  82078. */
  82079. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82080. /**
  82081. * Prepares the list of attributes required for morph targets according to the effect defines.
  82082. * @param attribs The current list of supported attribs
  82083. * @param mesh The mesh to prepare the morph targets attributes for
  82084. * @param defines The current Defines of the effect
  82085. */
  82086. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82087. /**
  82088. * Prepares the list of attributes required for bones according to the effect defines.
  82089. * @param attribs The current list of supported attribs
  82090. * @param mesh The mesh to prepare the bones attributes for
  82091. * @param defines The current Defines of the effect
  82092. * @param fallbacks The current efffect fallback strategy
  82093. */
  82094. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82095. /**
  82096. * Check and prepare the list of attributes required for instances according to the effect defines.
  82097. * @param attribs The current list of supported attribs
  82098. * @param defines The current MaterialDefines of the effect
  82099. */
  82100. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82101. /**
  82102. * Add the list of attributes required for instances to the attribs array.
  82103. * @param attribs The current list of supported attribs
  82104. */
  82105. static PushAttributesForInstances(attribs: string[]): void;
  82106. /**
  82107. * Binds the light information to the effect.
  82108. * @param light The light containing the generator
  82109. * @param effect The effect we are binding the data to
  82110. * @param lightIndex The light index in the effect used to render
  82111. */
  82112. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82113. /**
  82114. * Binds the lights information from the scene to the effect for the given mesh.
  82115. * @param light Light to bind
  82116. * @param lightIndex Light index
  82117. * @param scene The scene where the light belongs to
  82118. * @param effect The effect we are binding the data to
  82119. * @param useSpecular Defines if specular is supported
  82120. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82121. */
  82122. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82123. /**
  82124. * Binds the lights information from the scene to the effect for the given mesh.
  82125. * @param scene The scene the lights belongs to
  82126. * @param mesh The mesh we are binding the information to render
  82127. * @param effect The effect we are binding the data to
  82128. * @param defines The generated defines for the effect
  82129. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82130. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82131. */
  82132. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82133. private static _tempFogColor;
  82134. /**
  82135. * Binds the fog information from the scene to the effect for the given mesh.
  82136. * @param scene The scene the lights belongs to
  82137. * @param mesh The mesh we are binding the information to render
  82138. * @param effect The effect we are binding the data to
  82139. * @param linearSpace Defines if the fog effect is applied in linear space
  82140. */
  82141. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82142. /**
  82143. * Binds the bones information from the mesh to the effect.
  82144. * @param mesh The mesh we are binding the information to render
  82145. * @param effect The effect we are binding the data to
  82146. */
  82147. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82148. /**
  82149. * Binds the morph targets information from the mesh to the effect.
  82150. * @param abstractMesh The mesh we are binding the information to render
  82151. * @param effect The effect we are binding the data to
  82152. */
  82153. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82154. /**
  82155. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82156. * @param defines The generated defines used in the effect
  82157. * @param effect The effect we are binding the data to
  82158. * @param scene The scene we are willing to render with logarithmic scale for
  82159. */
  82160. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82161. /**
  82162. * Binds the clip plane information from the scene to the effect.
  82163. * @param scene The scene the clip plane information are extracted from
  82164. * @param effect The effect we are binding the data to
  82165. */
  82166. static BindClipPlane(effect: Effect, scene: Scene): void;
  82167. }
  82168. }
  82169. declare module BABYLON {
  82170. /** @hidden */
  82171. export var packingFunctions: {
  82172. name: string;
  82173. shader: string;
  82174. };
  82175. }
  82176. declare module BABYLON {
  82177. /** @hidden */
  82178. export var clipPlaneFragmentDeclaration: {
  82179. name: string;
  82180. shader: string;
  82181. };
  82182. }
  82183. declare module BABYLON {
  82184. /** @hidden */
  82185. export var clipPlaneFragment: {
  82186. name: string;
  82187. shader: string;
  82188. };
  82189. }
  82190. declare module BABYLON {
  82191. /** @hidden */
  82192. export var shadowMapPixelShader: {
  82193. name: string;
  82194. shader: string;
  82195. };
  82196. }
  82197. declare module BABYLON {
  82198. /** @hidden */
  82199. export var bonesDeclaration: {
  82200. name: string;
  82201. shader: string;
  82202. };
  82203. }
  82204. declare module BABYLON {
  82205. /** @hidden */
  82206. export var morphTargetsVertexGlobalDeclaration: {
  82207. name: string;
  82208. shader: string;
  82209. };
  82210. }
  82211. declare module BABYLON {
  82212. /** @hidden */
  82213. export var morphTargetsVertexDeclaration: {
  82214. name: string;
  82215. shader: string;
  82216. };
  82217. }
  82218. declare module BABYLON {
  82219. /** @hidden */
  82220. export var instancesDeclaration: {
  82221. name: string;
  82222. shader: string;
  82223. };
  82224. }
  82225. declare module BABYLON {
  82226. /** @hidden */
  82227. export var helperFunctions: {
  82228. name: string;
  82229. shader: string;
  82230. };
  82231. }
  82232. declare module BABYLON {
  82233. /** @hidden */
  82234. export var clipPlaneVertexDeclaration: {
  82235. name: string;
  82236. shader: string;
  82237. };
  82238. }
  82239. declare module BABYLON {
  82240. /** @hidden */
  82241. export var morphTargetsVertex: {
  82242. name: string;
  82243. shader: string;
  82244. };
  82245. }
  82246. declare module BABYLON {
  82247. /** @hidden */
  82248. export var instancesVertex: {
  82249. name: string;
  82250. shader: string;
  82251. };
  82252. }
  82253. declare module BABYLON {
  82254. /** @hidden */
  82255. export var bonesVertex: {
  82256. name: string;
  82257. shader: string;
  82258. };
  82259. }
  82260. declare module BABYLON {
  82261. /** @hidden */
  82262. export var clipPlaneVertex: {
  82263. name: string;
  82264. shader: string;
  82265. };
  82266. }
  82267. declare module BABYLON {
  82268. /** @hidden */
  82269. export var shadowMapVertexShader: {
  82270. name: string;
  82271. shader: string;
  82272. };
  82273. }
  82274. declare module BABYLON {
  82275. /** @hidden */
  82276. export var depthBoxBlurPixelShader: {
  82277. name: string;
  82278. shader: string;
  82279. };
  82280. }
  82281. declare module BABYLON {
  82282. /**
  82283. * Defines the options associated with the creation of a custom shader for a shadow generator.
  82284. */
  82285. export interface ICustomShaderOptions {
  82286. /**
  82287. * Gets or sets the custom shader name to use
  82288. */
  82289. shaderName: string;
  82290. /**
  82291. * The list of attribute names used in the shader
  82292. */
  82293. attributes?: string[];
  82294. /**
  82295. * The list of unifrom names used in the shader
  82296. */
  82297. uniforms?: string[];
  82298. /**
  82299. * The list of sampler names used in the shader
  82300. */
  82301. samplers?: string[];
  82302. /**
  82303. * The list of defines used in the shader
  82304. */
  82305. defines?: string[];
  82306. }
  82307. /**
  82308. * Interface to implement to create a shadow generator compatible with BJS.
  82309. */
  82310. export interface IShadowGenerator {
  82311. /**
  82312. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82313. * @returns The render target texture if present otherwise, null
  82314. */
  82315. getShadowMap(): Nullable<RenderTargetTexture>;
  82316. /**
  82317. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82318. * @param subMesh The submesh we want to render in the shadow map
  82319. * @param useInstances Defines wether will draw in the map using instances
  82320. * @returns true if ready otherwise, false
  82321. */
  82322. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82323. /**
  82324. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82325. * @param defines Defines of the material we want to update
  82326. * @param lightIndex Index of the light in the enabled light list of the material
  82327. */
  82328. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  82329. /**
  82330. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82331. * defined in the generator but impacting the effect).
  82332. * It implies the unifroms available on the materials are the standard BJS ones.
  82333. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82334. * @param effect The effect we are binfing the information for
  82335. */
  82336. bindShadowLight(lightIndex: string, effect: Effect): void;
  82337. /**
  82338. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82339. * (eq to shadow prjection matrix * light transform matrix)
  82340. * @returns The transform matrix used to create the shadow map
  82341. */
  82342. getTransformMatrix(): Matrix;
  82343. /**
  82344. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82345. * Cube and 2D textures for instance.
  82346. */
  82347. recreateShadowMap(): void;
  82348. /**
  82349. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82350. * @param onCompiled Callback triggered at the and of the effects compilation
  82351. * @param options Sets of optional options forcing the compilation with different modes
  82352. */
  82353. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82354. useInstances: boolean;
  82355. }>): void;
  82356. /**
  82357. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82358. * @param options Sets of optional options forcing the compilation with different modes
  82359. * @returns A promise that resolves when the compilation completes
  82360. */
  82361. forceCompilationAsync(options?: Partial<{
  82362. useInstances: boolean;
  82363. }>): Promise<void>;
  82364. /**
  82365. * Serializes the shadow generator setup to a json object.
  82366. * @returns The serialized JSON object
  82367. */
  82368. serialize(): any;
  82369. /**
  82370. * Disposes the Shadow map and related Textures and effects.
  82371. */
  82372. dispose(): void;
  82373. }
  82374. /**
  82375. * Default implementation IShadowGenerator.
  82376. * This is the main object responsible of generating shadows in the framework.
  82377. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  82378. */
  82379. export class ShadowGenerator implements IShadowGenerator {
  82380. /**
  82381. * Name of the shadow generator class
  82382. */
  82383. static CLASSNAME: string;
  82384. /**
  82385. * Shadow generator mode None: no filtering applied.
  82386. */
  82387. static readonly FILTER_NONE: number;
  82388. /**
  82389. * Shadow generator mode ESM: Exponential Shadow Mapping.
  82390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82391. */
  82392. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  82393. /**
  82394. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  82395. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  82396. */
  82397. static readonly FILTER_POISSONSAMPLING: number;
  82398. /**
  82399. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  82400. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82401. */
  82402. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  82403. /**
  82404. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  82405. * edge artifacts on steep falloff.
  82406. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82407. */
  82408. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  82409. /**
  82410. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  82411. * edge artifacts on steep falloff.
  82412. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82413. */
  82414. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  82415. /**
  82416. * Shadow generator mode PCF: Percentage Closer Filtering
  82417. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82418. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  82419. */
  82420. static readonly FILTER_PCF: number;
  82421. /**
  82422. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  82423. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82424. * Contact Hardening
  82425. */
  82426. static readonly FILTER_PCSS: number;
  82427. /**
  82428. * Reserved for PCF and PCSS
  82429. * Highest Quality.
  82430. *
  82431. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  82432. *
  82433. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  82434. */
  82435. static readonly QUALITY_HIGH: number;
  82436. /**
  82437. * Reserved for PCF and PCSS
  82438. * Good tradeoff for quality/perf cross devices
  82439. *
  82440. * Execute PCF on a 3*3 kernel.
  82441. *
  82442. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  82443. */
  82444. static readonly QUALITY_MEDIUM: number;
  82445. /**
  82446. * Reserved for PCF and PCSS
  82447. * The lowest quality but the fastest.
  82448. *
  82449. * Execute PCF on a 1*1 kernel.
  82450. *
  82451. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  82452. */
  82453. static readonly QUALITY_LOW: number;
  82454. /** Gets or sets the custom shader name to use */
  82455. customShaderOptions: ICustomShaderOptions;
  82456. /**
  82457. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  82458. */
  82459. onBeforeShadowMapRenderObservable: Observable<Effect>;
  82460. /**
  82461. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  82462. */
  82463. onAfterShadowMapRenderObservable: Observable<Effect>;
  82464. /**
  82465. * Observable triggered before a mesh is rendered in the shadow map.
  82466. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  82467. */
  82468. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  82469. /**
  82470. * Observable triggered after a mesh is rendered in the shadow map.
  82471. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  82472. */
  82473. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  82474. protected _bias: number;
  82475. /**
  82476. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  82477. */
  82478. get bias(): number;
  82479. /**
  82480. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  82481. */
  82482. set bias(bias: number);
  82483. protected _normalBias: number;
  82484. /**
  82485. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82486. */
  82487. get normalBias(): number;
  82488. /**
  82489. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82490. */
  82491. set normalBias(normalBias: number);
  82492. protected _blurBoxOffset: number;
  82493. /**
  82494. * Gets the blur box offset: offset applied during the blur pass.
  82495. * Only useful if useKernelBlur = false
  82496. */
  82497. get blurBoxOffset(): number;
  82498. /**
  82499. * Sets the blur box offset: offset applied during the blur pass.
  82500. * Only useful if useKernelBlur = false
  82501. */
  82502. set blurBoxOffset(value: number);
  82503. protected _blurScale: number;
  82504. /**
  82505. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  82506. * 2 means half of the size.
  82507. */
  82508. get blurScale(): number;
  82509. /**
  82510. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  82511. * 2 means half of the size.
  82512. */
  82513. set blurScale(value: number);
  82514. protected _blurKernel: number;
  82515. /**
  82516. * Gets the blur kernel: kernel size of the blur pass.
  82517. * Only useful if useKernelBlur = true
  82518. */
  82519. get blurKernel(): number;
  82520. /**
  82521. * Sets the blur kernel: kernel size of the blur pass.
  82522. * Only useful if useKernelBlur = true
  82523. */
  82524. set blurKernel(value: number);
  82525. protected _useKernelBlur: boolean;
  82526. /**
  82527. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  82528. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82529. */
  82530. get useKernelBlur(): boolean;
  82531. /**
  82532. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  82533. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82534. */
  82535. set useKernelBlur(value: boolean);
  82536. protected _depthScale: number;
  82537. /**
  82538. * Gets the depth scale used in ESM mode.
  82539. */
  82540. get depthScale(): number;
  82541. /**
  82542. * Sets the depth scale used in ESM mode.
  82543. * This can override the scale stored on the light.
  82544. */
  82545. set depthScale(value: number);
  82546. protected _validateFilter(filter: number): number;
  82547. protected _filter: number;
  82548. /**
  82549. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  82550. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82551. */
  82552. get filter(): number;
  82553. /**
  82554. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  82555. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82556. */
  82557. set filter(value: number);
  82558. /**
  82559. * Gets if the current filter is set to Poisson Sampling.
  82560. */
  82561. get usePoissonSampling(): boolean;
  82562. /**
  82563. * Sets the current filter to Poisson Sampling.
  82564. */
  82565. set usePoissonSampling(value: boolean);
  82566. /**
  82567. * Gets if the current filter is set to ESM.
  82568. */
  82569. get useExponentialShadowMap(): boolean;
  82570. /**
  82571. * Sets the current filter is to ESM.
  82572. */
  82573. set useExponentialShadowMap(value: boolean);
  82574. /**
  82575. * Gets if the current filter is set to filtered ESM.
  82576. */
  82577. get useBlurExponentialShadowMap(): boolean;
  82578. /**
  82579. * Gets if the current filter is set to filtered ESM.
  82580. */
  82581. set useBlurExponentialShadowMap(value: boolean);
  82582. /**
  82583. * Gets if the current filter is set to "close ESM" (using the inverse of the
  82584. * exponential to prevent steep falloff artifacts).
  82585. */
  82586. get useCloseExponentialShadowMap(): boolean;
  82587. /**
  82588. * Sets the current filter to "close ESM" (using the inverse of the
  82589. * exponential to prevent steep falloff artifacts).
  82590. */
  82591. set useCloseExponentialShadowMap(value: boolean);
  82592. /**
  82593. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  82594. * exponential to prevent steep falloff artifacts).
  82595. */
  82596. get useBlurCloseExponentialShadowMap(): boolean;
  82597. /**
  82598. * Sets the current filter to filtered "close ESM" (using the inverse of the
  82599. * exponential to prevent steep falloff artifacts).
  82600. */
  82601. set useBlurCloseExponentialShadowMap(value: boolean);
  82602. /**
  82603. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  82604. */
  82605. get usePercentageCloserFiltering(): boolean;
  82606. /**
  82607. * Sets the current filter to "PCF" (percentage closer filtering).
  82608. */
  82609. set usePercentageCloserFiltering(value: boolean);
  82610. protected _filteringQuality: number;
  82611. /**
  82612. * Gets the PCF or PCSS Quality.
  82613. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82614. */
  82615. get filteringQuality(): number;
  82616. /**
  82617. * Sets the PCF or PCSS Quality.
  82618. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82619. */
  82620. set filteringQuality(filteringQuality: number);
  82621. /**
  82622. * Gets if the current filter is set to "PCSS" (contact hardening).
  82623. */
  82624. get useContactHardeningShadow(): boolean;
  82625. /**
  82626. * Sets the current filter to "PCSS" (contact hardening).
  82627. */
  82628. set useContactHardeningShadow(value: boolean);
  82629. protected _contactHardeningLightSizeUVRatio: number;
  82630. /**
  82631. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82632. * Using a ratio helps keeping shape stability independently of the map size.
  82633. *
  82634. * It does not account for the light projection as it was having too much
  82635. * instability during the light setup or during light position changes.
  82636. *
  82637. * Only valid if useContactHardeningShadow is true.
  82638. */
  82639. get contactHardeningLightSizeUVRatio(): number;
  82640. /**
  82641. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82642. * Using a ratio helps keeping shape stability independently of the map size.
  82643. *
  82644. * It does not account for the light projection as it was having too much
  82645. * instability during the light setup or during light position changes.
  82646. *
  82647. * Only valid if useContactHardeningShadow is true.
  82648. */
  82649. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  82650. protected _darkness: number;
  82651. /** Gets or sets the actual darkness of a shadow */
  82652. get darkness(): number;
  82653. set darkness(value: number);
  82654. /**
  82655. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  82656. * 0 means strongest and 1 would means no shadow.
  82657. * @returns the darkness.
  82658. */
  82659. getDarkness(): number;
  82660. /**
  82661. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  82662. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  82663. * @returns the shadow generator allowing fluent coding.
  82664. */
  82665. setDarkness(darkness: number): ShadowGenerator;
  82666. protected _transparencyShadow: boolean;
  82667. /** Gets or sets the ability to have transparent shadow */
  82668. get transparencyShadow(): boolean;
  82669. set transparencyShadow(value: boolean);
  82670. /**
  82671. * Sets the ability to have transparent shadow (boolean).
  82672. * @param transparent True if transparent else False
  82673. * @returns the shadow generator allowing fluent coding
  82674. */
  82675. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  82676. protected _shadowMap: Nullable<RenderTargetTexture>;
  82677. protected _shadowMap2: Nullable<RenderTargetTexture>;
  82678. /**
  82679. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82680. * @returns The render target texture if present otherwise, null
  82681. */
  82682. getShadowMap(): Nullable<RenderTargetTexture>;
  82683. /**
  82684. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  82685. * @returns The render target texture if the shadow map is present otherwise, null
  82686. */
  82687. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  82688. /**
  82689. * Gets the class name of that object
  82690. * @returns "ShadowGenerator"
  82691. */
  82692. getClassName(): string;
  82693. /**
  82694. * Helper function to add a mesh and its descendants to the list of shadow casters.
  82695. * @param mesh Mesh to add
  82696. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  82697. * @returns the Shadow Generator itself
  82698. */
  82699. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82700. /**
  82701. * Helper function to remove a mesh and its descendants from the list of shadow casters
  82702. * @param mesh Mesh to remove
  82703. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  82704. * @returns the Shadow Generator itself
  82705. */
  82706. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82707. /**
  82708. * Controls the extent to which the shadows fade out at the edge of the frustum
  82709. */
  82710. frustumEdgeFalloff: number;
  82711. protected _light: IShadowLight;
  82712. /**
  82713. * Returns the associated light object.
  82714. * @returns the light generating the shadow
  82715. */
  82716. getLight(): IShadowLight;
  82717. /**
  82718. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  82719. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  82720. * It might on the other hand introduce peter panning.
  82721. */
  82722. forceBackFacesOnly: boolean;
  82723. protected _scene: Scene;
  82724. protected _lightDirection: Vector3;
  82725. protected _effect: Effect;
  82726. protected _viewMatrix: Matrix;
  82727. protected _projectionMatrix: Matrix;
  82728. protected _transformMatrix: Matrix;
  82729. protected _cachedPosition: Vector3;
  82730. protected _cachedDirection: Vector3;
  82731. protected _cachedDefines: string;
  82732. protected _currentRenderID: number;
  82733. protected _boxBlurPostprocess: Nullable<PostProcess>;
  82734. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  82735. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  82736. protected _blurPostProcesses: PostProcess[];
  82737. protected _mapSize: number;
  82738. protected _currentFaceIndex: number;
  82739. protected _currentFaceIndexCache: number;
  82740. protected _textureType: number;
  82741. protected _defaultTextureMatrix: Matrix;
  82742. protected _storedUniqueId: Nullable<number>;
  82743. /** @hidden */
  82744. static _SceneComponentInitialization: (scene: Scene) => void;
  82745. /**
  82746. * Creates a ShadowGenerator object.
  82747. * A ShadowGenerator is the required tool to use the shadows.
  82748. * Each light casting shadows needs to use its own ShadowGenerator.
  82749. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  82750. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  82751. * @param light The light object generating the shadows.
  82752. * @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.
  82753. */
  82754. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  82755. protected _initializeGenerator(): void;
  82756. protected _createTargetRenderTexture(): void;
  82757. protected _initializeShadowMap(): void;
  82758. protected _initializeBlurRTTAndPostProcesses(): void;
  82759. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  82760. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  82761. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  82762. protected _applyFilterValues(): void;
  82763. /**
  82764. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82765. * @param onCompiled Callback triggered at the and of the effects compilation
  82766. * @param options Sets of optional options forcing the compilation with different modes
  82767. */
  82768. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82769. useInstances: boolean;
  82770. }>): void;
  82771. /**
  82772. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82773. * @param options Sets of optional options forcing the compilation with different modes
  82774. * @returns A promise that resolves when the compilation completes
  82775. */
  82776. forceCompilationAsync(options?: Partial<{
  82777. useInstances: boolean;
  82778. }>): Promise<void>;
  82779. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  82780. /**
  82781. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82782. * @param subMesh The submesh we want to render in the shadow map
  82783. * @param useInstances Defines wether will draw in the map using instances
  82784. * @returns true if ready otherwise, false
  82785. */
  82786. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82787. /**
  82788. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82789. * @param defines Defines of the material we want to update
  82790. * @param lightIndex Index of the light in the enabled light list of the material
  82791. */
  82792. prepareDefines(defines: any, lightIndex: number): void;
  82793. /**
  82794. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82795. * defined in the generator but impacting the effect).
  82796. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82797. * @param effect The effect we are binfing the information for
  82798. */
  82799. bindShadowLight(lightIndex: string, effect: Effect): void;
  82800. /**
  82801. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82802. * (eq to shadow prjection matrix * light transform matrix)
  82803. * @returns The transform matrix used to create the shadow map
  82804. */
  82805. getTransformMatrix(): Matrix;
  82806. /**
  82807. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82808. * Cube and 2D textures for instance.
  82809. */
  82810. recreateShadowMap(): void;
  82811. protected _disposeBlurPostProcesses(): void;
  82812. protected _disposeRTTandPostProcesses(): void;
  82813. /**
  82814. * Disposes the ShadowGenerator.
  82815. * Returns nothing.
  82816. */
  82817. dispose(): void;
  82818. /**
  82819. * Serializes the shadow generator setup to a json object.
  82820. * @returns The serialized JSON object
  82821. */
  82822. serialize(): any;
  82823. /**
  82824. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  82825. * @param parsedShadowGenerator The JSON object to parse
  82826. * @param scene The scene to create the shadow map for
  82827. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  82828. * @returns The parsed shadow generator
  82829. */
  82830. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  82831. }
  82832. }
  82833. declare module BABYLON {
  82834. /**
  82835. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  82836. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  82837. * 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.
  82838. */
  82839. export abstract class Light extends Node {
  82840. /**
  82841. * Falloff Default: light is falling off following the material specification:
  82842. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  82843. */
  82844. static readonly FALLOFF_DEFAULT: number;
  82845. /**
  82846. * Falloff Physical: light is falling off following the inverse squared distance law.
  82847. */
  82848. static readonly FALLOFF_PHYSICAL: number;
  82849. /**
  82850. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  82851. * to enhance interoperability with other engines.
  82852. */
  82853. static readonly FALLOFF_GLTF: number;
  82854. /**
  82855. * Falloff Standard: light is falling off like in the standard material
  82856. * to enhance interoperability with other materials.
  82857. */
  82858. static readonly FALLOFF_STANDARD: number;
  82859. /**
  82860. * If every light affecting the material is in this lightmapMode,
  82861. * material.lightmapTexture adds or multiplies
  82862. * (depends on material.useLightmapAsShadowmap)
  82863. * after every other light calculations.
  82864. */
  82865. static readonly LIGHTMAP_DEFAULT: number;
  82866. /**
  82867. * material.lightmapTexture as only diffuse lighting from this light
  82868. * adds only specular lighting from this light
  82869. * adds dynamic shadows
  82870. */
  82871. static readonly LIGHTMAP_SPECULAR: number;
  82872. /**
  82873. * material.lightmapTexture as only lighting
  82874. * no light calculation from this light
  82875. * only adds dynamic shadows from this light
  82876. */
  82877. static readonly LIGHTMAP_SHADOWSONLY: number;
  82878. /**
  82879. * Each light type uses the default quantity according to its type:
  82880. * point/spot lights use luminous intensity
  82881. * directional lights use illuminance
  82882. */
  82883. static readonly INTENSITYMODE_AUTOMATIC: number;
  82884. /**
  82885. * lumen (lm)
  82886. */
  82887. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  82888. /**
  82889. * candela (lm/sr)
  82890. */
  82891. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  82892. /**
  82893. * lux (lm/m^2)
  82894. */
  82895. static readonly INTENSITYMODE_ILLUMINANCE: number;
  82896. /**
  82897. * nit (cd/m^2)
  82898. */
  82899. static readonly INTENSITYMODE_LUMINANCE: number;
  82900. /**
  82901. * Light type const id of the point light.
  82902. */
  82903. static readonly LIGHTTYPEID_POINTLIGHT: number;
  82904. /**
  82905. * Light type const id of the directional light.
  82906. */
  82907. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  82908. /**
  82909. * Light type const id of the spot light.
  82910. */
  82911. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  82912. /**
  82913. * Light type const id of the hemispheric light.
  82914. */
  82915. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  82916. /**
  82917. * Diffuse gives the basic color to an object.
  82918. */
  82919. diffuse: Color3;
  82920. /**
  82921. * Specular produces a highlight color on an object.
  82922. * Note: This is note affecting PBR materials.
  82923. */
  82924. specular: Color3;
  82925. /**
  82926. * Defines the falloff type for this light. This lets overrriding how punctual light are
  82927. * falling off base on range or angle.
  82928. * This can be set to any values in Light.FALLOFF_x.
  82929. *
  82930. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  82931. * other types of materials.
  82932. */
  82933. falloffType: number;
  82934. /**
  82935. * Strength of the light.
  82936. * Note: By default it is define in the framework own unit.
  82937. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  82938. */
  82939. intensity: number;
  82940. private _range;
  82941. protected _inverseSquaredRange: number;
  82942. /**
  82943. * Defines how far from the source the light is impacting in scene units.
  82944. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82945. */
  82946. get range(): number;
  82947. /**
  82948. * Defines how far from the source the light is impacting in scene units.
  82949. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82950. */
  82951. set range(value: number);
  82952. /**
  82953. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  82954. * of light.
  82955. */
  82956. private _photometricScale;
  82957. private _intensityMode;
  82958. /**
  82959. * Gets the photometric scale used to interpret the intensity.
  82960. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82961. */
  82962. get intensityMode(): number;
  82963. /**
  82964. * Sets the photometric scale used to interpret the intensity.
  82965. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82966. */
  82967. set intensityMode(value: number);
  82968. private _radius;
  82969. /**
  82970. * Gets the light radius used by PBR Materials to simulate soft area lights.
  82971. */
  82972. get radius(): number;
  82973. /**
  82974. * sets the light radius used by PBR Materials to simulate soft area lights.
  82975. */
  82976. set radius(value: number);
  82977. private _renderPriority;
  82978. /**
  82979. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  82980. * exceeding the number allowed of the materials.
  82981. */
  82982. renderPriority: number;
  82983. private _shadowEnabled;
  82984. /**
  82985. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82986. * the current shadow generator.
  82987. */
  82988. get shadowEnabled(): boolean;
  82989. /**
  82990. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82991. * the current shadow generator.
  82992. */
  82993. set shadowEnabled(value: boolean);
  82994. private _includedOnlyMeshes;
  82995. /**
  82996. * Gets the only meshes impacted by this light.
  82997. */
  82998. get includedOnlyMeshes(): AbstractMesh[];
  82999. /**
  83000. * Sets the only meshes impacted by this light.
  83001. */
  83002. set includedOnlyMeshes(value: AbstractMesh[]);
  83003. private _excludedMeshes;
  83004. /**
  83005. * Gets the meshes not impacted by this light.
  83006. */
  83007. get excludedMeshes(): AbstractMesh[];
  83008. /**
  83009. * Sets the meshes not impacted by this light.
  83010. */
  83011. set excludedMeshes(value: AbstractMesh[]);
  83012. private _excludeWithLayerMask;
  83013. /**
  83014. * Gets the layer id use to find what meshes are not impacted by the light.
  83015. * Inactive if 0
  83016. */
  83017. get excludeWithLayerMask(): number;
  83018. /**
  83019. * Sets the layer id use to find what meshes are not impacted by the light.
  83020. * Inactive if 0
  83021. */
  83022. set excludeWithLayerMask(value: number);
  83023. private _includeOnlyWithLayerMask;
  83024. /**
  83025. * Gets the layer id use to find what meshes are impacted by the light.
  83026. * Inactive if 0
  83027. */
  83028. get includeOnlyWithLayerMask(): number;
  83029. /**
  83030. * Sets the layer id use to find what meshes are impacted by the light.
  83031. * Inactive if 0
  83032. */
  83033. set includeOnlyWithLayerMask(value: number);
  83034. private _lightmapMode;
  83035. /**
  83036. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  83037. */
  83038. get lightmapMode(): number;
  83039. /**
  83040. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  83041. */
  83042. set lightmapMode(value: number);
  83043. /**
  83044. * Shadow generator associted to the light.
  83045. * @hidden Internal use only.
  83046. */
  83047. _shadowGenerator: Nullable<IShadowGenerator>;
  83048. /**
  83049. * @hidden Internal use only.
  83050. */
  83051. _excludedMeshesIds: string[];
  83052. /**
  83053. * @hidden Internal use only.
  83054. */
  83055. _includedOnlyMeshesIds: string[];
  83056. /**
  83057. * The current light unifom buffer.
  83058. * @hidden Internal use only.
  83059. */
  83060. _uniformBuffer: UniformBuffer;
  83061. /** @hidden */
  83062. _renderId: number;
  83063. /**
  83064. * Creates a Light object in the scene.
  83065. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83066. * @param name The firendly name of the light
  83067. * @param scene The scene the light belongs too
  83068. */
  83069. constructor(name: string, scene: Scene);
  83070. protected abstract _buildUniformLayout(): void;
  83071. /**
  83072. * Sets the passed Effect "effect" with the Light information.
  83073. * @param effect The effect to update
  83074. * @param lightIndex The index of the light in the effect to update
  83075. * @returns The light
  83076. */
  83077. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  83078. /**
  83079. * Sets the passed Effect "effect" with the Light textures.
  83080. * @param effect The effect to update
  83081. * @param lightIndex The index of the light in the effect to update
  83082. * @returns The light
  83083. */
  83084. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  83085. /**
  83086. * Binds the lights information from the scene to the effect for the given mesh.
  83087. * @param lightIndex Light index
  83088. * @param scene The scene where the light belongs to
  83089. * @param effect The effect we are binding the data to
  83090. * @param useSpecular Defines if specular is supported
  83091. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83092. */
  83093. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83094. /**
  83095. * Sets the passed Effect "effect" with the Light information.
  83096. * @param effect The effect to update
  83097. * @param lightDataUniformName The uniform used to store light data (position or direction)
  83098. * @returns The light
  83099. */
  83100. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  83101. /**
  83102. * Returns the string "Light".
  83103. * @returns the class name
  83104. */
  83105. getClassName(): string;
  83106. /** @hidden */
  83107. readonly _isLight: boolean;
  83108. /**
  83109. * Converts the light information to a readable string for debug purpose.
  83110. * @param fullDetails Supports for multiple levels of logging within scene loading
  83111. * @returns the human readable light info
  83112. */
  83113. toString(fullDetails?: boolean): string;
  83114. /** @hidden */
  83115. protected _syncParentEnabledState(): void;
  83116. /**
  83117. * Set the enabled state of this node.
  83118. * @param value - the new enabled state
  83119. */
  83120. setEnabled(value: boolean): void;
  83121. /**
  83122. * Returns the Light associated shadow generator if any.
  83123. * @return the associated shadow generator.
  83124. */
  83125. getShadowGenerator(): Nullable<IShadowGenerator>;
  83126. /**
  83127. * Returns a Vector3, the absolute light position in the World.
  83128. * @returns the world space position of the light
  83129. */
  83130. getAbsolutePosition(): Vector3;
  83131. /**
  83132. * Specifies if the light will affect the passed mesh.
  83133. * @param mesh The mesh to test against the light
  83134. * @return true the mesh is affected otherwise, false.
  83135. */
  83136. canAffectMesh(mesh: AbstractMesh): boolean;
  83137. /**
  83138. * Sort function to order lights for rendering.
  83139. * @param a First Light object to compare to second.
  83140. * @param b Second Light object to compare first.
  83141. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  83142. */
  83143. static CompareLightsPriority(a: Light, b: Light): number;
  83144. /**
  83145. * Releases resources associated with this node.
  83146. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83147. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83148. */
  83149. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83150. /**
  83151. * Returns the light type ID (integer).
  83152. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83153. */
  83154. getTypeID(): number;
  83155. /**
  83156. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  83157. * @returns the scaled intensity in intensity mode unit
  83158. */
  83159. getScaledIntensity(): number;
  83160. /**
  83161. * Returns a new Light object, named "name", from the current one.
  83162. * @param name The name of the cloned light
  83163. * @returns the new created light
  83164. */
  83165. clone(name: string): Nullable<Light>;
  83166. /**
  83167. * Serializes the current light into a Serialization object.
  83168. * @returns the serialized object.
  83169. */
  83170. serialize(): any;
  83171. /**
  83172. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  83173. * This new light is named "name" and added to the passed scene.
  83174. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  83175. * @param name The friendly name of the light
  83176. * @param scene The scene the new light will belong to
  83177. * @returns the constructor function
  83178. */
  83179. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  83180. /**
  83181. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  83182. * @param parsedLight The JSON representation of the light
  83183. * @param scene The scene to create the parsed light in
  83184. * @returns the created light after parsing
  83185. */
  83186. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  83187. private _hookArrayForExcluded;
  83188. private _hookArrayForIncludedOnly;
  83189. private _resyncMeshes;
  83190. /**
  83191. * Forces the meshes to update their light related information in their rendering used effects
  83192. * @hidden Internal Use Only
  83193. */
  83194. _markMeshesAsLightDirty(): void;
  83195. /**
  83196. * Recomputes the cached photometric scale if needed.
  83197. */
  83198. private _computePhotometricScale;
  83199. /**
  83200. * Returns the Photometric Scale according to the light type and intensity mode.
  83201. */
  83202. private _getPhotometricScale;
  83203. /**
  83204. * Reorder the light in the scene according to their defined priority.
  83205. * @hidden Internal Use Only
  83206. */
  83207. _reorderLightsInScene(): void;
  83208. /**
  83209. * Prepares the list of defines specific to the light type.
  83210. * @param defines the list of defines
  83211. * @param lightIndex defines the index of the light for the effect
  83212. */
  83213. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83214. }
  83215. }
  83216. declare module BABYLON {
  83217. /**
  83218. * Interface used to define Action
  83219. */
  83220. export interface IAction {
  83221. /**
  83222. * Trigger for the action
  83223. */
  83224. trigger: number;
  83225. /** Options of the trigger */
  83226. triggerOptions: any;
  83227. /**
  83228. * Gets the trigger parameters
  83229. * @returns the trigger parameters
  83230. */
  83231. getTriggerParameter(): any;
  83232. /**
  83233. * Internal only - executes current action event
  83234. * @hidden
  83235. */
  83236. _executeCurrent(evt?: ActionEvent): void;
  83237. /**
  83238. * Serialize placeholder for child classes
  83239. * @param parent of child
  83240. * @returns the serialized object
  83241. */
  83242. serialize(parent: any): any;
  83243. /**
  83244. * Internal only
  83245. * @hidden
  83246. */
  83247. _prepare(): void;
  83248. /**
  83249. * Internal only - manager for action
  83250. * @hidden
  83251. */
  83252. _actionManager: AbstractActionManager;
  83253. /**
  83254. * Adds action to chain of actions, may be a DoNothingAction
  83255. * @param action defines the next action to execute
  83256. * @returns The action passed in
  83257. * @see https://www.babylonjs-playground.com/#1T30HR#0
  83258. */
  83259. then(action: IAction): IAction;
  83260. }
  83261. /**
  83262. * The action to be carried out following a trigger
  83263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  83264. */
  83265. export class Action implements IAction {
  83266. /** the trigger, with or without parameters, for the action */
  83267. triggerOptions: any;
  83268. /**
  83269. * Trigger for the action
  83270. */
  83271. trigger: number;
  83272. /**
  83273. * Internal only - manager for action
  83274. * @hidden
  83275. */
  83276. _actionManager: ActionManager;
  83277. private _nextActiveAction;
  83278. private _child;
  83279. private _condition?;
  83280. private _triggerParameter;
  83281. /**
  83282. * An event triggered prior to action being executed.
  83283. */
  83284. onBeforeExecuteObservable: Observable<Action>;
  83285. /**
  83286. * Creates a new Action
  83287. * @param triggerOptions the trigger, with or without parameters, for the action
  83288. * @param condition an optional determinant of action
  83289. */
  83290. constructor(
  83291. /** the trigger, with or without parameters, for the action */
  83292. triggerOptions: any, condition?: Condition);
  83293. /**
  83294. * Internal only
  83295. * @hidden
  83296. */
  83297. _prepare(): void;
  83298. /**
  83299. * Gets the trigger parameters
  83300. * @returns the trigger parameters
  83301. */
  83302. getTriggerParameter(): any;
  83303. /**
  83304. * Internal only - executes current action event
  83305. * @hidden
  83306. */
  83307. _executeCurrent(evt?: ActionEvent): void;
  83308. /**
  83309. * Execute placeholder for child classes
  83310. * @param evt optional action event
  83311. */
  83312. execute(evt?: ActionEvent): void;
  83313. /**
  83314. * Skips to next active action
  83315. */
  83316. skipToNextActiveAction(): void;
  83317. /**
  83318. * Adds action to chain of actions, may be a DoNothingAction
  83319. * @param action defines the next action to execute
  83320. * @returns The action passed in
  83321. * @see https://www.babylonjs-playground.com/#1T30HR#0
  83322. */
  83323. then(action: Action): Action;
  83324. /**
  83325. * Internal only
  83326. * @hidden
  83327. */
  83328. _getProperty(propertyPath: string): string;
  83329. /**
  83330. * Internal only
  83331. * @hidden
  83332. */
  83333. _getEffectiveTarget(target: any, propertyPath: string): any;
  83334. /**
  83335. * Serialize placeholder for child classes
  83336. * @param parent of child
  83337. * @returns the serialized object
  83338. */
  83339. serialize(parent: any): any;
  83340. /**
  83341. * Internal only called by serialize
  83342. * @hidden
  83343. */
  83344. protected _serialize(serializedAction: any, parent?: any): any;
  83345. /**
  83346. * Internal only
  83347. * @hidden
  83348. */
  83349. static _SerializeValueAsString: (value: any) => string;
  83350. /**
  83351. * Internal only
  83352. * @hidden
  83353. */
  83354. static _GetTargetProperty: (target: Node | Scene) => {
  83355. name: string;
  83356. targetType: string;
  83357. value: string;
  83358. };
  83359. }
  83360. }
  83361. declare module BABYLON {
  83362. /**
  83363. * A Condition applied to an Action
  83364. */
  83365. export class Condition {
  83366. /**
  83367. * Internal only - manager for action
  83368. * @hidden
  83369. */
  83370. _actionManager: ActionManager;
  83371. /**
  83372. * Internal only
  83373. * @hidden
  83374. */
  83375. _evaluationId: number;
  83376. /**
  83377. * Internal only
  83378. * @hidden
  83379. */
  83380. _currentResult: boolean;
  83381. /**
  83382. * Creates a new Condition
  83383. * @param actionManager the manager of the action the condition is applied to
  83384. */
  83385. constructor(actionManager: ActionManager);
  83386. /**
  83387. * Check if the current condition is valid
  83388. * @returns a boolean
  83389. */
  83390. isValid(): boolean;
  83391. /**
  83392. * Internal only
  83393. * @hidden
  83394. */
  83395. _getProperty(propertyPath: string): string;
  83396. /**
  83397. * Internal only
  83398. * @hidden
  83399. */
  83400. _getEffectiveTarget(target: any, propertyPath: string): any;
  83401. /**
  83402. * Serialize placeholder for child classes
  83403. * @returns the serialized object
  83404. */
  83405. serialize(): any;
  83406. /**
  83407. * Internal only
  83408. * @hidden
  83409. */
  83410. protected _serialize(serializedCondition: any): any;
  83411. }
  83412. /**
  83413. * Defines specific conditional operators as extensions of Condition
  83414. */
  83415. export class ValueCondition extends Condition {
  83416. /** path to specify the property of the target the conditional operator uses */
  83417. propertyPath: string;
  83418. /** the value compared by the conditional operator against the current value of the property */
  83419. value: any;
  83420. /** the conditional operator, default ValueCondition.IsEqual */
  83421. operator: number;
  83422. /**
  83423. * Internal only
  83424. * @hidden
  83425. */
  83426. private static _IsEqual;
  83427. /**
  83428. * Internal only
  83429. * @hidden
  83430. */
  83431. private static _IsDifferent;
  83432. /**
  83433. * Internal only
  83434. * @hidden
  83435. */
  83436. private static _IsGreater;
  83437. /**
  83438. * Internal only
  83439. * @hidden
  83440. */
  83441. private static _IsLesser;
  83442. /**
  83443. * returns the number for IsEqual
  83444. */
  83445. static get IsEqual(): number;
  83446. /**
  83447. * Returns the number for IsDifferent
  83448. */
  83449. static get IsDifferent(): number;
  83450. /**
  83451. * Returns the number for IsGreater
  83452. */
  83453. static get IsGreater(): number;
  83454. /**
  83455. * Returns the number for IsLesser
  83456. */
  83457. static get IsLesser(): number;
  83458. /**
  83459. * Internal only The action manager for the condition
  83460. * @hidden
  83461. */
  83462. _actionManager: ActionManager;
  83463. /**
  83464. * Internal only
  83465. * @hidden
  83466. */
  83467. private _target;
  83468. /**
  83469. * Internal only
  83470. * @hidden
  83471. */
  83472. private _effectiveTarget;
  83473. /**
  83474. * Internal only
  83475. * @hidden
  83476. */
  83477. private _property;
  83478. /**
  83479. * Creates a new ValueCondition
  83480. * @param actionManager manager for the action the condition applies to
  83481. * @param target for the action
  83482. * @param propertyPath path to specify the property of the target the conditional operator uses
  83483. * @param value the value compared by the conditional operator against the current value of the property
  83484. * @param operator the conditional operator, default ValueCondition.IsEqual
  83485. */
  83486. constructor(actionManager: ActionManager, target: any,
  83487. /** path to specify the property of the target the conditional operator uses */
  83488. propertyPath: string,
  83489. /** the value compared by the conditional operator against the current value of the property */
  83490. value: any,
  83491. /** the conditional operator, default ValueCondition.IsEqual */
  83492. operator?: number);
  83493. /**
  83494. * Compares the given value with the property value for the specified conditional operator
  83495. * @returns the result of the comparison
  83496. */
  83497. isValid(): boolean;
  83498. /**
  83499. * Serialize the ValueCondition into a JSON compatible object
  83500. * @returns serialization object
  83501. */
  83502. serialize(): any;
  83503. /**
  83504. * Gets the name of the conditional operator for the ValueCondition
  83505. * @param operator the conditional operator
  83506. * @returns the name
  83507. */
  83508. static GetOperatorName(operator: number): string;
  83509. }
  83510. /**
  83511. * Defines a predicate condition as an extension of Condition
  83512. */
  83513. export class PredicateCondition extends Condition {
  83514. /** defines the predicate function used to validate the condition */
  83515. predicate: () => boolean;
  83516. /**
  83517. * Internal only - manager for action
  83518. * @hidden
  83519. */
  83520. _actionManager: ActionManager;
  83521. /**
  83522. * Creates a new PredicateCondition
  83523. * @param actionManager manager for the action the condition applies to
  83524. * @param predicate defines the predicate function used to validate the condition
  83525. */
  83526. constructor(actionManager: ActionManager,
  83527. /** defines the predicate function used to validate the condition */
  83528. predicate: () => boolean);
  83529. /**
  83530. * @returns the validity of the predicate condition
  83531. */
  83532. isValid(): boolean;
  83533. }
  83534. /**
  83535. * Defines a state condition as an extension of Condition
  83536. */
  83537. export class StateCondition extends Condition {
  83538. /** Value to compare with target state */
  83539. value: string;
  83540. /**
  83541. * Internal only - manager for action
  83542. * @hidden
  83543. */
  83544. _actionManager: ActionManager;
  83545. /**
  83546. * Internal only
  83547. * @hidden
  83548. */
  83549. private _target;
  83550. /**
  83551. * Creates a new StateCondition
  83552. * @param actionManager manager for the action the condition applies to
  83553. * @param target of the condition
  83554. * @param value to compare with target state
  83555. */
  83556. constructor(actionManager: ActionManager, target: any,
  83557. /** Value to compare with target state */
  83558. value: string);
  83559. /**
  83560. * Gets a boolean indicating if the current condition is met
  83561. * @returns the validity of the state
  83562. */
  83563. isValid(): boolean;
  83564. /**
  83565. * Serialize the StateCondition into a JSON compatible object
  83566. * @returns serialization object
  83567. */
  83568. serialize(): any;
  83569. }
  83570. }
  83571. declare module BABYLON {
  83572. /**
  83573. * This defines an action responsible to toggle a boolean once triggered.
  83574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83575. */
  83576. export class SwitchBooleanAction extends Action {
  83577. /**
  83578. * The path to the boolean property in the target object
  83579. */
  83580. propertyPath: string;
  83581. private _target;
  83582. private _effectiveTarget;
  83583. private _property;
  83584. /**
  83585. * Instantiate the action
  83586. * @param triggerOptions defines the trigger options
  83587. * @param target defines the object containing the boolean
  83588. * @param propertyPath defines the path to the boolean property in the target object
  83589. * @param condition defines the trigger related conditions
  83590. */
  83591. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  83592. /** @hidden */
  83593. _prepare(): void;
  83594. /**
  83595. * Execute the action toggle the boolean value.
  83596. */
  83597. execute(): void;
  83598. /**
  83599. * Serializes the actions and its related information.
  83600. * @param parent defines the object to serialize in
  83601. * @returns the serialized object
  83602. */
  83603. serialize(parent: any): any;
  83604. }
  83605. /**
  83606. * This defines an action responsible to set a the state field of the target
  83607. * to a desired value once triggered.
  83608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83609. */
  83610. export class SetStateAction extends Action {
  83611. /**
  83612. * The value to store in the state field.
  83613. */
  83614. value: string;
  83615. private _target;
  83616. /**
  83617. * Instantiate the action
  83618. * @param triggerOptions defines the trigger options
  83619. * @param target defines the object containing the state property
  83620. * @param value defines the value to store in the state field
  83621. * @param condition defines the trigger related conditions
  83622. */
  83623. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  83624. /**
  83625. * Execute the action and store the value on the target state property.
  83626. */
  83627. execute(): void;
  83628. /**
  83629. * Serializes the actions and its related information.
  83630. * @param parent defines the object to serialize in
  83631. * @returns the serialized object
  83632. */
  83633. serialize(parent: any): any;
  83634. }
  83635. /**
  83636. * This defines an action responsible to set a property of the target
  83637. * to a desired value once triggered.
  83638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83639. */
  83640. export class SetValueAction extends Action {
  83641. /**
  83642. * The path of the property to set in the target.
  83643. */
  83644. propertyPath: string;
  83645. /**
  83646. * The value to set in the property
  83647. */
  83648. value: any;
  83649. private _target;
  83650. private _effectiveTarget;
  83651. private _property;
  83652. /**
  83653. * Instantiate the action
  83654. * @param triggerOptions defines the trigger options
  83655. * @param target defines the object containing the property
  83656. * @param propertyPath defines the path of the property to set in the target
  83657. * @param value defines the value to set in the property
  83658. * @param condition defines the trigger related conditions
  83659. */
  83660. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83661. /** @hidden */
  83662. _prepare(): void;
  83663. /**
  83664. * Execute the action and set the targetted property to the desired value.
  83665. */
  83666. execute(): void;
  83667. /**
  83668. * Serializes the actions and its related information.
  83669. * @param parent defines the object to serialize in
  83670. * @returns the serialized object
  83671. */
  83672. serialize(parent: any): any;
  83673. }
  83674. /**
  83675. * This defines an action responsible to increment the target value
  83676. * to a desired value once triggered.
  83677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83678. */
  83679. export class IncrementValueAction extends Action {
  83680. /**
  83681. * The path of the property to increment in the target.
  83682. */
  83683. propertyPath: string;
  83684. /**
  83685. * The value we should increment the property by.
  83686. */
  83687. value: any;
  83688. private _target;
  83689. private _effectiveTarget;
  83690. private _property;
  83691. /**
  83692. * Instantiate the action
  83693. * @param triggerOptions defines the trigger options
  83694. * @param target defines the object containing the property
  83695. * @param propertyPath defines the path of the property to increment in the target
  83696. * @param value defines the value value we should increment the property by
  83697. * @param condition defines the trigger related conditions
  83698. */
  83699. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83700. /** @hidden */
  83701. _prepare(): void;
  83702. /**
  83703. * Execute the action and increment the target of the value amount.
  83704. */
  83705. execute(): void;
  83706. /**
  83707. * Serializes the actions and its related information.
  83708. * @param parent defines the object to serialize in
  83709. * @returns the serialized object
  83710. */
  83711. serialize(parent: any): any;
  83712. }
  83713. /**
  83714. * This defines an action responsible to start an animation once triggered.
  83715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83716. */
  83717. export class PlayAnimationAction extends Action {
  83718. /**
  83719. * Where the animation should start (animation frame)
  83720. */
  83721. from: number;
  83722. /**
  83723. * Where the animation should stop (animation frame)
  83724. */
  83725. to: number;
  83726. /**
  83727. * Define if the animation should loop or stop after the first play.
  83728. */
  83729. loop?: boolean;
  83730. private _target;
  83731. /**
  83732. * Instantiate the action
  83733. * @param triggerOptions defines the trigger options
  83734. * @param target defines the target animation or animation name
  83735. * @param from defines from where the animation should start (animation frame)
  83736. * @param end defines where the animation should stop (animation frame)
  83737. * @param loop defines if the animation should loop or stop after the first play
  83738. * @param condition defines the trigger related conditions
  83739. */
  83740. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  83741. /** @hidden */
  83742. _prepare(): void;
  83743. /**
  83744. * Execute the action and play the animation.
  83745. */
  83746. execute(): void;
  83747. /**
  83748. * Serializes the actions and its related information.
  83749. * @param parent defines the object to serialize in
  83750. * @returns the serialized object
  83751. */
  83752. serialize(parent: any): any;
  83753. }
  83754. /**
  83755. * This defines an action responsible to stop an animation once triggered.
  83756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83757. */
  83758. export class StopAnimationAction extends Action {
  83759. private _target;
  83760. /**
  83761. * Instantiate the action
  83762. * @param triggerOptions defines the trigger options
  83763. * @param target defines the target animation or animation name
  83764. * @param condition defines the trigger related conditions
  83765. */
  83766. constructor(triggerOptions: any, target: any, condition?: Condition);
  83767. /** @hidden */
  83768. _prepare(): void;
  83769. /**
  83770. * Execute the action and stop the animation.
  83771. */
  83772. execute(): void;
  83773. /**
  83774. * Serializes the actions and its related information.
  83775. * @param parent defines the object to serialize in
  83776. * @returns the serialized object
  83777. */
  83778. serialize(parent: any): any;
  83779. }
  83780. /**
  83781. * This defines an action responsible that does nothing once triggered.
  83782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83783. */
  83784. export class DoNothingAction extends Action {
  83785. /**
  83786. * Instantiate the action
  83787. * @param triggerOptions defines the trigger options
  83788. * @param condition defines the trigger related conditions
  83789. */
  83790. constructor(triggerOptions?: any, condition?: Condition);
  83791. /**
  83792. * Execute the action and do nothing.
  83793. */
  83794. execute(): void;
  83795. /**
  83796. * Serializes the actions and its related information.
  83797. * @param parent defines the object to serialize in
  83798. * @returns the serialized object
  83799. */
  83800. serialize(parent: any): any;
  83801. }
  83802. /**
  83803. * This defines an action responsible to trigger several actions once triggered.
  83804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83805. */
  83806. export class CombineAction extends Action {
  83807. /**
  83808. * The list of aggregated animations to run.
  83809. */
  83810. children: Action[];
  83811. /**
  83812. * Instantiate the action
  83813. * @param triggerOptions defines the trigger options
  83814. * @param children defines the list of aggregated animations to run
  83815. * @param condition defines the trigger related conditions
  83816. */
  83817. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  83818. /** @hidden */
  83819. _prepare(): void;
  83820. /**
  83821. * Execute the action and executes all the aggregated actions.
  83822. */
  83823. execute(evt: ActionEvent): void;
  83824. /**
  83825. * Serializes the actions and its related information.
  83826. * @param parent defines the object to serialize in
  83827. * @returns the serialized object
  83828. */
  83829. serialize(parent: any): any;
  83830. }
  83831. /**
  83832. * This defines an action responsible to run code (external event) once triggered.
  83833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83834. */
  83835. export class ExecuteCodeAction extends Action {
  83836. /**
  83837. * The callback function to run.
  83838. */
  83839. func: (evt: ActionEvent) => void;
  83840. /**
  83841. * Instantiate the action
  83842. * @param triggerOptions defines the trigger options
  83843. * @param func defines the callback function to run
  83844. * @param condition defines the trigger related conditions
  83845. */
  83846. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  83847. /**
  83848. * Execute the action and run the attached code.
  83849. */
  83850. execute(evt: ActionEvent): void;
  83851. }
  83852. /**
  83853. * This defines an action responsible to set the parent property of the target once triggered.
  83854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83855. */
  83856. export class SetParentAction extends Action {
  83857. private _parent;
  83858. private _target;
  83859. /**
  83860. * Instantiate the action
  83861. * @param triggerOptions defines the trigger options
  83862. * @param target defines the target containing the parent property
  83863. * @param parent defines from where the animation should start (animation frame)
  83864. * @param condition defines the trigger related conditions
  83865. */
  83866. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  83867. /** @hidden */
  83868. _prepare(): void;
  83869. /**
  83870. * Execute the action and set the parent property.
  83871. */
  83872. execute(): void;
  83873. /**
  83874. * Serializes the actions and its related information.
  83875. * @param parent defines the object to serialize in
  83876. * @returns the serialized object
  83877. */
  83878. serialize(parent: any): any;
  83879. }
  83880. }
  83881. declare module BABYLON {
  83882. /**
  83883. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  83884. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  83885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83886. */
  83887. export class ActionManager extends AbstractActionManager {
  83888. /**
  83889. * Nothing
  83890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83891. */
  83892. static readonly NothingTrigger: number;
  83893. /**
  83894. * On pick
  83895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83896. */
  83897. static readonly OnPickTrigger: number;
  83898. /**
  83899. * On left pick
  83900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83901. */
  83902. static readonly OnLeftPickTrigger: number;
  83903. /**
  83904. * On right pick
  83905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83906. */
  83907. static readonly OnRightPickTrigger: number;
  83908. /**
  83909. * On center pick
  83910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83911. */
  83912. static readonly OnCenterPickTrigger: number;
  83913. /**
  83914. * On pick down
  83915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83916. */
  83917. static readonly OnPickDownTrigger: number;
  83918. /**
  83919. * On double pick
  83920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83921. */
  83922. static readonly OnDoublePickTrigger: number;
  83923. /**
  83924. * On pick up
  83925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83926. */
  83927. static readonly OnPickUpTrigger: number;
  83928. /**
  83929. * On pick out.
  83930. * This trigger will only be raised if you also declared a OnPickDown
  83931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83932. */
  83933. static readonly OnPickOutTrigger: number;
  83934. /**
  83935. * On long press
  83936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83937. */
  83938. static readonly OnLongPressTrigger: number;
  83939. /**
  83940. * On pointer over
  83941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83942. */
  83943. static readonly OnPointerOverTrigger: number;
  83944. /**
  83945. * On pointer out
  83946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83947. */
  83948. static readonly OnPointerOutTrigger: number;
  83949. /**
  83950. * On every frame
  83951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83952. */
  83953. static readonly OnEveryFrameTrigger: number;
  83954. /**
  83955. * On intersection enter
  83956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83957. */
  83958. static readonly OnIntersectionEnterTrigger: number;
  83959. /**
  83960. * On intersection exit
  83961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83962. */
  83963. static readonly OnIntersectionExitTrigger: number;
  83964. /**
  83965. * On key down
  83966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83967. */
  83968. static readonly OnKeyDownTrigger: number;
  83969. /**
  83970. * On key up
  83971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83972. */
  83973. static readonly OnKeyUpTrigger: number;
  83974. private _scene;
  83975. /**
  83976. * Creates a new action manager
  83977. * @param scene defines the hosting scene
  83978. */
  83979. constructor(scene: Scene);
  83980. /**
  83981. * Releases all associated resources
  83982. */
  83983. dispose(): void;
  83984. /**
  83985. * Gets hosting scene
  83986. * @returns the hosting scene
  83987. */
  83988. getScene(): Scene;
  83989. /**
  83990. * Does this action manager handles actions of any of the given triggers
  83991. * @param triggers defines the triggers to be tested
  83992. * @return a boolean indicating whether one (or more) of the triggers is handled
  83993. */
  83994. hasSpecificTriggers(triggers: number[]): boolean;
  83995. /**
  83996. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83997. * speed.
  83998. * @param triggerA defines the trigger to be tested
  83999. * @param triggerB defines the trigger to be tested
  84000. * @return a boolean indicating whether one (or more) of the triggers is handled
  84001. */
  84002. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84003. /**
  84004. * Does this action manager handles actions of a given trigger
  84005. * @param trigger defines the trigger to be tested
  84006. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84007. * @return whether the trigger is handled
  84008. */
  84009. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84010. /**
  84011. * Does this action manager has pointer triggers
  84012. */
  84013. get hasPointerTriggers(): boolean;
  84014. /**
  84015. * Does this action manager has pick triggers
  84016. */
  84017. get hasPickTriggers(): boolean;
  84018. /**
  84019. * Registers an action to this action manager
  84020. * @param action defines the action to be registered
  84021. * @return the action amended (prepared) after registration
  84022. */
  84023. registerAction(action: IAction): Nullable<IAction>;
  84024. /**
  84025. * Unregisters an action to this action manager
  84026. * @param action defines the action to be unregistered
  84027. * @return a boolean indicating whether the action has been unregistered
  84028. */
  84029. unregisterAction(action: IAction): Boolean;
  84030. /**
  84031. * Process a specific trigger
  84032. * @param trigger defines the trigger to process
  84033. * @param evt defines the event details to be processed
  84034. */
  84035. processTrigger(trigger: number, evt?: IActionEvent): void;
  84036. /** @hidden */
  84037. _getEffectiveTarget(target: any, propertyPath: string): any;
  84038. /** @hidden */
  84039. _getProperty(propertyPath: string): string;
  84040. /**
  84041. * Serialize this manager to a JSON object
  84042. * @param name defines the property name to store this manager
  84043. * @returns a JSON representation of this manager
  84044. */
  84045. serialize(name: string): any;
  84046. /**
  84047. * Creates a new ActionManager from a JSON data
  84048. * @param parsedActions defines the JSON data to read from
  84049. * @param object defines the hosting mesh
  84050. * @param scene defines the hosting scene
  84051. */
  84052. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  84053. /**
  84054. * Get a trigger name by index
  84055. * @param trigger defines the trigger index
  84056. * @returns a trigger name
  84057. */
  84058. static GetTriggerName(trigger: number): string;
  84059. }
  84060. }
  84061. declare module BABYLON {
  84062. /**
  84063. * Class representing a ray with position and direction
  84064. */
  84065. export class Ray {
  84066. /** origin point */
  84067. origin: Vector3;
  84068. /** direction */
  84069. direction: Vector3;
  84070. /** length of the ray */
  84071. length: number;
  84072. private static readonly TmpVector3;
  84073. private _tmpRay;
  84074. /**
  84075. * Creates a new ray
  84076. * @param origin origin point
  84077. * @param direction direction
  84078. * @param length length of the ray
  84079. */
  84080. constructor(
  84081. /** origin point */
  84082. origin: Vector3,
  84083. /** direction */
  84084. direction: Vector3,
  84085. /** length of the ray */
  84086. length?: number);
  84087. /**
  84088. * Checks if the ray intersects a box
  84089. * @param minimum bound of the box
  84090. * @param maximum bound of the box
  84091. * @param intersectionTreshold extra extend to be added to the box in all direction
  84092. * @returns if the box was hit
  84093. */
  84094. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  84095. /**
  84096. * Checks if the ray intersects a box
  84097. * @param box the bounding box to check
  84098. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  84099. * @returns if the box was hit
  84100. */
  84101. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  84102. /**
  84103. * If the ray hits a sphere
  84104. * @param sphere the bounding sphere to check
  84105. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  84106. * @returns true if it hits the sphere
  84107. */
  84108. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  84109. /**
  84110. * If the ray hits a triange
  84111. * @param vertex0 triangle vertex
  84112. * @param vertex1 triangle vertex
  84113. * @param vertex2 triangle vertex
  84114. * @returns intersection information if hit
  84115. */
  84116. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  84117. /**
  84118. * Checks if ray intersects a plane
  84119. * @param plane the plane to check
  84120. * @returns the distance away it was hit
  84121. */
  84122. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  84123. /**
  84124. * Calculate the intercept of a ray on a given axis
  84125. * @param axis to check 'x' | 'y' | 'z'
  84126. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  84127. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  84128. */
  84129. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  84130. /**
  84131. * Checks if ray intersects a mesh
  84132. * @param mesh the mesh to check
  84133. * @param fastCheck if only the bounding box should checked
  84134. * @returns picking info of the intersecton
  84135. */
  84136. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  84137. /**
  84138. * Checks if ray intersects a mesh
  84139. * @param meshes the meshes to check
  84140. * @param fastCheck if only the bounding box should checked
  84141. * @param results array to store result in
  84142. * @returns Array of picking infos
  84143. */
  84144. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  84145. private _comparePickingInfo;
  84146. private static smallnum;
  84147. private static rayl;
  84148. /**
  84149. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  84150. * @param sega the first point of the segment to test the intersection against
  84151. * @param segb the second point of the segment to test the intersection against
  84152. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  84153. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  84154. */
  84155. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  84156. /**
  84157. * Update the ray from viewport position
  84158. * @param x position
  84159. * @param y y position
  84160. * @param viewportWidth viewport width
  84161. * @param viewportHeight viewport height
  84162. * @param world world matrix
  84163. * @param view view matrix
  84164. * @param projection projection matrix
  84165. * @returns this ray updated
  84166. */
  84167. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  84168. /**
  84169. * Creates a ray with origin and direction of 0,0,0
  84170. * @returns the new ray
  84171. */
  84172. static Zero(): Ray;
  84173. /**
  84174. * Creates a new ray from screen space and viewport
  84175. * @param x position
  84176. * @param y y position
  84177. * @param viewportWidth viewport width
  84178. * @param viewportHeight viewport height
  84179. * @param world world matrix
  84180. * @param view view matrix
  84181. * @param projection projection matrix
  84182. * @returns new ray
  84183. */
  84184. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  84185. /**
  84186. * 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
  84187. * transformed to the given world matrix.
  84188. * @param origin The origin point
  84189. * @param end The end point
  84190. * @param world a matrix to transform the ray to. Default is the identity matrix.
  84191. * @returns the new ray
  84192. */
  84193. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  84194. /**
  84195. * Transforms a ray by a matrix
  84196. * @param ray ray to transform
  84197. * @param matrix matrix to apply
  84198. * @returns the resulting new ray
  84199. */
  84200. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  84201. /**
  84202. * Transforms a ray by a matrix
  84203. * @param ray ray to transform
  84204. * @param matrix matrix to apply
  84205. * @param result ray to store result in
  84206. */
  84207. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  84208. /**
  84209. * Unproject a ray from screen space to object space
  84210. * @param sourceX defines the screen space x coordinate to use
  84211. * @param sourceY defines the screen space y coordinate to use
  84212. * @param viewportWidth defines the current width of the viewport
  84213. * @param viewportHeight defines the current height of the viewport
  84214. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84215. * @param view defines the view matrix to use
  84216. * @param projection defines the projection matrix to use
  84217. */
  84218. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  84219. }
  84220. /**
  84221. * Type used to define predicate used to select faces when a mesh intersection is detected
  84222. */
  84223. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  84224. interface Scene {
  84225. /** @hidden */
  84226. _tempPickingRay: Nullable<Ray>;
  84227. /** @hidden */
  84228. _cachedRayForTransform: Ray;
  84229. /** @hidden */
  84230. _pickWithRayInverseMatrix: Matrix;
  84231. /** @hidden */
  84232. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  84233. /** @hidden */
  84234. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  84235. }
  84236. }
  84237. declare module BABYLON {
  84238. /**
  84239. * Groups all the scene component constants in one place to ease maintenance.
  84240. * @hidden
  84241. */
  84242. export class SceneComponentConstants {
  84243. static readonly NAME_EFFECTLAYER: string;
  84244. static readonly NAME_LAYER: string;
  84245. static readonly NAME_LENSFLARESYSTEM: string;
  84246. static readonly NAME_BOUNDINGBOXRENDERER: string;
  84247. static readonly NAME_PARTICLESYSTEM: string;
  84248. static readonly NAME_GAMEPAD: string;
  84249. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  84250. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  84251. static readonly NAME_DEPTHRENDERER: string;
  84252. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  84253. static readonly NAME_SPRITE: string;
  84254. static readonly NAME_OUTLINERENDERER: string;
  84255. static readonly NAME_PROCEDURALTEXTURE: string;
  84256. static readonly NAME_SHADOWGENERATOR: string;
  84257. static readonly NAME_OCTREE: string;
  84258. static readonly NAME_PHYSICSENGINE: string;
  84259. static readonly NAME_AUDIO: string;
  84260. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  84261. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84262. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  84263. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84264. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  84265. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  84266. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  84267. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  84268. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  84269. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  84270. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  84271. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  84272. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  84273. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  84274. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  84275. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  84276. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  84277. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  84278. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  84279. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  84280. static readonly STEP_AFTERRENDER_AUDIO: number;
  84281. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  84282. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  84283. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  84284. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  84285. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  84286. static readonly STEP_POINTERMOVE_SPRITE: number;
  84287. static readonly STEP_POINTERDOWN_SPRITE: number;
  84288. static readonly STEP_POINTERUP_SPRITE: number;
  84289. }
  84290. /**
  84291. * This represents a scene component.
  84292. *
  84293. * This is used to decouple the dependency the scene is having on the different workloads like
  84294. * layers, post processes...
  84295. */
  84296. export interface ISceneComponent {
  84297. /**
  84298. * The name of the component. Each component must have a unique name.
  84299. */
  84300. name: string;
  84301. /**
  84302. * The scene the component belongs to.
  84303. */
  84304. scene: Scene;
  84305. /**
  84306. * Register the component to one instance of a scene.
  84307. */
  84308. register(): void;
  84309. /**
  84310. * Rebuilds the elements related to this component in case of
  84311. * context lost for instance.
  84312. */
  84313. rebuild(): void;
  84314. /**
  84315. * Disposes the component and the associated ressources.
  84316. */
  84317. dispose(): void;
  84318. }
  84319. /**
  84320. * This represents a SERIALIZABLE scene component.
  84321. *
  84322. * This extends Scene Component to add Serialization methods on top.
  84323. */
  84324. export interface ISceneSerializableComponent extends ISceneComponent {
  84325. /**
  84326. * Adds all the elements from the container to the scene
  84327. * @param container the container holding the elements
  84328. */
  84329. addFromContainer(container: AbstractScene): void;
  84330. /**
  84331. * Removes all the elements in the container from the scene
  84332. * @param container contains the elements to remove
  84333. * @param dispose if the removed element should be disposed (default: false)
  84334. */
  84335. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84336. /**
  84337. * Serializes the component data to the specified json object
  84338. * @param serializationObject The object to serialize to
  84339. */
  84340. serialize(serializationObject: any): void;
  84341. }
  84342. /**
  84343. * Strong typing of a Mesh related stage step action
  84344. */
  84345. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84346. /**
  84347. * Strong typing of a Evaluate Sub Mesh related stage step action
  84348. */
  84349. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84350. /**
  84351. * Strong typing of a Active Mesh related stage step action
  84352. */
  84353. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84354. /**
  84355. * Strong typing of a Camera related stage step action
  84356. */
  84357. export type CameraStageAction = (camera: Camera) => void;
  84358. /**
  84359. * Strong typing of a Camera Frame buffer related stage step action
  84360. */
  84361. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84362. /**
  84363. * Strong typing of a Render Target related stage step action
  84364. */
  84365. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84366. /**
  84367. * Strong typing of a RenderingGroup related stage step action
  84368. */
  84369. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84370. /**
  84371. * Strong typing of a Mesh Render related stage step action
  84372. */
  84373. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84374. /**
  84375. * Strong typing of a simple stage step action
  84376. */
  84377. export type SimpleStageAction = () => void;
  84378. /**
  84379. * Strong typing of a render target action.
  84380. */
  84381. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84382. /**
  84383. * Strong typing of a pointer move action.
  84384. */
  84385. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84386. /**
  84387. * Strong typing of a pointer up/down action.
  84388. */
  84389. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84390. /**
  84391. * Representation of a stage in the scene (Basically a list of ordered steps)
  84392. * @hidden
  84393. */
  84394. export class Stage<T extends Function> extends Array<{
  84395. index: number;
  84396. component: ISceneComponent;
  84397. action: T;
  84398. }> {
  84399. /**
  84400. * Hide ctor from the rest of the world.
  84401. * @param items The items to add.
  84402. */
  84403. private constructor();
  84404. /**
  84405. * Creates a new Stage.
  84406. * @returns A new instance of a Stage
  84407. */
  84408. static Create<T extends Function>(): Stage<T>;
  84409. /**
  84410. * Registers a step in an ordered way in the targeted stage.
  84411. * @param index Defines the position to register the step in
  84412. * @param component Defines the component attached to the step
  84413. * @param action Defines the action to launch during the step
  84414. */
  84415. registerStep(index: number, component: ISceneComponent, action: T): void;
  84416. /**
  84417. * Clears all the steps from the stage.
  84418. */
  84419. clear(): void;
  84420. }
  84421. }
  84422. declare module BABYLON {
  84423. interface Scene {
  84424. /** @hidden */
  84425. _pointerOverSprite: Nullable<Sprite>;
  84426. /** @hidden */
  84427. _pickedDownSprite: Nullable<Sprite>;
  84428. /** @hidden */
  84429. _tempSpritePickingRay: Nullable<Ray>;
  84430. /**
  84431. * All of the sprite managers added to this scene
  84432. * @see http://doc.babylonjs.com/babylon101/sprites
  84433. */
  84434. spriteManagers: Array<ISpriteManager>;
  84435. /**
  84436. * An event triggered when sprites rendering is about to start
  84437. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84438. */
  84439. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84440. /**
  84441. * An event triggered when sprites rendering is done
  84442. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84443. */
  84444. onAfterSpritesRenderingObservable: Observable<Scene>;
  84445. /** @hidden */
  84446. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84447. /** Launch a ray to try to pick a sprite in the scene
  84448. * @param x position on screen
  84449. * @param y position on screen
  84450. * @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
  84451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84452. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84453. * @returns a PickingInfo
  84454. */
  84455. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84456. /** Use the given ray to pick a sprite in the scene
  84457. * @param ray The ray (in world space) to use to pick meshes
  84458. * @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
  84459. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84460. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84461. * @returns a PickingInfo
  84462. */
  84463. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84464. /** @hidden */
  84465. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84466. /** Launch a ray to try to pick sprites in the scene
  84467. * @param x position on screen
  84468. * @param y position on screen
  84469. * @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
  84470. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84471. * @returns a PickingInfo array
  84472. */
  84473. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84474. /** Use the given ray to pick sprites in the scene
  84475. * @param ray The ray (in world space) to use to pick meshes
  84476. * @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
  84477. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84478. * @returns a PickingInfo array
  84479. */
  84480. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84481. /**
  84482. * Force the sprite under the pointer
  84483. * @param sprite defines the sprite to use
  84484. */
  84485. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84486. /**
  84487. * Gets the sprite under the pointer
  84488. * @returns a Sprite or null if no sprite is under the pointer
  84489. */
  84490. getPointerOverSprite(): Nullable<Sprite>;
  84491. }
  84492. /**
  84493. * Defines the sprite scene component responsible to manage sprites
  84494. * in a given scene.
  84495. */
  84496. export class SpriteSceneComponent implements ISceneComponent {
  84497. /**
  84498. * The component name helpfull to identify the component in the list of scene components.
  84499. */
  84500. readonly name: string;
  84501. /**
  84502. * The scene the component belongs to.
  84503. */
  84504. scene: Scene;
  84505. /** @hidden */
  84506. private _spritePredicate;
  84507. /**
  84508. * Creates a new instance of the component for the given scene
  84509. * @param scene Defines the scene to register the component in
  84510. */
  84511. constructor(scene: Scene);
  84512. /**
  84513. * Registers the component in a given scene
  84514. */
  84515. register(): void;
  84516. /**
  84517. * Rebuilds the elements related to this component in case of
  84518. * context lost for instance.
  84519. */
  84520. rebuild(): void;
  84521. /**
  84522. * Disposes the component and the associated ressources.
  84523. */
  84524. dispose(): void;
  84525. private _pickSpriteButKeepRay;
  84526. private _pointerMove;
  84527. private _pointerDown;
  84528. private _pointerUp;
  84529. }
  84530. }
  84531. declare module BABYLON {
  84532. /** @hidden */
  84533. export var fogFragmentDeclaration: {
  84534. name: string;
  84535. shader: string;
  84536. };
  84537. }
  84538. declare module BABYLON {
  84539. /** @hidden */
  84540. export var fogFragment: {
  84541. name: string;
  84542. shader: string;
  84543. };
  84544. }
  84545. declare module BABYLON {
  84546. /** @hidden */
  84547. export var spritesPixelShader: {
  84548. name: string;
  84549. shader: string;
  84550. };
  84551. }
  84552. declare module BABYLON {
  84553. /** @hidden */
  84554. export var fogVertexDeclaration: {
  84555. name: string;
  84556. shader: string;
  84557. };
  84558. }
  84559. declare module BABYLON {
  84560. /** @hidden */
  84561. export var spritesVertexShader: {
  84562. name: string;
  84563. shader: string;
  84564. };
  84565. }
  84566. declare module BABYLON {
  84567. /**
  84568. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84569. */
  84570. export interface ISpriteManager extends IDisposable {
  84571. /**
  84572. * Restricts the camera to viewing objects with the same layerMask.
  84573. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84574. */
  84575. layerMask: number;
  84576. /**
  84577. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84578. */
  84579. isPickable: boolean;
  84580. /**
  84581. * Specifies the rendering group id for this mesh (0 by default)
  84582. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84583. */
  84584. renderingGroupId: number;
  84585. /**
  84586. * Defines the list of sprites managed by the manager.
  84587. */
  84588. sprites: Array<Sprite>;
  84589. /**
  84590. * Tests the intersection of a sprite with a specific ray.
  84591. * @param ray The ray we are sending to test the collision
  84592. * @param camera The camera space we are sending rays in
  84593. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84594. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84595. * @returns picking info or null.
  84596. */
  84597. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84598. /**
  84599. * Intersects the sprites with a ray
  84600. * @param ray defines the ray to intersect with
  84601. * @param camera defines the current active camera
  84602. * @param predicate defines a predicate used to select candidate sprites
  84603. * @returns null if no hit or a PickingInfo array
  84604. */
  84605. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84606. /**
  84607. * Renders the list of sprites on screen.
  84608. */
  84609. render(): void;
  84610. }
  84611. /**
  84612. * Class used to manage multiple sprites on the same spritesheet
  84613. * @see http://doc.babylonjs.com/babylon101/sprites
  84614. */
  84615. export class SpriteManager implements ISpriteManager {
  84616. /** defines the manager's name */
  84617. name: string;
  84618. /** Gets the list of sprites */
  84619. sprites: Sprite[];
  84620. /** Gets or sets the rendering group id (0 by default) */
  84621. renderingGroupId: number;
  84622. /** Gets or sets camera layer mask */
  84623. layerMask: number;
  84624. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84625. fogEnabled: boolean;
  84626. /** Gets or sets a boolean indicating if the sprites are pickable */
  84627. isPickable: boolean;
  84628. /** Defines the default width of a cell in the spritesheet */
  84629. cellWidth: number;
  84630. /** Defines the default height of a cell in the spritesheet */
  84631. cellHeight: number;
  84632. /** Associative array from JSON sprite data file */
  84633. private _cellData;
  84634. /** Array of sprite names from JSON sprite data file */
  84635. private _spriteMap;
  84636. /** True when packed cell data from JSON file is ready*/
  84637. private _packedAndReady;
  84638. /**
  84639. * An event triggered when the manager is disposed.
  84640. */
  84641. onDisposeObservable: Observable<SpriteManager>;
  84642. private _onDisposeObserver;
  84643. /**
  84644. * Callback called when the manager is disposed
  84645. */
  84646. set onDispose(callback: () => void);
  84647. private _capacity;
  84648. private _fromPacked;
  84649. private _spriteTexture;
  84650. private _epsilon;
  84651. private _scene;
  84652. private _vertexData;
  84653. private _buffer;
  84654. private _vertexBuffers;
  84655. private _indexBuffer;
  84656. private _effectBase;
  84657. private _effectFog;
  84658. /**
  84659. * Gets or sets the spritesheet texture
  84660. */
  84661. get texture(): Texture;
  84662. set texture(value: Texture);
  84663. /**
  84664. * Creates a new sprite manager
  84665. * @param name defines the manager's name
  84666. * @param imgUrl defines the sprite sheet url
  84667. * @param capacity defines the maximum allowed number of sprites
  84668. * @param cellSize defines the size of a sprite cell
  84669. * @param scene defines the hosting scene
  84670. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84671. * @param samplingMode defines the smapling mode to use with spritesheet
  84672. * @param fromPacked set to false; do not alter
  84673. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84674. */
  84675. constructor(
  84676. /** defines the manager's name */
  84677. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84678. private _makePacked;
  84679. private _appendSpriteVertex;
  84680. /**
  84681. * Intersects the sprites with a ray
  84682. * @param ray defines the ray to intersect with
  84683. * @param camera defines the current active camera
  84684. * @param predicate defines a predicate used to select candidate sprites
  84685. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84686. * @returns null if no hit or a PickingInfo
  84687. */
  84688. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84689. /**
  84690. * Intersects the sprites with a ray
  84691. * @param ray defines the ray to intersect with
  84692. * @param camera defines the current active camera
  84693. * @param predicate defines a predicate used to select candidate sprites
  84694. * @returns null if no hit or a PickingInfo array
  84695. */
  84696. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84697. /**
  84698. * Render all child sprites
  84699. */
  84700. render(): void;
  84701. /**
  84702. * Release associated resources
  84703. */
  84704. dispose(): void;
  84705. }
  84706. }
  84707. declare module BABYLON {
  84708. /**
  84709. * Class used to represent a sprite
  84710. * @see http://doc.babylonjs.com/babylon101/sprites
  84711. */
  84712. export class Sprite {
  84713. /** defines the name */
  84714. name: string;
  84715. /** Gets or sets the current world position */
  84716. position: Vector3;
  84717. /** Gets or sets the main color */
  84718. color: Color4;
  84719. /** Gets or sets the width */
  84720. width: number;
  84721. /** Gets or sets the height */
  84722. height: number;
  84723. /** Gets or sets rotation angle */
  84724. angle: number;
  84725. /** Gets or sets the cell index in the sprite sheet */
  84726. cellIndex: number;
  84727. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  84728. cellRef: string;
  84729. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  84730. invertU: number;
  84731. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  84732. invertV: number;
  84733. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  84734. disposeWhenFinishedAnimating: boolean;
  84735. /** Gets the list of attached animations */
  84736. animations: Animation[];
  84737. /** Gets or sets a boolean indicating if the sprite can be picked */
  84738. isPickable: boolean;
  84739. /**
  84740. * Gets or sets the associated action manager
  84741. */
  84742. actionManager: Nullable<ActionManager>;
  84743. private _animationStarted;
  84744. private _loopAnimation;
  84745. private _fromIndex;
  84746. private _toIndex;
  84747. private _delay;
  84748. private _direction;
  84749. private _manager;
  84750. private _time;
  84751. private _onAnimationEnd;
  84752. /**
  84753. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  84754. */
  84755. isVisible: boolean;
  84756. /**
  84757. * Gets or sets the sprite size
  84758. */
  84759. get size(): number;
  84760. set size(value: number);
  84761. /**
  84762. * Creates a new Sprite
  84763. * @param name defines the name
  84764. * @param manager defines the manager
  84765. */
  84766. constructor(
  84767. /** defines the name */
  84768. name: string, manager: ISpriteManager);
  84769. /**
  84770. * Starts an animation
  84771. * @param from defines the initial key
  84772. * @param to defines the end key
  84773. * @param loop defines if the animation must loop
  84774. * @param delay defines the start delay (in ms)
  84775. * @param onAnimationEnd defines a callback to call when animation ends
  84776. */
  84777. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  84778. /** Stops current animation (if any) */
  84779. stopAnimation(): void;
  84780. /** @hidden */
  84781. _animate(deltaTime: number): void;
  84782. /** Release associated resources */
  84783. dispose(): void;
  84784. }
  84785. }
  84786. declare module BABYLON {
  84787. /**
  84788. * Information about the result of picking within a scene
  84789. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  84790. */
  84791. export class PickingInfo {
  84792. /** @hidden */
  84793. _pickingUnavailable: boolean;
  84794. /**
  84795. * If the pick collided with an object
  84796. */
  84797. hit: boolean;
  84798. /**
  84799. * Distance away where the pick collided
  84800. */
  84801. distance: number;
  84802. /**
  84803. * The location of pick collision
  84804. */
  84805. pickedPoint: Nullable<Vector3>;
  84806. /**
  84807. * The mesh corresponding the the pick collision
  84808. */
  84809. pickedMesh: Nullable<AbstractMesh>;
  84810. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  84811. bu: number;
  84812. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  84813. bv: number;
  84814. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  84815. faceId: number;
  84816. /** Id of the the submesh that was picked */
  84817. subMeshId: number;
  84818. /** If a sprite was picked, this will be the sprite the pick collided with */
  84819. pickedSprite: Nullable<Sprite>;
  84820. /**
  84821. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  84822. */
  84823. originMesh: Nullable<AbstractMesh>;
  84824. /**
  84825. * The ray that was used to perform the picking.
  84826. */
  84827. ray: Nullable<Ray>;
  84828. /**
  84829. * Gets the normal correspodning to the face the pick collided with
  84830. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  84831. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  84832. * @returns The normal correspodning to the face the pick collided with
  84833. */
  84834. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  84835. /**
  84836. * Gets the texture coordinates of where the pick occured
  84837. * @returns the vector containing the coordnates of the texture
  84838. */
  84839. getTextureCoordinates(): Nullable<Vector2>;
  84840. }
  84841. }
  84842. declare module BABYLON {
  84843. /**
  84844. * Gather the list of pointer event types as constants.
  84845. */
  84846. export class PointerEventTypes {
  84847. /**
  84848. * 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.
  84849. */
  84850. static readonly POINTERDOWN: number;
  84851. /**
  84852. * The pointerup event is fired when a pointer is no longer active.
  84853. */
  84854. static readonly POINTERUP: number;
  84855. /**
  84856. * The pointermove event is fired when a pointer changes coordinates.
  84857. */
  84858. static readonly POINTERMOVE: number;
  84859. /**
  84860. * The pointerwheel event is fired when a mouse wheel has been rotated.
  84861. */
  84862. static readonly POINTERWHEEL: number;
  84863. /**
  84864. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  84865. */
  84866. static readonly POINTERPICK: number;
  84867. /**
  84868. * The pointertap event is fired when a the object has been touched and released without drag.
  84869. */
  84870. static readonly POINTERTAP: number;
  84871. /**
  84872. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  84873. */
  84874. static readonly POINTERDOUBLETAP: number;
  84875. }
  84876. /**
  84877. * Base class of pointer info types.
  84878. */
  84879. export class PointerInfoBase {
  84880. /**
  84881. * Defines the type of event (PointerEventTypes)
  84882. */
  84883. type: number;
  84884. /**
  84885. * Defines the related dom event
  84886. */
  84887. event: PointerEvent | MouseWheelEvent;
  84888. /**
  84889. * Instantiates the base class of pointers info.
  84890. * @param type Defines the type of event (PointerEventTypes)
  84891. * @param event Defines the related dom event
  84892. */
  84893. constructor(
  84894. /**
  84895. * Defines the type of event (PointerEventTypes)
  84896. */
  84897. type: number,
  84898. /**
  84899. * Defines the related dom event
  84900. */
  84901. event: PointerEvent | MouseWheelEvent);
  84902. }
  84903. /**
  84904. * This class is used to store pointer related info for the onPrePointerObservable event.
  84905. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  84906. */
  84907. export class PointerInfoPre extends PointerInfoBase {
  84908. /**
  84909. * Ray from a pointer if availible (eg. 6dof controller)
  84910. */
  84911. ray: Nullable<Ray>;
  84912. /**
  84913. * Defines the local position of the pointer on the canvas.
  84914. */
  84915. localPosition: Vector2;
  84916. /**
  84917. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  84918. */
  84919. skipOnPointerObservable: boolean;
  84920. /**
  84921. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  84922. * @param type Defines the type of event (PointerEventTypes)
  84923. * @param event Defines the related dom event
  84924. * @param localX Defines the local x coordinates of the pointer when the event occured
  84925. * @param localY Defines the local y coordinates of the pointer when the event occured
  84926. */
  84927. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  84928. }
  84929. /**
  84930. * This type contains all the data related to a pointer event in Babylon.js.
  84931. * 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.
  84932. */
  84933. export class PointerInfo extends PointerInfoBase {
  84934. /**
  84935. * Defines the picking info associated to the info (if any)\
  84936. */
  84937. pickInfo: Nullable<PickingInfo>;
  84938. /**
  84939. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  84940. * @param type Defines the type of event (PointerEventTypes)
  84941. * @param event Defines the related dom event
  84942. * @param pickInfo Defines the picking info associated to the info (if any)\
  84943. */
  84944. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  84945. /**
  84946. * Defines the picking info associated to the info (if any)\
  84947. */
  84948. pickInfo: Nullable<PickingInfo>);
  84949. }
  84950. /**
  84951. * Data relating to a touch event on the screen.
  84952. */
  84953. export interface PointerTouch {
  84954. /**
  84955. * X coordinate of touch.
  84956. */
  84957. x: number;
  84958. /**
  84959. * Y coordinate of touch.
  84960. */
  84961. y: number;
  84962. /**
  84963. * Id of touch. Unique for each finger.
  84964. */
  84965. pointerId: number;
  84966. /**
  84967. * Event type passed from DOM.
  84968. */
  84969. type: any;
  84970. }
  84971. }
  84972. declare module BABYLON {
  84973. /**
  84974. * Manage the mouse inputs to control the movement of a free camera.
  84975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84976. */
  84977. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  84978. /**
  84979. * Define if touch is enabled in the mouse input
  84980. */
  84981. touchEnabled: boolean;
  84982. /**
  84983. * Defines the camera the input is attached to.
  84984. */
  84985. camera: FreeCamera;
  84986. /**
  84987. * Defines the buttons associated with the input to handle camera move.
  84988. */
  84989. buttons: number[];
  84990. /**
  84991. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  84992. */
  84993. angularSensibility: number;
  84994. private _pointerInput;
  84995. private _onMouseMove;
  84996. private _observer;
  84997. private previousPosition;
  84998. /**
  84999. * Observable for when a pointer move event occurs containing the move offset
  85000. */
  85001. onPointerMovedObservable: Observable<{
  85002. offsetX: number;
  85003. offsetY: number;
  85004. }>;
  85005. /**
  85006. * @hidden
  85007. * If the camera should be rotated automatically based on pointer movement
  85008. */
  85009. _allowCameraRotation: boolean;
  85010. /**
  85011. * Manage the mouse inputs to control the movement of a free camera.
  85012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85013. * @param touchEnabled Defines if touch is enabled or not
  85014. */
  85015. constructor(
  85016. /**
  85017. * Define if touch is enabled in the mouse input
  85018. */
  85019. touchEnabled?: boolean);
  85020. /**
  85021. * Attach the input controls to a specific dom element to get the input from.
  85022. * @param element Defines the element the controls should be listened from
  85023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85024. */
  85025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85026. /**
  85027. * Called on JS contextmenu event.
  85028. * Override this method to provide functionality.
  85029. */
  85030. protected onContextMenu(evt: PointerEvent): void;
  85031. /**
  85032. * Detach the current controls from the specified dom element.
  85033. * @param element Defines the element to stop listening the inputs from
  85034. */
  85035. detachControl(element: Nullable<HTMLElement>): void;
  85036. /**
  85037. * Gets the class name of the current intput.
  85038. * @returns the class name
  85039. */
  85040. getClassName(): string;
  85041. /**
  85042. * Get the friendly name associated with the input class.
  85043. * @returns the input friendly name
  85044. */
  85045. getSimpleName(): string;
  85046. }
  85047. }
  85048. declare module BABYLON {
  85049. /**
  85050. * Manage the touch inputs to control the movement of a free camera.
  85051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85052. */
  85053. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  85054. /**
  85055. * Defines the camera the input is attached to.
  85056. */
  85057. camera: FreeCamera;
  85058. /**
  85059. * Defines the touch sensibility for rotation.
  85060. * The higher the faster.
  85061. */
  85062. touchAngularSensibility: number;
  85063. /**
  85064. * Defines the touch sensibility for move.
  85065. * The higher the faster.
  85066. */
  85067. touchMoveSensibility: number;
  85068. private _offsetX;
  85069. private _offsetY;
  85070. private _pointerPressed;
  85071. private _pointerInput;
  85072. private _observer;
  85073. private _onLostFocus;
  85074. /**
  85075. * Attach the input controls to a specific dom element to get the input from.
  85076. * @param element Defines the element the controls should be listened from
  85077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85078. */
  85079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85080. /**
  85081. * Detach the current controls from the specified dom element.
  85082. * @param element Defines the element to stop listening the inputs from
  85083. */
  85084. detachControl(element: Nullable<HTMLElement>): void;
  85085. /**
  85086. * Update the current camera state depending on the inputs that have been used this frame.
  85087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85088. */
  85089. checkInputs(): void;
  85090. /**
  85091. * Gets the class name of the current intput.
  85092. * @returns the class name
  85093. */
  85094. getClassName(): string;
  85095. /**
  85096. * Get the friendly name associated with the input class.
  85097. * @returns the input friendly name
  85098. */
  85099. getSimpleName(): string;
  85100. }
  85101. }
  85102. declare module BABYLON {
  85103. /**
  85104. * Default Inputs manager for the FreeCamera.
  85105. * It groups all the default supported inputs for ease of use.
  85106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85107. */
  85108. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  85109. /**
  85110. * @hidden
  85111. */
  85112. _mouseInput: Nullable<FreeCameraMouseInput>;
  85113. /**
  85114. * Instantiates a new FreeCameraInputsManager.
  85115. * @param camera Defines the camera the inputs belong to
  85116. */
  85117. constructor(camera: FreeCamera);
  85118. /**
  85119. * Add keyboard input support to the input manager.
  85120. * @returns the current input manager
  85121. */
  85122. addKeyboard(): FreeCameraInputsManager;
  85123. /**
  85124. * Add mouse input support to the input manager.
  85125. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  85126. * @returns the current input manager
  85127. */
  85128. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  85129. /**
  85130. * Removes the mouse input support from the manager
  85131. * @returns the current input manager
  85132. */
  85133. removeMouse(): FreeCameraInputsManager;
  85134. /**
  85135. * Add touch input support to the input manager.
  85136. * @returns the current input manager
  85137. */
  85138. addTouch(): FreeCameraInputsManager;
  85139. /**
  85140. * Remove all attached input methods from a camera
  85141. */
  85142. clear(): void;
  85143. }
  85144. }
  85145. declare module BABYLON {
  85146. /**
  85147. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  85148. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  85149. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  85150. */
  85151. export class FreeCamera extends TargetCamera {
  85152. /**
  85153. * Define the collision ellipsoid of the camera.
  85154. * This is helpful to simulate a camera body like the player body around the camera
  85155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  85156. */
  85157. ellipsoid: Vector3;
  85158. /**
  85159. * Define an offset for the position of the ellipsoid around the camera.
  85160. * This can be helpful to determine the center of the body near the gravity center of the body
  85161. * instead of its head.
  85162. */
  85163. ellipsoidOffset: Vector3;
  85164. /**
  85165. * Enable or disable collisions of the camera with the rest of the scene objects.
  85166. */
  85167. checkCollisions: boolean;
  85168. /**
  85169. * Enable or disable gravity on the camera.
  85170. */
  85171. applyGravity: boolean;
  85172. /**
  85173. * Define the input manager associated to the camera.
  85174. */
  85175. inputs: FreeCameraInputsManager;
  85176. /**
  85177. * Gets the input sensibility for a mouse input. (default is 2000.0)
  85178. * Higher values reduce sensitivity.
  85179. */
  85180. get angularSensibility(): number;
  85181. /**
  85182. * Sets the input sensibility for a mouse input. (default is 2000.0)
  85183. * Higher values reduce sensitivity.
  85184. */
  85185. set angularSensibility(value: number);
  85186. /**
  85187. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  85188. */
  85189. get keysUp(): number[];
  85190. set keysUp(value: number[]);
  85191. /**
  85192. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  85193. */
  85194. get keysDown(): number[];
  85195. set keysDown(value: number[]);
  85196. /**
  85197. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  85198. */
  85199. get keysLeft(): number[];
  85200. set keysLeft(value: number[]);
  85201. /**
  85202. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  85203. */
  85204. get keysRight(): number[];
  85205. set keysRight(value: number[]);
  85206. /**
  85207. * Event raised when the camera collide with a mesh in the scene.
  85208. */
  85209. onCollide: (collidedMesh: AbstractMesh) => void;
  85210. private _collider;
  85211. private _needMoveForGravity;
  85212. private _oldPosition;
  85213. private _diffPosition;
  85214. private _newPosition;
  85215. /** @hidden */
  85216. _localDirection: Vector3;
  85217. /** @hidden */
  85218. _transformedDirection: Vector3;
  85219. /**
  85220. * Instantiates a Free Camera.
  85221. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  85222. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  85223. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  85224. * @param name Define the name of the camera in the scene
  85225. * @param position Define the start position of the camera in the scene
  85226. * @param scene Define the scene the camera belongs to
  85227. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  85228. */
  85229. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  85230. /**
  85231. * Attached controls to the current camera.
  85232. * @param element Defines the element the controls should be listened from
  85233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85234. */
  85235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85236. /**
  85237. * Detach the current controls from the camera.
  85238. * The camera will stop reacting to inputs.
  85239. * @param element Defines the element to stop listening the inputs from
  85240. */
  85241. detachControl(element: HTMLElement): void;
  85242. private _collisionMask;
  85243. /**
  85244. * Define a collision mask to limit the list of object the camera can collide with
  85245. */
  85246. get collisionMask(): number;
  85247. set collisionMask(mask: number);
  85248. /** @hidden */
  85249. _collideWithWorld(displacement: Vector3): void;
  85250. private _onCollisionPositionChange;
  85251. /** @hidden */
  85252. _checkInputs(): void;
  85253. /** @hidden */
  85254. _decideIfNeedsToMove(): boolean;
  85255. /** @hidden */
  85256. _updatePosition(): void;
  85257. /**
  85258. * Destroy the camera and release the current resources hold by it.
  85259. */
  85260. dispose(): void;
  85261. /**
  85262. * Gets the current object class name.
  85263. * @return the class name
  85264. */
  85265. getClassName(): string;
  85266. }
  85267. }
  85268. declare module BABYLON {
  85269. /**
  85270. * Represents a gamepad control stick position
  85271. */
  85272. export class StickValues {
  85273. /**
  85274. * The x component of the control stick
  85275. */
  85276. x: number;
  85277. /**
  85278. * The y component of the control stick
  85279. */
  85280. y: number;
  85281. /**
  85282. * Initializes the gamepad x and y control stick values
  85283. * @param x The x component of the gamepad control stick value
  85284. * @param y The y component of the gamepad control stick value
  85285. */
  85286. constructor(
  85287. /**
  85288. * The x component of the control stick
  85289. */
  85290. x: number,
  85291. /**
  85292. * The y component of the control stick
  85293. */
  85294. y: number);
  85295. }
  85296. /**
  85297. * An interface which manages callbacks for gamepad button changes
  85298. */
  85299. export interface GamepadButtonChanges {
  85300. /**
  85301. * Called when a gamepad has been changed
  85302. */
  85303. changed: boolean;
  85304. /**
  85305. * Called when a gamepad press event has been triggered
  85306. */
  85307. pressChanged: boolean;
  85308. /**
  85309. * Called when a touch event has been triggered
  85310. */
  85311. touchChanged: boolean;
  85312. /**
  85313. * Called when a value has changed
  85314. */
  85315. valueChanged: boolean;
  85316. }
  85317. /**
  85318. * Represents a gamepad
  85319. */
  85320. export class Gamepad {
  85321. /**
  85322. * The id of the gamepad
  85323. */
  85324. id: string;
  85325. /**
  85326. * The index of the gamepad
  85327. */
  85328. index: number;
  85329. /**
  85330. * The browser gamepad
  85331. */
  85332. browserGamepad: any;
  85333. /**
  85334. * Specifies what type of gamepad this represents
  85335. */
  85336. type: number;
  85337. private _leftStick;
  85338. private _rightStick;
  85339. /** @hidden */
  85340. _isConnected: boolean;
  85341. private _leftStickAxisX;
  85342. private _leftStickAxisY;
  85343. private _rightStickAxisX;
  85344. private _rightStickAxisY;
  85345. /**
  85346. * Triggered when the left control stick has been changed
  85347. */
  85348. private _onleftstickchanged;
  85349. /**
  85350. * Triggered when the right control stick has been changed
  85351. */
  85352. private _onrightstickchanged;
  85353. /**
  85354. * Represents a gamepad controller
  85355. */
  85356. static GAMEPAD: number;
  85357. /**
  85358. * Represents a generic controller
  85359. */
  85360. static GENERIC: number;
  85361. /**
  85362. * Represents an XBox controller
  85363. */
  85364. static XBOX: number;
  85365. /**
  85366. * Represents a pose-enabled controller
  85367. */
  85368. static POSE_ENABLED: number;
  85369. /**
  85370. * Represents an Dual Shock controller
  85371. */
  85372. static DUALSHOCK: number;
  85373. /**
  85374. * Specifies whether the left control stick should be Y-inverted
  85375. */
  85376. protected _invertLeftStickY: boolean;
  85377. /**
  85378. * Specifies if the gamepad has been connected
  85379. */
  85380. get isConnected(): boolean;
  85381. /**
  85382. * Initializes the gamepad
  85383. * @param id The id of the gamepad
  85384. * @param index The index of the gamepad
  85385. * @param browserGamepad The browser gamepad
  85386. * @param leftStickX The x component of the left joystick
  85387. * @param leftStickY The y component of the left joystick
  85388. * @param rightStickX The x component of the right joystick
  85389. * @param rightStickY The y component of the right joystick
  85390. */
  85391. constructor(
  85392. /**
  85393. * The id of the gamepad
  85394. */
  85395. id: string,
  85396. /**
  85397. * The index of the gamepad
  85398. */
  85399. index: number,
  85400. /**
  85401. * The browser gamepad
  85402. */
  85403. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  85404. /**
  85405. * Callback triggered when the left joystick has changed
  85406. * @param callback
  85407. */
  85408. onleftstickchanged(callback: (values: StickValues) => void): void;
  85409. /**
  85410. * Callback triggered when the right joystick has changed
  85411. * @param callback
  85412. */
  85413. onrightstickchanged(callback: (values: StickValues) => void): void;
  85414. /**
  85415. * Gets the left joystick
  85416. */
  85417. get leftStick(): StickValues;
  85418. /**
  85419. * Sets the left joystick values
  85420. */
  85421. set leftStick(newValues: StickValues);
  85422. /**
  85423. * Gets the right joystick
  85424. */
  85425. get rightStick(): StickValues;
  85426. /**
  85427. * Sets the right joystick value
  85428. */
  85429. set rightStick(newValues: StickValues);
  85430. /**
  85431. * Updates the gamepad joystick positions
  85432. */
  85433. update(): void;
  85434. /**
  85435. * Disposes the gamepad
  85436. */
  85437. dispose(): void;
  85438. }
  85439. /**
  85440. * Represents a generic gamepad
  85441. */
  85442. export class GenericPad extends Gamepad {
  85443. private _buttons;
  85444. private _onbuttondown;
  85445. private _onbuttonup;
  85446. /**
  85447. * Observable triggered when a button has been pressed
  85448. */
  85449. onButtonDownObservable: Observable<number>;
  85450. /**
  85451. * Observable triggered when a button has been released
  85452. */
  85453. onButtonUpObservable: Observable<number>;
  85454. /**
  85455. * Callback triggered when a button has been pressed
  85456. * @param callback Called when a button has been pressed
  85457. */
  85458. onbuttondown(callback: (buttonPressed: number) => void): void;
  85459. /**
  85460. * Callback triggered when a button has been released
  85461. * @param callback Called when a button has been released
  85462. */
  85463. onbuttonup(callback: (buttonReleased: number) => void): void;
  85464. /**
  85465. * Initializes the generic gamepad
  85466. * @param id The id of the generic gamepad
  85467. * @param index The index of the generic gamepad
  85468. * @param browserGamepad The browser gamepad
  85469. */
  85470. constructor(id: string, index: number, browserGamepad: any);
  85471. private _setButtonValue;
  85472. /**
  85473. * Updates the generic gamepad
  85474. */
  85475. update(): void;
  85476. /**
  85477. * Disposes the generic gamepad
  85478. */
  85479. dispose(): void;
  85480. }
  85481. }
  85482. declare module BABYLON {
  85483. interface Engine {
  85484. /**
  85485. * Creates a raw texture
  85486. * @param data defines the data to store in the texture
  85487. * @param width defines the width of the texture
  85488. * @param height defines the height of the texture
  85489. * @param format defines the format of the data
  85490. * @param generateMipMaps defines if the engine should generate the mip levels
  85491. * @param invertY defines if data must be stored with Y axis inverted
  85492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85493. * @param compression defines the compression used (null by default)
  85494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85495. * @returns the raw texture inside an InternalTexture
  85496. */
  85497. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85498. /**
  85499. * Update a raw texture
  85500. * @param texture defines the texture to update
  85501. * @param data defines the data to store in the texture
  85502. * @param format defines the format of the data
  85503. * @param invertY defines if data must be stored with Y axis inverted
  85504. */
  85505. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85506. /**
  85507. * Update a raw texture
  85508. * @param texture defines the texture to update
  85509. * @param data defines the data to store in the texture
  85510. * @param format defines the format of the data
  85511. * @param invertY defines if data must be stored with Y axis inverted
  85512. * @param compression defines the compression used (null by default)
  85513. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85514. */
  85515. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85516. /**
  85517. * Creates a new raw cube texture
  85518. * @param data defines the array of data to use to create each face
  85519. * @param size defines the size of the textures
  85520. * @param format defines the format of the data
  85521. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85522. * @param generateMipMaps defines if the engine should generate the mip levels
  85523. * @param invertY defines if data must be stored with Y axis inverted
  85524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85525. * @param compression defines the compression used (null by default)
  85526. * @returns the cube texture as an InternalTexture
  85527. */
  85528. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  85529. /**
  85530. * Update a raw cube texture
  85531. * @param texture defines the texture to udpdate
  85532. * @param data defines the data to store
  85533. * @param format defines the data format
  85534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85535. * @param invertY defines if data must be stored with Y axis inverted
  85536. */
  85537. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  85538. /**
  85539. * Update a raw cube texture
  85540. * @param texture defines the texture to udpdate
  85541. * @param data defines the data to store
  85542. * @param format defines the data format
  85543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85544. * @param invertY defines if data must be stored with Y axis inverted
  85545. * @param compression defines the compression used (null by default)
  85546. */
  85547. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  85548. /**
  85549. * Update a raw cube texture
  85550. * @param texture defines the texture to udpdate
  85551. * @param data defines the data to store
  85552. * @param format defines the data format
  85553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85554. * @param invertY defines if data must be stored with Y axis inverted
  85555. * @param compression defines the compression used (null by default)
  85556. * @param level defines which level of the texture to update
  85557. */
  85558. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  85559. /**
  85560. * Creates a new raw cube texture from a specified url
  85561. * @param url defines the url where the data is located
  85562. * @param scene defines the current scene
  85563. * @param size defines the size of the textures
  85564. * @param format defines the format of the data
  85565. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85566. * @param noMipmap defines if the engine should avoid generating the mip levels
  85567. * @param callback defines a callback used to extract texture data from loaded data
  85568. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85569. * @param onLoad defines a callback called when texture is loaded
  85570. * @param onError defines a callback called if there is an error
  85571. * @returns the cube texture as an InternalTexture
  85572. */
  85573. 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;
  85574. /**
  85575. * Creates a new raw cube texture from a specified url
  85576. * @param url defines the url where the data is located
  85577. * @param scene defines the current scene
  85578. * @param size defines the size of the textures
  85579. * @param format defines the format of the data
  85580. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85581. * @param noMipmap defines if the engine should avoid generating the mip levels
  85582. * @param callback defines a callback used to extract texture data from loaded data
  85583. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85584. * @param onLoad defines a callback called when texture is loaded
  85585. * @param onError defines a callback called if there is an error
  85586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85587. * @param invertY defines if data must be stored with Y axis inverted
  85588. * @returns the cube texture as an InternalTexture
  85589. */
  85590. 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;
  85591. /**
  85592. * Creates a new raw 3D texture
  85593. * @param data defines the data used to create the texture
  85594. * @param width defines the width of the texture
  85595. * @param height defines the height of the texture
  85596. * @param depth defines the depth of the texture
  85597. * @param format defines the format of the texture
  85598. * @param generateMipMaps defines if the engine must generate mip levels
  85599. * @param invertY defines if data must be stored with Y axis inverted
  85600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85601. * @param compression defines the compressed used (can be null)
  85602. * @param textureType defines the compressed used (can be null)
  85603. * @returns a new raw 3D texture (stored in an InternalTexture)
  85604. */
  85605. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85606. /**
  85607. * Update a raw 3D texture
  85608. * @param texture defines the texture to update
  85609. * @param data defines the data to store
  85610. * @param format defines the data format
  85611. * @param invertY defines if data must be stored with Y axis inverted
  85612. */
  85613. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85614. /**
  85615. * Update a raw 3D texture
  85616. * @param texture defines the texture to update
  85617. * @param data defines the data to store
  85618. * @param format defines the data format
  85619. * @param invertY defines if data must be stored with Y axis inverted
  85620. * @param compression defines the used compression (can be null)
  85621. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85622. */
  85623. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85624. /**
  85625. * Creates a new raw 2D array texture
  85626. * @param data defines the data used to create the texture
  85627. * @param width defines the width of the texture
  85628. * @param height defines the height of the texture
  85629. * @param depth defines the number of layers of the texture
  85630. * @param format defines the format of the texture
  85631. * @param generateMipMaps defines if the engine must generate mip levels
  85632. * @param invertY defines if data must be stored with Y axis inverted
  85633. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85634. * @param compression defines the compressed used (can be null)
  85635. * @param textureType defines the compressed used (can be null)
  85636. * @returns a new raw 2D array texture (stored in an InternalTexture)
  85637. */
  85638. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85639. /**
  85640. * Update a raw 2D array texture
  85641. * @param texture defines the texture to update
  85642. * @param data defines the data to store
  85643. * @param format defines the data format
  85644. * @param invertY defines if data must be stored with Y axis inverted
  85645. */
  85646. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85647. /**
  85648. * Update a raw 2D array texture
  85649. * @param texture defines the texture to update
  85650. * @param data defines the data to store
  85651. * @param format defines the data format
  85652. * @param invertY defines if data must be stored with Y axis inverted
  85653. * @param compression defines the used compression (can be null)
  85654. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85655. */
  85656. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85657. }
  85658. }
  85659. declare module BABYLON {
  85660. /**
  85661. * Raw texture can help creating a texture directly from an array of data.
  85662. * This can be super useful if you either get the data from an uncompressed source or
  85663. * if you wish to create your texture pixel by pixel.
  85664. */
  85665. export class RawTexture extends Texture {
  85666. /**
  85667. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85668. */
  85669. format: number;
  85670. private _engine;
  85671. /**
  85672. * Instantiates a new RawTexture.
  85673. * Raw texture can help creating a texture directly from an array of data.
  85674. * This can be super useful if you either get the data from an uncompressed source or
  85675. * if you wish to create your texture pixel by pixel.
  85676. * @param data define the array of data to use to create the texture
  85677. * @param width define the width of the texture
  85678. * @param height define the height of the texture
  85679. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85680. * @param scene define the scene the texture belongs to
  85681. * @param generateMipMaps define whether mip maps should be generated or not
  85682. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85683. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85684. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85685. */
  85686. constructor(data: ArrayBufferView, width: number, height: number,
  85687. /**
  85688. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85689. */
  85690. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  85691. /**
  85692. * Updates the texture underlying data.
  85693. * @param data Define the new data of the texture
  85694. */
  85695. update(data: ArrayBufferView): void;
  85696. /**
  85697. * Creates a luminance texture from some data.
  85698. * @param data Define the texture data
  85699. * @param width Define the width of the texture
  85700. * @param height Define the height of the texture
  85701. * @param scene Define the scene the texture belongs to
  85702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85705. * @returns the luminance texture
  85706. */
  85707. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85708. /**
  85709. * Creates a luminance alpha texture from some data.
  85710. * @param data Define the texture data
  85711. * @param width Define the width of the texture
  85712. * @param height Define the height of the texture
  85713. * @param scene Define the scene the texture belongs to
  85714. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85715. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85716. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85717. * @returns the luminance alpha texture
  85718. */
  85719. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85720. /**
  85721. * Creates an alpha texture from some data.
  85722. * @param data Define the texture data
  85723. * @param width Define the width of the texture
  85724. * @param height Define the height of the texture
  85725. * @param scene Define the scene the texture belongs to
  85726. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85729. * @returns the alpha texture
  85730. */
  85731. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85732. /**
  85733. * Creates a RGB texture from some data.
  85734. * @param data Define the texture data
  85735. * @param width Define the width of the texture
  85736. * @param height Define the height of the texture
  85737. * @param scene Define the scene the texture belongs to
  85738. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85739. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85740. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85741. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85742. * @returns the RGB alpha texture
  85743. */
  85744. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85745. /**
  85746. * Creates a RGBA texture from some data.
  85747. * @param data Define the texture data
  85748. * @param width Define the width of the texture
  85749. * @param height Define the height of the texture
  85750. * @param scene Define the scene the texture belongs to
  85751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85754. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85755. * @returns the RGBA texture
  85756. */
  85757. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85758. /**
  85759. * Creates a R texture from some data.
  85760. * @param data Define the texture data
  85761. * @param width Define the width of the texture
  85762. * @param height Define the height of the texture
  85763. * @param scene Define the scene the texture belongs to
  85764. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85765. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85766. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85767. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85768. * @returns the R texture
  85769. */
  85770. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85771. }
  85772. }
  85773. declare module BABYLON {
  85774. /**
  85775. * Interface for the size containing width and height
  85776. */
  85777. export interface ISize {
  85778. /**
  85779. * Width
  85780. */
  85781. width: number;
  85782. /**
  85783. * Heighht
  85784. */
  85785. height: number;
  85786. }
  85787. /**
  85788. * Size containing widht and height
  85789. */
  85790. export class Size implements ISize {
  85791. /**
  85792. * Width
  85793. */
  85794. width: number;
  85795. /**
  85796. * Height
  85797. */
  85798. height: number;
  85799. /**
  85800. * Creates a Size object from the given width and height (floats).
  85801. * @param width width of the new size
  85802. * @param height height of the new size
  85803. */
  85804. constructor(width: number, height: number);
  85805. /**
  85806. * Returns a string with the Size width and height
  85807. * @returns a string with the Size width and height
  85808. */
  85809. toString(): string;
  85810. /**
  85811. * "Size"
  85812. * @returns the string "Size"
  85813. */
  85814. getClassName(): string;
  85815. /**
  85816. * Returns the Size hash code.
  85817. * @returns a hash code for a unique width and height
  85818. */
  85819. getHashCode(): number;
  85820. /**
  85821. * Updates the current size from the given one.
  85822. * @param src the given size
  85823. */
  85824. copyFrom(src: Size): void;
  85825. /**
  85826. * Updates in place the current Size from the given floats.
  85827. * @param width width of the new size
  85828. * @param height height of the new size
  85829. * @returns the updated Size.
  85830. */
  85831. copyFromFloats(width: number, height: number): Size;
  85832. /**
  85833. * Updates in place the current Size from the given floats.
  85834. * @param width width to set
  85835. * @param height height to set
  85836. * @returns the updated Size.
  85837. */
  85838. set(width: number, height: number): Size;
  85839. /**
  85840. * Multiplies the width and height by numbers
  85841. * @param w factor to multiple the width by
  85842. * @param h factor to multiple the height by
  85843. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85844. */
  85845. multiplyByFloats(w: number, h: number): Size;
  85846. /**
  85847. * Clones the size
  85848. * @returns a new Size copied from the given one.
  85849. */
  85850. clone(): Size;
  85851. /**
  85852. * True if the current Size and the given one width and height are strictly equal.
  85853. * @param other the other size to compare against
  85854. * @returns True if the current Size and the given one width and height are strictly equal.
  85855. */
  85856. equals(other: Size): boolean;
  85857. /**
  85858. * The surface of the Size : width * height (float).
  85859. */
  85860. get surface(): number;
  85861. /**
  85862. * Create a new size of zero
  85863. * @returns a new Size set to (0.0, 0.0)
  85864. */
  85865. static Zero(): Size;
  85866. /**
  85867. * Sums the width and height of two sizes
  85868. * @param otherSize size to add to this size
  85869. * @returns a new Size set as the addition result of the current Size and the given one.
  85870. */
  85871. add(otherSize: Size): Size;
  85872. /**
  85873. * Subtracts the width and height of two
  85874. * @param otherSize size to subtract to this size
  85875. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85876. */
  85877. subtract(otherSize: Size): Size;
  85878. /**
  85879. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85880. * @param start starting size to lerp between
  85881. * @param end end size to lerp between
  85882. * @param amount amount to lerp between the start and end values
  85883. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85884. */
  85885. static Lerp(start: Size, end: Size, amount: number): Size;
  85886. }
  85887. }
  85888. declare module BABYLON {
  85889. /**
  85890. * Defines a runtime animation
  85891. */
  85892. export class RuntimeAnimation {
  85893. private _events;
  85894. /**
  85895. * The current frame of the runtime animation
  85896. */
  85897. private _currentFrame;
  85898. /**
  85899. * The animation used by the runtime animation
  85900. */
  85901. private _animation;
  85902. /**
  85903. * The target of the runtime animation
  85904. */
  85905. private _target;
  85906. /**
  85907. * The initiating animatable
  85908. */
  85909. private _host;
  85910. /**
  85911. * The original value of the runtime animation
  85912. */
  85913. private _originalValue;
  85914. /**
  85915. * The original blend value of the runtime animation
  85916. */
  85917. private _originalBlendValue;
  85918. /**
  85919. * The offsets cache of the runtime animation
  85920. */
  85921. private _offsetsCache;
  85922. /**
  85923. * The high limits cache of the runtime animation
  85924. */
  85925. private _highLimitsCache;
  85926. /**
  85927. * Specifies if the runtime animation has been stopped
  85928. */
  85929. private _stopped;
  85930. /**
  85931. * The blending factor of the runtime animation
  85932. */
  85933. private _blendingFactor;
  85934. /**
  85935. * The BabylonJS scene
  85936. */
  85937. private _scene;
  85938. /**
  85939. * The current value of the runtime animation
  85940. */
  85941. private _currentValue;
  85942. /** @hidden */
  85943. _animationState: _IAnimationState;
  85944. /**
  85945. * The active target of the runtime animation
  85946. */
  85947. private _activeTargets;
  85948. private _currentActiveTarget;
  85949. private _directTarget;
  85950. /**
  85951. * The target path of the runtime animation
  85952. */
  85953. private _targetPath;
  85954. /**
  85955. * The weight of the runtime animation
  85956. */
  85957. private _weight;
  85958. /**
  85959. * The ratio offset of the runtime animation
  85960. */
  85961. private _ratioOffset;
  85962. /**
  85963. * The previous delay of the runtime animation
  85964. */
  85965. private _previousDelay;
  85966. /**
  85967. * The previous ratio of the runtime animation
  85968. */
  85969. private _previousRatio;
  85970. private _enableBlending;
  85971. private _keys;
  85972. private _minFrame;
  85973. private _maxFrame;
  85974. private _minValue;
  85975. private _maxValue;
  85976. private _targetIsArray;
  85977. /**
  85978. * Gets the current frame of the runtime animation
  85979. */
  85980. get currentFrame(): number;
  85981. /**
  85982. * Gets the weight of the runtime animation
  85983. */
  85984. get weight(): number;
  85985. /**
  85986. * Gets the current value of the runtime animation
  85987. */
  85988. get currentValue(): any;
  85989. /**
  85990. * Gets the target path of the runtime animation
  85991. */
  85992. get targetPath(): string;
  85993. /**
  85994. * Gets the actual target of the runtime animation
  85995. */
  85996. get target(): any;
  85997. /** @hidden */
  85998. _onLoop: () => void;
  85999. /**
  86000. * Create a new RuntimeAnimation object
  86001. * @param target defines the target of the animation
  86002. * @param animation defines the source animation object
  86003. * @param scene defines the hosting scene
  86004. * @param host defines the initiating Animatable
  86005. */
  86006. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  86007. private _preparePath;
  86008. /**
  86009. * Gets the animation from the runtime animation
  86010. */
  86011. get animation(): Animation;
  86012. /**
  86013. * Resets the runtime animation to the beginning
  86014. * @param restoreOriginal defines whether to restore the target property to the original value
  86015. */
  86016. reset(restoreOriginal?: boolean): void;
  86017. /**
  86018. * Specifies if the runtime animation is stopped
  86019. * @returns Boolean specifying if the runtime animation is stopped
  86020. */
  86021. isStopped(): boolean;
  86022. /**
  86023. * Disposes of the runtime animation
  86024. */
  86025. dispose(): void;
  86026. /**
  86027. * Apply the interpolated value to the target
  86028. * @param currentValue defines the value computed by the animation
  86029. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  86030. */
  86031. setValue(currentValue: any, weight: number): void;
  86032. private _getOriginalValues;
  86033. private _setValue;
  86034. /**
  86035. * Gets the loop pmode of the runtime animation
  86036. * @returns Loop Mode
  86037. */
  86038. private _getCorrectLoopMode;
  86039. /**
  86040. * Move the current animation to a given frame
  86041. * @param frame defines the frame to move to
  86042. */
  86043. goToFrame(frame: number): void;
  86044. /**
  86045. * @hidden Internal use only
  86046. */
  86047. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  86048. /**
  86049. * Execute the current animation
  86050. * @param delay defines the delay to add to the current frame
  86051. * @param from defines the lower bound of the animation range
  86052. * @param to defines the upper bound of the animation range
  86053. * @param loop defines if the current animation must loop
  86054. * @param speedRatio defines the current speed ratio
  86055. * @param weight defines the weight of the animation (default is -1 so no weight)
  86056. * @param onLoop optional callback called when animation loops
  86057. * @returns a boolean indicating if the animation is running
  86058. */
  86059. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  86060. }
  86061. }
  86062. declare module BABYLON {
  86063. /**
  86064. * Class used to store an actual running animation
  86065. */
  86066. export class Animatable {
  86067. /** defines the target object */
  86068. target: any;
  86069. /** defines the starting frame number (default is 0) */
  86070. fromFrame: number;
  86071. /** defines the ending frame number (default is 100) */
  86072. toFrame: number;
  86073. /** defines if the animation must loop (default is false) */
  86074. loopAnimation: boolean;
  86075. /** defines a callback to call when animation ends if it is not looping */
  86076. onAnimationEnd?: (() => void) | null | undefined;
  86077. /** defines a callback to call when animation loops */
  86078. onAnimationLoop?: (() => void) | null | undefined;
  86079. private _localDelayOffset;
  86080. private _pausedDelay;
  86081. private _runtimeAnimations;
  86082. private _paused;
  86083. private _scene;
  86084. private _speedRatio;
  86085. private _weight;
  86086. private _syncRoot;
  86087. /**
  86088. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  86089. * This will only apply for non looping animation (default is true)
  86090. */
  86091. disposeOnEnd: boolean;
  86092. /**
  86093. * Gets a boolean indicating if the animation has started
  86094. */
  86095. animationStarted: boolean;
  86096. /**
  86097. * Observer raised when the animation ends
  86098. */
  86099. onAnimationEndObservable: Observable<Animatable>;
  86100. /**
  86101. * Observer raised when the animation loops
  86102. */
  86103. onAnimationLoopObservable: Observable<Animatable>;
  86104. /**
  86105. * Gets the root Animatable used to synchronize and normalize animations
  86106. */
  86107. get syncRoot(): Nullable<Animatable>;
  86108. /**
  86109. * Gets the current frame of the first RuntimeAnimation
  86110. * Used to synchronize Animatables
  86111. */
  86112. get masterFrame(): number;
  86113. /**
  86114. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  86115. */
  86116. get weight(): number;
  86117. set weight(value: number);
  86118. /**
  86119. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  86120. */
  86121. get speedRatio(): number;
  86122. set speedRatio(value: number);
  86123. /**
  86124. * Creates a new Animatable
  86125. * @param scene defines the hosting scene
  86126. * @param target defines the target object
  86127. * @param fromFrame defines the starting frame number (default is 0)
  86128. * @param toFrame defines the ending frame number (default is 100)
  86129. * @param loopAnimation defines if the animation must loop (default is false)
  86130. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  86131. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  86132. * @param animations defines a group of animation to add to the new Animatable
  86133. * @param onAnimationLoop defines a callback to call when animation loops
  86134. */
  86135. constructor(scene: Scene,
  86136. /** defines the target object */
  86137. target: any,
  86138. /** defines the starting frame number (default is 0) */
  86139. fromFrame?: number,
  86140. /** defines the ending frame number (default is 100) */
  86141. toFrame?: number,
  86142. /** defines if the animation must loop (default is false) */
  86143. loopAnimation?: boolean, speedRatio?: number,
  86144. /** defines a callback to call when animation ends if it is not looping */
  86145. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  86146. /** defines a callback to call when animation loops */
  86147. onAnimationLoop?: (() => void) | null | undefined);
  86148. /**
  86149. * Synchronize and normalize current Animatable with a source Animatable
  86150. * This is useful when using animation weights and when animations are not of the same length
  86151. * @param root defines the root Animatable to synchronize with
  86152. * @returns the current Animatable
  86153. */
  86154. syncWith(root: Animatable): Animatable;
  86155. /**
  86156. * Gets the list of runtime animations
  86157. * @returns an array of RuntimeAnimation
  86158. */
  86159. getAnimations(): RuntimeAnimation[];
  86160. /**
  86161. * Adds more animations to the current animatable
  86162. * @param target defines the target of the animations
  86163. * @param animations defines the new animations to add
  86164. */
  86165. appendAnimations(target: any, animations: Animation[]): void;
  86166. /**
  86167. * Gets the source animation for a specific property
  86168. * @param property defines the propertyu to look for
  86169. * @returns null or the source animation for the given property
  86170. */
  86171. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  86172. /**
  86173. * Gets the runtime animation for a specific property
  86174. * @param property defines the propertyu to look for
  86175. * @returns null or the runtime animation for the given property
  86176. */
  86177. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  86178. /**
  86179. * Resets the animatable to its original state
  86180. */
  86181. reset(): void;
  86182. /**
  86183. * Allows the animatable to blend with current running animations
  86184. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86185. * @param blendingSpeed defines the blending speed to use
  86186. */
  86187. enableBlending(blendingSpeed: number): void;
  86188. /**
  86189. * Disable animation blending
  86190. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86191. */
  86192. disableBlending(): void;
  86193. /**
  86194. * Jump directly to a given frame
  86195. * @param frame defines the frame to jump to
  86196. */
  86197. goToFrame(frame: number): void;
  86198. /**
  86199. * Pause the animation
  86200. */
  86201. pause(): void;
  86202. /**
  86203. * Restart the animation
  86204. */
  86205. restart(): void;
  86206. private _raiseOnAnimationEnd;
  86207. /**
  86208. * Stop and delete the current animation
  86209. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  86210. * @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)
  86211. */
  86212. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  86213. /**
  86214. * Wait asynchronously for the animation to end
  86215. * @returns a promise which will be fullfilled when the animation ends
  86216. */
  86217. waitAsync(): Promise<Animatable>;
  86218. /** @hidden */
  86219. _animate(delay: number): boolean;
  86220. }
  86221. interface Scene {
  86222. /** @hidden */
  86223. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  86224. /** @hidden */
  86225. _processLateAnimationBindingsForMatrices(holder: {
  86226. totalWeight: number;
  86227. animations: RuntimeAnimation[];
  86228. originalValue: Matrix;
  86229. }): any;
  86230. /** @hidden */
  86231. _processLateAnimationBindingsForQuaternions(holder: {
  86232. totalWeight: number;
  86233. animations: RuntimeAnimation[];
  86234. originalValue: Quaternion;
  86235. }, refQuaternion: Quaternion): Quaternion;
  86236. /** @hidden */
  86237. _processLateAnimationBindings(): void;
  86238. /**
  86239. * Will start the animation sequence of a given target
  86240. * @param target defines the target
  86241. * @param from defines from which frame should animation start
  86242. * @param to defines until which frame should animation run.
  86243. * @param weight defines the weight to apply to the animation (1.0 by default)
  86244. * @param loop defines if the animation loops
  86245. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86246. * @param onAnimationEnd defines the function to be executed when the animation ends
  86247. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86248. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  86249. * @param onAnimationLoop defines the callback to call when an animation loops
  86250. * @returns the animatable object created for this animation
  86251. */
  86252. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  86253. /**
  86254. * Will start the animation sequence of a given target
  86255. * @param target defines the target
  86256. * @param from defines from which frame should animation start
  86257. * @param to defines until which frame should animation run.
  86258. * @param loop defines if the animation loops
  86259. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86260. * @param onAnimationEnd defines the function to be executed when the animation ends
  86261. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86262. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  86263. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  86264. * @param onAnimationLoop defines the callback to call when an animation loops
  86265. * @returns the animatable object created for this animation
  86266. */
  86267. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  86268. /**
  86269. * Will start the animation sequence of a given target and its hierarchy
  86270. * @param target defines the target
  86271. * @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.
  86272. * @param from defines from which frame should animation start
  86273. * @param to defines until which frame should animation run.
  86274. * @param loop defines if the animation loops
  86275. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86276. * @param onAnimationEnd defines the function to be executed when the animation ends
  86277. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86278. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  86279. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  86280. * @param onAnimationLoop defines the callback to call when an animation loops
  86281. * @returns the list of created animatables
  86282. */
  86283. 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[];
  86284. /**
  86285. * Begin a new animation on a given node
  86286. * @param target defines the target where the animation will take place
  86287. * @param animations defines the list of animations to start
  86288. * @param from defines the initial value
  86289. * @param to defines the final value
  86290. * @param loop defines if you want animation to loop (off by default)
  86291. * @param speedRatio defines the speed ratio to apply to all animations
  86292. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  86293. * @param onAnimationLoop defines the callback to call when an animation loops
  86294. * @returns the list of created animatables
  86295. */
  86296. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  86297. /**
  86298. * Begin a new animation on a given node and its hierarchy
  86299. * @param target defines the root node where the animation will take place
  86300. * @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.
  86301. * @param animations defines the list of animations to start
  86302. * @param from defines the initial value
  86303. * @param to defines the final value
  86304. * @param loop defines if you want animation to loop (off by default)
  86305. * @param speedRatio defines the speed ratio to apply to all animations
  86306. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  86307. * @param onAnimationLoop defines the callback to call when an animation loops
  86308. * @returns the list of animatables created for all nodes
  86309. */
  86310. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  86311. /**
  86312. * Gets the animatable associated with a specific target
  86313. * @param target defines the target of the animatable
  86314. * @returns the required animatable if found
  86315. */
  86316. getAnimatableByTarget(target: any): Nullable<Animatable>;
  86317. /**
  86318. * Gets all animatables associated with a given target
  86319. * @param target defines the target to look animatables for
  86320. * @returns an array of Animatables
  86321. */
  86322. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  86323. /**
  86324. * Stops and removes all animations that have been applied to the scene
  86325. */
  86326. stopAllAnimations(): void;
  86327. /**
  86328. * Gets the current delta time used by animation engine
  86329. */
  86330. deltaTime: number;
  86331. }
  86332. interface Bone {
  86333. /**
  86334. * Copy an animation range from another bone
  86335. * @param source defines the source bone
  86336. * @param rangeName defines the range name to copy
  86337. * @param frameOffset defines the frame offset
  86338. * @param rescaleAsRequired defines if rescaling must be applied if required
  86339. * @param skelDimensionsRatio defines the scaling ratio
  86340. * @returns true if operation was successful
  86341. */
  86342. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  86343. }
  86344. }
  86345. declare module BABYLON {
  86346. /**
  86347. * Class used to override all child animations of a given target
  86348. */
  86349. export class AnimationPropertiesOverride {
  86350. /**
  86351. * Gets or sets a value indicating if animation blending must be used
  86352. */
  86353. enableBlending: boolean;
  86354. /**
  86355. * Gets or sets the blending speed to use when enableBlending is true
  86356. */
  86357. blendingSpeed: number;
  86358. /**
  86359. * Gets or sets the default loop mode to use
  86360. */
  86361. loopMode: number;
  86362. }
  86363. }
  86364. declare module BABYLON {
  86365. /**
  86366. * Class used to handle skinning animations
  86367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86368. */
  86369. export class Skeleton implements IAnimatable {
  86370. /** defines the skeleton name */
  86371. name: string;
  86372. /** defines the skeleton Id */
  86373. id: string;
  86374. /**
  86375. * Defines the list of child bones
  86376. */
  86377. bones: Bone[];
  86378. /**
  86379. * Defines an estimate of the dimension of the skeleton at rest
  86380. */
  86381. dimensionsAtRest: Vector3;
  86382. /**
  86383. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  86384. */
  86385. needInitialSkinMatrix: boolean;
  86386. /**
  86387. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  86388. */
  86389. overrideMesh: Nullable<AbstractMesh>;
  86390. /**
  86391. * Gets the list of animations attached to this skeleton
  86392. */
  86393. animations: Array<Animation>;
  86394. private _scene;
  86395. private _isDirty;
  86396. private _transformMatrices;
  86397. private _transformMatrixTexture;
  86398. private _meshesWithPoseMatrix;
  86399. private _animatables;
  86400. private _identity;
  86401. private _synchronizedWithMesh;
  86402. private _ranges;
  86403. private _lastAbsoluteTransformsUpdateId;
  86404. private _canUseTextureForBones;
  86405. private _uniqueId;
  86406. /** @hidden */
  86407. _numBonesWithLinkedTransformNode: number;
  86408. /** @hidden */
  86409. _hasWaitingData: Nullable<boolean>;
  86410. /**
  86411. * Specifies if the skeleton should be serialized
  86412. */
  86413. doNotSerialize: boolean;
  86414. private _useTextureToStoreBoneMatrices;
  86415. /**
  86416. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  86417. * Please note that this option is not available if the hardware does not support it
  86418. */
  86419. get useTextureToStoreBoneMatrices(): boolean;
  86420. set useTextureToStoreBoneMatrices(value: boolean);
  86421. private _animationPropertiesOverride;
  86422. /**
  86423. * Gets or sets the animation properties override
  86424. */
  86425. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86426. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  86427. /**
  86428. * List of inspectable custom properties (used by the Inspector)
  86429. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86430. */
  86431. inspectableCustomProperties: IInspectable[];
  86432. /**
  86433. * An observable triggered before computing the skeleton's matrices
  86434. */
  86435. onBeforeComputeObservable: Observable<Skeleton>;
  86436. /**
  86437. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  86438. */
  86439. get isUsingTextureForMatrices(): boolean;
  86440. /**
  86441. * Gets the unique ID of this skeleton
  86442. */
  86443. get uniqueId(): number;
  86444. /**
  86445. * Creates a new skeleton
  86446. * @param name defines the skeleton name
  86447. * @param id defines the skeleton Id
  86448. * @param scene defines the hosting scene
  86449. */
  86450. constructor(
  86451. /** defines the skeleton name */
  86452. name: string,
  86453. /** defines the skeleton Id */
  86454. id: string, scene: Scene);
  86455. /**
  86456. * Gets the current object class name.
  86457. * @return the class name
  86458. */
  86459. getClassName(): string;
  86460. /**
  86461. * Returns an array containing the root bones
  86462. * @returns an array containing the root bones
  86463. */
  86464. getChildren(): Array<Bone>;
  86465. /**
  86466. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  86467. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86468. * @returns a Float32Array containing matrices data
  86469. */
  86470. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  86471. /**
  86472. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  86473. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86474. * @returns a raw texture containing the data
  86475. */
  86476. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  86477. /**
  86478. * Gets the current hosting scene
  86479. * @returns a scene object
  86480. */
  86481. getScene(): Scene;
  86482. /**
  86483. * Gets a string representing the current skeleton data
  86484. * @param fullDetails defines a boolean indicating if we want a verbose version
  86485. * @returns a string representing the current skeleton data
  86486. */
  86487. toString(fullDetails?: boolean): string;
  86488. /**
  86489. * Get bone's index searching by name
  86490. * @param name defines bone's name to search for
  86491. * @return the indice of the bone. Returns -1 if not found
  86492. */
  86493. getBoneIndexByName(name: string): number;
  86494. /**
  86495. * Creater a new animation range
  86496. * @param name defines the name of the range
  86497. * @param from defines the start key
  86498. * @param to defines the end key
  86499. */
  86500. createAnimationRange(name: string, from: number, to: number): void;
  86501. /**
  86502. * Delete a specific animation range
  86503. * @param name defines the name of the range
  86504. * @param deleteFrames defines if frames must be removed as well
  86505. */
  86506. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  86507. /**
  86508. * Gets a specific animation range
  86509. * @param name defines the name of the range to look for
  86510. * @returns the requested animation range or null if not found
  86511. */
  86512. getAnimationRange(name: string): Nullable<AnimationRange>;
  86513. /**
  86514. * Gets the list of all animation ranges defined on this skeleton
  86515. * @returns an array
  86516. */
  86517. getAnimationRanges(): Nullable<AnimationRange>[];
  86518. /**
  86519. * Copy animation range from a source skeleton.
  86520. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  86521. * @param source defines the source skeleton
  86522. * @param name defines the name of the range to copy
  86523. * @param rescaleAsRequired defines if rescaling must be applied if required
  86524. * @returns true if operation was successful
  86525. */
  86526. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  86527. /**
  86528. * Forces the skeleton to go to rest pose
  86529. */
  86530. returnToRest(): void;
  86531. private _getHighestAnimationFrame;
  86532. /**
  86533. * Begin a specific animation range
  86534. * @param name defines the name of the range to start
  86535. * @param loop defines if looping must be turned on (false by default)
  86536. * @param speedRatio defines the speed ratio to apply (1 by default)
  86537. * @param onAnimationEnd defines a callback which will be called when animation will end
  86538. * @returns a new animatable
  86539. */
  86540. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  86541. /** @hidden */
  86542. _markAsDirty(): void;
  86543. /** @hidden */
  86544. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86545. /** @hidden */
  86546. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86547. private _computeTransformMatrices;
  86548. /**
  86549. * Build all resources required to render a skeleton
  86550. */
  86551. prepare(): void;
  86552. /**
  86553. * Gets the list of animatables currently running for this skeleton
  86554. * @returns an array of animatables
  86555. */
  86556. getAnimatables(): IAnimatable[];
  86557. /**
  86558. * Clone the current skeleton
  86559. * @param name defines the name of the new skeleton
  86560. * @param id defines the id of the new skeleton
  86561. * @returns the new skeleton
  86562. */
  86563. clone(name: string, id?: string): Skeleton;
  86564. /**
  86565. * Enable animation blending for this skeleton
  86566. * @param blendingSpeed defines the blending speed to apply
  86567. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86568. */
  86569. enableBlending(blendingSpeed?: number): void;
  86570. /**
  86571. * Releases all resources associated with the current skeleton
  86572. */
  86573. dispose(): void;
  86574. /**
  86575. * Serialize the skeleton in a JSON object
  86576. * @returns a JSON object
  86577. */
  86578. serialize(): any;
  86579. /**
  86580. * Creates a new skeleton from serialized data
  86581. * @param parsedSkeleton defines the serialized data
  86582. * @param scene defines the hosting scene
  86583. * @returns a new skeleton
  86584. */
  86585. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  86586. /**
  86587. * Compute all node absolute transforms
  86588. * @param forceUpdate defines if computation must be done even if cache is up to date
  86589. */
  86590. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  86591. /**
  86592. * Gets the root pose matrix
  86593. * @returns a matrix
  86594. */
  86595. getPoseMatrix(): Nullable<Matrix>;
  86596. /**
  86597. * Sorts bones per internal index
  86598. */
  86599. sortBones(): void;
  86600. private _sortBones;
  86601. }
  86602. }
  86603. declare module BABYLON {
  86604. /**
  86605. * Class used to store bone information
  86606. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86607. */
  86608. export class Bone extends Node {
  86609. /**
  86610. * defines the bone name
  86611. */
  86612. name: string;
  86613. private static _tmpVecs;
  86614. private static _tmpQuat;
  86615. private static _tmpMats;
  86616. /**
  86617. * Gets the list of child bones
  86618. */
  86619. children: Bone[];
  86620. /** Gets the animations associated with this bone */
  86621. animations: Animation[];
  86622. /**
  86623. * Gets or sets bone length
  86624. */
  86625. length: number;
  86626. /**
  86627. * @hidden Internal only
  86628. * Set this value to map this bone to a different index in the transform matrices
  86629. * Set this value to -1 to exclude the bone from the transform matrices
  86630. */
  86631. _index: Nullable<number>;
  86632. private _skeleton;
  86633. private _localMatrix;
  86634. private _restPose;
  86635. private _baseMatrix;
  86636. private _absoluteTransform;
  86637. private _invertedAbsoluteTransform;
  86638. private _parent;
  86639. private _scalingDeterminant;
  86640. private _worldTransform;
  86641. private _localScaling;
  86642. private _localRotation;
  86643. private _localPosition;
  86644. private _needToDecompose;
  86645. private _needToCompose;
  86646. /** @hidden */
  86647. _linkedTransformNode: Nullable<TransformNode>;
  86648. /** @hidden */
  86649. _waitingTransformNodeId: Nullable<string>;
  86650. /** @hidden */
  86651. get _matrix(): Matrix;
  86652. /** @hidden */
  86653. set _matrix(value: Matrix);
  86654. /**
  86655. * Create a new bone
  86656. * @param name defines the bone name
  86657. * @param skeleton defines the parent skeleton
  86658. * @param parentBone defines the parent (can be null if the bone is the root)
  86659. * @param localMatrix defines the local matrix
  86660. * @param restPose defines the rest pose matrix
  86661. * @param baseMatrix defines the base matrix
  86662. * @param index defines index of the bone in the hiearchy
  86663. */
  86664. constructor(
  86665. /**
  86666. * defines the bone name
  86667. */
  86668. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  86669. /**
  86670. * Gets the current object class name.
  86671. * @return the class name
  86672. */
  86673. getClassName(): string;
  86674. /**
  86675. * Gets the parent skeleton
  86676. * @returns a skeleton
  86677. */
  86678. getSkeleton(): Skeleton;
  86679. /**
  86680. * Gets parent bone
  86681. * @returns a bone or null if the bone is the root of the bone hierarchy
  86682. */
  86683. getParent(): Nullable<Bone>;
  86684. /**
  86685. * Returns an array containing the root bones
  86686. * @returns an array containing the root bones
  86687. */
  86688. getChildren(): Array<Bone>;
  86689. /**
  86690. * Gets the node index in matrix array generated for rendering
  86691. * @returns the node index
  86692. */
  86693. getIndex(): number;
  86694. /**
  86695. * Sets the parent bone
  86696. * @param parent defines the parent (can be null if the bone is the root)
  86697. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86698. */
  86699. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  86700. /**
  86701. * Gets the local matrix
  86702. * @returns a matrix
  86703. */
  86704. getLocalMatrix(): Matrix;
  86705. /**
  86706. * Gets the base matrix (initial matrix which remains unchanged)
  86707. * @returns a matrix
  86708. */
  86709. getBaseMatrix(): Matrix;
  86710. /**
  86711. * Gets the rest pose matrix
  86712. * @returns a matrix
  86713. */
  86714. getRestPose(): Matrix;
  86715. /**
  86716. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  86717. */
  86718. getWorldMatrix(): Matrix;
  86719. /**
  86720. * Sets the local matrix to rest pose matrix
  86721. */
  86722. returnToRest(): void;
  86723. /**
  86724. * Gets the inverse of the absolute transform matrix.
  86725. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  86726. * @returns a matrix
  86727. */
  86728. getInvertedAbsoluteTransform(): Matrix;
  86729. /**
  86730. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  86731. * @returns a matrix
  86732. */
  86733. getAbsoluteTransform(): Matrix;
  86734. /**
  86735. * Links with the given transform node.
  86736. * The local matrix of this bone is copied from the transform node every frame.
  86737. * @param transformNode defines the transform node to link to
  86738. */
  86739. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  86740. /**
  86741. * Gets the node used to drive the bone's transformation
  86742. * @returns a transform node or null
  86743. */
  86744. getTransformNode(): Nullable<TransformNode>;
  86745. /** Gets or sets current position (in local space) */
  86746. get position(): Vector3;
  86747. set position(newPosition: Vector3);
  86748. /** Gets or sets current rotation (in local space) */
  86749. get rotation(): Vector3;
  86750. set rotation(newRotation: Vector3);
  86751. /** Gets or sets current rotation quaternion (in local space) */
  86752. get rotationQuaternion(): Quaternion;
  86753. set rotationQuaternion(newRotation: Quaternion);
  86754. /** Gets or sets current scaling (in local space) */
  86755. get scaling(): Vector3;
  86756. set scaling(newScaling: Vector3);
  86757. /**
  86758. * Gets the animation properties override
  86759. */
  86760. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86761. private _decompose;
  86762. private _compose;
  86763. /**
  86764. * Update the base and local matrices
  86765. * @param matrix defines the new base or local matrix
  86766. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86767. * @param updateLocalMatrix defines if the local matrix should be updated
  86768. */
  86769. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  86770. /** @hidden */
  86771. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  86772. /**
  86773. * Flag the bone as dirty (Forcing it to update everything)
  86774. */
  86775. markAsDirty(): void;
  86776. /** @hidden */
  86777. _markAsDirtyAndCompose(): void;
  86778. private _markAsDirtyAndDecompose;
  86779. /**
  86780. * Translate the bone in local or world space
  86781. * @param vec The amount to translate the bone
  86782. * @param space The space that the translation is in
  86783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86784. */
  86785. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86786. /**
  86787. * Set the postion of the bone in local or world space
  86788. * @param position The position to set the bone
  86789. * @param space The space that the position is in
  86790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86791. */
  86792. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86793. /**
  86794. * Set the absolute position of the bone (world space)
  86795. * @param position The position to set the bone
  86796. * @param mesh The mesh that this bone is attached to
  86797. */
  86798. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  86799. /**
  86800. * Scale the bone on the x, y and z axes (in local space)
  86801. * @param x The amount to scale the bone on the x axis
  86802. * @param y The amount to scale the bone on the y axis
  86803. * @param z The amount to scale the bone on the z axis
  86804. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  86805. */
  86806. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  86807. /**
  86808. * Set the bone scaling in local space
  86809. * @param scale defines the scaling vector
  86810. */
  86811. setScale(scale: Vector3): void;
  86812. /**
  86813. * Gets the current scaling in local space
  86814. * @returns the current scaling vector
  86815. */
  86816. getScale(): Vector3;
  86817. /**
  86818. * Gets the current scaling in local space and stores it in a target vector
  86819. * @param result defines the target vector
  86820. */
  86821. getScaleToRef(result: Vector3): void;
  86822. /**
  86823. * Set the yaw, pitch, and roll of the bone in local or world space
  86824. * @param yaw The rotation of the bone on the y axis
  86825. * @param pitch The rotation of the bone on the x axis
  86826. * @param roll The rotation of the bone on the z axis
  86827. * @param space The space that the axes of rotation are in
  86828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86829. */
  86830. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  86831. /**
  86832. * Add a rotation to the bone on an axis in local or world space
  86833. * @param axis The axis to rotate the bone on
  86834. * @param amount The amount to rotate the bone
  86835. * @param space The space that the axis is in
  86836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86837. */
  86838. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  86839. /**
  86840. * Set the rotation of the bone to a particular axis angle in local or world space
  86841. * @param axis The axis to rotate the bone on
  86842. * @param angle The angle that the bone should be rotated to
  86843. * @param space The space that the axis is in
  86844. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86845. */
  86846. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  86847. /**
  86848. * Set the euler rotation of the bone in local of world space
  86849. * @param rotation The euler rotation that the bone should be set to
  86850. * @param space The space that the rotation is in
  86851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86852. */
  86853. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86854. /**
  86855. * Set the quaternion rotation of the bone in local of world space
  86856. * @param quat The quaternion rotation that the bone should be set to
  86857. * @param space The space that the rotation is in
  86858. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86859. */
  86860. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  86861. /**
  86862. * Set the rotation matrix of the bone in local of world space
  86863. * @param rotMat The rotation matrix that the bone should be set to
  86864. * @param space The space that the rotation is in
  86865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86866. */
  86867. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  86868. private _rotateWithMatrix;
  86869. private _getNegativeRotationToRef;
  86870. /**
  86871. * Get the position of the bone in local or world space
  86872. * @param space The space that the returned position is in
  86873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86874. * @returns The position of the bone
  86875. */
  86876. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86877. /**
  86878. * Copy the position of the bone to a vector3 in local or world space
  86879. * @param space The space that the returned position is in
  86880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86881. * @param result The vector3 to copy the position to
  86882. */
  86883. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  86884. /**
  86885. * Get the absolute position of the bone (world space)
  86886. * @param mesh The mesh that this bone is attached to
  86887. * @returns The absolute position of the bone
  86888. */
  86889. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  86890. /**
  86891. * Copy the absolute position of the bone (world space) to the result param
  86892. * @param mesh The mesh that this bone is attached to
  86893. * @param result The vector3 to copy the absolute position to
  86894. */
  86895. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  86896. /**
  86897. * Compute the absolute transforms of this bone and its children
  86898. */
  86899. computeAbsoluteTransforms(): void;
  86900. /**
  86901. * Get the world direction from an axis that is in the local space of the bone
  86902. * @param localAxis The local direction that is used to compute the world direction
  86903. * @param mesh The mesh that this bone is attached to
  86904. * @returns The world direction
  86905. */
  86906. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86907. /**
  86908. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  86909. * @param localAxis The local direction that is used to compute the world direction
  86910. * @param mesh The mesh that this bone is attached to
  86911. * @param result The vector3 that the world direction will be copied to
  86912. */
  86913. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86914. /**
  86915. * Get the euler rotation of the bone in local or world space
  86916. * @param space The space that the rotation should be in
  86917. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86918. * @returns The euler rotation
  86919. */
  86920. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86921. /**
  86922. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  86923. * @param space The space that the rotation should be in
  86924. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86925. * @param result The vector3 that the rotation should be copied to
  86926. */
  86927. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86928. /**
  86929. * Get the quaternion rotation of the bone in either local or world space
  86930. * @param space The space that the rotation should be in
  86931. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86932. * @returns The quaternion rotation
  86933. */
  86934. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  86935. /**
  86936. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  86937. * @param space The space that the rotation should be in
  86938. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86939. * @param result The quaternion that the rotation should be copied to
  86940. */
  86941. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  86942. /**
  86943. * Get the rotation matrix of the bone in local or world space
  86944. * @param space The space that the rotation should be in
  86945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86946. * @returns The rotation matrix
  86947. */
  86948. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  86949. /**
  86950. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  86951. * @param space The space that the rotation should be in
  86952. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86953. * @param result The quaternion that the rotation should be copied to
  86954. */
  86955. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  86956. /**
  86957. * Get the world position of a point that is in the local space of the bone
  86958. * @param position The local position
  86959. * @param mesh The mesh that this bone is attached to
  86960. * @returns The world position
  86961. */
  86962. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86963. /**
  86964. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  86965. * @param position The local position
  86966. * @param mesh The mesh that this bone is attached to
  86967. * @param result The vector3 that the world position should be copied to
  86968. */
  86969. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86970. /**
  86971. * Get the local position of a point that is in world space
  86972. * @param position The world position
  86973. * @param mesh The mesh that this bone is attached to
  86974. * @returns The local position
  86975. */
  86976. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86977. /**
  86978. * Get the local position of a point that is in world space and copy it to the result param
  86979. * @param position The world position
  86980. * @param mesh The mesh that this bone is attached to
  86981. * @param result The vector3 that the local position should be copied to
  86982. */
  86983. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86984. }
  86985. }
  86986. declare module BABYLON {
  86987. /**
  86988. * 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.
  86989. * @see https://doc.babylonjs.com/how_to/transformnode
  86990. */
  86991. export class TransformNode extends Node {
  86992. /**
  86993. * Object will not rotate to face the camera
  86994. */
  86995. static BILLBOARDMODE_NONE: number;
  86996. /**
  86997. * Object will rotate to face the camera but only on the x axis
  86998. */
  86999. static BILLBOARDMODE_X: number;
  87000. /**
  87001. * Object will rotate to face the camera but only on the y axis
  87002. */
  87003. static BILLBOARDMODE_Y: number;
  87004. /**
  87005. * Object will rotate to face the camera but only on the z axis
  87006. */
  87007. static BILLBOARDMODE_Z: number;
  87008. /**
  87009. * Object will rotate to face the camera
  87010. */
  87011. static BILLBOARDMODE_ALL: number;
  87012. /**
  87013. * Object will rotate to face the camera's position instead of orientation
  87014. */
  87015. static BILLBOARDMODE_USE_POSITION: number;
  87016. private _forward;
  87017. private _forwardInverted;
  87018. private _up;
  87019. private _right;
  87020. private _rightInverted;
  87021. private _position;
  87022. private _rotation;
  87023. private _rotationQuaternion;
  87024. protected _scaling: Vector3;
  87025. protected _isDirty: boolean;
  87026. private _transformToBoneReferal;
  87027. private _isAbsoluteSynced;
  87028. private _billboardMode;
  87029. /**
  87030. * Gets or sets the billboard mode. Default is 0.
  87031. *
  87032. * | Value | Type | Description |
  87033. * | --- | --- | --- |
  87034. * | 0 | BILLBOARDMODE_NONE | |
  87035. * | 1 | BILLBOARDMODE_X | |
  87036. * | 2 | BILLBOARDMODE_Y | |
  87037. * | 4 | BILLBOARDMODE_Z | |
  87038. * | 7 | BILLBOARDMODE_ALL | |
  87039. *
  87040. */
  87041. get billboardMode(): number;
  87042. set billboardMode(value: number);
  87043. private _preserveParentRotationForBillboard;
  87044. /**
  87045. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87046. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87047. */
  87048. get preserveParentRotationForBillboard(): boolean;
  87049. set preserveParentRotationForBillboard(value: boolean);
  87050. /**
  87051. * 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
  87052. */
  87053. scalingDeterminant: number;
  87054. private _infiniteDistance;
  87055. /**
  87056. * Gets or sets the distance of the object to max, often used by skybox
  87057. */
  87058. get infiniteDistance(): boolean;
  87059. set infiniteDistance(value: boolean);
  87060. /**
  87061. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87062. * By default the system will update normals to compensate
  87063. */
  87064. ignoreNonUniformScaling: boolean;
  87065. /**
  87066. * 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
  87067. */
  87068. reIntegrateRotationIntoRotationQuaternion: boolean;
  87069. /** @hidden */
  87070. _poseMatrix: Nullable<Matrix>;
  87071. /** @hidden */
  87072. _localMatrix: Matrix;
  87073. private _usePivotMatrix;
  87074. private _absolutePosition;
  87075. private _absoluteScaling;
  87076. private _absoluteRotationQuaternion;
  87077. private _pivotMatrix;
  87078. private _pivotMatrixInverse;
  87079. protected _postMultiplyPivotMatrix: boolean;
  87080. protected _isWorldMatrixFrozen: boolean;
  87081. /** @hidden */
  87082. _indexInSceneTransformNodesArray: number;
  87083. /**
  87084. * An event triggered after the world matrix is updated
  87085. */
  87086. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87087. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87088. /**
  87089. * Gets a string identifying the name of the class
  87090. * @returns "TransformNode" string
  87091. */
  87092. getClassName(): string;
  87093. /**
  87094. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87095. */
  87096. get position(): Vector3;
  87097. set position(newPosition: Vector3);
  87098. /**
  87099. * 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)).
  87100. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87101. */
  87102. get rotation(): Vector3;
  87103. set rotation(newRotation: Vector3);
  87104. /**
  87105. * 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)).
  87106. */
  87107. get scaling(): Vector3;
  87108. set scaling(newScaling: Vector3);
  87109. /**
  87110. * 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).
  87111. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87112. */
  87113. get rotationQuaternion(): Nullable<Quaternion>;
  87114. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87115. /**
  87116. * The forward direction of that transform in world space.
  87117. */
  87118. get forward(): Vector3;
  87119. /**
  87120. * The up direction of that transform in world space.
  87121. */
  87122. get up(): Vector3;
  87123. /**
  87124. * The right direction of that transform in world space.
  87125. */
  87126. get right(): Vector3;
  87127. /**
  87128. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87129. * @param matrix the matrix to copy the pose from
  87130. * @returns this TransformNode.
  87131. */
  87132. updatePoseMatrix(matrix: Matrix): TransformNode;
  87133. /**
  87134. * Returns the mesh Pose matrix.
  87135. * @returns the pose matrix
  87136. */
  87137. getPoseMatrix(): Matrix;
  87138. /** @hidden */
  87139. _isSynchronized(): boolean;
  87140. /** @hidden */
  87141. _initCache(): void;
  87142. /**
  87143. * Flag the transform node as dirty (Forcing it to update everything)
  87144. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87145. * @returns this transform node
  87146. */
  87147. markAsDirty(property: string): TransformNode;
  87148. /**
  87149. * Returns the current mesh absolute position.
  87150. * Returns a Vector3.
  87151. */
  87152. get absolutePosition(): Vector3;
  87153. /**
  87154. * Returns the current mesh absolute scaling.
  87155. * Returns a Vector3.
  87156. */
  87157. get absoluteScaling(): Vector3;
  87158. /**
  87159. * Returns the current mesh absolute rotation.
  87160. * Returns a Quaternion.
  87161. */
  87162. get absoluteRotationQuaternion(): Quaternion;
  87163. /**
  87164. * Sets a new matrix to apply before all other transformation
  87165. * @param matrix defines the transform matrix
  87166. * @returns the current TransformNode
  87167. */
  87168. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87169. /**
  87170. * Sets a new pivot matrix to the current node
  87171. * @param matrix defines the new pivot matrix to use
  87172. * @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
  87173. * @returns the current TransformNode
  87174. */
  87175. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87176. /**
  87177. * Returns the mesh pivot matrix.
  87178. * Default : Identity.
  87179. * @returns the matrix
  87180. */
  87181. getPivotMatrix(): Matrix;
  87182. /**
  87183. * Instantiate (when possible) or clone that node with its hierarchy
  87184. * @param newParent defines the new parent to use for the instance (or clone)
  87185. * @param options defines options to configure how copy is done
  87186. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87187. * @returns an instance (or a clone) of the current node with its hiearchy
  87188. */
  87189. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87190. doNotInstantiate: boolean;
  87191. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87192. /**
  87193. * Prevents the World matrix to be computed any longer
  87194. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87195. * @returns the TransformNode.
  87196. */
  87197. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87198. /**
  87199. * Allows back the World matrix computation.
  87200. * @returns the TransformNode.
  87201. */
  87202. unfreezeWorldMatrix(): this;
  87203. /**
  87204. * True if the World matrix has been frozen.
  87205. */
  87206. get isWorldMatrixFrozen(): boolean;
  87207. /**
  87208. * Retuns the mesh absolute position in the World.
  87209. * @returns a Vector3.
  87210. */
  87211. getAbsolutePosition(): Vector3;
  87212. /**
  87213. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87214. * @param absolutePosition the absolute position to set
  87215. * @returns the TransformNode.
  87216. */
  87217. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87218. /**
  87219. * Sets the mesh position in its local space.
  87220. * @param vector3 the position to set in localspace
  87221. * @returns the TransformNode.
  87222. */
  87223. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87224. /**
  87225. * Returns the mesh position in the local space from the current World matrix values.
  87226. * @returns a new Vector3.
  87227. */
  87228. getPositionExpressedInLocalSpace(): Vector3;
  87229. /**
  87230. * Translates the mesh along the passed Vector3 in its local space.
  87231. * @param vector3 the distance to translate in localspace
  87232. * @returns the TransformNode.
  87233. */
  87234. locallyTranslate(vector3: Vector3): TransformNode;
  87235. private static _lookAtVectorCache;
  87236. /**
  87237. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87238. * @param targetPoint the position (must be in same space as current mesh) to look at
  87239. * @param yawCor optional yaw (y-axis) correction in radians
  87240. * @param pitchCor optional pitch (x-axis) correction in radians
  87241. * @param rollCor optional roll (z-axis) correction in radians
  87242. * @param space the choosen space of the target
  87243. * @returns the TransformNode.
  87244. */
  87245. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87246. /**
  87247. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87248. * This Vector3 is expressed in the World space.
  87249. * @param localAxis axis to rotate
  87250. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87251. */
  87252. getDirection(localAxis: Vector3): Vector3;
  87253. /**
  87254. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87255. * localAxis is expressed in the mesh local space.
  87256. * result is computed in the Wordl space from the mesh World matrix.
  87257. * @param localAxis axis to rotate
  87258. * @param result the resulting transformnode
  87259. * @returns this TransformNode.
  87260. */
  87261. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87262. /**
  87263. * Sets this transform node rotation to the given local axis.
  87264. * @param localAxis the axis in local space
  87265. * @param yawCor optional yaw (y-axis) correction in radians
  87266. * @param pitchCor optional pitch (x-axis) correction in radians
  87267. * @param rollCor optional roll (z-axis) correction in radians
  87268. * @returns this TransformNode
  87269. */
  87270. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87271. /**
  87272. * Sets a new pivot point to the current node
  87273. * @param point defines the new pivot point to use
  87274. * @param space defines if the point is in world or local space (local by default)
  87275. * @returns the current TransformNode
  87276. */
  87277. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87278. /**
  87279. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87280. * @returns the pivot point
  87281. */
  87282. getPivotPoint(): Vector3;
  87283. /**
  87284. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87285. * @param result the vector3 to store the result
  87286. * @returns this TransformNode.
  87287. */
  87288. getPivotPointToRef(result: Vector3): TransformNode;
  87289. /**
  87290. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87291. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87292. */
  87293. getAbsolutePivotPoint(): Vector3;
  87294. /**
  87295. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87296. * @param result vector3 to store the result
  87297. * @returns this TransformNode.
  87298. */
  87299. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87300. /**
  87301. * Defines the passed node as the parent of the current node.
  87302. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87303. * @see https://doc.babylonjs.com/how_to/parenting
  87304. * @param node the node ot set as the parent
  87305. * @returns this TransformNode.
  87306. */
  87307. setParent(node: Nullable<Node>): TransformNode;
  87308. private _nonUniformScaling;
  87309. /**
  87310. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87311. */
  87312. get nonUniformScaling(): boolean;
  87313. /** @hidden */
  87314. _updateNonUniformScalingState(value: boolean): boolean;
  87315. /**
  87316. * Attach the current TransformNode to another TransformNode associated with a bone
  87317. * @param bone Bone affecting the TransformNode
  87318. * @param affectedTransformNode TransformNode associated with the bone
  87319. * @returns this object
  87320. */
  87321. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87322. /**
  87323. * Detach the transform node if its associated with a bone
  87324. * @returns this object
  87325. */
  87326. detachFromBone(): TransformNode;
  87327. private static _rotationAxisCache;
  87328. /**
  87329. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87330. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87331. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87332. * The passed axis is also normalized.
  87333. * @param axis the axis to rotate around
  87334. * @param amount the amount to rotate in radians
  87335. * @param space Space to rotate in (Default: local)
  87336. * @returns the TransformNode.
  87337. */
  87338. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87339. /**
  87340. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87341. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87342. * The passed axis is also normalized. .
  87343. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87344. * @param point the point to rotate around
  87345. * @param axis the axis to rotate around
  87346. * @param amount the amount to rotate in radians
  87347. * @returns the TransformNode
  87348. */
  87349. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87350. /**
  87351. * Translates the mesh along the axis vector for the passed distance in the given space.
  87352. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87353. * @param axis the axis to translate in
  87354. * @param distance the distance to translate
  87355. * @param space Space to rotate in (Default: local)
  87356. * @returns the TransformNode.
  87357. */
  87358. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87359. /**
  87360. * Adds a rotation step to the mesh current rotation.
  87361. * x, y, z are Euler angles expressed in radians.
  87362. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87363. * This means this rotation is made in the mesh local space only.
  87364. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87365. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87366. * ```javascript
  87367. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87368. * ```
  87369. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87370. * 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.
  87371. * @param x Rotation to add
  87372. * @param y Rotation to add
  87373. * @param z Rotation to add
  87374. * @returns the TransformNode.
  87375. */
  87376. addRotation(x: number, y: number, z: number): TransformNode;
  87377. /**
  87378. * @hidden
  87379. */
  87380. protected _getEffectiveParent(): Nullable<Node>;
  87381. /**
  87382. * Computes the world matrix of the node
  87383. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87384. * @returns the world matrix
  87385. */
  87386. computeWorldMatrix(force?: boolean): Matrix;
  87387. /**
  87388. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87389. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87390. */
  87391. resetLocalMatrix(independentOfChildren?: boolean): void;
  87392. protected _afterComputeWorldMatrix(): void;
  87393. /**
  87394. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87395. * @param func callback function to add
  87396. *
  87397. * @returns the TransformNode.
  87398. */
  87399. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87400. /**
  87401. * Removes a registered callback function.
  87402. * @param func callback function to remove
  87403. * @returns the TransformNode.
  87404. */
  87405. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87406. /**
  87407. * Gets the position of the current mesh in camera space
  87408. * @param camera defines the camera to use
  87409. * @returns a position
  87410. */
  87411. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87412. /**
  87413. * Returns the distance from the mesh to the active camera
  87414. * @param camera defines the camera to use
  87415. * @returns the distance
  87416. */
  87417. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87418. /**
  87419. * Clone the current transform node
  87420. * @param name Name of the new clone
  87421. * @param newParent New parent for the clone
  87422. * @param doNotCloneChildren Do not clone children hierarchy
  87423. * @returns the new transform node
  87424. */
  87425. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87426. /**
  87427. * Serializes the objects information.
  87428. * @param currentSerializationObject defines the object to serialize in
  87429. * @returns the serialized object
  87430. */
  87431. serialize(currentSerializationObject?: any): any;
  87432. /**
  87433. * Returns a new TransformNode object parsed from the source provided.
  87434. * @param parsedTransformNode is the source.
  87435. * @param scene the scne the object belongs to
  87436. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87437. * @returns a new TransformNode object parsed from the source provided.
  87438. */
  87439. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87440. /**
  87441. * Get all child-transformNodes of this node
  87442. * @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
  87443. * @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
  87444. * @returns an array of TransformNode
  87445. */
  87446. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87447. /**
  87448. * Releases resources associated with this transform node.
  87449. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87450. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87451. */
  87452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87453. /**
  87454. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87455. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87456. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87457. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87458. * @returns the current mesh
  87459. */
  87460. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87461. private _syncAbsoluteScalingAndRotation;
  87462. }
  87463. }
  87464. declare module BABYLON {
  87465. /**
  87466. * Defines the types of pose enabled controllers that are supported
  87467. */
  87468. export enum PoseEnabledControllerType {
  87469. /**
  87470. * HTC Vive
  87471. */
  87472. VIVE = 0,
  87473. /**
  87474. * Oculus Rift
  87475. */
  87476. OCULUS = 1,
  87477. /**
  87478. * Windows mixed reality
  87479. */
  87480. WINDOWS = 2,
  87481. /**
  87482. * Samsung gear VR
  87483. */
  87484. GEAR_VR = 3,
  87485. /**
  87486. * Google Daydream
  87487. */
  87488. DAYDREAM = 4,
  87489. /**
  87490. * Generic
  87491. */
  87492. GENERIC = 5
  87493. }
  87494. /**
  87495. * Defines the MutableGamepadButton interface for the state of a gamepad button
  87496. */
  87497. export interface MutableGamepadButton {
  87498. /**
  87499. * Value of the button/trigger
  87500. */
  87501. value: number;
  87502. /**
  87503. * If the button/trigger is currently touched
  87504. */
  87505. touched: boolean;
  87506. /**
  87507. * If the button/trigger is currently pressed
  87508. */
  87509. pressed: boolean;
  87510. }
  87511. /**
  87512. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  87513. * @hidden
  87514. */
  87515. export interface ExtendedGamepadButton extends GamepadButton {
  87516. /**
  87517. * If the button/trigger is currently pressed
  87518. */
  87519. readonly pressed: boolean;
  87520. /**
  87521. * If the button/trigger is currently touched
  87522. */
  87523. readonly touched: boolean;
  87524. /**
  87525. * Value of the button/trigger
  87526. */
  87527. readonly value: number;
  87528. }
  87529. /** @hidden */
  87530. export interface _GamePadFactory {
  87531. /**
  87532. * Returns whether or not the current gamepad can be created for this type of controller.
  87533. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  87534. * @returns true if it can be created, otherwise false
  87535. */
  87536. canCreate(gamepadInfo: any): boolean;
  87537. /**
  87538. * Creates a new instance of the Gamepad.
  87539. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  87540. * @returns the new gamepad instance
  87541. */
  87542. create(gamepadInfo: any): Gamepad;
  87543. }
  87544. /**
  87545. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87546. */
  87547. export class PoseEnabledControllerHelper {
  87548. /** @hidden */
  87549. static _ControllerFactories: _GamePadFactory[];
  87550. /** @hidden */
  87551. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  87552. /**
  87553. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87554. * @param vrGamepad the gamepad to initialized
  87555. * @returns a vr controller of the type the gamepad identified as
  87556. */
  87557. static InitiateController(vrGamepad: any): Gamepad;
  87558. }
  87559. /**
  87560. * Defines the PoseEnabledController object that contains state of a vr capable controller
  87561. */
  87562. export class PoseEnabledController extends Gamepad implements PoseControlled {
  87563. /**
  87564. * If the controller is used in a webXR session
  87565. */
  87566. isXR: boolean;
  87567. private _deviceRoomPosition;
  87568. private _deviceRoomRotationQuaternion;
  87569. /**
  87570. * The device position in babylon space
  87571. */
  87572. devicePosition: Vector3;
  87573. /**
  87574. * The device rotation in babylon space
  87575. */
  87576. deviceRotationQuaternion: Quaternion;
  87577. /**
  87578. * The scale factor of the device in babylon space
  87579. */
  87580. deviceScaleFactor: number;
  87581. /**
  87582. * (Likely devicePosition should be used instead) The device position in its room space
  87583. */
  87584. position: Vector3;
  87585. /**
  87586. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  87587. */
  87588. rotationQuaternion: Quaternion;
  87589. /**
  87590. * The type of controller (Eg. Windows mixed reality)
  87591. */
  87592. controllerType: PoseEnabledControllerType;
  87593. protected _calculatedPosition: Vector3;
  87594. private _calculatedRotation;
  87595. /**
  87596. * The raw pose from the device
  87597. */
  87598. rawPose: DevicePose;
  87599. private _trackPosition;
  87600. private _maxRotationDistFromHeadset;
  87601. private _draggedRoomRotation;
  87602. /**
  87603. * @hidden
  87604. */
  87605. _disableTrackPosition(fixedPosition: Vector3): void;
  87606. /**
  87607. * Internal, the mesh attached to the controller
  87608. * @hidden
  87609. */
  87610. _mesh: Nullable<AbstractMesh>;
  87611. private _poseControlledCamera;
  87612. private _leftHandSystemQuaternion;
  87613. /**
  87614. * Internal, matrix used to convert room space to babylon space
  87615. * @hidden
  87616. */
  87617. _deviceToWorld: Matrix;
  87618. /**
  87619. * Node to be used when casting a ray from the controller
  87620. * @hidden
  87621. */
  87622. _pointingPoseNode: Nullable<TransformNode>;
  87623. /**
  87624. * Name of the child mesh that can be used to cast a ray from the controller
  87625. */
  87626. static readonly POINTING_POSE: string;
  87627. /**
  87628. * Creates a new PoseEnabledController from a gamepad
  87629. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  87630. */
  87631. constructor(browserGamepad: any);
  87632. private _workingMatrix;
  87633. /**
  87634. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  87635. */
  87636. update(): void;
  87637. /**
  87638. * Updates only the pose device and mesh without doing any button event checking
  87639. */
  87640. protected _updatePoseAndMesh(): void;
  87641. /**
  87642. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  87643. * @param poseData raw pose fromthe device
  87644. */
  87645. updateFromDevice(poseData: DevicePose): void;
  87646. /**
  87647. * @hidden
  87648. */
  87649. _meshAttachedObservable: Observable<AbstractMesh>;
  87650. /**
  87651. * Attaches a mesh to the controller
  87652. * @param mesh the mesh to be attached
  87653. */
  87654. attachToMesh(mesh: AbstractMesh): void;
  87655. /**
  87656. * Attaches the controllers mesh to a camera
  87657. * @param camera the camera the mesh should be attached to
  87658. */
  87659. attachToPoseControlledCamera(camera: TargetCamera): void;
  87660. /**
  87661. * Disposes of the controller
  87662. */
  87663. dispose(): void;
  87664. /**
  87665. * The mesh that is attached to the controller
  87666. */
  87667. get mesh(): Nullable<AbstractMesh>;
  87668. /**
  87669. * Gets the ray of the controller in the direction the controller is pointing
  87670. * @param length the length the resulting ray should be
  87671. * @returns a ray in the direction the controller is pointing
  87672. */
  87673. getForwardRay(length?: number): Ray;
  87674. }
  87675. }
  87676. declare module BABYLON {
  87677. /**
  87678. * Defines the WebVRController object that represents controllers tracked in 3D space
  87679. */
  87680. export abstract class WebVRController extends PoseEnabledController {
  87681. /**
  87682. * Internal, the default controller model for the controller
  87683. */
  87684. protected _defaultModel: Nullable<AbstractMesh>;
  87685. /**
  87686. * Fired when the trigger state has changed
  87687. */
  87688. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  87689. /**
  87690. * Fired when the main button state has changed
  87691. */
  87692. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87693. /**
  87694. * Fired when the secondary button state has changed
  87695. */
  87696. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87697. /**
  87698. * Fired when the pad state has changed
  87699. */
  87700. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  87701. /**
  87702. * Fired when controllers stick values have changed
  87703. */
  87704. onPadValuesChangedObservable: Observable<StickValues>;
  87705. /**
  87706. * Array of button availible on the controller
  87707. */
  87708. protected _buttons: Array<MutableGamepadButton>;
  87709. private _onButtonStateChange;
  87710. /**
  87711. * Fired when a controller button's state has changed
  87712. * @param callback the callback containing the button that was modified
  87713. */
  87714. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  87715. /**
  87716. * X and Y axis corresponding to the controllers joystick
  87717. */
  87718. pad: StickValues;
  87719. /**
  87720. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  87721. */
  87722. hand: string;
  87723. /**
  87724. * The default controller model for the controller
  87725. */
  87726. get defaultModel(): Nullable<AbstractMesh>;
  87727. /**
  87728. * Creates a new WebVRController from a gamepad
  87729. * @param vrGamepad the gamepad that the WebVRController should be created from
  87730. */
  87731. constructor(vrGamepad: any);
  87732. /**
  87733. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  87734. */
  87735. update(): void;
  87736. /**
  87737. * Function to be called when a button is modified
  87738. */
  87739. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  87740. /**
  87741. * Loads a mesh and attaches it to the controller
  87742. * @param scene the scene the mesh should be added to
  87743. * @param meshLoaded callback for when the mesh has been loaded
  87744. */
  87745. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  87746. private _setButtonValue;
  87747. private _changes;
  87748. private _checkChanges;
  87749. /**
  87750. * Disposes of th webVRCOntroller
  87751. */
  87752. dispose(): void;
  87753. }
  87754. }
  87755. declare module BABYLON {
  87756. /**
  87757. * The HemisphericLight simulates the ambient environment light,
  87758. * so the passed direction is the light reflection direction, not the incoming direction.
  87759. */
  87760. export class HemisphericLight extends Light {
  87761. /**
  87762. * The groundColor is the light in the opposite direction to the one specified during creation.
  87763. * 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.
  87764. */
  87765. groundColor: Color3;
  87766. /**
  87767. * The light reflection direction, not the incoming direction.
  87768. */
  87769. direction: Vector3;
  87770. /**
  87771. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  87772. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  87773. * The HemisphericLight can't cast shadows.
  87774. * Documentation : https://doc.babylonjs.com/babylon101/lights
  87775. * @param name The friendly name of the light
  87776. * @param direction The direction of the light reflection
  87777. * @param scene The scene the light belongs to
  87778. */
  87779. constructor(name: string, direction: Vector3, scene: Scene);
  87780. protected _buildUniformLayout(): void;
  87781. /**
  87782. * Returns the string "HemisphericLight".
  87783. * @return The class name
  87784. */
  87785. getClassName(): string;
  87786. /**
  87787. * Sets the HemisphericLight direction towards the passed target (Vector3).
  87788. * Returns the updated direction.
  87789. * @param target The target the direction should point to
  87790. * @return The computed direction
  87791. */
  87792. setDirectionToTarget(target: Vector3): Vector3;
  87793. /**
  87794. * Returns the shadow generator associated to the light.
  87795. * @returns Always null for hemispheric lights because it does not support shadows.
  87796. */
  87797. getShadowGenerator(): Nullable<IShadowGenerator>;
  87798. /**
  87799. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  87800. * @param effect The effect to update
  87801. * @param lightIndex The index of the light in the effect to update
  87802. * @returns The hemispheric light
  87803. */
  87804. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  87805. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  87806. /**
  87807. * Computes the world matrix of the node
  87808. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87809. * @param useWasUpdatedFlag defines a reserved property
  87810. * @returns the world matrix
  87811. */
  87812. computeWorldMatrix(): Matrix;
  87813. /**
  87814. * Returns the integer 3.
  87815. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  87816. */
  87817. getTypeID(): number;
  87818. /**
  87819. * Prepares the list of defines specific to the light type.
  87820. * @param defines the list of defines
  87821. * @param lightIndex defines the index of the light for the effect
  87822. */
  87823. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  87824. }
  87825. }
  87826. declare module BABYLON {
  87827. /** @hidden */
  87828. export var vrMultiviewToSingleviewPixelShader: {
  87829. name: string;
  87830. shader: string;
  87831. };
  87832. }
  87833. declare module BABYLON {
  87834. /**
  87835. * Renders to multiple views with a single draw call
  87836. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  87837. */
  87838. export class MultiviewRenderTarget extends RenderTargetTexture {
  87839. /**
  87840. * Creates a multiview render target
  87841. * @param scene scene used with the render target
  87842. * @param size the size of the render target (used for each view)
  87843. */
  87844. constructor(scene: Scene, size?: number | {
  87845. width: number;
  87846. height: number;
  87847. } | {
  87848. ratio: number;
  87849. });
  87850. /**
  87851. * @hidden
  87852. * @param faceIndex the face index, if its a cube texture
  87853. */
  87854. _bindFrameBuffer(faceIndex?: number): void;
  87855. /**
  87856. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87857. * @returns the view count
  87858. */
  87859. getViewCount(): number;
  87860. }
  87861. }
  87862. declare module BABYLON {
  87863. /**
  87864. * Represents a camera frustum
  87865. */
  87866. export class Frustum {
  87867. /**
  87868. * Gets the planes representing the frustum
  87869. * @param transform matrix to be applied to the returned planes
  87870. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87871. */
  87872. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87873. /**
  87874. * Gets the near frustum plane transformed by the transform matrix
  87875. * @param transform transformation matrix to be applied to the resulting frustum plane
  87876. * @param frustumPlane the resuling frustum plane
  87877. */
  87878. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87879. /**
  87880. * Gets the far frustum plane transformed by the transform matrix
  87881. * @param transform transformation matrix to be applied to the resulting frustum plane
  87882. * @param frustumPlane the resuling frustum plane
  87883. */
  87884. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87885. /**
  87886. * Gets the left frustum plane transformed by the transform matrix
  87887. * @param transform transformation matrix to be applied to the resulting frustum plane
  87888. * @param frustumPlane the resuling frustum plane
  87889. */
  87890. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87891. /**
  87892. * Gets the right frustum plane transformed by the transform matrix
  87893. * @param transform transformation matrix to be applied to the resulting frustum plane
  87894. * @param frustumPlane the resuling frustum plane
  87895. */
  87896. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87897. /**
  87898. * Gets the top frustum plane transformed by the transform matrix
  87899. * @param transform transformation matrix to be applied to the resulting frustum plane
  87900. * @param frustumPlane the resuling frustum plane
  87901. */
  87902. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87903. /**
  87904. * Gets the bottom frustum plane transformed by the transform matrix
  87905. * @param transform transformation matrix to be applied to the resulting frustum plane
  87906. * @param frustumPlane the resuling frustum plane
  87907. */
  87908. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87909. /**
  87910. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87911. * @param transform transformation matrix to be applied to the resulting frustum planes
  87912. * @param frustumPlanes the resuling frustum planes
  87913. */
  87914. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87915. }
  87916. }
  87917. declare module BABYLON {
  87918. interface Engine {
  87919. /**
  87920. * Creates a new multiview render target
  87921. * @param width defines the width of the texture
  87922. * @param height defines the height of the texture
  87923. * @returns the created multiview texture
  87924. */
  87925. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  87926. /**
  87927. * Binds a multiview framebuffer to be drawn to
  87928. * @param multiviewTexture texture to bind
  87929. */
  87930. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  87931. }
  87932. interface Camera {
  87933. /**
  87934. * @hidden
  87935. * 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)
  87936. */
  87937. _useMultiviewToSingleView: boolean;
  87938. /**
  87939. * @hidden
  87940. * 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)
  87941. */
  87942. _multiviewTexture: Nullable<RenderTargetTexture>;
  87943. /**
  87944. * @hidden
  87945. * ensures the multiview texture of the camera exists and has the specified width/height
  87946. * @param width height to set on the multiview texture
  87947. * @param height width to set on the multiview texture
  87948. */
  87949. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  87950. }
  87951. interface Scene {
  87952. /** @hidden */
  87953. _transformMatrixR: Matrix;
  87954. /** @hidden */
  87955. _multiviewSceneUbo: Nullable<UniformBuffer>;
  87956. /** @hidden */
  87957. _createMultiviewUbo(): void;
  87958. /** @hidden */
  87959. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  87960. /** @hidden */
  87961. _renderMultiviewToSingleView(camera: Camera): void;
  87962. }
  87963. }
  87964. declare module BABYLON {
  87965. /**
  87966. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  87967. * This will not be used for webXR as it supports displaying texture arrays directly
  87968. */
  87969. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  87970. /**
  87971. * Initializes a VRMultiviewToSingleview
  87972. * @param name name of the post process
  87973. * @param camera camera to be applied to
  87974. * @param scaleFactor scaling factor to the size of the output texture
  87975. */
  87976. constructor(name: string, camera: Camera, scaleFactor: number);
  87977. }
  87978. }
  87979. declare module BABYLON {
  87980. /**
  87981. * Interface used to define additional presentation attributes
  87982. */
  87983. export interface IVRPresentationAttributes {
  87984. /**
  87985. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  87986. */
  87987. highRefreshRate: boolean;
  87988. /**
  87989. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  87990. */
  87991. foveationLevel: number;
  87992. }
  87993. interface Engine {
  87994. /** @hidden */
  87995. _vrDisplay: any;
  87996. /** @hidden */
  87997. _vrSupported: boolean;
  87998. /** @hidden */
  87999. _oldSize: Size;
  88000. /** @hidden */
  88001. _oldHardwareScaleFactor: number;
  88002. /** @hidden */
  88003. _vrExclusivePointerMode: boolean;
  88004. /** @hidden */
  88005. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  88006. /** @hidden */
  88007. _onVRDisplayPointerRestricted: () => void;
  88008. /** @hidden */
  88009. _onVRDisplayPointerUnrestricted: () => void;
  88010. /** @hidden */
  88011. _onVrDisplayConnect: Nullable<(display: any) => void>;
  88012. /** @hidden */
  88013. _onVrDisplayDisconnect: Nullable<() => void>;
  88014. /** @hidden */
  88015. _onVrDisplayPresentChange: Nullable<() => void>;
  88016. /**
  88017. * Observable signaled when VR display mode changes
  88018. */
  88019. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  88020. /**
  88021. * Observable signaled when VR request present is complete
  88022. */
  88023. onVRRequestPresentComplete: Observable<boolean>;
  88024. /**
  88025. * Observable signaled when VR request present starts
  88026. */
  88027. onVRRequestPresentStart: Observable<Engine>;
  88028. /**
  88029. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  88030. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  88031. */
  88032. isInVRExclusivePointerMode: boolean;
  88033. /**
  88034. * Gets a boolean indicating if a webVR device was detected
  88035. * @returns true if a webVR device was detected
  88036. */
  88037. isVRDevicePresent(): boolean;
  88038. /**
  88039. * Gets the current webVR device
  88040. * @returns the current webVR device (or null)
  88041. */
  88042. getVRDevice(): any;
  88043. /**
  88044. * Initializes a webVR display and starts listening to display change events
  88045. * The onVRDisplayChangedObservable will be notified upon these changes
  88046. * @returns A promise containing a VRDisplay and if vr is supported
  88047. */
  88048. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  88049. /** @hidden */
  88050. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  88051. /**
  88052. * Gets or sets the presentation attributes used to configure VR rendering
  88053. */
  88054. vrPresentationAttributes?: IVRPresentationAttributes;
  88055. /**
  88056. * Call this function to switch to webVR mode
  88057. * Will do nothing if webVR is not supported or if there is no webVR device
  88058. * @param options the webvr options provided to the camera. mainly used for multiview
  88059. * @see http://doc.babylonjs.com/how_to/webvr_camera
  88060. */
  88061. enableVR(options: WebVROptions): void;
  88062. /** @hidden */
  88063. _onVRFullScreenTriggered(): void;
  88064. }
  88065. }
  88066. declare module BABYLON {
  88067. /**
  88068. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  88069. * IMPORTANT!! The data is right-hand data.
  88070. * @export
  88071. * @interface DevicePose
  88072. */
  88073. export interface DevicePose {
  88074. /**
  88075. * The position of the device, values in array are [x,y,z].
  88076. */
  88077. readonly position: Nullable<Float32Array>;
  88078. /**
  88079. * The linearVelocity of the device, values in array are [x,y,z].
  88080. */
  88081. readonly linearVelocity: Nullable<Float32Array>;
  88082. /**
  88083. * The linearAcceleration of the device, values in array are [x,y,z].
  88084. */
  88085. readonly linearAcceleration: Nullable<Float32Array>;
  88086. /**
  88087. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  88088. */
  88089. readonly orientation: Nullable<Float32Array>;
  88090. /**
  88091. * The angularVelocity of the device, values in array are [x,y,z].
  88092. */
  88093. readonly angularVelocity: Nullable<Float32Array>;
  88094. /**
  88095. * The angularAcceleration of the device, values in array are [x,y,z].
  88096. */
  88097. readonly angularAcceleration: Nullable<Float32Array>;
  88098. }
  88099. /**
  88100. * Interface representing a pose controlled object in Babylon.
  88101. * A pose controlled object has both regular pose values as well as pose values
  88102. * from an external device such as a VR head mounted display
  88103. */
  88104. export interface PoseControlled {
  88105. /**
  88106. * The position of the object in babylon space.
  88107. */
  88108. position: Vector3;
  88109. /**
  88110. * The rotation quaternion of the object in babylon space.
  88111. */
  88112. rotationQuaternion: Quaternion;
  88113. /**
  88114. * The position of the device in babylon space.
  88115. */
  88116. devicePosition?: Vector3;
  88117. /**
  88118. * The rotation quaternion of the device in babylon space.
  88119. */
  88120. deviceRotationQuaternion: Quaternion;
  88121. /**
  88122. * The raw pose coming from the device.
  88123. */
  88124. rawPose: Nullable<DevicePose>;
  88125. /**
  88126. * The scale of the device to be used when translating from device space to babylon space.
  88127. */
  88128. deviceScaleFactor: number;
  88129. /**
  88130. * Updates the poseControlled values based on the input device pose.
  88131. * @param poseData the pose data to update the object with
  88132. */
  88133. updateFromDevice(poseData: DevicePose): void;
  88134. }
  88135. /**
  88136. * Set of options to customize the webVRCamera
  88137. */
  88138. export interface WebVROptions {
  88139. /**
  88140. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  88141. */
  88142. trackPosition?: boolean;
  88143. /**
  88144. * Sets the scale of the vrDevice in babylon space. (default: 1)
  88145. */
  88146. positionScale?: number;
  88147. /**
  88148. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  88149. */
  88150. displayName?: string;
  88151. /**
  88152. * Should the native controller meshes be initialized. (default: true)
  88153. */
  88154. controllerMeshes?: boolean;
  88155. /**
  88156. * Creating a default HemiLight only on controllers. (default: true)
  88157. */
  88158. defaultLightingOnControllers?: boolean;
  88159. /**
  88160. * If you don't want to use the default VR button of the helper. (default: false)
  88161. */
  88162. useCustomVRButton?: boolean;
  88163. /**
  88164. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  88165. */
  88166. customVRButton?: HTMLButtonElement;
  88167. /**
  88168. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  88169. */
  88170. rayLength?: number;
  88171. /**
  88172. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  88173. */
  88174. defaultHeight?: number;
  88175. /**
  88176. * If multiview should be used if availible (default: false)
  88177. */
  88178. useMultiview?: boolean;
  88179. }
  88180. /**
  88181. * This represents a WebVR camera.
  88182. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  88183. * @example http://doc.babylonjs.com/how_to/webvr_camera
  88184. */
  88185. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  88186. private webVROptions;
  88187. /**
  88188. * @hidden
  88189. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  88190. */
  88191. _vrDevice: any;
  88192. /**
  88193. * The rawPose of the vrDevice.
  88194. */
  88195. rawPose: Nullable<DevicePose>;
  88196. private _onVREnabled;
  88197. private _specsVersion;
  88198. private _attached;
  88199. private _frameData;
  88200. protected _descendants: Array<Node>;
  88201. private _deviceRoomPosition;
  88202. /** @hidden */
  88203. _deviceRoomRotationQuaternion: Quaternion;
  88204. private _standingMatrix;
  88205. /**
  88206. * Represents device position in babylon space.
  88207. */
  88208. devicePosition: Vector3;
  88209. /**
  88210. * Represents device rotation in babylon space.
  88211. */
  88212. deviceRotationQuaternion: Quaternion;
  88213. /**
  88214. * The scale of the device to be used when translating from device space to babylon space.
  88215. */
  88216. deviceScaleFactor: number;
  88217. private _deviceToWorld;
  88218. private _worldToDevice;
  88219. /**
  88220. * References to the webVR controllers for the vrDevice.
  88221. */
  88222. controllers: Array<WebVRController>;
  88223. /**
  88224. * Emits an event when a controller is attached.
  88225. */
  88226. onControllersAttachedObservable: Observable<WebVRController[]>;
  88227. /**
  88228. * Emits an event when a controller's mesh has been loaded;
  88229. */
  88230. onControllerMeshLoadedObservable: Observable<WebVRController>;
  88231. /**
  88232. * Emits an event when the HMD's pose has been updated.
  88233. */
  88234. onPoseUpdatedFromDeviceObservable: Observable<any>;
  88235. private _poseSet;
  88236. /**
  88237. * If the rig cameras be used as parent instead of this camera.
  88238. */
  88239. rigParenting: boolean;
  88240. private _lightOnControllers;
  88241. private _defaultHeight?;
  88242. /**
  88243. * Instantiates a WebVRFreeCamera.
  88244. * @param name The name of the WebVRFreeCamera
  88245. * @param position The starting anchor position for the camera
  88246. * @param scene The scene the camera belongs to
  88247. * @param webVROptions a set of customizable options for the webVRCamera
  88248. */
  88249. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  88250. /**
  88251. * Gets the device distance from the ground in meters.
  88252. * @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.
  88253. */
  88254. deviceDistanceToRoomGround(): number;
  88255. /**
  88256. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  88257. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  88258. */
  88259. useStandingMatrix(callback?: (bool: boolean) => void): void;
  88260. /**
  88261. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  88262. * @returns A promise with a boolean set to if the standing matrix is supported.
  88263. */
  88264. useStandingMatrixAsync(): Promise<boolean>;
  88265. /**
  88266. * Disposes the camera
  88267. */
  88268. dispose(): void;
  88269. /**
  88270. * Gets a vrController by name.
  88271. * @param name The name of the controller to retreive
  88272. * @returns the controller matching the name specified or null if not found
  88273. */
  88274. getControllerByName(name: string): Nullable<WebVRController>;
  88275. private _leftController;
  88276. /**
  88277. * The controller corresponding to the users left hand.
  88278. */
  88279. get leftController(): Nullable<WebVRController>;
  88280. private _rightController;
  88281. /**
  88282. * The controller corresponding to the users right hand.
  88283. */
  88284. get rightController(): Nullable<WebVRController>;
  88285. /**
  88286. * Casts a ray forward from the vrCamera's gaze.
  88287. * @param length Length of the ray (default: 100)
  88288. * @returns the ray corresponding to the gaze
  88289. */
  88290. getForwardRay(length?: number): Ray;
  88291. /**
  88292. * @hidden
  88293. * Updates the camera based on device's frame data
  88294. */
  88295. _checkInputs(): void;
  88296. /**
  88297. * Updates the poseControlled values based on the input device pose.
  88298. * @param poseData Pose coming from the device
  88299. */
  88300. updateFromDevice(poseData: DevicePose): void;
  88301. private _htmlElementAttached;
  88302. private _detachIfAttached;
  88303. /**
  88304. * WebVR's attach control will start broadcasting frames to the device.
  88305. * Note that in certain browsers (chrome for example) this function must be called
  88306. * within a user-interaction callback. Example:
  88307. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  88308. *
  88309. * @param element html element to attach the vrDevice to
  88310. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  88311. */
  88312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88313. /**
  88314. * Detaches the camera from the html element and disables VR
  88315. *
  88316. * @param element html element to detach from
  88317. */
  88318. detachControl(element: HTMLElement): void;
  88319. /**
  88320. * @returns the name of this class
  88321. */
  88322. getClassName(): string;
  88323. /**
  88324. * Calls resetPose on the vrDisplay
  88325. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  88326. */
  88327. resetToCurrentRotation(): void;
  88328. /**
  88329. * @hidden
  88330. * Updates the rig cameras (left and right eye)
  88331. */
  88332. _updateRigCameras(): void;
  88333. private _workingVector;
  88334. private _oneVector;
  88335. private _workingMatrix;
  88336. private updateCacheCalled;
  88337. private _correctPositionIfNotTrackPosition;
  88338. /**
  88339. * @hidden
  88340. * Updates the cached values of the camera
  88341. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  88342. */
  88343. _updateCache(ignoreParentClass?: boolean): void;
  88344. /**
  88345. * @hidden
  88346. * Get current device position in babylon world
  88347. */
  88348. _computeDevicePosition(): void;
  88349. /**
  88350. * Updates the current device position and rotation in the babylon world
  88351. */
  88352. update(): void;
  88353. /**
  88354. * @hidden
  88355. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  88356. * @returns an identity matrix
  88357. */
  88358. _getViewMatrix(): Matrix;
  88359. private _tmpMatrix;
  88360. /**
  88361. * This function is called by the two RIG cameras.
  88362. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  88363. * @hidden
  88364. */
  88365. _getWebVRViewMatrix(): Matrix;
  88366. /** @hidden */
  88367. _getWebVRProjectionMatrix(): Matrix;
  88368. private _onGamepadConnectedObserver;
  88369. private _onGamepadDisconnectedObserver;
  88370. private _updateCacheWhenTrackingDisabledObserver;
  88371. /**
  88372. * Initializes the controllers and their meshes
  88373. */
  88374. initControllers(): void;
  88375. }
  88376. }
  88377. declare module BABYLON {
  88378. /**
  88379. * Size options for a post process
  88380. */
  88381. export type PostProcessOptions = {
  88382. width: number;
  88383. height: number;
  88384. };
  88385. /**
  88386. * PostProcess can be used to apply a shader to a texture after it has been rendered
  88387. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  88388. */
  88389. export class PostProcess {
  88390. /** Name of the PostProcess. */
  88391. name: string;
  88392. /**
  88393. * Gets or sets the unique id of the post process
  88394. */
  88395. uniqueId: number;
  88396. /**
  88397. * Width of the texture to apply the post process on
  88398. */
  88399. width: number;
  88400. /**
  88401. * Height of the texture to apply the post process on
  88402. */
  88403. height: number;
  88404. /**
  88405. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  88406. * @hidden
  88407. */
  88408. _outputTexture: Nullable<InternalTexture>;
  88409. /**
  88410. * Sampling mode used by the shader
  88411. * See https://doc.babylonjs.com/classes/3.1/texture
  88412. */
  88413. renderTargetSamplingMode: number;
  88414. /**
  88415. * Clear color to use when screen clearing
  88416. */
  88417. clearColor: Color4;
  88418. /**
  88419. * If the buffer needs to be cleared before applying the post process. (default: true)
  88420. * Should be set to false if shader will overwrite all previous pixels.
  88421. */
  88422. autoClear: boolean;
  88423. /**
  88424. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  88425. */
  88426. alphaMode: number;
  88427. /**
  88428. * Sets the setAlphaBlendConstants of the babylon engine
  88429. */
  88430. alphaConstants: Color4;
  88431. /**
  88432. * Animations to be used for the post processing
  88433. */
  88434. animations: Animation[];
  88435. /**
  88436. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  88437. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  88438. */
  88439. enablePixelPerfectMode: boolean;
  88440. /**
  88441. * Force the postprocess to be applied without taking in account viewport
  88442. */
  88443. forceFullscreenViewport: boolean;
  88444. /**
  88445. * List of inspectable custom properties (used by the Inspector)
  88446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88447. */
  88448. inspectableCustomProperties: IInspectable[];
  88449. /**
  88450. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  88451. *
  88452. * | Value | Type | Description |
  88453. * | ----- | ----------------------------------- | ----------- |
  88454. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  88455. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  88456. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  88457. *
  88458. */
  88459. scaleMode: number;
  88460. /**
  88461. * Force textures to be a power of two (default: false)
  88462. */
  88463. alwaysForcePOT: boolean;
  88464. private _samples;
  88465. /**
  88466. * Number of sample textures (default: 1)
  88467. */
  88468. get samples(): number;
  88469. set samples(n: number);
  88470. /**
  88471. * Modify the scale of the post process to be the same as the viewport (default: false)
  88472. */
  88473. adaptScaleToCurrentViewport: boolean;
  88474. private _camera;
  88475. private _scene;
  88476. private _engine;
  88477. private _options;
  88478. private _reusable;
  88479. private _textureType;
  88480. private _textureFormat;
  88481. /**
  88482. * Smart array of input and output textures for the post process.
  88483. * @hidden
  88484. */
  88485. _textures: SmartArray<InternalTexture>;
  88486. /**
  88487. * The index in _textures that corresponds to the output texture.
  88488. * @hidden
  88489. */
  88490. _currentRenderTextureInd: number;
  88491. private _effect;
  88492. private _samplers;
  88493. private _fragmentUrl;
  88494. private _vertexUrl;
  88495. private _parameters;
  88496. private _scaleRatio;
  88497. protected _indexParameters: any;
  88498. private _shareOutputWithPostProcess;
  88499. private _texelSize;
  88500. private _forcedOutputTexture;
  88501. /**
  88502. * Returns the fragment url or shader name used in the post process.
  88503. * @returns the fragment url or name in the shader store.
  88504. */
  88505. getEffectName(): string;
  88506. /**
  88507. * An event triggered when the postprocess is activated.
  88508. */
  88509. onActivateObservable: Observable<Camera>;
  88510. private _onActivateObserver;
  88511. /**
  88512. * A function that is added to the onActivateObservable
  88513. */
  88514. set onActivate(callback: Nullable<(camera: Camera) => void>);
  88515. /**
  88516. * An event triggered when the postprocess changes its size.
  88517. */
  88518. onSizeChangedObservable: Observable<PostProcess>;
  88519. private _onSizeChangedObserver;
  88520. /**
  88521. * A function that is added to the onSizeChangedObservable
  88522. */
  88523. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  88524. /**
  88525. * An event triggered when the postprocess applies its effect.
  88526. */
  88527. onApplyObservable: Observable<Effect>;
  88528. private _onApplyObserver;
  88529. /**
  88530. * A function that is added to the onApplyObservable
  88531. */
  88532. set onApply(callback: (effect: Effect) => void);
  88533. /**
  88534. * An event triggered before rendering the postprocess
  88535. */
  88536. onBeforeRenderObservable: Observable<Effect>;
  88537. private _onBeforeRenderObserver;
  88538. /**
  88539. * A function that is added to the onBeforeRenderObservable
  88540. */
  88541. set onBeforeRender(callback: (effect: Effect) => void);
  88542. /**
  88543. * An event triggered after rendering the postprocess
  88544. */
  88545. onAfterRenderObservable: Observable<Effect>;
  88546. private _onAfterRenderObserver;
  88547. /**
  88548. * A function that is added to the onAfterRenderObservable
  88549. */
  88550. set onAfterRender(callback: (efect: Effect) => void);
  88551. /**
  88552. * 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
  88553. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  88554. */
  88555. get inputTexture(): InternalTexture;
  88556. set inputTexture(value: InternalTexture);
  88557. /**
  88558. * Gets the camera which post process is applied to.
  88559. * @returns The camera the post process is applied to.
  88560. */
  88561. getCamera(): Camera;
  88562. /**
  88563. * Gets the texel size of the postprocess.
  88564. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  88565. */
  88566. get texelSize(): Vector2;
  88567. /**
  88568. * Creates a new instance PostProcess
  88569. * @param name The name of the PostProcess.
  88570. * @param fragmentUrl The url of the fragment shader to be used.
  88571. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  88572. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  88573. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88574. * @param camera The camera to apply the render pass to.
  88575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88576. * @param engine The engine which the post process will be applied. (default: current engine)
  88577. * @param reusable If the post process can be reused on the same frame. (default: false)
  88578. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  88579. * @param textureType Type of textures used when performing the post process. (default: 0)
  88580. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  88581. * @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
  88582. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  88583. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  88584. */
  88585. constructor(
  88586. /** Name of the PostProcess. */
  88587. 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);
  88588. /**
  88589. * Gets a string idenfifying the name of the class
  88590. * @returns "PostProcess" string
  88591. */
  88592. getClassName(): string;
  88593. /**
  88594. * Gets the engine which this post process belongs to.
  88595. * @returns The engine the post process was enabled with.
  88596. */
  88597. getEngine(): Engine;
  88598. /**
  88599. * The effect that is created when initializing the post process.
  88600. * @returns The created effect corresponding the the postprocess.
  88601. */
  88602. getEffect(): Effect;
  88603. /**
  88604. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  88605. * @param postProcess The post process to share the output with.
  88606. * @returns This post process.
  88607. */
  88608. shareOutputWith(postProcess: PostProcess): PostProcess;
  88609. /**
  88610. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  88611. * This should be called if the post process that shares output with this post process is disabled/disposed.
  88612. */
  88613. useOwnOutput(): void;
  88614. /**
  88615. * Updates the effect with the current post process compile time values and recompiles the shader.
  88616. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88617. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88618. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88619. * @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
  88620. * @param onCompiled Called when the shader has been compiled.
  88621. * @param onError Called if there is an error when compiling a shader.
  88622. */
  88623. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88624. /**
  88625. * The post process is reusable if it can be used multiple times within one frame.
  88626. * @returns If the post process is reusable
  88627. */
  88628. isReusable(): boolean;
  88629. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  88630. markTextureDirty(): void;
  88631. /**
  88632. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  88633. * 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.
  88634. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  88635. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  88636. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  88637. * @returns The target texture that was bound to be written to.
  88638. */
  88639. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  88640. /**
  88641. * If the post process is supported.
  88642. */
  88643. get isSupported(): boolean;
  88644. /**
  88645. * The aspect ratio of the output texture.
  88646. */
  88647. get aspectRatio(): number;
  88648. /**
  88649. * Get a value indicating if the post-process is ready to be used
  88650. * @returns true if the post-process is ready (shader is compiled)
  88651. */
  88652. isReady(): boolean;
  88653. /**
  88654. * Binds all textures and uniforms to the shader, this will be run on every pass.
  88655. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  88656. */
  88657. apply(): Nullable<Effect>;
  88658. private _disposeTextures;
  88659. /**
  88660. * Disposes the post process.
  88661. * @param camera The camera to dispose the post process on.
  88662. */
  88663. dispose(camera?: Camera): void;
  88664. }
  88665. }
  88666. declare module BABYLON {
  88667. /** @hidden */
  88668. export var kernelBlurVaryingDeclaration: {
  88669. name: string;
  88670. shader: string;
  88671. };
  88672. }
  88673. declare module BABYLON {
  88674. /** @hidden */
  88675. export var kernelBlurFragment: {
  88676. name: string;
  88677. shader: string;
  88678. };
  88679. }
  88680. declare module BABYLON {
  88681. /** @hidden */
  88682. export var kernelBlurFragment2: {
  88683. name: string;
  88684. shader: string;
  88685. };
  88686. }
  88687. declare module BABYLON {
  88688. /** @hidden */
  88689. export var kernelBlurPixelShader: {
  88690. name: string;
  88691. shader: string;
  88692. };
  88693. }
  88694. declare module BABYLON {
  88695. /** @hidden */
  88696. export var kernelBlurVertex: {
  88697. name: string;
  88698. shader: string;
  88699. };
  88700. }
  88701. declare module BABYLON {
  88702. /** @hidden */
  88703. export var kernelBlurVertexShader: {
  88704. name: string;
  88705. shader: string;
  88706. };
  88707. }
  88708. declare module BABYLON {
  88709. /**
  88710. * The Blur Post Process which blurs an image based on a kernel and direction.
  88711. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  88712. */
  88713. export class BlurPostProcess extends PostProcess {
  88714. /** The direction in which to blur the image. */
  88715. direction: Vector2;
  88716. private blockCompilation;
  88717. protected _kernel: number;
  88718. protected _idealKernel: number;
  88719. protected _packedFloat: boolean;
  88720. private _staticDefines;
  88721. /**
  88722. * Sets the length in pixels of the blur sample region
  88723. */
  88724. set kernel(v: number);
  88725. /**
  88726. * Gets the length in pixels of the blur sample region
  88727. */
  88728. get kernel(): number;
  88729. /**
  88730. * Sets wether or not the blur needs to unpack/repack floats
  88731. */
  88732. set packedFloat(v: boolean);
  88733. /**
  88734. * Gets wether or not the blur is unpacking/repacking floats
  88735. */
  88736. get packedFloat(): boolean;
  88737. /**
  88738. * Creates a new instance BlurPostProcess
  88739. * @param name The name of the effect.
  88740. * @param direction The direction in which to blur the image.
  88741. * @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.
  88742. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88743. * @param camera The camera to apply the render pass to.
  88744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88745. * @param engine The engine which the post process will be applied. (default: current engine)
  88746. * @param reusable If the post process can be reused on the same frame. (default: false)
  88747. * @param textureType Type of textures used when performing the post process. (default: 0)
  88748. * @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)
  88749. */
  88750. constructor(name: string,
  88751. /** The direction in which to blur the image. */
  88752. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  88753. /**
  88754. * Updates the effect with the current post process compile time values and recompiles the shader.
  88755. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88756. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88757. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88758. * @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
  88759. * @param onCompiled Called when the shader has been compiled.
  88760. * @param onError Called if there is an error when compiling a shader.
  88761. */
  88762. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88763. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88764. /**
  88765. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  88766. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  88767. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  88768. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  88769. * The gaps between physical kernels are compensated for in the weighting of the samples
  88770. * @param idealKernel Ideal blur kernel.
  88771. * @return Nearest best kernel.
  88772. */
  88773. protected _nearestBestKernel(idealKernel: number): number;
  88774. /**
  88775. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  88776. * @param x The point on the Gaussian distribution to sample.
  88777. * @return the value of the Gaussian function at x.
  88778. */
  88779. protected _gaussianWeight(x: number): number;
  88780. /**
  88781. * Generates a string that can be used as a floating point number in GLSL.
  88782. * @param x Value to print.
  88783. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  88784. * @return GLSL float string.
  88785. */
  88786. protected _glslFloat(x: number, decimalFigures?: number): string;
  88787. }
  88788. }
  88789. declare module BABYLON {
  88790. /**
  88791. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88792. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88793. * You can then easily use it as a reflectionTexture on a flat surface.
  88794. * In case the surface is not a plane, please consider relying on reflection probes.
  88795. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88796. */
  88797. export class MirrorTexture extends RenderTargetTexture {
  88798. private scene;
  88799. /**
  88800. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  88801. * 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.
  88802. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88803. */
  88804. mirrorPlane: Plane;
  88805. /**
  88806. * Define the blur ratio used to blur the reflection if needed.
  88807. */
  88808. set blurRatio(value: number);
  88809. get blurRatio(): number;
  88810. /**
  88811. * Define the adaptive blur kernel used to blur the reflection if needed.
  88812. * This will autocompute the closest best match for the `blurKernel`
  88813. */
  88814. set adaptiveBlurKernel(value: number);
  88815. /**
  88816. * Define the blur kernel used to blur the reflection if needed.
  88817. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88818. */
  88819. set blurKernel(value: number);
  88820. /**
  88821. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  88822. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88823. */
  88824. set blurKernelX(value: number);
  88825. get blurKernelX(): number;
  88826. /**
  88827. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  88828. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88829. */
  88830. set blurKernelY(value: number);
  88831. get blurKernelY(): number;
  88832. private _autoComputeBlurKernel;
  88833. protected _onRatioRescale(): void;
  88834. private _updateGammaSpace;
  88835. private _imageProcessingConfigChangeObserver;
  88836. private _transformMatrix;
  88837. private _mirrorMatrix;
  88838. private _savedViewMatrix;
  88839. private _blurX;
  88840. private _blurY;
  88841. private _adaptiveBlurKernel;
  88842. private _blurKernelX;
  88843. private _blurKernelY;
  88844. private _blurRatio;
  88845. /**
  88846. * Instantiates a Mirror Texture.
  88847. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88848. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88849. * You can then easily use it as a reflectionTexture on a flat surface.
  88850. * In case the surface is not a plane, please consider relying on reflection probes.
  88851. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88852. * @param name
  88853. * @param size
  88854. * @param scene
  88855. * @param generateMipMaps
  88856. * @param type
  88857. * @param samplingMode
  88858. * @param generateDepthBuffer
  88859. */
  88860. constructor(name: string, size: number | {
  88861. width: number;
  88862. height: number;
  88863. } | {
  88864. ratio: number;
  88865. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  88866. private _preparePostProcesses;
  88867. /**
  88868. * Clone the mirror texture.
  88869. * @returns the cloned texture
  88870. */
  88871. clone(): MirrorTexture;
  88872. /**
  88873. * Serialize the texture to a JSON representation you could use in Parse later on
  88874. * @returns the serialized JSON representation
  88875. */
  88876. serialize(): any;
  88877. /**
  88878. * Dispose the texture and release its associated resources.
  88879. */
  88880. dispose(): void;
  88881. }
  88882. }
  88883. declare module BABYLON {
  88884. /**
  88885. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88886. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88887. */
  88888. export class Texture extends BaseTexture {
  88889. /**
  88890. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  88891. */
  88892. static SerializeBuffers: boolean;
  88893. /** @hidden */
  88894. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  88895. /** @hidden */
  88896. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  88897. /** @hidden */
  88898. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  88899. /** nearest is mag = nearest and min = nearest and mip = linear */
  88900. static readonly NEAREST_SAMPLINGMODE: number;
  88901. /** nearest is mag = nearest and min = nearest and mip = linear */
  88902. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  88903. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88904. static readonly BILINEAR_SAMPLINGMODE: number;
  88905. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88906. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  88907. /** Trilinear is mag = linear and min = linear and mip = linear */
  88908. static readonly TRILINEAR_SAMPLINGMODE: number;
  88909. /** Trilinear is mag = linear and min = linear and mip = linear */
  88910. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  88911. /** mag = nearest and min = nearest and mip = nearest */
  88912. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  88913. /** mag = nearest and min = linear and mip = nearest */
  88914. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  88915. /** mag = nearest and min = linear and mip = linear */
  88916. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  88917. /** mag = nearest and min = linear and mip = none */
  88918. static readonly NEAREST_LINEAR: number;
  88919. /** mag = nearest and min = nearest and mip = none */
  88920. static readonly NEAREST_NEAREST: number;
  88921. /** mag = linear and min = nearest and mip = nearest */
  88922. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  88923. /** mag = linear and min = nearest and mip = linear */
  88924. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  88925. /** mag = linear and min = linear and mip = none */
  88926. static readonly LINEAR_LINEAR: number;
  88927. /** mag = linear and min = nearest and mip = none */
  88928. static readonly LINEAR_NEAREST: number;
  88929. /** Explicit coordinates mode */
  88930. static readonly EXPLICIT_MODE: number;
  88931. /** Spherical coordinates mode */
  88932. static readonly SPHERICAL_MODE: number;
  88933. /** Planar coordinates mode */
  88934. static readonly PLANAR_MODE: number;
  88935. /** Cubic coordinates mode */
  88936. static readonly CUBIC_MODE: number;
  88937. /** Projection coordinates mode */
  88938. static readonly PROJECTION_MODE: number;
  88939. /** Inverse Cubic coordinates mode */
  88940. static readonly SKYBOX_MODE: number;
  88941. /** Inverse Cubic coordinates mode */
  88942. static readonly INVCUBIC_MODE: number;
  88943. /** Equirectangular coordinates mode */
  88944. static readonly EQUIRECTANGULAR_MODE: number;
  88945. /** Equirectangular Fixed coordinates mode */
  88946. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  88947. /** Equirectangular Fixed Mirrored coordinates mode */
  88948. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  88949. /** Texture is not repeating outside of 0..1 UVs */
  88950. static readonly CLAMP_ADDRESSMODE: number;
  88951. /** Texture is repeating outside of 0..1 UVs */
  88952. static readonly WRAP_ADDRESSMODE: number;
  88953. /** Texture is repeating and mirrored */
  88954. static readonly MIRROR_ADDRESSMODE: number;
  88955. /**
  88956. * 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
  88957. */
  88958. static UseSerializedUrlIfAny: boolean;
  88959. /**
  88960. * Define the url of the texture.
  88961. */
  88962. url: Nullable<string>;
  88963. /**
  88964. * Define an offset on the texture to offset the u coordinates of the UVs
  88965. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88966. */
  88967. uOffset: number;
  88968. /**
  88969. * Define an offset on the texture to offset the v coordinates of the UVs
  88970. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88971. */
  88972. vOffset: number;
  88973. /**
  88974. * Define an offset on the texture to scale the u coordinates of the UVs
  88975. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88976. */
  88977. uScale: number;
  88978. /**
  88979. * Define an offset on the texture to scale the v coordinates of the UVs
  88980. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88981. */
  88982. vScale: number;
  88983. /**
  88984. * Define an offset on the texture to rotate around the u coordinates of the UVs
  88985. * @see http://doc.babylonjs.com/how_to/more_materials
  88986. */
  88987. uAng: number;
  88988. /**
  88989. * Define an offset on the texture to rotate around the v coordinates of the UVs
  88990. * @see http://doc.babylonjs.com/how_to/more_materials
  88991. */
  88992. vAng: number;
  88993. /**
  88994. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  88995. * @see http://doc.babylonjs.com/how_to/more_materials
  88996. */
  88997. wAng: number;
  88998. /**
  88999. * Defines the center of rotation (U)
  89000. */
  89001. uRotationCenter: number;
  89002. /**
  89003. * Defines the center of rotation (V)
  89004. */
  89005. vRotationCenter: number;
  89006. /**
  89007. * Defines the center of rotation (W)
  89008. */
  89009. wRotationCenter: number;
  89010. /**
  89011. * Are mip maps generated for this texture or not.
  89012. */
  89013. get noMipmap(): boolean;
  89014. /**
  89015. * List of inspectable custom properties (used by the Inspector)
  89016. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89017. */
  89018. inspectableCustomProperties: Nullable<IInspectable[]>;
  89019. private _noMipmap;
  89020. /** @hidden */
  89021. _invertY: boolean;
  89022. private _rowGenerationMatrix;
  89023. private _cachedTextureMatrix;
  89024. private _projectionModeMatrix;
  89025. private _t0;
  89026. private _t1;
  89027. private _t2;
  89028. private _cachedUOffset;
  89029. private _cachedVOffset;
  89030. private _cachedUScale;
  89031. private _cachedVScale;
  89032. private _cachedUAng;
  89033. private _cachedVAng;
  89034. private _cachedWAng;
  89035. private _cachedProjectionMatrixId;
  89036. private _cachedCoordinatesMode;
  89037. /** @hidden */
  89038. protected _initialSamplingMode: number;
  89039. /** @hidden */
  89040. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  89041. private _deleteBuffer;
  89042. protected _format: Nullable<number>;
  89043. private _delayedOnLoad;
  89044. private _delayedOnError;
  89045. private _mimeType?;
  89046. /**
  89047. * Observable triggered once the texture has been loaded.
  89048. */
  89049. onLoadObservable: Observable<Texture>;
  89050. protected _isBlocking: boolean;
  89051. /**
  89052. * Is the texture preventing material to render while loading.
  89053. * If false, a default texture will be used instead of the loading one during the preparation step.
  89054. */
  89055. set isBlocking(value: boolean);
  89056. get isBlocking(): boolean;
  89057. /**
  89058. * Get the current sampling mode associated with the texture.
  89059. */
  89060. get samplingMode(): number;
  89061. /**
  89062. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  89063. */
  89064. get invertY(): boolean;
  89065. /**
  89066. * Instantiates a new texture.
  89067. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  89068. * @see http://doc.babylonjs.com/babylon101/materials#texture
  89069. * @param url defines the url of the picture to load as a texture
  89070. * @param scene defines the scene or engine the texture will belong to
  89071. * @param noMipmap defines if the texture will require mip maps or not
  89072. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  89073. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89074. * @param onLoad defines a callback triggered when the texture has been loaded
  89075. * @param onError defines a callback triggered when an error occurred during the loading session
  89076. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  89077. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  89078. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89079. * @param mimeType defines an optional mime type information
  89080. */
  89081. 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);
  89082. /**
  89083. * Update the url (and optional buffer) of this texture if url was null during construction.
  89084. * @param url the url of the texture
  89085. * @param buffer the buffer of the texture (defaults to null)
  89086. * @param onLoad callback called when the texture is loaded (defaults to null)
  89087. */
  89088. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  89089. /**
  89090. * Finish the loading sequence of a texture flagged as delayed load.
  89091. * @hidden
  89092. */
  89093. delayLoad(): void;
  89094. private _prepareRowForTextureGeneration;
  89095. /**
  89096. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  89097. * @returns the transform matrix of the texture.
  89098. */
  89099. getTextureMatrix(uBase?: number): Matrix;
  89100. /**
  89101. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  89102. * @returns The reflection texture transform
  89103. */
  89104. getReflectionTextureMatrix(): Matrix;
  89105. /**
  89106. * Clones the texture.
  89107. * @returns the cloned texture
  89108. */
  89109. clone(): Texture;
  89110. /**
  89111. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89112. * @returns The JSON representation of the texture
  89113. */
  89114. serialize(): any;
  89115. /**
  89116. * Get the current class name of the texture useful for serialization or dynamic coding.
  89117. * @returns "Texture"
  89118. */
  89119. getClassName(): string;
  89120. /**
  89121. * Dispose the texture and release its associated resources.
  89122. */
  89123. dispose(): void;
  89124. /**
  89125. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  89126. * @param parsedTexture Define the JSON representation of the texture
  89127. * @param scene Define the scene the parsed texture should be instantiated in
  89128. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  89129. * @returns The parsed texture if successful
  89130. */
  89131. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  89132. /**
  89133. * Creates a texture from its base 64 representation.
  89134. * @param data Define the base64 payload without the data: prefix
  89135. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  89136. * @param scene Define the scene the texture should belong to
  89137. * @param noMipmap Forces the texture to not create mip map information if true
  89138. * @param invertY define if the texture needs to be inverted on the y axis during loading
  89139. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89140. * @param onLoad define a callback triggered when the texture has been loaded
  89141. * @param onError define a callback triggered when an error occurred during the loading session
  89142. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89143. * @returns the created texture
  89144. */
  89145. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  89146. /**
  89147. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  89148. * @param data Define the base64 payload without the data: prefix
  89149. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  89150. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  89151. * @param scene Define the scene the texture should belong to
  89152. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  89153. * @param noMipmap Forces the texture to not create mip map information if true
  89154. * @param invertY define if the texture needs to be inverted on the y axis during loading
  89155. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89156. * @param onLoad define a callback triggered when the texture has been loaded
  89157. * @param onError define a callback triggered when an error occurred during the loading session
  89158. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89159. * @returns the created texture
  89160. */
  89161. 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;
  89162. }
  89163. }
  89164. declare module BABYLON {
  89165. /**
  89166. * PostProcessManager is used to manage one or more post processes or post process pipelines
  89167. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  89168. */
  89169. export class PostProcessManager {
  89170. private _scene;
  89171. private _indexBuffer;
  89172. private _vertexBuffers;
  89173. /**
  89174. * Creates a new instance PostProcess
  89175. * @param scene The scene that the post process is associated with.
  89176. */
  89177. constructor(scene: Scene);
  89178. private _prepareBuffers;
  89179. private _buildIndexBuffer;
  89180. /**
  89181. * Rebuilds the vertex buffers of the manager.
  89182. * @hidden
  89183. */
  89184. _rebuild(): void;
  89185. /**
  89186. * Prepares a frame to be run through a post process.
  89187. * @param sourceTexture The input texture to the post procesess. (default: null)
  89188. * @param postProcesses An array of post processes to be run. (default: null)
  89189. * @returns True if the post processes were able to be run.
  89190. * @hidden
  89191. */
  89192. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  89193. /**
  89194. * Manually render a set of post processes to a texture.
  89195. * @param postProcesses An array of post processes to be run.
  89196. * @param targetTexture The target texture to render to.
  89197. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  89198. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  89199. * @param lodLevel defines which lod of the texture to render to
  89200. */
  89201. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  89202. /**
  89203. * Finalize the result of the output of the postprocesses.
  89204. * @param doNotPresent If true the result will not be displayed to the screen.
  89205. * @param targetTexture The target texture to render to.
  89206. * @param faceIndex The index of the face to bind the target texture to.
  89207. * @param postProcesses The array of post processes to render.
  89208. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  89209. * @hidden
  89210. */
  89211. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  89212. /**
  89213. * Disposes of the post process manager.
  89214. */
  89215. dispose(): void;
  89216. }
  89217. }
  89218. declare module BABYLON {
  89219. /** Interface used by value gradients (color, factor, ...) */
  89220. export interface IValueGradient {
  89221. /**
  89222. * Gets or sets the gradient value (between 0 and 1)
  89223. */
  89224. gradient: number;
  89225. }
  89226. /** Class used to store color4 gradient */
  89227. export class ColorGradient implements IValueGradient {
  89228. /**
  89229. * Gets or sets the gradient value (between 0 and 1)
  89230. */
  89231. gradient: number;
  89232. /**
  89233. * Gets or sets first associated color
  89234. */
  89235. color1: Color4;
  89236. /**
  89237. * Gets or sets second associated color
  89238. */
  89239. color2?: Color4;
  89240. /**
  89241. * Will get a color picked randomly between color1 and color2.
  89242. * If color2 is undefined then color1 will be used
  89243. * @param result defines the target Color4 to store the result in
  89244. */
  89245. getColorToRef(result: Color4): void;
  89246. }
  89247. /** Class used to store color 3 gradient */
  89248. export class Color3Gradient implements IValueGradient {
  89249. /**
  89250. * Gets or sets the gradient value (between 0 and 1)
  89251. */
  89252. gradient: number;
  89253. /**
  89254. * Gets or sets the associated color
  89255. */
  89256. color: Color3;
  89257. }
  89258. /** Class used to store factor gradient */
  89259. export class FactorGradient implements IValueGradient {
  89260. /**
  89261. * Gets or sets the gradient value (between 0 and 1)
  89262. */
  89263. gradient: number;
  89264. /**
  89265. * Gets or sets first associated factor
  89266. */
  89267. factor1: number;
  89268. /**
  89269. * Gets or sets second associated factor
  89270. */
  89271. factor2?: number;
  89272. /**
  89273. * Will get a number picked randomly between factor1 and factor2.
  89274. * If factor2 is undefined then factor1 will be used
  89275. * @returns the picked number
  89276. */
  89277. getFactor(): number;
  89278. }
  89279. /**
  89280. * Helper used to simplify some generic gradient tasks
  89281. */
  89282. export class GradientHelper {
  89283. /**
  89284. * Gets the current gradient from an array of IValueGradient
  89285. * @param ratio defines the current ratio to get
  89286. * @param gradients defines the array of IValueGradient
  89287. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89288. */
  89289. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89290. }
  89291. }
  89292. declare module BABYLON {
  89293. interface ThinEngine {
  89294. /**
  89295. * Creates a dynamic texture
  89296. * @param width defines the width of the texture
  89297. * @param height defines the height of the texture
  89298. * @param generateMipMaps defines if the engine should generate the mip levels
  89299. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89300. * @returns the dynamic texture inside an InternalTexture
  89301. */
  89302. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  89303. /**
  89304. * Update the content of a dynamic texture
  89305. * @param texture defines the texture to update
  89306. * @param canvas defines the canvas containing the source
  89307. * @param invertY defines if data must be stored with Y axis inverted
  89308. * @param premulAlpha defines if alpha is stored as premultiplied
  89309. * @param format defines the format of the data
  89310. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  89311. */
  89312. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  89313. }
  89314. }
  89315. declare module BABYLON {
  89316. /**
  89317. * Helper class used to generate a canvas to manipulate images
  89318. */
  89319. export class CanvasGenerator {
  89320. /**
  89321. * Create a new canvas (or offscreen canvas depending on the context)
  89322. * @param width defines the expected width
  89323. * @param height defines the expected height
  89324. * @return a new canvas or offscreen canvas
  89325. */
  89326. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  89327. }
  89328. }
  89329. declare module BABYLON {
  89330. /**
  89331. * A class extending Texture allowing drawing on a texture
  89332. * @see http://doc.babylonjs.com/how_to/dynamictexture
  89333. */
  89334. export class DynamicTexture extends Texture {
  89335. private _generateMipMaps;
  89336. private _canvas;
  89337. private _context;
  89338. private _engine;
  89339. /**
  89340. * Creates a DynamicTexture
  89341. * @param name defines the name of the texture
  89342. * @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
  89343. * @param scene defines the scene where you want the texture
  89344. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  89345. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  89346. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  89347. */
  89348. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  89349. /**
  89350. * Get the current class name of the texture useful for serialization or dynamic coding.
  89351. * @returns "DynamicTexture"
  89352. */
  89353. getClassName(): string;
  89354. /**
  89355. * Gets the current state of canRescale
  89356. */
  89357. get canRescale(): boolean;
  89358. private _recreate;
  89359. /**
  89360. * Scales the texture
  89361. * @param ratio the scale factor to apply to both width and height
  89362. */
  89363. scale(ratio: number): void;
  89364. /**
  89365. * Resizes the texture
  89366. * @param width the new width
  89367. * @param height the new height
  89368. */
  89369. scaleTo(width: number, height: number): void;
  89370. /**
  89371. * Gets the context of the canvas used by the texture
  89372. * @returns the canvas context of the dynamic texture
  89373. */
  89374. getContext(): CanvasRenderingContext2D;
  89375. /**
  89376. * Clears the texture
  89377. */
  89378. clear(): void;
  89379. /**
  89380. * Updates the texture
  89381. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89382. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  89383. */
  89384. update(invertY?: boolean, premulAlpha?: boolean): void;
  89385. /**
  89386. * Draws text onto the texture
  89387. * @param text defines the text to be drawn
  89388. * @param x defines the placement of the text from the left
  89389. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  89390. * @param font defines the font to be used with font-style, font-size, font-name
  89391. * @param color defines the color used for the text
  89392. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  89393. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89394. * @param update defines whether texture is immediately update (default is true)
  89395. */
  89396. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  89397. /**
  89398. * Clones the texture
  89399. * @returns the clone of the texture.
  89400. */
  89401. clone(): DynamicTexture;
  89402. /**
  89403. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  89404. * @returns a serialized dynamic texture object
  89405. */
  89406. serialize(): any;
  89407. /** @hidden */
  89408. _rebuild(): void;
  89409. }
  89410. }
  89411. declare module BABYLON {
  89412. interface AbstractScene {
  89413. /**
  89414. * The list of procedural textures added to the scene
  89415. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89416. */
  89417. proceduralTextures: Array<ProceduralTexture>;
  89418. }
  89419. /**
  89420. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89421. * in a given scene.
  89422. */
  89423. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89424. /**
  89425. * The component name helpfull to identify the component in the list of scene components.
  89426. */
  89427. readonly name: string;
  89428. /**
  89429. * The scene the component belongs to.
  89430. */
  89431. scene: Scene;
  89432. /**
  89433. * Creates a new instance of the component for the given scene
  89434. * @param scene Defines the scene to register the component in
  89435. */
  89436. constructor(scene: Scene);
  89437. /**
  89438. * Registers the component in a given scene
  89439. */
  89440. register(): void;
  89441. /**
  89442. * Rebuilds the elements related to this component in case of
  89443. * context lost for instance.
  89444. */
  89445. rebuild(): void;
  89446. /**
  89447. * Disposes the component and the associated ressources.
  89448. */
  89449. dispose(): void;
  89450. private _beforeClear;
  89451. }
  89452. }
  89453. declare module BABYLON {
  89454. interface ThinEngine {
  89455. /**
  89456. * Creates a new render target cube texture
  89457. * @param size defines the size of the texture
  89458. * @param options defines the options used to create the texture
  89459. * @returns a new render target cube texture stored in an InternalTexture
  89460. */
  89461. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89462. }
  89463. }
  89464. declare module BABYLON {
  89465. /** @hidden */
  89466. export var proceduralVertexShader: {
  89467. name: string;
  89468. shader: string;
  89469. };
  89470. }
  89471. declare module BABYLON {
  89472. /**
  89473. * 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.
  89474. * This is the base class of any Procedural texture and contains most of the shareable code.
  89475. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89476. */
  89477. export class ProceduralTexture extends Texture {
  89478. isCube: boolean;
  89479. /**
  89480. * Define if the texture is enabled or not (disabled texture will not render)
  89481. */
  89482. isEnabled: boolean;
  89483. /**
  89484. * Define if the texture must be cleared before rendering (default is true)
  89485. */
  89486. autoClear: boolean;
  89487. /**
  89488. * Callback called when the texture is generated
  89489. */
  89490. onGenerated: () => void;
  89491. /**
  89492. * Event raised when the texture is generated
  89493. */
  89494. onGeneratedObservable: Observable<ProceduralTexture>;
  89495. /** @hidden */
  89496. _generateMipMaps: boolean;
  89497. /** @hidden **/
  89498. _effect: Effect;
  89499. /** @hidden */
  89500. _textures: {
  89501. [key: string]: Texture;
  89502. };
  89503. private _size;
  89504. private _currentRefreshId;
  89505. private _frameId;
  89506. private _refreshRate;
  89507. private _vertexBuffers;
  89508. private _indexBuffer;
  89509. private _uniforms;
  89510. private _samplers;
  89511. private _fragment;
  89512. private _floats;
  89513. private _ints;
  89514. private _floatsArrays;
  89515. private _colors3;
  89516. private _colors4;
  89517. private _vectors2;
  89518. private _vectors3;
  89519. private _matrices;
  89520. private _fallbackTexture;
  89521. private _fallbackTextureUsed;
  89522. private _engine;
  89523. private _cachedDefines;
  89524. private _contentUpdateId;
  89525. private _contentData;
  89526. /**
  89527. * Instantiates a new procedural texture.
  89528. * 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.
  89529. * This is the base class of any Procedural texture and contains most of the shareable code.
  89530. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89531. * @param name Define the name of the texture
  89532. * @param size Define the size of the texture to create
  89533. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89534. * @param scene Define the scene the texture belongs to
  89535. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89536. * @param generateMipMaps Define if the texture should creates mip maps or not
  89537. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89538. */
  89539. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89540. /**
  89541. * The effect that is created when initializing the post process.
  89542. * @returns The created effect corresponding the the postprocess.
  89543. */
  89544. getEffect(): Effect;
  89545. /**
  89546. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89547. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89548. */
  89549. getContent(): Nullable<ArrayBufferView>;
  89550. private _createIndexBuffer;
  89551. /** @hidden */
  89552. _rebuild(): void;
  89553. /**
  89554. * Resets the texture in order to recreate its associated resources.
  89555. * This can be called in case of context loss
  89556. */
  89557. reset(): void;
  89558. protected _getDefines(): string;
  89559. /**
  89560. * Is the texture ready to be used ? (rendered at least once)
  89561. * @returns true if ready, otherwise, false.
  89562. */
  89563. isReady(): boolean;
  89564. /**
  89565. * Resets the refresh counter of the texture and start bak from scratch.
  89566. * Could be useful to regenerate the texture if it is setup to render only once.
  89567. */
  89568. resetRefreshCounter(): void;
  89569. /**
  89570. * Set the fragment shader to use in order to render the texture.
  89571. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89572. */
  89573. setFragment(fragment: any): void;
  89574. /**
  89575. * Define the refresh rate of the texture or the rendering frequency.
  89576. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89577. */
  89578. get refreshRate(): number;
  89579. set refreshRate(value: number);
  89580. /** @hidden */
  89581. _shouldRender(): boolean;
  89582. /**
  89583. * Get the size the texture is rendering at.
  89584. * @returns the size (texture is always squared)
  89585. */
  89586. getRenderSize(): number;
  89587. /**
  89588. * Resize the texture to new value.
  89589. * @param size Define the new size the texture should have
  89590. * @param generateMipMaps Define whether the new texture should create mip maps
  89591. */
  89592. resize(size: number, generateMipMaps: boolean): void;
  89593. private _checkUniform;
  89594. /**
  89595. * Set a texture in the shader program used to render.
  89596. * @param name Define the name of the uniform samplers as defined in the shader
  89597. * @param texture Define the texture to bind to this sampler
  89598. * @return the texture itself allowing "fluent" like uniform updates
  89599. */
  89600. setTexture(name: string, texture: Texture): ProceduralTexture;
  89601. /**
  89602. * Set a float in the shader.
  89603. * @param name Define the name of the uniform as defined in the shader
  89604. * @param value Define the value to give to the uniform
  89605. * @return the texture itself allowing "fluent" like uniform updates
  89606. */
  89607. setFloat(name: string, value: number): ProceduralTexture;
  89608. /**
  89609. * Set a int in the shader.
  89610. * @param name Define the name of the uniform as defined in the shader
  89611. * @param value Define the value to give to the uniform
  89612. * @return the texture itself allowing "fluent" like uniform updates
  89613. */
  89614. setInt(name: string, value: number): ProceduralTexture;
  89615. /**
  89616. * Set an array of floats in the shader.
  89617. * @param name Define the name of the uniform as defined in the shader
  89618. * @param value Define the value to give to the uniform
  89619. * @return the texture itself allowing "fluent" like uniform updates
  89620. */
  89621. setFloats(name: string, value: number[]): ProceduralTexture;
  89622. /**
  89623. * Set a vec3 in the shader from a Color3.
  89624. * @param name Define the name of the uniform as defined in the shader
  89625. * @param value Define the value to give to the uniform
  89626. * @return the texture itself allowing "fluent" like uniform updates
  89627. */
  89628. setColor3(name: string, value: Color3): ProceduralTexture;
  89629. /**
  89630. * Set a vec4 in the shader from a Color4.
  89631. * @param name Define the name of the uniform as defined in the shader
  89632. * @param value Define the value to give to the uniform
  89633. * @return the texture itself allowing "fluent" like uniform updates
  89634. */
  89635. setColor4(name: string, value: Color4): ProceduralTexture;
  89636. /**
  89637. * Set a vec2 in the shader from a Vector2.
  89638. * @param name Define the name of the uniform as defined in the shader
  89639. * @param value Define the value to give to the uniform
  89640. * @return the texture itself allowing "fluent" like uniform updates
  89641. */
  89642. setVector2(name: string, value: Vector2): ProceduralTexture;
  89643. /**
  89644. * Set a vec3 in the shader from a Vector3.
  89645. * @param name Define the name of the uniform as defined in the shader
  89646. * @param value Define the value to give to the uniform
  89647. * @return the texture itself allowing "fluent" like uniform updates
  89648. */
  89649. setVector3(name: string, value: Vector3): ProceduralTexture;
  89650. /**
  89651. * Set a mat4 in the shader from a MAtrix.
  89652. * @param name Define the name of the uniform as defined in the shader
  89653. * @param value Define the value to give to the uniform
  89654. * @return the texture itself allowing "fluent" like uniform updates
  89655. */
  89656. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89657. /**
  89658. * Render the texture to its associated render target.
  89659. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89660. */
  89661. render(useCameraPostProcess?: boolean): void;
  89662. /**
  89663. * Clone the texture.
  89664. * @returns the cloned texture
  89665. */
  89666. clone(): ProceduralTexture;
  89667. /**
  89668. * Dispose the texture and release its asoociated resources.
  89669. */
  89670. dispose(): void;
  89671. }
  89672. }
  89673. declare module BABYLON {
  89674. /**
  89675. * This represents the base class for particle system in Babylon.
  89676. * 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.
  89677. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89678. * @example https://doc.babylonjs.com/babylon101/particles
  89679. */
  89680. export class BaseParticleSystem {
  89681. /**
  89682. * Source color is added to the destination color without alpha affecting the result
  89683. */
  89684. static BLENDMODE_ONEONE: number;
  89685. /**
  89686. * Blend current color and particle color using particle’s alpha
  89687. */
  89688. static BLENDMODE_STANDARD: number;
  89689. /**
  89690. * Add current color and particle color multiplied by particle’s alpha
  89691. */
  89692. static BLENDMODE_ADD: number;
  89693. /**
  89694. * Multiply current color with particle color
  89695. */
  89696. static BLENDMODE_MULTIPLY: number;
  89697. /**
  89698. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89699. */
  89700. static BLENDMODE_MULTIPLYADD: number;
  89701. /**
  89702. * List of animations used by the particle system.
  89703. */
  89704. animations: Animation[];
  89705. /**
  89706. * The id of the Particle system.
  89707. */
  89708. id: string;
  89709. /**
  89710. * The friendly name of the Particle system.
  89711. */
  89712. name: string;
  89713. /**
  89714. * The rendering group used by the Particle system to chose when to render.
  89715. */
  89716. renderingGroupId: number;
  89717. /**
  89718. * The emitter represents the Mesh or position we are attaching the particle system to.
  89719. */
  89720. emitter: Nullable<AbstractMesh | Vector3>;
  89721. /**
  89722. * The maximum number of particles to emit per frame
  89723. */
  89724. emitRate: number;
  89725. /**
  89726. * If you want to launch only a few particles at once, that can be done, as well.
  89727. */
  89728. manualEmitCount: number;
  89729. /**
  89730. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89731. */
  89732. updateSpeed: number;
  89733. /**
  89734. * The amount of time the particle system is running (depends of the overall update speed).
  89735. */
  89736. targetStopDuration: number;
  89737. /**
  89738. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89739. */
  89740. disposeOnStop: boolean;
  89741. /**
  89742. * Minimum power of emitting particles.
  89743. */
  89744. minEmitPower: number;
  89745. /**
  89746. * Maximum power of emitting particles.
  89747. */
  89748. maxEmitPower: number;
  89749. /**
  89750. * Minimum life time of emitting particles.
  89751. */
  89752. minLifeTime: number;
  89753. /**
  89754. * Maximum life time of emitting particles.
  89755. */
  89756. maxLifeTime: number;
  89757. /**
  89758. * Minimum Size of emitting particles.
  89759. */
  89760. minSize: number;
  89761. /**
  89762. * Maximum Size of emitting particles.
  89763. */
  89764. maxSize: number;
  89765. /**
  89766. * Minimum scale of emitting particles on X axis.
  89767. */
  89768. minScaleX: number;
  89769. /**
  89770. * Maximum scale of emitting particles on X axis.
  89771. */
  89772. maxScaleX: number;
  89773. /**
  89774. * Minimum scale of emitting particles on Y axis.
  89775. */
  89776. minScaleY: number;
  89777. /**
  89778. * Maximum scale of emitting particles on Y axis.
  89779. */
  89780. maxScaleY: number;
  89781. /**
  89782. * Gets or sets the minimal initial rotation in radians.
  89783. */
  89784. minInitialRotation: number;
  89785. /**
  89786. * Gets or sets the maximal initial rotation in radians.
  89787. */
  89788. maxInitialRotation: number;
  89789. /**
  89790. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89791. */
  89792. minAngularSpeed: number;
  89793. /**
  89794. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89795. */
  89796. maxAngularSpeed: number;
  89797. /**
  89798. * The texture used to render each particle. (this can be a spritesheet)
  89799. */
  89800. particleTexture: Nullable<Texture>;
  89801. /**
  89802. * The layer mask we are rendering the particles through.
  89803. */
  89804. layerMask: number;
  89805. /**
  89806. * This can help using your own shader to render the particle system.
  89807. * The according effect will be created
  89808. */
  89809. customShader: any;
  89810. /**
  89811. * By default particle system starts as soon as they are created. This prevents the
  89812. * automatic start to happen and let you decide when to start emitting particles.
  89813. */
  89814. preventAutoStart: boolean;
  89815. private _noiseTexture;
  89816. /**
  89817. * Gets or sets a texture used to add random noise to particle positions
  89818. */
  89819. get noiseTexture(): Nullable<ProceduralTexture>;
  89820. set noiseTexture(value: Nullable<ProceduralTexture>);
  89821. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89822. noiseStrength: Vector3;
  89823. /**
  89824. * Callback triggered when the particle animation is ending.
  89825. */
  89826. onAnimationEnd: Nullable<() => void>;
  89827. /**
  89828. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89829. */
  89830. blendMode: number;
  89831. /**
  89832. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89833. * to override the particles.
  89834. */
  89835. forceDepthWrite: boolean;
  89836. /** 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 */
  89837. preWarmCycles: number;
  89838. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89839. preWarmStepOffset: number;
  89840. /**
  89841. * 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)
  89842. */
  89843. spriteCellChangeSpeed: number;
  89844. /**
  89845. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89846. */
  89847. startSpriteCellID: number;
  89848. /**
  89849. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89850. */
  89851. endSpriteCellID: number;
  89852. /**
  89853. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89854. */
  89855. spriteCellWidth: number;
  89856. /**
  89857. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89858. */
  89859. spriteCellHeight: number;
  89860. /**
  89861. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89862. */
  89863. spriteRandomStartCell: boolean;
  89864. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89865. translationPivot: Vector2;
  89866. /** @hidden */
  89867. protected _isAnimationSheetEnabled: boolean;
  89868. /**
  89869. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89870. */
  89871. beginAnimationOnStart: boolean;
  89872. /**
  89873. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89874. */
  89875. beginAnimationFrom: number;
  89876. /**
  89877. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89878. */
  89879. beginAnimationTo: number;
  89880. /**
  89881. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89882. */
  89883. beginAnimationLoop: boolean;
  89884. /**
  89885. * Gets or sets a world offset applied to all particles
  89886. */
  89887. worldOffset: Vector3;
  89888. /**
  89889. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89890. */
  89891. get isAnimationSheetEnabled(): boolean;
  89892. set isAnimationSheetEnabled(value: boolean);
  89893. /**
  89894. * Get hosting scene
  89895. * @returns the scene
  89896. */
  89897. getScene(): Scene;
  89898. /**
  89899. * You can use gravity if you want to give an orientation to your particles.
  89900. */
  89901. gravity: Vector3;
  89902. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89903. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89904. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89905. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89906. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89907. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89908. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89909. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89910. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89911. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89912. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89913. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89914. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89915. /**
  89916. * Defines the delay in milliseconds before starting the system (0 by default)
  89917. */
  89918. startDelay: number;
  89919. /**
  89920. * Gets the current list of drag gradients.
  89921. * You must use addDragGradient and removeDragGradient to udpate this list
  89922. * @returns the list of drag gradients
  89923. */
  89924. getDragGradients(): Nullable<Array<FactorGradient>>;
  89925. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89926. limitVelocityDamping: number;
  89927. /**
  89928. * Gets the current list of limit velocity gradients.
  89929. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89930. * @returns the list of limit velocity gradients
  89931. */
  89932. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89933. /**
  89934. * Gets the current list of color gradients.
  89935. * You must use addColorGradient and removeColorGradient to udpate this list
  89936. * @returns the list of color gradients
  89937. */
  89938. getColorGradients(): Nullable<Array<ColorGradient>>;
  89939. /**
  89940. * Gets the current list of size gradients.
  89941. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89942. * @returns the list of size gradients
  89943. */
  89944. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89945. /**
  89946. * Gets the current list of color remap gradients.
  89947. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89948. * @returns the list of color remap gradients
  89949. */
  89950. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89951. /**
  89952. * Gets the current list of alpha remap gradients.
  89953. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89954. * @returns the list of alpha remap gradients
  89955. */
  89956. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89957. /**
  89958. * Gets the current list of life time gradients.
  89959. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89960. * @returns the list of life time gradients
  89961. */
  89962. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89963. /**
  89964. * Gets the current list of angular speed gradients.
  89965. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89966. * @returns the list of angular speed gradients
  89967. */
  89968. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89969. /**
  89970. * Gets the current list of velocity gradients.
  89971. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89972. * @returns the list of velocity gradients
  89973. */
  89974. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89975. /**
  89976. * Gets the current list of start size gradients.
  89977. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89978. * @returns the list of start size gradients
  89979. */
  89980. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89981. /**
  89982. * Gets the current list of emit rate gradients.
  89983. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89984. * @returns the list of emit rate gradients
  89985. */
  89986. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89987. /**
  89988. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89989. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89990. */
  89991. get direction1(): Vector3;
  89992. set direction1(value: Vector3);
  89993. /**
  89994. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89995. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89996. */
  89997. get direction2(): Vector3;
  89998. set direction2(value: Vector3);
  89999. /**
  90000. * 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.
  90001. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90002. */
  90003. get minEmitBox(): Vector3;
  90004. set minEmitBox(value: Vector3);
  90005. /**
  90006. * 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.
  90007. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90008. */
  90009. get maxEmitBox(): Vector3;
  90010. set maxEmitBox(value: Vector3);
  90011. /**
  90012. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90013. */
  90014. color1: Color4;
  90015. /**
  90016. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90017. */
  90018. color2: Color4;
  90019. /**
  90020. * Color the particle will have at the end of its lifetime
  90021. */
  90022. colorDead: Color4;
  90023. /**
  90024. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90025. */
  90026. textureMask: Color4;
  90027. /**
  90028. * The particle emitter type defines the emitter used by the particle system.
  90029. * It can be for example box, sphere, or cone...
  90030. */
  90031. particleEmitterType: IParticleEmitterType;
  90032. /** @hidden */
  90033. _isSubEmitter: boolean;
  90034. /**
  90035. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90036. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90037. */
  90038. billboardMode: number;
  90039. protected _isBillboardBased: boolean;
  90040. /**
  90041. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90042. */
  90043. get isBillboardBased(): boolean;
  90044. set isBillboardBased(value: boolean);
  90045. /**
  90046. * The scene the particle system belongs to.
  90047. */
  90048. protected _scene: Scene;
  90049. /**
  90050. * Local cache of defines for image processing.
  90051. */
  90052. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90053. /**
  90054. * Default configuration related to image processing available in the standard Material.
  90055. */
  90056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90057. /**
  90058. * Gets the image processing configuration used either in this material.
  90059. */
  90060. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90061. /**
  90062. * Sets the Default image processing configuration used either in the this material.
  90063. *
  90064. * If sets to null, the scene one is in use.
  90065. */
  90066. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90067. /**
  90068. * Attaches a new image processing configuration to the Standard Material.
  90069. * @param configuration
  90070. */
  90071. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90072. /** @hidden */
  90073. protected _reset(): void;
  90074. /** @hidden */
  90075. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90076. /**
  90077. * Instantiates a particle system.
  90078. * 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.
  90079. * @param name The name of the particle system
  90080. */
  90081. constructor(name: string);
  90082. /**
  90083. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90084. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90085. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90086. * @returns the emitter
  90087. */
  90088. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90089. /**
  90090. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90091. * @param radius The radius of the hemisphere to emit from
  90092. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90093. * @returns the emitter
  90094. */
  90095. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90096. /**
  90097. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90098. * @param radius The radius of the sphere to emit from
  90099. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90100. * @returns the emitter
  90101. */
  90102. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90103. /**
  90104. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90105. * @param radius The radius of the sphere to emit from
  90106. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90107. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90108. * @returns the emitter
  90109. */
  90110. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90111. /**
  90112. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90113. * @param radius The radius of the emission cylinder
  90114. * @param height The height of the emission cylinder
  90115. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90116. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90117. * @returns the emitter
  90118. */
  90119. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90120. /**
  90121. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90122. * @param radius The radius of the cylinder to emit from
  90123. * @param height The height of the emission cylinder
  90124. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90125. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90126. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90127. * @returns the emitter
  90128. */
  90129. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90130. /**
  90131. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90132. * @param radius The radius of the cone to emit from
  90133. * @param angle The base angle of the cone
  90134. * @returns the emitter
  90135. */
  90136. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90137. /**
  90138. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90139. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90140. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90141. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90142. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90143. * @returns the emitter
  90144. */
  90145. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90146. }
  90147. }
  90148. declare module BABYLON {
  90149. /**
  90150. * Type of sub emitter
  90151. */
  90152. export enum SubEmitterType {
  90153. /**
  90154. * Attached to the particle over it's lifetime
  90155. */
  90156. ATTACHED = 0,
  90157. /**
  90158. * Created when the particle dies
  90159. */
  90160. END = 1
  90161. }
  90162. /**
  90163. * Sub emitter class used to emit particles from an existing particle
  90164. */
  90165. export class SubEmitter {
  90166. /**
  90167. * the particle system to be used by the sub emitter
  90168. */
  90169. particleSystem: ParticleSystem;
  90170. /**
  90171. * Type of the submitter (Default: END)
  90172. */
  90173. type: SubEmitterType;
  90174. /**
  90175. * 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)
  90176. * Note: This only is supported when using an emitter of type Mesh
  90177. */
  90178. inheritDirection: boolean;
  90179. /**
  90180. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90181. */
  90182. inheritedVelocityAmount: number;
  90183. /**
  90184. * Creates a sub emitter
  90185. * @param particleSystem the particle system to be used by the sub emitter
  90186. */
  90187. constructor(
  90188. /**
  90189. * the particle system to be used by the sub emitter
  90190. */
  90191. particleSystem: ParticleSystem);
  90192. /**
  90193. * Clones the sub emitter
  90194. * @returns the cloned sub emitter
  90195. */
  90196. clone(): SubEmitter;
  90197. /**
  90198. * Serialize current object to a JSON object
  90199. * @returns the serialized object
  90200. */
  90201. serialize(): any;
  90202. /** @hidden */
  90203. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90204. /**
  90205. * Creates a new SubEmitter from a serialized JSON version
  90206. * @param serializationObject defines the JSON object to read from
  90207. * @param scene defines the hosting scene
  90208. * @param rootUrl defines the rootUrl for data loading
  90209. * @returns a new SubEmitter
  90210. */
  90211. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90212. /** Release associated resources */
  90213. dispose(): void;
  90214. }
  90215. }
  90216. declare module BABYLON {
  90217. /** @hidden */
  90218. export var imageProcessingDeclaration: {
  90219. name: string;
  90220. shader: string;
  90221. };
  90222. }
  90223. declare module BABYLON {
  90224. /** @hidden */
  90225. export var imageProcessingFunctions: {
  90226. name: string;
  90227. shader: string;
  90228. };
  90229. }
  90230. declare module BABYLON {
  90231. /** @hidden */
  90232. export var particlesPixelShader: {
  90233. name: string;
  90234. shader: string;
  90235. };
  90236. }
  90237. declare module BABYLON {
  90238. /** @hidden */
  90239. export var particlesVertexShader: {
  90240. name: string;
  90241. shader: string;
  90242. };
  90243. }
  90244. declare module BABYLON {
  90245. /**
  90246. * This represents a particle system in Babylon.
  90247. * 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.
  90248. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90249. * @example https://doc.babylonjs.com/babylon101/particles
  90250. */
  90251. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90252. /**
  90253. * Billboard mode will only apply to Y axis
  90254. */
  90255. static readonly BILLBOARDMODE_Y: number;
  90256. /**
  90257. * Billboard mode will apply to all axes
  90258. */
  90259. static readonly BILLBOARDMODE_ALL: number;
  90260. /**
  90261. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90262. */
  90263. static readonly BILLBOARDMODE_STRETCHED: number;
  90264. /**
  90265. * This function can be defined to provide custom update for active particles.
  90266. * This function will be called instead of regular update (age, position, color, etc.).
  90267. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90268. */
  90269. updateFunction: (particles: Particle[]) => void;
  90270. private _emitterWorldMatrix;
  90271. /**
  90272. * This function can be defined to specify initial direction for every new particle.
  90273. * It by default use the emitterType defined function
  90274. */
  90275. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  90276. /**
  90277. * This function can be defined to specify initial position for every new particle.
  90278. * It by default use the emitterType defined function
  90279. */
  90280. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  90281. /**
  90282. * @hidden
  90283. */
  90284. _inheritedVelocityOffset: Vector3;
  90285. /**
  90286. * An event triggered when the system is disposed
  90287. */
  90288. onDisposeObservable: Observable<ParticleSystem>;
  90289. private _onDisposeObserver;
  90290. /**
  90291. * Sets a callback that will be triggered when the system is disposed
  90292. */
  90293. set onDispose(callback: () => void);
  90294. private _particles;
  90295. private _epsilon;
  90296. private _capacity;
  90297. private _stockParticles;
  90298. private _newPartsExcess;
  90299. private _vertexData;
  90300. private _vertexBuffer;
  90301. private _vertexBuffers;
  90302. private _spriteBuffer;
  90303. private _indexBuffer;
  90304. private _effect;
  90305. private _customEffect;
  90306. private _cachedDefines;
  90307. private _scaledColorStep;
  90308. private _colorDiff;
  90309. private _scaledDirection;
  90310. private _scaledGravity;
  90311. private _currentRenderId;
  90312. private _alive;
  90313. private _useInstancing;
  90314. private _started;
  90315. private _stopped;
  90316. private _actualFrame;
  90317. private _scaledUpdateSpeed;
  90318. private _vertexBufferSize;
  90319. /** @hidden */
  90320. _currentEmitRateGradient: Nullable<FactorGradient>;
  90321. /** @hidden */
  90322. _currentEmitRate1: number;
  90323. /** @hidden */
  90324. _currentEmitRate2: number;
  90325. /** @hidden */
  90326. _currentStartSizeGradient: Nullable<FactorGradient>;
  90327. /** @hidden */
  90328. _currentStartSize1: number;
  90329. /** @hidden */
  90330. _currentStartSize2: number;
  90331. private readonly _rawTextureWidth;
  90332. private _rampGradientsTexture;
  90333. private _useRampGradients;
  90334. /** Gets or sets a boolean indicating that ramp gradients must be used
  90335. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90336. */
  90337. get useRampGradients(): boolean;
  90338. set useRampGradients(value: boolean);
  90339. /**
  90340. * 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.
  90341. * 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: [])
  90342. */
  90343. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90344. private _subEmitters;
  90345. /**
  90346. * @hidden
  90347. * If the particle systems emitter should be disposed when the particle system is disposed
  90348. */
  90349. _disposeEmitterOnDispose: boolean;
  90350. /**
  90351. * The current active Sub-systems, this property is used by the root particle system only.
  90352. */
  90353. activeSubSystems: Array<ParticleSystem>;
  90354. private _rootParticleSystem;
  90355. /**
  90356. * Gets the current list of active particles
  90357. */
  90358. get particles(): Particle[];
  90359. /**
  90360. * Returns the string "ParticleSystem"
  90361. * @returns a string containing the class name
  90362. */
  90363. getClassName(): string;
  90364. /**
  90365. * Instantiates a particle system.
  90366. * 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.
  90367. * @param name The name of the particle system
  90368. * @param capacity The max number of particles alive at the same time
  90369. * @param scene The scene the particle system belongs to
  90370. * @param customEffect a custom effect used to change the way particles are rendered by default
  90371. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90372. * @param epsilon Offset used to render the particles
  90373. */
  90374. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90375. private _addFactorGradient;
  90376. private _removeFactorGradient;
  90377. /**
  90378. * Adds a new life time gradient
  90379. * @param gradient defines the gradient to use (between 0 and 1)
  90380. * @param factor defines the life time factor to affect to the specified gradient
  90381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90382. * @returns the current particle system
  90383. */
  90384. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90385. /**
  90386. * Remove a specific life time gradient
  90387. * @param gradient defines the gradient to remove
  90388. * @returns the current particle system
  90389. */
  90390. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90391. /**
  90392. * Adds a new size gradient
  90393. * @param gradient defines the gradient to use (between 0 and 1)
  90394. * @param factor defines the size factor to affect to the specified gradient
  90395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90396. * @returns the current particle system
  90397. */
  90398. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90399. /**
  90400. * Remove a specific size gradient
  90401. * @param gradient defines the gradient to remove
  90402. * @returns the current particle system
  90403. */
  90404. removeSizeGradient(gradient: number): IParticleSystem;
  90405. /**
  90406. * Adds a new color remap gradient
  90407. * @param gradient defines the gradient to use (between 0 and 1)
  90408. * @param min defines the color remap minimal range
  90409. * @param max defines the color remap maximal range
  90410. * @returns the current particle system
  90411. */
  90412. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90413. /**
  90414. * Remove a specific color remap gradient
  90415. * @param gradient defines the gradient to remove
  90416. * @returns the current particle system
  90417. */
  90418. removeColorRemapGradient(gradient: number): IParticleSystem;
  90419. /**
  90420. * Adds a new alpha remap gradient
  90421. * @param gradient defines the gradient to use (between 0 and 1)
  90422. * @param min defines the alpha remap minimal range
  90423. * @param max defines the alpha remap maximal range
  90424. * @returns the current particle system
  90425. */
  90426. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90427. /**
  90428. * Remove a specific alpha remap gradient
  90429. * @param gradient defines the gradient to remove
  90430. * @returns the current particle system
  90431. */
  90432. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90433. /**
  90434. * Adds a new angular speed gradient
  90435. * @param gradient defines the gradient to use (between 0 and 1)
  90436. * @param factor defines the angular speed to affect to the specified gradient
  90437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90438. * @returns the current particle system
  90439. */
  90440. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90441. /**
  90442. * Remove a specific angular speed gradient
  90443. * @param gradient defines the gradient to remove
  90444. * @returns the current particle system
  90445. */
  90446. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90447. /**
  90448. * Adds a new velocity gradient
  90449. * @param gradient defines the gradient to use (between 0 and 1)
  90450. * @param factor defines the velocity to affect to the specified gradient
  90451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90452. * @returns the current particle system
  90453. */
  90454. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90455. /**
  90456. * Remove a specific velocity gradient
  90457. * @param gradient defines the gradient to remove
  90458. * @returns the current particle system
  90459. */
  90460. removeVelocityGradient(gradient: number): IParticleSystem;
  90461. /**
  90462. * Adds a new limit velocity gradient
  90463. * @param gradient defines the gradient to use (between 0 and 1)
  90464. * @param factor defines the limit velocity value to affect to the specified gradient
  90465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90466. * @returns the current particle system
  90467. */
  90468. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90469. /**
  90470. * Remove a specific limit velocity gradient
  90471. * @param gradient defines the gradient to remove
  90472. * @returns the current particle system
  90473. */
  90474. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90475. /**
  90476. * Adds a new drag gradient
  90477. * @param gradient defines the gradient to use (between 0 and 1)
  90478. * @param factor defines the drag value to affect to the specified gradient
  90479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90480. * @returns the current particle system
  90481. */
  90482. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90483. /**
  90484. * Remove a specific drag gradient
  90485. * @param gradient defines the gradient to remove
  90486. * @returns the current particle system
  90487. */
  90488. removeDragGradient(gradient: number): IParticleSystem;
  90489. /**
  90490. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90491. * @param gradient defines the gradient to use (between 0 and 1)
  90492. * @param factor defines the emit rate value to affect to the specified gradient
  90493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90494. * @returns the current particle system
  90495. */
  90496. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90497. /**
  90498. * Remove a specific emit rate gradient
  90499. * @param gradient defines the gradient to remove
  90500. * @returns the current particle system
  90501. */
  90502. removeEmitRateGradient(gradient: number): IParticleSystem;
  90503. /**
  90504. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90505. * @param gradient defines the gradient to use (between 0 and 1)
  90506. * @param factor defines the start size value to affect to the specified gradient
  90507. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90508. * @returns the current particle system
  90509. */
  90510. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90511. /**
  90512. * Remove a specific start size gradient
  90513. * @param gradient defines the gradient to remove
  90514. * @returns the current particle system
  90515. */
  90516. removeStartSizeGradient(gradient: number): IParticleSystem;
  90517. private _createRampGradientTexture;
  90518. /**
  90519. * Gets the current list of ramp gradients.
  90520. * You must use addRampGradient and removeRampGradient to udpate this list
  90521. * @returns the list of ramp gradients
  90522. */
  90523. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90524. /**
  90525. * Adds a new ramp gradient used to remap particle colors
  90526. * @param gradient defines the gradient to use (between 0 and 1)
  90527. * @param color defines the color to affect to the specified gradient
  90528. * @returns the current particle system
  90529. */
  90530. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90531. /**
  90532. * Remove a specific ramp gradient
  90533. * @param gradient defines the gradient to remove
  90534. * @returns the current particle system
  90535. */
  90536. removeRampGradient(gradient: number): ParticleSystem;
  90537. /**
  90538. * Adds a new color gradient
  90539. * @param gradient defines the gradient to use (between 0 and 1)
  90540. * @param color1 defines the color to affect to the specified gradient
  90541. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90542. * @returns this particle system
  90543. */
  90544. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90545. /**
  90546. * Remove a specific color gradient
  90547. * @param gradient defines the gradient to remove
  90548. * @returns this particle system
  90549. */
  90550. removeColorGradient(gradient: number): IParticleSystem;
  90551. private _fetchR;
  90552. protected _reset(): void;
  90553. private _resetEffect;
  90554. private _createVertexBuffers;
  90555. private _createIndexBuffer;
  90556. /**
  90557. * Gets the maximum number of particles active at the same time.
  90558. * @returns The max number of active particles.
  90559. */
  90560. getCapacity(): number;
  90561. /**
  90562. * Gets whether there are still active particles in the system.
  90563. * @returns True if it is alive, otherwise false.
  90564. */
  90565. isAlive(): boolean;
  90566. /**
  90567. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90568. * @returns True if it has been started, otherwise false.
  90569. */
  90570. isStarted(): boolean;
  90571. private _prepareSubEmitterInternalArray;
  90572. /**
  90573. * Starts the particle system and begins to emit
  90574. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90575. */
  90576. start(delay?: number): void;
  90577. /**
  90578. * Stops the particle system.
  90579. * @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.
  90580. */
  90581. stop(stopSubEmitters?: boolean): void;
  90582. /**
  90583. * Remove all active particles
  90584. */
  90585. reset(): void;
  90586. /**
  90587. * @hidden (for internal use only)
  90588. */
  90589. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90590. /**
  90591. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90592. * Its lifetime will start back at 0.
  90593. */
  90594. recycleParticle: (particle: Particle) => void;
  90595. private _stopSubEmitters;
  90596. private _createParticle;
  90597. private _removeFromRoot;
  90598. private _emitFromParticle;
  90599. private _update;
  90600. /** @hidden */
  90601. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90602. /** @hidden */
  90603. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90604. /** @hidden */
  90605. private _getEffect;
  90606. /**
  90607. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90608. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90609. */
  90610. animate(preWarmOnly?: boolean): void;
  90611. private _appendParticleVertices;
  90612. /**
  90613. * Rebuilds the particle system.
  90614. */
  90615. rebuild(): void;
  90616. /**
  90617. * Is this system ready to be used/rendered
  90618. * @return true if the system is ready
  90619. */
  90620. isReady(): boolean;
  90621. private _render;
  90622. /**
  90623. * Renders the particle system in its current state.
  90624. * @returns the current number of particles
  90625. */
  90626. render(): number;
  90627. /**
  90628. * Disposes the particle system and free the associated resources
  90629. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90630. */
  90631. dispose(disposeTexture?: boolean): void;
  90632. /**
  90633. * Clones the particle system.
  90634. * @param name The name of the cloned object
  90635. * @param newEmitter The new emitter to use
  90636. * @returns the cloned particle system
  90637. */
  90638. clone(name: string, newEmitter: any): ParticleSystem;
  90639. /**
  90640. * Serializes the particle system to a JSON object.
  90641. * @returns the JSON object
  90642. */
  90643. serialize(): any;
  90644. /** @hidden */
  90645. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  90646. /** @hidden */
  90647. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90648. /**
  90649. * Parses a JSON object to create a particle system.
  90650. * @param parsedParticleSystem The JSON object to parse
  90651. * @param scene The scene to create the particle system in
  90652. * @param rootUrl The root url to use to load external dependencies like texture
  90653. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90654. * @returns the Parsed particle system
  90655. */
  90656. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90657. }
  90658. }
  90659. declare module BABYLON {
  90660. /**
  90661. * A particle represents one of the element emitted by a particle system.
  90662. * This is mainly define by its coordinates, direction, velocity and age.
  90663. */
  90664. export class Particle {
  90665. /**
  90666. * The particle system the particle belongs to.
  90667. */
  90668. particleSystem: ParticleSystem;
  90669. private static _Count;
  90670. /**
  90671. * Unique ID of the particle
  90672. */
  90673. id: number;
  90674. /**
  90675. * The world position of the particle in the scene.
  90676. */
  90677. position: Vector3;
  90678. /**
  90679. * The world direction of the particle in the scene.
  90680. */
  90681. direction: Vector3;
  90682. /**
  90683. * The color of the particle.
  90684. */
  90685. color: Color4;
  90686. /**
  90687. * The color change of the particle per step.
  90688. */
  90689. colorStep: Color4;
  90690. /**
  90691. * Defines how long will the life of the particle be.
  90692. */
  90693. lifeTime: number;
  90694. /**
  90695. * The current age of the particle.
  90696. */
  90697. age: number;
  90698. /**
  90699. * The current size of the particle.
  90700. */
  90701. size: number;
  90702. /**
  90703. * The current scale of the particle.
  90704. */
  90705. scale: Vector2;
  90706. /**
  90707. * The current angle of the particle.
  90708. */
  90709. angle: number;
  90710. /**
  90711. * Defines how fast is the angle changing.
  90712. */
  90713. angularSpeed: number;
  90714. /**
  90715. * Defines the cell index used by the particle to be rendered from a sprite.
  90716. */
  90717. cellIndex: number;
  90718. /**
  90719. * The information required to support color remapping
  90720. */
  90721. remapData: Vector4;
  90722. /** @hidden */
  90723. _randomCellOffset?: number;
  90724. /** @hidden */
  90725. _initialDirection: Nullable<Vector3>;
  90726. /** @hidden */
  90727. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90728. /** @hidden */
  90729. _initialStartSpriteCellID: number;
  90730. /** @hidden */
  90731. _initialEndSpriteCellID: number;
  90732. /** @hidden */
  90733. _currentColorGradient: Nullable<ColorGradient>;
  90734. /** @hidden */
  90735. _currentColor1: Color4;
  90736. /** @hidden */
  90737. _currentColor2: Color4;
  90738. /** @hidden */
  90739. _currentSizeGradient: Nullable<FactorGradient>;
  90740. /** @hidden */
  90741. _currentSize1: number;
  90742. /** @hidden */
  90743. _currentSize2: number;
  90744. /** @hidden */
  90745. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90746. /** @hidden */
  90747. _currentAngularSpeed1: number;
  90748. /** @hidden */
  90749. _currentAngularSpeed2: number;
  90750. /** @hidden */
  90751. _currentVelocityGradient: Nullable<FactorGradient>;
  90752. /** @hidden */
  90753. _currentVelocity1: number;
  90754. /** @hidden */
  90755. _currentVelocity2: number;
  90756. /** @hidden */
  90757. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90758. /** @hidden */
  90759. _currentLimitVelocity1: number;
  90760. /** @hidden */
  90761. _currentLimitVelocity2: number;
  90762. /** @hidden */
  90763. _currentDragGradient: Nullable<FactorGradient>;
  90764. /** @hidden */
  90765. _currentDrag1: number;
  90766. /** @hidden */
  90767. _currentDrag2: number;
  90768. /** @hidden */
  90769. _randomNoiseCoordinates1: Vector3;
  90770. /** @hidden */
  90771. _randomNoiseCoordinates2: Vector3;
  90772. /**
  90773. * Creates a new instance Particle
  90774. * @param particleSystem the particle system the particle belongs to
  90775. */
  90776. constructor(
  90777. /**
  90778. * The particle system the particle belongs to.
  90779. */
  90780. particleSystem: ParticleSystem);
  90781. private updateCellInfoFromSystem;
  90782. /**
  90783. * Defines how the sprite cell index is updated for the particle
  90784. */
  90785. updateCellIndex(): void;
  90786. /** @hidden */
  90787. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90788. /** @hidden */
  90789. _inheritParticleInfoToSubEmitters(): void;
  90790. /** @hidden */
  90791. _reset(): void;
  90792. /**
  90793. * Copy the properties of particle to another one.
  90794. * @param other the particle to copy the information to.
  90795. */
  90796. copyTo(other: Particle): void;
  90797. }
  90798. }
  90799. declare module BABYLON {
  90800. /**
  90801. * Particle emitter represents a volume emitting particles.
  90802. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90803. */
  90804. export interface IParticleEmitterType {
  90805. /**
  90806. * Called by the particle System when the direction is computed for the created particle.
  90807. * @param worldMatrix is the world matrix of the particle system
  90808. * @param directionToUpdate is the direction vector to update with the result
  90809. * @param particle is the particle we are computed the direction for
  90810. */
  90811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90812. /**
  90813. * Called by the particle System when the position is computed for the created particle.
  90814. * @param worldMatrix is the world matrix of the particle system
  90815. * @param positionToUpdate is the position vector to update with the result
  90816. * @param particle is the particle we are computed the position for
  90817. */
  90818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90819. /**
  90820. * Clones the current emitter and returns a copy of it
  90821. * @returns the new emitter
  90822. */
  90823. clone(): IParticleEmitterType;
  90824. /**
  90825. * Called by the GPUParticleSystem to setup the update shader
  90826. * @param effect defines the update shader
  90827. */
  90828. applyToShader(effect: Effect): void;
  90829. /**
  90830. * Returns a string to use to update the GPU particles update shader
  90831. * @returns the effect defines string
  90832. */
  90833. getEffectDefines(): string;
  90834. /**
  90835. * Returns a string representing the class name
  90836. * @returns a string containing the class name
  90837. */
  90838. getClassName(): string;
  90839. /**
  90840. * Serializes the particle system to a JSON object.
  90841. * @returns the JSON object
  90842. */
  90843. serialize(): any;
  90844. /**
  90845. * Parse properties from a JSON object
  90846. * @param serializationObject defines the JSON object
  90847. */
  90848. parse(serializationObject: any): void;
  90849. }
  90850. }
  90851. declare module BABYLON {
  90852. /**
  90853. * Particle emitter emitting particles from the inside of a box.
  90854. * It emits the particles randomly between 2 given directions.
  90855. */
  90856. export class BoxParticleEmitter implements IParticleEmitterType {
  90857. /**
  90858. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90859. */
  90860. direction1: Vector3;
  90861. /**
  90862. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90863. */
  90864. direction2: Vector3;
  90865. /**
  90866. * 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.
  90867. */
  90868. minEmitBox: Vector3;
  90869. /**
  90870. * 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.
  90871. */
  90872. maxEmitBox: Vector3;
  90873. /**
  90874. * Creates a new instance BoxParticleEmitter
  90875. */
  90876. constructor();
  90877. /**
  90878. * Called by the particle System when the direction is computed for the created particle.
  90879. * @param worldMatrix is the world matrix of the particle system
  90880. * @param directionToUpdate is the direction vector to update with the result
  90881. * @param particle is the particle we are computed the direction for
  90882. */
  90883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90884. /**
  90885. * Called by the particle System when the position is computed for the created particle.
  90886. * @param worldMatrix is the world matrix of the particle system
  90887. * @param positionToUpdate is the position vector to update with the result
  90888. * @param particle is the particle we are computed the position for
  90889. */
  90890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90891. /**
  90892. * Clones the current emitter and returns a copy of it
  90893. * @returns the new emitter
  90894. */
  90895. clone(): BoxParticleEmitter;
  90896. /**
  90897. * Called by the GPUParticleSystem to setup the update shader
  90898. * @param effect defines the update shader
  90899. */
  90900. applyToShader(effect: Effect): void;
  90901. /**
  90902. * Returns a string to use to update the GPU particles update shader
  90903. * @returns a string containng the defines string
  90904. */
  90905. getEffectDefines(): string;
  90906. /**
  90907. * Returns the string "BoxParticleEmitter"
  90908. * @returns a string containing the class name
  90909. */
  90910. getClassName(): string;
  90911. /**
  90912. * Serializes the particle system to a JSON object.
  90913. * @returns the JSON object
  90914. */
  90915. serialize(): any;
  90916. /**
  90917. * Parse properties from a JSON object
  90918. * @param serializationObject defines the JSON object
  90919. */
  90920. parse(serializationObject: any): void;
  90921. }
  90922. }
  90923. declare module BABYLON {
  90924. /**
  90925. * Particle emitter emitting particles from the inside of a cone.
  90926. * It emits the particles alongside the cone volume from the base to the particle.
  90927. * The emission direction might be randomized.
  90928. */
  90929. export class ConeParticleEmitter implements IParticleEmitterType {
  90930. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90931. directionRandomizer: number;
  90932. private _radius;
  90933. private _angle;
  90934. private _height;
  90935. /**
  90936. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90937. */
  90938. radiusRange: number;
  90939. /**
  90940. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90941. */
  90942. heightRange: number;
  90943. /**
  90944. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90945. */
  90946. emitFromSpawnPointOnly: boolean;
  90947. /**
  90948. * Gets or sets the radius of the emission cone
  90949. */
  90950. get radius(): number;
  90951. set radius(value: number);
  90952. /**
  90953. * Gets or sets the angle of the emission cone
  90954. */
  90955. get angle(): number;
  90956. set angle(value: number);
  90957. private _buildHeight;
  90958. /**
  90959. * Creates a new instance ConeParticleEmitter
  90960. * @param radius the radius of the emission cone (1 by default)
  90961. * @param angle the cone base angle (PI by default)
  90962. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90963. */
  90964. constructor(radius?: number, angle?: number,
  90965. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90966. directionRandomizer?: number);
  90967. /**
  90968. * Called by the particle System when the direction is computed for the created particle.
  90969. * @param worldMatrix is the world matrix of the particle system
  90970. * @param directionToUpdate is the direction vector to update with the result
  90971. * @param particle is the particle we are computed the direction for
  90972. */
  90973. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90974. /**
  90975. * Called by the particle System when the position is computed for the created particle.
  90976. * @param worldMatrix is the world matrix of the particle system
  90977. * @param positionToUpdate is the position vector to update with the result
  90978. * @param particle is the particle we are computed the position for
  90979. */
  90980. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90981. /**
  90982. * Clones the current emitter and returns a copy of it
  90983. * @returns the new emitter
  90984. */
  90985. clone(): ConeParticleEmitter;
  90986. /**
  90987. * Called by the GPUParticleSystem to setup the update shader
  90988. * @param effect defines the update shader
  90989. */
  90990. applyToShader(effect: Effect): void;
  90991. /**
  90992. * Returns a string to use to update the GPU particles update shader
  90993. * @returns a string containng the defines string
  90994. */
  90995. getEffectDefines(): string;
  90996. /**
  90997. * Returns the string "ConeParticleEmitter"
  90998. * @returns a string containing the class name
  90999. */
  91000. getClassName(): string;
  91001. /**
  91002. * Serializes the particle system to a JSON object.
  91003. * @returns the JSON object
  91004. */
  91005. serialize(): any;
  91006. /**
  91007. * Parse properties from a JSON object
  91008. * @param serializationObject defines the JSON object
  91009. */
  91010. parse(serializationObject: any): void;
  91011. }
  91012. }
  91013. declare module BABYLON {
  91014. /**
  91015. * Particle emitter emitting particles from the inside of a cylinder.
  91016. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91017. */
  91018. export class CylinderParticleEmitter implements IParticleEmitterType {
  91019. /**
  91020. * The radius of the emission cylinder.
  91021. */
  91022. radius: number;
  91023. /**
  91024. * The height of the emission cylinder.
  91025. */
  91026. height: number;
  91027. /**
  91028. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91029. */
  91030. radiusRange: number;
  91031. /**
  91032. * How much to randomize the particle direction [0-1].
  91033. */
  91034. directionRandomizer: number;
  91035. /**
  91036. * Creates a new instance CylinderParticleEmitter
  91037. * @param radius the radius of the emission cylinder (1 by default)
  91038. * @param height the height of the emission cylinder (1 by default)
  91039. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91040. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91041. */
  91042. constructor(
  91043. /**
  91044. * The radius of the emission cylinder.
  91045. */
  91046. radius?: number,
  91047. /**
  91048. * The height of the emission cylinder.
  91049. */
  91050. height?: number,
  91051. /**
  91052. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91053. */
  91054. radiusRange?: number,
  91055. /**
  91056. * How much to randomize the particle direction [0-1].
  91057. */
  91058. directionRandomizer?: number);
  91059. /**
  91060. * Called by the particle System when the direction is computed for the created particle.
  91061. * @param worldMatrix is the world matrix of the particle system
  91062. * @param directionToUpdate is the direction vector to update with the result
  91063. * @param particle is the particle we are computed the direction for
  91064. */
  91065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91066. /**
  91067. * Called by the particle System when the position is computed for the created particle.
  91068. * @param worldMatrix is the world matrix of the particle system
  91069. * @param positionToUpdate is the position vector to update with the result
  91070. * @param particle is the particle we are computed the position for
  91071. */
  91072. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91073. /**
  91074. * Clones the current emitter and returns a copy of it
  91075. * @returns the new emitter
  91076. */
  91077. clone(): CylinderParticleEmitter;
  91078. /**
  91079. * Called by the GPUParticleSystem to setup the update shader
  91080. * @param effect defines the update shader
  91081. */
  91082. applyToShader(effect: Effect): void;
  91083. /**
  91084. * Returns a string to use to update the GPU particles update shader
  91085. * @returns a string containng the defines string
  91086. */
  91087. getEffectDefines(): string;
  91088. /**
  91089. * Returns the string "CylinderParticleEmitter"
  91090. * @returns a string containing the class name
  91091. */
  91092. getClassName(): string;
  91093. /**
  91094. * Serializes the particle system to a JSON object.
  91095. * @returns the JSON object
  91096. */
  91097. serialize(): any;
  91098. /**
  91099. * Parse properties from a JSON object
  91100. * @param serializationObject defines the JSON object
  91101. */
  91102. parse(serializationObject: any): void;
  91103. }
  91104. /**
  91105. * Particle emitter emitting particles from the inside of a cylinder.
  91106. * It emits the particles randomly between two vectors.
  91107. */
  91108. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91109. /**
  91110. * The min limit of the emission direction.
  91111. */
  91112. direction1: Vector3;
  91113. /**
  91114. * The max limit of the emission direction.
  91115. */
  91116. direction2: Vector3;
  91117. /**
  91118. * Creates a new instance CylinderDirectedParticleEmitter
  91119. * @param radius the radius of the emission cylinder (1 by default)
  91120. * @param height the height of the emission cylinder (1 by default)
  91121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91122. * @param direction1 the min limit of the emission direction (up vector by default)
  91123. * @param direction2 the max limit of the emission direction (up vector by default)
  91124. */
  91125. constructor(radius?: number, height?: number, radiusRange?: number,
  91126. /**
  91127. * The min limit of the emission direction.
  91128. */
  91129. direction1?: Vector3,
  91130. /**
  91131. * The max limit of the emission direction.
  91132. */
  91133. direction2?: Vector3);
  91134. /**
  91135. * Called by the particle System when the direction is computed for the created particle.
  91136. * @param worldMatrix is the world matrix of the particle system
  91137. * @param directionToUpdate is the direction vector to update with the result
  91138. * @param particle is the particle we are computed the direction for
  91139. */
  91140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91141. /**
  91142. * Clones the current emitter and returns a copy of it
  91143. * @returns the new emitter
  91144. */
  91145. clone(): CylinderDirectedParticleEmitter;
  91146. /**
  91147. * Called by the GPUParticleSystem to setup the update shader
  91148. * @param effect defines the update shader
  91149. */
  91150. applyToShader(effect: Effect): void;
  91151. /**
  91152. * Returns a string to use to update the GPU particles update shader
  91153. * @returns a string containng the defines string
  91154. */
  91155. getEffectDefines(): string;
  91156. /**
  91157. * Returns the string "CylinderDirectedParticleEmitter"
  91158. * @returns a string containing the class name
  91159. */
  91160. getClassName(): string;
  91161. /**
  91162. * Serializes the particle system to a JSON object.
  91163. * @returns the JSON object
  91164. */
  91165. serialize(): any;
  91166. /**
  91167. * Parse properties from a JSON object
  91168. * @param serializationObject defines the JSON object
  91169. */
  91170. parse(serializationObject: any): void;
  91171. }
  91172. }
  91173. declare module BABYLON {
  91174. /**
  91175. * Particle emitter emitting particles from the inside of a hemisphere.
  91176. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91177. */
  91178. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91179. /**
  91180. * The radius of the emission hemisphere.
  91181. */
  91182. radius: number;
  91183. /**
  91184. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91185. */
  91186. radiusRange: number;
  91187. /**
  91188. * How much to randomize the particle direction [0-1].
  91189. */
  91190. directionRandomizer: number;
  91191. /**
  91192. * Creates a new instance HemisphericParticleEmitter
  91193. * @param radius the radius of the emission hemisphere (1 by default)
  91194. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91195. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91196. */
  91197. constructor(
  91198. /**
  91199. * The radius of the emission hemisphere.
  91200. */
  91201. radius?: number,
  91202. /**
  91203. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91204. */
  91205. radiusRange?: number,
  91206. /**
  91207. * How much to randomize the particle direction [0-1].
  91208. */
  91209. directionRandomizer?: number);
  91210. /**
  91211. * Called by the particle System when the direction is computed for the created particle.
  91212. * @param worldMatrix is the world matrix of the particle system
  91213. * @param directionToUpdate is the direction vector to update with the result
  91214. * @param particle is the particle we are computed the direction for
  91215. */
  91216. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91217. /**
  91218. * Called by the particle System when the position is computed for the created particle.
  91219. * @param worldMatrix is the world matrix of the particle system
  91220. * @param positionToUpdate is the position vector to update with the result
  91221. * @param particle is the particle we are computed the position for
  91222. */
  91223. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91224. /**
  91225. * Clones the current emitter and returns a copy of it
  91226. * @returns the new emitter
  91227. */
  91228. clone(): HemisphericParticleEmitter;
  91229. /**
  91230. * Called by the GPUParticleSystem to setup the update shader
  91231. * @param effect defines the update shader
  91232. */
  91233. applyToShader(effect: Effect): void;
  91234. /**
  91235. * Returns a string to use to update the GPU particles update shader
  91236. * @returns a string containng the defines string
  91237. */
  91238. getEffectDefines(): string;
  91239. /**
  91240. * Returns the string "HemisphericParticleEmitter"
  91241. * @returns a string containing the class name
  91242. */
  91243. getClassName(): string;
  91244. /**
  91245. * Serializes the particle system to a JSON object.
  91246. * @returns the JSON object
  91247. */
  91248. serialize(): any;
  91249. /**
  91250. * Parse properties from a JSON object
  91251. * @param serializationObject defines the JSON object
  91252. */
  91253. parse(serializationObject: any): void;
  91254. }
  91255. }
  91256. declare module BABYLON {
  91257. /**
  91258. * Particle emitter emitting particles from a point.
  91259. * It emits the particles randomly between 2 given directions.
  91260. */
  91261. export class PointParticleEmitter implements IParticleEmitterType {
  91262. /**
  91263. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91264. */
  91265. direction1: Vector3;
  91266. /**
  91267. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91268. */
  91269. direction2: Vector3;
  91270. /**
  91271. * Creates a new instance PointParticleEmitter
  91272. */
  91273. constructor();
  91274. /**
  91275. * Called by the particle System when the direction is computed for the created particle.
  91276. * @param worldMatrix is the world matrix of the particle system
  91277. * @param directionToUpdate is the direction vector to update with the result
  91278. * @param particle is the particle we are computed the direction for
  91279. */
  91280. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91281. /**
  91282. * Called by the particle System when the position is computed for the created particle.
  91283. * @param worldMatrix is the world matrix of the particle system
  91284. * @param positionToUpdate is the position vector to update with the result
  91285. * @param particle is the particle we are computed the position for
  91286. */
  91287. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91288. /**
  91289. * Clones the current emitter and returns a copy of it
  91290. * @returns the new emitter
  91291. */
  91292. clone(): PointParticleEmitter;
  91293. /**
  91294. * Called by the GPUParticleSystem to setup the update shader
  91295. * @param effect defines the update shader
  91296. */
  91297. applyToShader(effect: Effect): void;
  91298. /**
  91299. * Returns a string to use to update the GPU particles update shader
  91300. * @returns a string containng the defines string
  91301. */
  91302. getEffectDefines(): string;
  91303. /**
  91304. * Returns the string "PointParticleEmitter"
  91305. * @returns a string containing the class name
  91306. */
  91307. getClassName(): string;
  91308. /**
  91309. * Serializes the particle system to a JSON object.
  91310. * @returns the JSON object
  91311. */
  91312. serialize(): any;
  91313. /**
  91314. * Parse properties from a JSON object
  91315. * @param serializationObject defines the JSON object
  91316. */
  91317. parse(serializationObject: any): void;
  91318. }
  91319. }
  91320. declare module BABYLON {
  91321. /**
  91322. * Particle emitter emitting particles from the inside of a sphere.
  91323. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91324. */
  91325. export class SphereParticleEmitter implements IParticleEmitterType {
  91326. /**
  91327. * The radius of the emission sphere.
  91328. */
  91329. radius: number;
  91330. /**
  91331. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91332. */
  91333. radiusRange: number;
  91334. /**
  91335. * How much to randomize the particle direction [0-1].
  91336. */
  91337. directionRandomizer: number;
  91338. /**
  91339. * Creates a new instance SphereParticleEmitter
  91340. * @param radius the radius of the emission sphere (1 by default)
  91341. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91342. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91343. */
  91344. constructor(
  91345. /**
  91346. * The radius of the emission sphere.
  91347. */
  91348. radius?: number,
  91349. /**
  91350. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91351. */
  91352. radiusRange?: number,
  91353. /**
  91354. * How much to randomize the particle direction [0-1].
  91355. */
  91356. directionRandomizer?: number);
  91357. /**
  91358. * Called by the particle System when the direction is computed for the created particle.
  91359. * @param worldMatrix is the world matrix of the particle system
  91360. * @param directionToUpdate is the direction vector to update with the result
  91361. * @param particle is the particle we are computed the direction for
  91362. */
  91363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91364. /**
  91365. * Called by the particle System when the position is computed for the created particle.
  91366. * @param worldMatrix is the world matrix of the particle system
  91367. * @param positionToUpdate is the position vector to update with the result
  91368. * @param particle is the particle we are computed the position for
  91369. */
  91370. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91371. /**
  91372. * Clones the current emitter and returns a copy of it
  91373. * @returns the new emitter
  91374. */
  91375. clone(): SphereParticleEmitter;
  91376. /**
  91377. * Called by the GPUParticleSystem to setup the update shader
  91378. * @param effect defines the update shader
  91379. */
  91380. applyToShader(effect: Effect): void;
  91381. /**
  91382. * Returns a string to use to update the GPU particles update shader
  91383. * @returns a string containng the defines string
  91384. */
  91385. getEffectDefines(): string;
  91386. /**
  91387. * Returns the string "SphereParticleEmitter"
  91388. * @returns a string containing the class name
  91389. */
  91390. getClassName(): string;
  91391. /**
  91392. * Serializes the particle system to a JSON object.
  91393. * @returns the JSON object
  91394. */
  91395. serialize(): any;
  91396. /**
  91397. * Parse properties from a JSON object
  91398. * @param serializationObject defines the JSON object
  91399. */
  91400. parse(serializationObject: any): void;
  91401. }
  91402. /**
  91403. * Particle emitter emitting particles from the inside of a sphere.
  91404. * It emits the particles randomly between two vectors.
  91405. */
  91406. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91407. /**
  91408. * The min limit of the emission direction.
  91409. */
  91410. direction1: Vector3;
  91411. /**
  91412. * The max limit of the emission direction.
  91413. */
  91414. direction2: Vector3;
  91415. /**
  91416. * Creates a new instance SphereDirectedParticleEmitter
  91417. * @param radius the radius of the emission sphere (1 by default)
  91418. * @param direction1 the min limit of the emission direction (up vector by default)
  91419. * @param direction2 the max limit of the emission direction (up vector by default)
  91420. */
  91421. constructor(radius?: number,
  91422. /**
  91423. * The min limit of the emission direction.
  91424. */
  91425. direction1?: Vector3,
  91426. /**
  91427. * The max limit of the emission direction.
  91428. */
  91429. direction2?: Vector3);
  91430. /**
  91431. * Called by the particle System when the direction is computed for the created particle.
  91432. * @param worldMatrix is the world matrix of the particle system
  91433. * @param directionToUpdate is the direction vector to update with the result
  91434. * @param particle is the particle we are computed the direction for
  91435. */
  91436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91437. /**
  91438. * Clones the current emitter and returns a copy of it
  91439. * @returns the new emitter
  91440. */
  91441. clone(): SphereDirectedParticleEmitter;
  91442. /**
  91443. * Called by the GPUParticleSystem to setup the update shader
  91444. * @param effect defines the update shader
  91445. */
  91446. applyToShader(effect: Effect): void;
  91447. /**
  91448. * Returns a string to use to update the GPU particles update shader
  91449. * @returns a string containng the defines string
  91450. */
  91451. getEffectDefines(): string;
  91452. /**
  91453. * Returns the string "SphereDirectedParticleEmitter"
  91454. * @returns a string containing the class name
  91455. */
  91456. getClassName(): string;
  91457. /**
  91458. * Serializes the particle system to a JSON object.
  91459. * @returns the JSON object
  91460. */
  91461. serialize(): any;
  91462. /**
  91463. * Parse properties from a JSON object
  91464. * @param serializationObject defines the JSON object
  91465. */
  91466. parse(serializationObject: any): void;
  91467. }
  91468. }
  91469. declare module BABYLON {
  91470. /**
  91471. * Particle emitter emitting particles from a custom list of positions.
  91472. */
  91473. export class CustomParticleEmitter implements IParticleEmitterType {
  91474. /**
  91475. * Gets or sets the position generator that will create the inital position of each particle.
  91476. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91477. */
  91478. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91479. /**
  91480. * Gets or sets the destination generator that will create the final destination of each particle.
  91481. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91482. */
  91483. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91484. /**
  91485. * Creates a new instance CustomParticleEmitter
  91486. */
  91487. constructor();
  91488. /**
  91489. * Called by the particle System when the direction is computed for the created particle.
  91490. * @param worldMatrix is the world matrix of the particle system
  91491. * @param directionToUpdate is the direction vector to update with the result
  91492. * @param particle is the particle we are computed the direction for
  91493. */
  91494. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91495. /**
  91496. * Called by the particle System when the position is computed for the created particle.
  91497. * @param worldMatrix is the world matrix of the particle system
  91498. * @param positionToUpdate is the position vector to update with the result
  91499. * @param particle is the particle we are computed the position for
  91500. */
  91501. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91502. /**
  91503. * Clones the current emitter and returns a copy of it
  91504. * @returns the new emitter
  91505. */
  91506. clone(): CustomParticleEmitter;
  91507. /**
  91508. * Called by the GPUParticleSystem to setup the update shader
  91509. * @param effect defines the update shader
  91510. */
  91511. applyToShader(effect: Effect): void;
  91512. /**
  91513. * Returns a string to use to update the GPU particles update shader
  91514. * @returns a string containng the defines string
  91515. */
  91516. getEffectDefines(): string;
  91517. /**
  91518. * Returns the string "PointParticleEmitter"
  91519. * @returns a string containing the class name
  91520. */
  91521. getClassName(): string;
  91522. /**
  91523. * Serializes the particle system to a JSON object.
  91524. * @returns the JSON object
  91525. */
  91526. serialize(): any;
  91527. /**
  91528. * Parse properties from a JSON object
  91529. * @param serializationObject defines the JSON object
  91530. */
  91531. parse(serializationObject: any): void;
  91532. }
  91533. }
  91534. declare module BABYLON {
  91535. /**
  91536. * Interface representing a particle system in Babylon.js.
  91537. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91538. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91539. */
  91540. export interface IParticleSystem {
  91541. /**
  91542. * List of animations used by the particle system.
  91543. */
  91544. animations: Animation[];
  91545. /**
  91546. * The id of the Particle system.
  91547. */
  91548. id: string;
  91549. /**
  91550. * The name of the Particle system.
  91551. */
  91552. name: string;
  91553. /**
  91554. * The emitter represents the Mesh or position we are attaching the particle system to.
  91555. */
  91556. emitter: Nullable<AbstractMesh | Vector3>;
  91557. /**
  91558. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91559. */
  91560. isBillboardBased: boolean;
  91561. /**
  91562. * The rendering group used by the Particle system to chose when to render.
  91563. */
  91564. renderingGroupId: number;
  91565. /**
  91566. * The layer mask we are rendering the particles through.
  91567. */
  91568. layerMask: number;
  91569. /**
  91570. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91571. */
  91572. updateSpeed: number;
  91573. /**
  91574. * The amount of time the particle system is running (depends of the overall update speed).
  91575. */
  91576. targetStopDuration: number;
  91577. /**
  91578. * The texture used to render each particle. (this can be a spritesheet)
  91579. */
  91580. particleTexture: Nullable<Texture>;
  91581. /**
  91582. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91583. */
  91584. blendMode: number;
  91585. /**
  91586. * Minimum life time of emitting particles.
  91587. */
  91588. minLifeTime: number;
  91589. /**
  91590. * Maximum life time of emitting particles.
  91591. */
  91592. maxLifeTime: number;
  91593. /**
  91594. * Minimum Size of emitting particles.
  91595. */
  91596. minSize: number;
  91597. /**
  91598. * Maximum Size of emitting particles.
  91599. */
  91600. maxSize: number;
  91601. /**
  91602. * Minimum scale of emitting particles on X axis.
  91603. */
  91604. minScaleX: number;
  91605. /**
  91606. * Maximum scale of emitting particles on X axis.
  91607. */
  91608. maxScaleX: number;
  91609. /**
  91610. * Minimum scale of emitting particles on Y axis.
  91611. */
  91612. minScaleY: number;
  91613. /**
  91614. * Maximum scale of emitting particles on Y axis.
  91615. */
  91616. maxScaleY: number;
  91617. /**
  91618. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91619. */
  91620. color1: Color4;
  91621. /**
  91622. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91623. */
  91624. color2: Color4;
  91625. /**
  91626. * Color the particle will have at the end of its lifetime.
  91627. */
  91628. colorDead: Color4;
  91629. /**
  91630. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91631. */
  91632. emitRate: number;
  91633. /**
  91634. * You can use gravity if you want to give an orientation to your particles.
  91635. */
  91636. gravity: Vector3;
  91637. /**
  91638. * Minimum power of emitting particles.
  91639. */
  91640. minEmitPower: number;
  91641. /**
  91642. * Maximum power of emitting particles.
  91643. */
  91644. maxEmitPower: number;
  91645. /**
  91646. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91647. */
  91648. minAngularSpeed: number;
  91649. /**
  91650. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91651. */
  91652. maxAngularSpeed: number;
  91653. /**
  91654. * Gets or sets the minimal initial rotation in radians.
  91655. */
  91656. minInitialRotation: number;
  91657. /**
  91658. * Gets or sets the maximal initial rotation in radians.
  91659. */
  91660. maxInitialRotation: number;
  91661. /**
  91662. * The particle emitter type defines the emitter used by the particle system.
  91663. * It can be for example box, sphere, or cone...
  91664. */
  91665. particleEmitterType: Nullable<IParticleEmitterType>;
  91666. /**
  91667. * Defines the delay in milliseconds before starting the system (0 by default)
  91668. */
  91669. startDelay: number;
  91670. /**
  91671. * 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
  91672. */
  91673. preWarmCycles: number;
  91674. /**
  91675. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91676. */
  91677. preWarmStepOffset: number;
  91678. /**
  91679. * 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)
  91680. */
  91681. spriteCellChangeSpeed: number;
  91682. /**
  91683. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91684. */
  91685. startSpriteCellID: number;
  91686. /**
  91687. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91688. */
  91689. endSpriteCellID: number;
  91690. /**
  91691. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91692. */
  91693. spriteCellWidth: number;
  91694. /**
  91695. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91696. */
  91697. spriteCellHeight: number;
  91698. /**
  91699. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91700. */
  91701. spriteRandomStartCell: boolean;
  91702. /**
  91703. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91704. */
  91705. isAnimationSheetEnabled: boolean;
  91706. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91707. translationPivot: Vector2;
  91708. /**
  91709. * Gets or sets a texture used to add random noise to particle positions
  91710. */
  91711. noiseTexture: Nullable<BaseTexture>;
  91712. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91713. noiseStrength: Vector3;
  91714. /**
  91715. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91716. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91717. */
  91718. billboardMode: number;
  91719. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91720. limitVelocityDamping: number;
  91721. /**
  91722. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91723. */
  91724. beginAnimationOnStart: boolean;
  91725. /**
  91726. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91727. */
  91728. beginAnimationFrom: number;
  91729. /**
  91730. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91731. */
  91732. beginAnimationTo: number;
  91733. /**
  91734. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91735. */
  91736. beginAnimationLoop: boolean;
  91737. /**
  91738. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91739. */
  91740. disposeOnStop: boolean;
  91741. /**
  91742. * Gets the maximum number of particles active at the same time.
  91743. * @returns The max number of active particles.
  91744. */
  91745. getCapacity(): number;
  91746. /**
  91747. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91748. * @returns True if it has been started, otherwise false.
  91749. */
  91750. isStarted(): boolean;
  91751. /**
  91752. * Animates the particle system for this frame.
  91753. */
  91754. animate(): void;
  91755. /**
  91756. * Renders the particle system in its current state.
  91757. * @returns the current number of particles
  91758. */
  91759. render(): number;
  91760. /**
  91761. * Dispose the particle system and frees its associated resources.
  91762. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91763. */
  91764. dispose(disposeTexture?: boolean): void;
  91765. /**
  91766. * Clones the particle system.
  91767. * @param name The name of the cloned object
  91768. * @param newEmitter The new emitter to use
  91769. * @returns the cloned particle system
  91770. */
  91771. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91772. /**
  91773. * Serializes the particle system to a JSON object.
  91774. * @returns the JSON object
  91775. */
  91776. serialize(): any;
  91777. /**
  91778. * Rebuild the particle system
  91779. */
  91780. rebuild(): void;
  91781. /**
  91782. * Starts the particle system and begins to emit
  91783. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91784. */
  91785. start(delay?: number): void;
  91786. /**
  91787. * Stops the particle system.
  91788. */
  91789. stop(): void;
  91790. /**
  91791. * Remove all active particles
  91792. */
  91793. reset(): void;
  91794. /**
  91795. * Is this system ready to be used/rendered
  91796. * @return true if the system is ready
  91797. */
  91798. isReady(): boolean;
  91799. /**
  91800. * Adds a new color gradient
  91801. * @param gradient defines the gradient to use (between 0 and 1)
  91802. * @param color1 defines the color to affect to the specified gradient
  91803. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91804. * @returns the current particle system
  91805. */
  91806. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91807. /**
  91808. * Remove a specific color gradient
  91809. * @param gradient defines the gradient to remove
  91810. * @returns the current particle system
  91811. */
  91812. removeColorGradient(gradient: number): IParticleSystem;
  91813. /**
  91814. * Adds a new size gradient
  91815. * @param gradient defines the gradient to use (between 0 and 1)
  91816. * @param factor defines the size factor to affect to the specified gradient
  91817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91818. * @returns the current particle system
  91819. */
  91820. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91821. /**
  91822. * Remove a specific size gradient
  91823. * @param gradient defines the gradient to remove
  91824. * @returns the current particle system
  91825. */
  91826. removeSizeGradient(gradient: number): IParticleSystem;
  91827. /**
  91828. * Gets the current list of color gradients.
  91829. * You must use addColorGradient and removeColorGradient to udpate this list
  91830. * @returns the list of color gradients
  91831. */
  91832. getColorGradients(): Nullable<Array<ColorGradient>>;
  91833. /**
  91834. * Gets the current list of size gradients.
  91835. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91836. * @returns the list of size gradients
  91837. */
  91838. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91839. /**
  91840. * Gets the current list of angular speed gradients.
  91841. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91842. * @returns the list of angular speed gradients
  91843. */
  91844. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91845. /**
  91846. * Adds a new angular speed gradient
  91847. * @param gradient defines the gradient to use (between 0 and 1)
  91848. * @param factor defines the angular speed to affect to the specified gradient
  91849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91850. * @returns the current particle system
  91851. */
  91852. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91853. /**
  91854. * Remove a specific angular speed gradient
  91855. * @param gradient defines the gradient to remove
  91856. * @returns the current particle system
  91857. */
  91858. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91859. /**
  91860. * Gets the current list of velocity gradients.
  91861. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91862. * @returns the list of velocity gradients
  91863. */
  91864. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91865. /**
  91866. * Adds a new velocity gradient
  91867. * @param gradient defines the gradient to use (between 0 and 1)
  91868. * @param factor defines the velocity to affect to the specified gradient
  91869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91870. * @returns the current particle system
  91871. */
  91872. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91873. /**
  91874. * Remove a specific velocity gradient
  91875. * @param gradient defines the gradient to remove
  91876. * @returns the current particle system
  91877. */
  91878. removeVelocityGradient(gradient: number): IParticleSystem;
  91879. /**
  91880. * Gets the current list of limit velocity gradients.
  91881. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91882. * @returns the list of limit velocity gradients
  91883. */
  91884. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91885. /**
  91886. * Adds a new limit velocity gradient
  91887. * @param gradient defines the gradient to use (between 0 and 1)
  91888. * @param factor defines the limit velocity to affect to the specified gradient
  91889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91890. * @returns the current particle system
  91891. */
  91892. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91893. /**
  91894. * Remove a specific limit velocity gradient
  91895. * @param gradient defines the gradient to remove
  91896. * @returns the current particle system
  91897. */
  91898. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91899. /**
  91900. * Adds a new drag gradient
  91901. * @param gradient defines the gradient to use (between 0 and 1)
  91902. * @param factor defines the drag to affect to the specified gradient
  91903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91904. * @returns the current particle system
  91905. */
  91906. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91907. /**
  91908. * Remove a specific drag gradient
  91909. * @param gradient defines the gradient to remove
  91910. * @returns the current particle system
  91911. */
  91912. removeDragGradient(gradient: number): IParticleSystem;
  91913. /**
  91914. * Gets the current list of drag gradients.
  91915. * You must use addDragGradient and removeDragGradient to udpate this list
  91916. * @returns the list of drag gradients
  91917. */
  91918. getDragGradients(): Nullable<Array<FactorGradient>>;
  91919. /**
  91920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91921. * @param gradient defines the gradient to use (between 0 and 1)
  91922. * @param factor defines the emit rate to affect to the specified gradient
  91923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91924. * @returns the current particle system
  91925. */
  91926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91927. /**
  91928. * Remove a specific emit rate gradient
  91929. * @param gradient defines the gradient to remove
  91930. * @returns the current particle system
  91931. */
  91932. removeEmitRateGradient(gradient: number): IParticleSystem;
  91933. /**
  91934. * Gets the current list of emit rate gradients.
  91935. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91936. * @returns the list of emit rate gradients
  91937. */
  91938. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91939. /**
  91940. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91941. * @param gradient defines the gradient to use (between 0 and 1)
  91942. * @param factor defines the start size to affect to the specified gradient
  91943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91944. * @returns the current particle system
  91945. */
  91946. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91947. /**
  91948. * Remove a specific start size gradient
  91949. * @param gradient defines the gradient to remove
  91950. * @returns the current particle system
  91951. */
  91952. removeStartSizeGradient(gradient: number): IParticleSystem;
  91953. /**
  91954. * Gets the current list of start size gradients.
  91955. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91956. * @returns the list of start size gradients
  91957. */
  91958. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91959. /**
  91960. * Adds a new life time gradient
  91961. * @param gradient defines the gradient to use (between 0 and 1)
  91962. * @param factor defines the life time factor to affect to the specified gradient
  91963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91964. * @returns the current particle system
  91965. */
  91966. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91967. /**
  91968. * Remove a specific life time gradient
  91969. * @param gradient defines the gradient to remove
  91970. * @returns the current particle system
  91971. */
  91972. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91973. /**
  91974. * Gets the current list of life time gradients.
  91975. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91976. * @returns the list of life time gradients
  91977. */
  91978. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91979. /**
  91980. * Gets the current list of color gradients.
  91981. * You must use addColorGradient and removeColorGradient to udpate this list
  91982. * @returns the list of color gradients
  91983. */
  91984. getColorGradients(): Nullable<Array<ColorGradient>>;
  91985. /**
  91986. * Adds a new ramp gradient used to remap particle colors
  91987. * @param gradient defines the gradient to use (between 0 and 1)
  91988. * @param color defines the color to affect to the specified gradient
  91989. * @returns the current particle system
  91990. */
  91991. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91992. /**
  91993. * Gets the current list of ramp gradients.
  91994. * You must use addRampGradient and removeRampGradient to udpate this list
  91995. * @returns the list of ramp gradients
  91996. */
  91997. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91998. /** Gets or sets a boolean indicating that ramp gradients must be used
  91999. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92000. */
  92001. useRampGradients: boolean;
  92002. /**
  92003. * Adds a new color remap gradient
  92004. * @param gradient defines the gradient to use (between 0 and 1)
  92005. * @param min defines the color remap minimal range
  92006. * @param max defines the color remap maximal range
  92007. * @returns the current particle system
  92008. */
  92009. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92010. /**
  92011. * Gets the current list of color remap gradients.
  92012. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92013. * @returns the list of color remap gradients
  92014. */
  92015. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92016. /**
  92017. * Adds a new alpha remap gradient
  92018. * @param gradient defines the gradient to use (between 0 and 1)
  92019. * @param min defines the alpha remap minimal range
  92020. * @param max defines the alpha remap maximal range
  92021. * @returns the current particle system
  92022. */
  92023. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92024. /**
  92025. * Gets the current list of alpha remap gradients.
  92026. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92027. * @returns the list of alpha remap gradients
  92028. */
  92029. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92030. /**
  92031. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92032. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92033. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92034. * @returns the emitter
  92035. */
  92036. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92037. /**
  92038. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92039. * @param radius The radius of the hemisphere to emit from
  92040. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92041. * @returns the emitter
  92042. */
  92043. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92044. /**
  92045. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92046. * @param radius The radius of the sphere to emit from
  92047. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92048. * @returns the emitter
  92049. */
  92050. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92051. /**
  92052. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92053. * @param radius The radius of the sphere to emit from
  92054. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92055. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92056. * @returns the emitter
  92057. */
  92058. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92059. /**
  92060. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92061. * @param radius The radius of the emission cylinder
  92062. * @param height The height of the emission cylinder
  92063. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92064. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92065. * @returns the emitter
  92066. */
  92067. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92068. /**
  92069. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92070. * @param radius The radius of the cylinder to emit from
  92071. * @param height The height of the emission cylinder
  92072. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92073. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92074. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92075. * @returns the emitter
  92076. */
  92077. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92078. /**
  92079. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92080. * @param radius The radius of the cone to emit from
  92081. * @param angle The base angle of the cone
  92082. * @returns the emitter
  92083. */
  92084. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92085. /**
  92086. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92087. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92088. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92089. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92090. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92091. * @returns the emitter
  92092. */
  92093. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92094. /**
  92095. * Get hosting scene
  92096. * @returns the scene
  92097. */
  92098. getScene(): Scene;
  92099. }
  92100. }
  92101. declare module BABYLON {
  92102. /**
  92103. * Creates an instance based on a source mesh.
  92104. */
  92105. export class InstancedMesh extends AbstractMesh {
  92106. private _sourceMesh;
  92107. private _currentLOD;
  92108. /** @hidden */
  92109. _indexInSourceMeshInstanceArray: number;
  92110. constructor(name: string, source: Mesh);
  92111. /**
  92112. * Returns the string "InstancedMesh".
  92113. */
  92114. getClassName(): string;
  92115. /** Gets the list of lights affecting that mesh */
  92116. get lightSources(): Light[];
  92117. _resyncLightSources(): void;
  92118. _resyncLightSource(light: Light): void;
  92119. _removeLightSource(light: Light, dispose: boolean): void;
  92120. /**
  92121. * If the source mesh receives shadows
  92122. */
  92123. get receiveShadows(): boolean;
  92124. /**
  92125. * The material of the source mesh
  92126. */
  92127. get material(): Nullable<Material>;
  92128. /**
  92129. * Visibility of the source mesh
  92130. */
  92131. get visibility(): number;
  92132. /**
  92133. * Skeleton of the source mesh
  92134. */
  92135. get skeleton(): Nullable<Skeleton>;
  92136. /**
  92137. * Rendering ground id of the source mesh
  92138. */
  92139. get renderingGroupId(): number;
  92140. set renderingGroupId(value: number);
  92141. /**
  92142. * Returns the total number of vertices (integer).
  92143. */
  92144. getTotalVertices(): number;
  92145. /**
  92146. * Returns a positive integer : the total number of indices in this mesh geometry.
  92147. * @returns the numner of indices or zero if the mesh has no geometry.
  92148. */
  92149. getTotalIndices(): number;
  92150. /**
  92151. * The source mesh of the instance
  92152. */
  92153. get sourceMesh(): Mesh;
  92154. /**
  92155. * Is this node ready to be used/rendered
  92156. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92157. * @return {boolean} is it ready
  92158. */
  92159. isReady(completeCheck?: boolean): boolean;
  92160. /**
  92161. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92162. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  92163. * @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.
  92164. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  92165. */
  92166. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  92167. /**
  92168. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92169. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92170. * The `data` are either a numeric array either a Float32Array.
  92171. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  92172. * 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).
  92173. * Note that a new underlying VertexBuffer object is created each call.
  92174. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92175. *
  92176. * Possible `kind` values :
  92177. * - VertexBuffer.PositionKind
  92178. * - VertexBuffer.UVKind
  92179. * - VertexBuffer.UV2Kind
  92180. * - VertexBuffer.UV3Kind
  92181. * - VertexBuffer.UV4Kind
  92182. * - VertexBuffer.UV5Kind
  92183. * - VertexBuffer.UV6Kind
  92184. * - VertexBuffer.ColorKind
  92185. * - VertexBuffer.MatricesIndicesKind
  92186. * - VertexBuffer.MatricesIndicesExtraKind
  92187. * - VertexBuffer.MatricesWeightsKind
  92188. * - VertexBuffer.MatricesWeightsExtraKind
  92189. *
  92190. * Returns the Mesh.
  92191. */
  92192. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92193. /**
  92194. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92195. * If the mesh has no geometry, it is simply returned as it is.
  92196. * The `data` are either a numeric array either a Float32Array.
  92197. * No new underlying VertexBuffer object is created.
  92198. * 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.
  92199. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  92200. *
  92201. * Possible `kind` values :
  92202. * - VertexBuffer.PositionKind
  92203. * - VertexBuffer.UVKind
  92204. * - VertexBuffer.UV2Kind
  92205. * - VertexBuffer.UV3Kind
  92206. * - VertexBuffer.UV4Kind
  92207. * - VertexBuffer.UV5Kind
  92208. * - VertexBuffer.UV6Kind
  92209. * - VertexBuffer.ColorKind
  92210. * - VertexBuffer.MatricesIndicesKind
  92211. * - VertexBuffer.MatricesIndicesExtraKind
  92212. * - VertexBuffer.MatricesWeightsKind
  92213. * - VertexBuffer.MatricesWeightsExtraKind
  92214. *
  92215. * Returns the Mesh.
  92216. */
  92217. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  92218. /**
  92219. * Sets the mesh indices.
  92220. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  92221. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92222. * This method creates a new index buffer each call.
  92223. * Returns the Mesh.
  92224. */
  92225. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  92226. /**
  92227. * Boolean : True if the mesh owns the requested kind of data.
  92228. */
  92229. isVerticesDataPresent(kind: string): boolean;
  92230. /**
  92231. * Returns an array of indices (IndicesArray).
  92232. */
  92233. getIndices(): Nullable<IndicesArray>;
  92234. get _positions(): Nullable<Vector3[]>;
  92235. /**
  92236. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92237. * This means the mesh underlying bounding box and sphere are recomputed.
  92238. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92239. * @returns the current mesh
  92240. */
  92241. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  92242. /** @hidden */
  92243. _preActivate(): InstancedMesh;
  92244. /** @hidden */
  92245. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92246. /** @hidden */
  92247. _postActivate(): void;
  92248. getWorldMatrix(): Matrix;
  92249. get isAnInstance(): boolean;
  92250. /**
  92251. * Returns the current associated LOD AbstractMesh.
  92252. */
  92253. getLOD(camera: Camera): AbstractMesh;
  92254. /** @hidden */
  92255. _syncSubMeshes(): InstancedMesh;
  92256. /** @hidden */
  92257. _generatePointsArray(): boolean;
  92258. /**
  92259. * Creates a new InstancedMesh from the current mesh.
  92260. * - name (string) : the cloned mesh name
  92261. * - newParent (optional Node) : the optional Node to parent the clone to.
  92262. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  92263. *
  92264. * Returns the clone.
  92265. */
  92266. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  92267. /**
  92268. * Disposes the InstancedMesh.
  92269. * Returns nothing.
  92270. */
  92271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92272. }
  92273. interface Mesh {
  92274. /**
  92275. * Register a custom buffer that will be instanced
  92276. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  92277. * @param kind defines the buffer kind
  92278. * @param stride defines the stride in floats
  92279. */
  92280. registerInstancedBuffer(kind: string, stride: number): void;
  92281. /** @hidden */
  92282. _userInstancedBuffersStorage: {
  92283. data: {
  92284. [key: string]: Float32Array;
  92285. };
  92286. sizes: {
  92287. [key: string]: number;
  92288. };
  92289. vertexBuffers: {
  92290. [key: string]: Nullable<VertexBuffer>;
  92291. };
  92292. strides: {
  92293. [key: string]: number;
  92294. };
  92295. };
  92296. }
  92297. interface AbstractMesh {
  92298. /**
  92299. * Object used to store instanced buffers defined by user
  92300. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  92301. */
  92302. instancedBuffers: {
  92303. [key: string]: any;
  92304. };
  92305. }
  92306. }
  92307. declare module BABYLON {
  92308. /**
  92309. * Defines the options associated with the creation of a shader material.
  92310. */
  92311. export interface IShaderMaterialOptions {
  92312. /**
  92313. * Does the material work in alpha blend mode
  92314. */
  92315. needAlphaBlending: boolean;
  92316. /**
  92317. * Does the material work in alpha test mode
  92318. */
  92319. needAlphaTesting: boolean;
  92320. /**
  92321. * The list of attribute names used in the shader
  92322. */
  92323. attributes: string[];
  92324. /**
  92325. * The list of unifrom names used in the shader
  92326. */
  92327. uniforms: string[];
  92328. /**
  92329. * The list of UBO names used in the shader
  92330. */
  92331. uniformBuffers: string[];
  92332. /**
  92333. * The list of sampler names used in the shader
  92334. */
  92335. samplers: string[];
  92336. /**
  92337. * The list of defines used in the shader
  92338. */
  92339. defines: string[];
  92340. }
  92341. /**
  92342. * 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.
  92343. *
  92344. * This returned material effects how the mesh will look based on the code in the shaders.
  92345. *
  92346. * @see http://doc.babylonjs.com/how_to/shader_material
  92347. */
  92348. export class ShaderMaterial extends Material {
  92349. private _shaderPath;
  92350. private _options;
  92351. private _textures;
  92352. private _textureArrays;
  92353. private _floats;
  92354. private _ints;
  92355. private _floatsArrays;
  92356. private _colors3;
  92357. private _colors3Arrays;
  92358. private _colors4;
  92359. private _colors4Arrays;
  92360. private _vectors2;
  92361. private _vectors3;
  92362. private _vectors4;
  92363. private _matrices;
  92364. private _matrixArrays;
  92365. private _matrices3x3;
  92366. private _matrices2x2;
  92367. private _vectors2Arrays;
  92368. private _vectors3Arrays;
  92369. private _vectors4Arrays;
  92370. private _cachedWorldViewMatrix;
  92371. private _cachedWorldViewProjectionMatrix;
  92372. private _renderId;
  92373. private _multiview;
  92374. /**
  92375. * Instantiate a new shader material.
  92376. * 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.
  92377. * This returned material effects how the mesh will look based on the code in the shaders.
  92378. * @see http://doc.babylonjs.com/how_to/shader_material
  92379. * @param name Define the name of the material in the scene
  92380. * @param scene Define the scene the material belongs to
  92381. * @param shaderPath Defines the route to the shader code in one of three ways:
  92382. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  92383. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  92384. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  92385. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  92386. * @param options Define the options used to create the shader
  92387. */
  92388. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  92389. /**
  92390. * Gets the shader path used to define the shader code
  92391. * It can be modified to trigger a new compilation
  92392. */
  92393. get shaderPath(): any;
  92394. /**
  92395. * Sets the shader path used to define the shader code
  92396. * It can be modified to trigger a new compilation
  92397. */
  92398. set shaderPath(shaderPath: any);
  92399. /**
  92400. * Gets the options used to compile the shader.
  92401. * They can be modified to trigger a new compilation
  92402. */
  92403. get options(): IShaderMaterialOptions;
  92404. /**
  92405. * Gets the current class name of the material e.g. "ShaderMaterial"
  92406. * Mainly use in serialization.
  92407. * @returns the class name
  92408. */
  92409. getClassName(): string;
  92410. /**
  92411. * Specifies if the material will require alpha blending
  92412. * @returns a boolean specifying if alpha blending is needed
  92413. */
  92414. needAlphaBlending(): boolean;
  92415. /**
  92416. * Specifies if this material should be rendered in alpha test mode
  92417. * @returns a boolean specifying if an alpha test is needed.
  92418. */
  92419. needAlphaTesting(): boolean;
  92420. private _checkUniform;
  92421. /**
  92422. * Set a texture in the shader.
  92423. * @param name Define the name of the uniform samplers as defined in the shader
  92424. * @param texture Define the texture to bind to this sampler
  92425. * @return the material itself allowing "fluent" like uniform updates
  92426. */
  92427. setTexture(name: string, texture: Texture): ShaderMaterial;
  92428. /**
  92429. * Set a texture array in the shader.
  92430. * @param name Define the name of the uniform sampler array as defined in the shader
  92431. * @param textures Define the list of textures to bind to this sampler
  92432. * @return the material itself allowing "fluent" like uniform updates
  92433. */
  92434. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  92435. /**
  92436. * Set a float in the shader.
  92437. * @param name Define the name of the uniform as defined in the shader
  92438. * @param value Define the value to give to the uniform
  92439. * @return the material itself allowing "fluent" like uniform updates
  92440. */
  92441. setFloat(name: string, value: number): ShaderMaterial;
  92442. /**
  92443. * Set a int in the shader.
  92444. * @param name Define the name of the uniform as defined in the shader
  92445. * @param value Define the value to give to the uniform
  92446. * @return the material itself allowing "fluent" like uniform updates
  92447. */
  92448. setInt(name: string, value: number): ShaderMaterial;
  92449. /**
  92450. * Set an array of floats in the shader.
  92451. * @param name Define the name of the uniform as defined in the shader
  92452. * @param value Define the value to give to the uniform
  92453. * @return the material itself allowing "fluent" like uniform updates
  92454. */
  92455. setFloats(name: string, value: number[]): ShaderMaterial;
  92456. /**
  92457. * Set a vec3 in the shader from a Color3.
  92458. * @param name Define the name of the uniform as defined in the shader
  92459. * @param value Define the value to give to the uniform
  92460. * @return the material itself allowing "fluent" like uniform updates
  92461. */
  92462. setColor3(name: string, value: Color3): ShaderMaterial;
  92463. /**
  92464. * Set a vec3 array in the shader from a Color3 array.
  92465. * @param name Define the name of the uniform as defined in the shader
  92466. * @param value Define the value to give to the uniform
  92467. * @return the material itself allowing "fluent" like uniform updates
  92468. */
  92469. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  92470. /**
  92471. * Set a vec4 in the shader from a Color4.
  92472. * @param name Define the name of the uniform as defined in the shader
  92473. * @param value Define the value to give to the uniform
  92474. * @return the material itself allowing "fluent" like uniform updates
  92475. */
  92476. setColor4(name: string, value: Color4): ShaderMaterial;
  92477. /**
  92478. * Set a vec4 array in the shader from a Color4 array.
  92479. * @param name Define the name of the uniform as defined in the shader
  92480. * @param value Define the value to give to the uniform
  92481. * @return the material itself allowing "fluent" like uniform updates
  92482. */
  92483. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  92484. /**
  92485. * Set a vec2 in the shader from a Vector2.
  92486. * @param name Define the name of the uniform as defined in the shader
  92487. * @param value Define the value to give to the uniform
  92488. * @return the material itself allowing "fluent" like uniform updates
  92489. */
  92490. setVector2(name: string, value: Vector2): ShaderMaterial;
  92491. /**
  92492. * Set a vec3 in the shader from a Vector3.
  92493. * @param name Define the name of the uniform as defined in the shader
  92494. * @param value Define the value to give to the uniform
  92495. * @return the material itself allowing "fluent" like uniform updates
  92496. */
  92497. setVector3(name: string, value: Vector3): ShaderMaterial;
  92498. /**
  92499. * Set a vec4 in the shader from a Vector4.
  92500. * @param name Define the name of the uniform as defined in the shader
  92501. * @param value Define the value to give to the uniform
  92502. * @return the material itself allowing "fluent" like uniform updates
  92503. */
  92504. setVector4(name: string, value: Vector4): ShaderMaterial;
  92505. /**
  92506. * Set a mat4 in the shader from a Matrix.
  92507. * @param name Define the name of the uniform as defined in the shader
  92508. * @param value Define the value to give to the uniform
  92509. * @return the material itself allowing "fluent" like uniform updates
  92510. */
  92511. setMatrix(name: string, value: Matrix): ShaderMaterial;
  92512. /**
  92513. * Set a float32Array in the shader from a matrix array.
  92514. * @param name Define the name of the uniform as defined in the shader
  92515. * @param value Define the value to give to the uniform
  92516. * @return the material itself allowing "fluent" like uniform updates
  92517. */
  92518. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  92519. /**
  92520. * Set a mat3 in the shader from a Float32Array.
  92521. * @param name Define the name of the uniform as defined in the shader
  92522. * @param value Define the value to give to the uniform
  92523. * @return the material itself allowing "fluent" like uniform updates
  92524. */
  92525. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  92526. /**
  92527. * Set a mat2 in the shader from a Float32Array.
  92528. * @param name Define the name of the uniform as defined in the shader
  92529. * @param value Define the value to give to the uniform
  92530. * @return the material itself allowing "fluent" like uniform updates
  92531. */
  92532. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  92533. /**
  92534. * Set a vec2 array in the shader from a number array.
  92535. * @param name Define the name of the uniform as defined in the shader
  92536. * @param value Define the value to give to the uniform
  92537. * @return the material itself allowing "fluent" like uniform updates
  92538. */
  92539. setArray2(name: string, value: number[]): ShaderMaterial;
  92540. /**
  92541. * Set a vec3 array in the shader from a number array.
  92542. * @param name Define the name of the uniform as defined in the shader
  92543. * @param value Define the value to give to the uniform
  92544. * @return the material itself allowing "fluent" like uniform updates
  92545. */
  92546. setArray3(name: string, value: number[]): ShaderMaterial;
  92547. /**
  92548. * Set a vec4 array in the shader from a number array.
  92549. * @param name Define the name of the uniform as defined in the shader
  92550. * @param value Define the value to give to the uniform
  92551. * @return the material itself allowing "fluent" like uniform updates
  92552. */
  92553. setArray4(name: string, value: number[]): ShaderMaterial;
  92554. private _checkCache;
  92555. /**
  92556. * Specifies that the submesh is ready to be used
  92557. * @param mesh defines the mesh to check
  92558. * @param subMesh defines which submesh to check
  92559. * @param useInstances specifies that instances should be used
  92560. * @returns a boolean indicating that the submesh is ready or not
  92561. */
  92562. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92563. /**
  92564. * Checks if the material is ready to render the requested mesh
  92565. * @param mesh Define the mesh to render
  92566. * @param useInstances Define whether or not the material is used with instances
  92567. * @returns true if ready, otherwise false
  92568. */
  92569. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92570. /**
  92571. * Binds the world matrix to the material
  92572. * @param world defines the world transformation matrix
  92573. */
  92574. bindOnlyWorldMatrix(world: Matrix): void;
  92575. /**
  92576. * Binds the material to the mesh
  92577. * @param world defines the world transformation matrix
  92578. * @param mesh defines the mesh to bind the material to
  92579. */
  92580. bind(world: Matrix, mesh?: Mesh): void;
  92581. /**
  92582. * Gets the active textures from the material
  92583. * @returns an array of textures
  92584. */
  92585. getActiveTextures(): BaseTexture[];
  92586. /**
  92587. * Specifies if the material uses a texture
  92588. * @param texture defines the texture to check against the material
  92589. * @returns a boolean specifying if the material uses the texture
  92590. */
  92591. hasTexture(texture: BaseTexture): boolean;
  92592. /**
  92593. * Makes a duplicate of the material, and gives it a new name
  92594. * @param name defines the new name for the duplicated material
  92595. * @returns the cloned material
  92596. */
  92597. clone(name: string): ShaderMaterial;
  92598. /**
  92599. * Disposes the material
  92600. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92601. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92602. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92603. */
  92604. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92605. /**
  92606. * Serializes this material in a JSON representation
  92607. * @returns the serialized material object
  92608. */
  92609. serialize(): any;
  92610. /**
  92611. * Creates a shader material from parsed shader material data
  92612. * @param source defines the JSON represnetation of the material
  92613. * @param scene defines the hosting scene
  92614. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92615. * @returns a new material
  92616. */
  92617. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  92618. }
  92619. }
  92620. declare module BABYLON {
  92621. /** @hidden */
  92622. export var colorPixelShader: {
  92623. name: string;
  92624. shader: string;
  92625. };
  92626. }
  92627. declare module BABYLON {
  92628. /** @hidden */
  92629. export var colorVertexShader: {
  92630. name: string;
  92631. shader: string;
  92632. };
  92633. }
  92634. declare module BABYLON {
  92635. /**
  92636. * Line mesh
  92637. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  92638. */
  92639. export class LinesMesh extends Mesh {
  92640. /**
  92641. * If vertex color should be applied to the mesh
  92642. */
  92643. readonly useVertexColor?: boolean | undefined;
  92644. /**
  92645. * If vertex alpha should be applied to the mesh
  92646. */
  92647. readonly useVertexAlpha?: boolean | undefined;
  92648. /**
  92649. * Color of the line (Default: White)
  92650. */
  92651. color: Color3;
  92652. /**
  92653. * Alpha of the line (Default: 1)
  92654. */
  92655. alpha: number;
  92656. /**
  92657. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92658. * This margin is expressed in world space coordinates, so its value may vary.
  92659. * Default value is 0.1
  92660. */
  92661. intersectionThreshold: number;
  92662. private _colorShader;
  92663. private color4;
  92664. /**
  92665. * Creates a new LinesMesh
  92666. * @param name defines the name
  92667. * @param scene defines the hosting scene
  92668. * @param parent defines the parent mesh if any
  92669. * @param source defines the optional source LinesMesh used to clone data from
  92670. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92671. * When false, achieved by calling a clone(), also passing False.
  92672. * This will make creation of children, recursive.
  92673. * @param useVertexColor defines if this LinesMesh supports vertex color
  92674. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  92675. */
  92676. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  92677. /**
  92678. * If vertex color should be applied to the mesh
  92679. */
  92680. useVertexColor?: boolean | undefined,
  92681. /**
  92682. * If vertex alpha should be applied to the mesh
  92683. */
  92684. useVertexAlpha?: boolean | undefined);
  92685. private _addClipPlaneDefine;
  92686. private _removeClipPlaneDefine;
  92687. isReady(): boolean;
  92688. /**
  92689. * Returns the string "LineMesh"
  92690. */
  92691. getClassName(): string;
  92692. /**
  92693. * @hidden
  92694. */
  92695. get material(): Material;
  92696. /**
  92697. * @hidden
  92698. */
  92699. set material(value: Material);
  92700. /**
  92701. * @hidden
  92702. */
  92703. get checkCollisions(): boolean;
  92704. /** @hidden */
  92705. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92706. /** @hidden */
  92707. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92708. /**
  92709. * Disposes of the line mesh
  92710. * @param doNotRecurse If children should be disposed
  92711. */
  92712. dispose(doNotRecurse?: boolean): void;
  92713. /**
  92714. * Returns a new LineMesh object cloned from the current one.
  92715. */
  92716. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  92717. /**
  92718. * Creates a new InstancedLinesMesh object from the mesh model.
  92719. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92720. * @param name defines the name of the new instance
  92721. * @returns a new InstancedLinesMesh
  92722. */
  92723. createInstance(name: string): InstancedLinesMesh;
  92724. }
  92725. /**
  92726. * Creates an instance based on a source LinesMesh
  92727. */
  92728. export class InstancedLinesMesh extends InstancedMesh {
  92729. /**
  92730. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92731. * This margin is expressed in world space coordinates, so its value may vary.
  92732. * Initilized with the intersectionThreshold value of the source LinesMesh
  92733. */
  92734. intersectionThreshold: number;
  92735. constructor(name: string, source: LinesMesh);
  92736. /**
  92737. * Returns the string "InstancedLinesMesh".
  92738. */
  92739. getClassName(): string;
  92740. }
  92741. }
  92742. declare module BABYLON {
  92743. /** @hidden */
  92744. export var linePixelShader: {
  92745. name: string;
  92746. shader: string;
  92747. };
  92748. }
  92749. declare module BABYLON {
  92750. /** @hidden */
  92751. export var lineVertexShader: {
  92752. name: string;
  92753. shader: string;
  92754. };
  92755. }
  92756. declare module BABYLON {
  92757. interface AbstractMesh {
  92758. /**
  92759. * Gets the edgesRenderer associated with the mesh
  92760. */
  92761. edgesRenderer: Nullable<EdgesRenderer>;
  92762. }
  92763. interface LinesMesh {
  92764. /**
  92765. * Enables the edge rendering mode on the mesh.
  92766. * This mode makes the mesh edges visible
  92767. * @param epsilon defines the maximal distance between two angles to detect a face
  92768. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92769. * @returns the currentAbstractMesh
  92770. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92771. */
  92772. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92773. }
  92774. interface InstancedLinesMesh {
  92775. /**
  92776. * Enables the edge rendering mode on the mesh.
  92777. * This mode makes the mesh edges visible
  92778. * @param epsilon defines the maximal distance between two angles to detect a face
  92779. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92780. * @returns the current InstancedLinesMesh
  92781. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92782. */
  92783. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  92784. }
  92785. /**
  92786. * Defines the minimum contract an Edges renderer should follow.
  92787. */
  92788. export interface IEdgesRenderer extends IDisposable {
  92789. /**
  92790. * Gets or sets a boolean indicating if the edgesRenderer is active
  92791. */
  92792. isEnabled: boolean;
  92793. /**
  92794. * Renders the edges of the attached mesh,
  92795. */
  92796. render(): void;
  92797. /**
  92798. * Checks wether or not the edges renderer is ready to render.
  92799. * @return true if ready, otherwise false.
  92800. */
  92801. isReady(): boolean;
  92802. }
  92803. /**
  92804. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  92805. */
  92806. export class EdgesRenderer implements IEdgesRenderer {
  92807. /**
  92808. * Define the size of the edges with an orthographic camera
  92809. */
  92810. edgesWidthScalerForOrthographic: number;
  92811. /**
  92812. * Define the size of the edges with a perspective camera
  92813. */
  92814. edgesWidthScalerForPerspective: number;
  92815. protected _source: AbstractMesh;
  92816. protected _linesPositions: number[];
  92817. protected _linesNormals: number[];
  92818. protected _linesIndices: number[];
  92819. protected _epsilon: number;
  92820. protected _indicesCount: number;
  92821. protected _lineShader: ShaderMaterial;
  92822. protected _ib: DataBuffer;
  92823. protected _buffers: {
  92824. [key: string]: Nullable<VertexBuffer>;
  92825. };
  92826. protected _checkVerticesInsteadOfIndices: boolean;
  92827. private _meshRebuildObserver;
  92828. private _meshDisposeObserver;
  92829. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  92830. isEnabled: boolean;
  92831. /**
  92832. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  92833. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  92834. * @param source Mesh used to create edges
  92835. * @param epsilon sum of angles in adjacency to check for edge
  92836. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  92837. * @param generateEdgesLines - should generate Lines or only prepare resources.
  92838. */
  92839. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  92840. protected _prepareRessources(): void;
  92841. /** @hidden */
  92842. _rebuild(): void;
  92843. /**
  92844. * Releases the required resources for the edges renderer
  92845. */
  92846. dispose(): void;
  92847. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92848. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92849. /**
  92850. * Checks if the pair of p0 and p1 is en edge
  92851. * @param faceIndex
  92852. * @param edge
  92853. * @param faceNormals
  92854. * @param p0
  92855. * @param p1
  92856. * @private
  92857. */
  92858. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92859. /**
  92860. * push line into the position, normal and index buffer
  92861. * @protected
  92862. */
  92863. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92864. /**
  92865. * Generates lines edges from adjacencjes
  92866. * @private
  92867. */
  92868. _generateEdgesLines(): void;
  92869. /**
  92870. * Checks wether or not the edges renderer is ready to render.
  92871. * @return true if ready, otherwise false.
  92872. */
  92873. isReady(): boolean;
  92874. /**
  92875. * Renders the edges of the attached mesh,
  92876. */
  92877. render(): void;
  92878. }
  92879. /**
  92880. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92881. */
  92882. export class LineEdgesRenderer extends EdgesRenderer {
  92883. /**
  92884. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92885. * @param source LineMesh used to generate edges
  92886. * @param epsilon not important (specified angle for edge detection)
  92887. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92888. */
  92889. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92890. /**
  92891. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92892. */
  92893. _generateEdgesLines(): void;
  92894. }
  92895. }
  92896. declare module BABYLON {
  92897. /**
  92898. * This represents the object necessary to create a rendering group.
  92899. * This is exclusively used and created by the rendering manager.
  92900. * To modify the behavior, you use the available helpers in your scene or meshes.
  92901. * @hidden
  92902. */
  92903. export class RenderingGroup {
  92904. index: number;
  92905. private static _zeroVector;
  92906. private _scene;
  92907. private _opaqueSubMeshes;
  92908. private _transparentSubMeshes;
  92909. private _alphaTestSubMeshes;
  92910. private _depthOnlySubMeshes;
  92911. private _particleSystems;
  92912. private _spriteManagers;
  92913. private _opaqueSortCompareFn;
  92914. private _alphaTestSortCompareFn;
  92915. private _transparentSortCompareFn;
  92916. private _renderOpaque;
  92917. private _renderAlphaTest;
  92918. private _renderTransparent;
  92919. /** @hidden */
  92920. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92921. onBeforeTransparentRendering: () => void;
  92922. /**
  92923. * Set the opaque sort comparison function.
  92924. * If null the sub meshes will be render in the order they were created
  92925. */
  92926. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92927. /**
  92928. * Set the alpha test sort comparison function.
  92929. * If null the sub meshes will be render in the order they were created
  92930. */
  92931. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92932. /**
  92933. * Set the transparent sort comparison function.
  92934. * If null the sub meshes will be render in the order they were created
  92935. */
  92936. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92937. /**
  92938. * Creates a new rendering group.
  92939. * @param index The rendering group index
  92940. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92941. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92942. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92943. */
  92944. 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>);
  92945. /**
  92946. * Render all the sub meshes contained in the group.
  92947. * @param customRenderFunction Used to override the default render behaviour of the group.
  92948. * @returns true if rendered some submeshes.
  92949. */
  92950. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92951. /**
  92952. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92953. * @param subMeshes The submeshes to render
  92954. */
  92955. private renderOpaqueSorted;
  92956. /**
  92957. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92958. * @param subMeshes The submeshes to render
  92959. */
  92960. private renderAlphaTestSorted;
  92961. /**
  92962. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92963. * @param subMeshes The submeshes to render
  92964. */
  92965. private renderTransparentSorted;
  92966. /**
  92967. * Renders the submeshes in a specified order.
  92968. * @param subMeshes The submeshes to sort before render
  92969. * @param sortCompareFn The comparison function use to sort
  92970. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92971. * @param transparent Specifies to activate blending if true
  92972. */
  92973. private static renderSorted;
  92974. /**
  92975. * Renders the submeshes in the order they were dispatched (no sort applied).
  92976. * @param subMeshes The submeshes to render
  92977. */
  92978. private static renderUnsorted;
  92979. /**
  92980. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92981. * are rendered back to front if in the same alpha index.
  92982. *
  92983. * @param a The first submesh
  92984. * @param b The second submesh
  92985. * @returns The result of the comparison
  92986. */
  92987. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92988. /**
  92989. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92990. * are rendered back to front.
  92991. *
  92992. * @param a The first submesh
  92993. * @param b The second submesh
  92994. * @returns The result of the comparison
  92995. */
  92996. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92997. /**
  92998. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92999. * are rendered front to back (prevent overdraw).
  93000. *
  93001. * @param a The first submesh
  93002. * @param b The second submesh
  93003. * @returns The result of the comparison
  93004. */
  93005. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  93006. /**
  93007. * Resets the different lists of submeshes to prepare a new frame.
  93008. */
  93009. prepare(): void;
  93010. dispose(): void;
  93011. /**
  93012. * Inserts the submesh in its correct queue depending on its material.
  93013. * @param subMesh The submesh to dispatch
  93014. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  93015. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  93016. */
  93017. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  93018. dispatchSprites(spriteManager: ISpriteManager): void;
  93019. dispatchParticles(particleSystem: IParticleSystem): void;
  93020. private _renderParticles;
  93021. private _renderSprites;
  93022. }
  93023. }
  93024. declare module BABYLON {
  93025. /**
  93026. * Interface describing the different options available in the rendering manager
  93027. * regarding Auto Clear between groups.
  93028. */
  93029. export interface IRenderingManagerAutoClearSetup {
  93030. /**
  93031. * Defines whether or not autoclear is enable.
  93032. */
  93033. autoClear: boolean;
  93034. /**
  93035. * Defines whether or not to autoclear the depth buffer.
  93036. */
  93037. depth: boolean;
  93038. /**
  93039. * Defines whether or not to autoclear the stencil buffer.
  93040. */
  93041. stencil: boolean;
  93042. }
  93043. /**
  93044. * This class is used by the onRenderingGroupObservable
  93045. */
  93046. export class RenderingGroupInfo {
  93047. /**
  93048. * The Scene that being rendered
  93049. */
  93050. scene: Scene;
  93051. /**
  93052. * The camera currently used for the rendering pass
  93053. */
  93054. camera: Nullable<Camera>;
  93055. /**
  93056. * The ID of the renderingGroup being processed
  93057. */
  93058. renderingGroupId: number;
  93059. }
  93060. /**
  93061. * This is the manager responsible of all the rendering for meshes sprites and particles.
  93062. * It is enable to manage the different groups as well as the different necessary sort functions.
  93063. * This should not be used directly aside of the few static configurations
  93064. */
  93065. export class RenderingManager {
  93066. /**
  93067. * The max id used for rendering groups (not included)
  93068. */
  93069. static MAX_RENDERINGGROUPS: number;
  93070. /**
  93071. * The min id used for rendering groups (included)
  93072. */
  93073. static MIN_RENDERINGGROUPS: number;
  93074. /**
  93075. * Used to globally prevent autoclearing scenes.
  93076. */
  93077. static AUTOCLEAR: boolean;
  93078. /**
  93079. * @hidden
  93080. */
  93081. _useSceneAutoClearSetup: boolean;
  93082. private _scene;
  93083. private _renderingGroups;
  93084. private _depthStencilBufferAlreadyCleaned;
  93085. private _autoClearDepthStencil;
  93086. private _customOpaqueSortCompareFn;
  93087. private _customAlphaTestSortCompareFn;
  93088. private _customTransparentSortCompareFn;
  93089. private _renderingGroupInfo;
  93090. /**
  93091. * Instantiates a new rendering group for a particular scene
  93092. * @param scene Defines the scene the groups belongs to
  93093. */
  93094. constructor(scene: Scene);
  93095. private _clearDepthStencilBuffer;
  93096. /**
  93097. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  93098. * @hidden
  93099. */
  93100. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  93101. /**
  93102. * Resets the different information of the group to prepare a new frame
  93103. * @hidden
  93104. */
  93105. reset(): void;
  93106. /**
  93107. * Dispose and release the group and its associated resources.
  93108. * @hidden
  93109. */
  93110. dispose(): void;
  93111. /**
  93112. * Clear the info related to rendering groups preventing retention points during dispose.
  93113. */
  93114. freeRenderingGroups(): void;
  93115. private _prepareRenderingGroup;
  93116. /**
  93117. * Add a sprite manager to the rendering manager in order to render it this frame.
  93118. * @param spriteManager Define the sprite manager to render
  93119. */
  93120. dispatchSprites(spriteManager: ISpriteManager): void;
  93121. /**
  93122. * Add a particle system to the rendering manager in order to render it this frame.
  93123. * @param particleSystem Define the particle system to render
  93124. */
  93125. dispatchParticles(particleSystem: IParticleSystem): void;
  93126. /**
  93127. * Add a submesh to the manager in order to render it this frame
  93128. * @param subMesh The submesh to dispatch
  93129. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  93130. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  93131. */
  93132. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  93133. /**
  93134. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93135. * This allowed control for front to back rendering or reversly depending of the special needs.
  93136. *
  93137. * @param renderingGroupId The rendering group id corresponding to its index
  93138. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93139. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93140. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93141. */
  93142. 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;
  93143. /**
  93144. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93145. *
  93146. * @param renderingGroupId The rendering group id corresponding to its index
  93147. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93148. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93149. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93150. */
  93151. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93152. /**
  93153. * Gets the current auto clear configuration for one rendering group of the rendering
  93154. * manager.
  93155. * @param index the rendering group index to get the information for
  93156. * @returns The auto clear setup for the requested rendering group
  93157. */
  93158. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93159. }
  93160. }
  93161. declare module BABYLON {
  93162. /**
  93163. * This Helps creating a texture that will be created from a camera in your scene.
  93164. * It is basically a dynamic texture that could be used to create special effects for instance.
  93165. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93166. */
  93167. export class RenderTargetTexture extends Texture {
  93168. isCube: boolean;
  93169. /**
  93170. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93171. */
  93172. static readonly REFRESHRATE_RENDER_ONCE: number;
  93173. /**
  93174. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93175. */
  93176. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93177. /**
  93178. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93179. * the central point of your effect and can save a lot of performances.
  93180. */
  93181. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93182. /**
  93183. * Use this predicate to dynamically define the list of mesh you want to render.
  93184. * If set, the renderList property will be overwritten.
  93185. */
  93186. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93187. private _renderList;
  93188. /**
  93189. * Use this list to define the list of mesh you want to render.
  93190. */
  93191. get renderList(): Nullable<Array<AbstractMesh>>;
  93192. set renderList(value: Nullable<Array<AbstractMesh>>);
  93193. /**
  93194. * Use this function to overload the renderList array at rendering time.
  93195. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93196. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93197. * the cube (if the RTT is a cube, else layerOrFace=0).
  93198. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93199. */
  93200. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93201. private _hookArray;
  93202. /**
  93203. * Define if particles should be rendered in your texture.
  93204. */
  93205. renderParticles: boolean;
  93206. /**
  93207. * Define if sprites should be rendered in your texture.
  93208. */
  93209. renderSprites: boolean;
  93210. /**
  93211. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93212. */
  93213. coordinatesMode: number;
  93214. /**
  93215. * Define the camera used to render the texture.
  93216. */
  93217. activeCamera: Nullable<Camera>;
  93218. /**
  93219. * Override the render function of the texture with your own one.
  93220. */
  93221. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93222. /**
  93223. * Define if camera post processes should be use while rendering the texture.
  93224. */
  93225. useCameraPostProcesses: boolean;
  93226. /**
  93227. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93228. */
  93229. ignoreCameraViewport: boolean;
  93230. private _postProcessManager;
  93231. private _postProcesses;
  93232. private _resizeObserver;
  93233. /**
  93234. * An event triggered when the texture is unbind.
  93235. */
  93236. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93237. /**
  93238. * An event triggered when the texture is unbind.
  93239. */
  93240. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93241. private _onAfterUnbindObserver;
  93242. /**
  93243. * Set a after unbind callback in the texture.
  93244. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93245. */
  93246. set onAfterUnbind(callback: () => void);
  93247. /**
  93248. * An event triggered before rendering the texture
  93249. */
  93250. onBeforeRenderObservable: Observable<number>;
  93251. private _onBeforeRenderObserver;
  93252. /**
  93253. * Set a before render callback in the texture.
  93254. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93255. */
  93256. set onBeforeRender(callback: (faceIndex: number) => void);
  93257. /**
  93258. * An event triggered after rendering the texture
  93259. */
  93260. onAfterRenderObservable: Observable<number>;
  93261. private _onAfterRenderObserver;
  93262. /**
  93263. * Set a after render callback in the texture.
  93264. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93265. */
  93266. set onAfterRender(callback: (faceIndex: number) => void);
  93267. /**
  93268. * An event triggered after the texture clear
  93269. */
  93270. onClearObservable: Observable<Engine>;
  93271. private _onClearObserver;
  93272. /**
  93273. * Set a clear callback in the texture.
  93274. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93275. */
  93276. set onClear(callback: (Engine: Engine) => void);
  93277. /**
  93278. * An event triggered when the texture is resized.
  93279. */
  93280. onResizeObservable: Observable<RenderTargetTexture>;
  93281. /**
  93282. * Define the clear color of the Render Target if it should be different from the scene.
  93283. */
  93284. clearColor: Color4;
  93285. protected _size: number | {
  93286. width: number;
  93287. height: number;
  93288. layers?: number;
  93289. };
  93290. protected _initialSizeParameter: number | {
  93291. width: number;
  93292. height: number;
  93293. } | {
  93294. ratio: number;
  93295. };
  93296. protected _sizeRatio: Nullable<number>;
  93297. /** @hidden */
  93298. _generateMipMaps: boolean;
  93299. protected _renderingManager: RenderingManager;
  93300. /** @hidden */
  93301. _waitingRenderList: string[];
  93302. protected _doNotChangeAspectRatio: boolean;
  93303. protected _currentRefreshId: number;
  93304. protected _refreshRate: number;
  93305. protected _textureMatrix: Matrix;
  93306. protected _samples: number;
  93307. protected _renderTargetOptions: RenderTargetCreationOptions;
  93308. /**
  93309. * Gets render target creation options that were used.
  93310. */
  93311. get renderTargetOptions(): RenderTargetCreationOptions;
  93312. protected _engine: Engine;
  93313. protected _onRatioRescale(): void;
  93314. /**
  93315. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93316. * It must define where the camera used to render the texture is set
  93317. */
  93318. boundingBoxPosition: Vector3;
  93319. private _boundingBoxSize;
  93320. /**
  93321. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93322. * When defined, the cubemap will switch to local mode
  93323. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93324. * @example https://www.babylonjs-playground.com/#RNASML
  93325. */
  93326. set boundingBoxSize(value: Vector3);
  93327. get boundingBoxSize(): Vector3;
  93328. /**
  93329. * In case the RTT has been created with a depth texture, get the associated
  93330. * depth texture.
  93331. * Otherwise, return null.
  93332. */
  93333. get depthStencilTexture(): Nullable<InternalTexture>;
  93334. /**
  93335. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93336. * or used a shadow, depth texture...
  93337. * @param name The friendly name of the texture
  93338. * @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)
  93339. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93340. * @param generateMipMaps True if mip maps need to be generated after render.
  93341. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93342. * @param type The type of the buffer in the RTT (int, half float, float...)
  93343. * @param isCube True if a cube texture needs to be created
  93344. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93345. * @param generateDepthBuffer True to generate a depth buffer
  93346. * @param generateStencilBuffer True to generate a stencil buffer
  93347. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93348. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93349. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93350. */
  93351. constructor(name: string, size: number | {
  93352. width: number;
  93353. height: number;
  93354. layers?: number;
  93355. } | {
  93356. ratio: number;
  93357. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93358. /**
  93359. * Creates a depth stencil texture.
  93360. * This is only available in WebGL 2 or with the depth texture extension available.
  93361. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93362. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93363. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93364. */
  93365. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93366. private _processSizeParameter;
  93367. /**
  93368. * Define the number of samples to use in case of MSAA.
  93369. * It defaults to one meaning no MSAA has been enabled.
  93370. */
  93371. get samples(): number;
  93372. set samples(value: number);
  93373. /**
  93374. * Resets the refresh counter of the texture and start bak from scratch.
  93375. * Could be useful to regenerate the texture if it is setup to render only once.
  93376. */
  93377. resetRefreshCounter(): void;
  93378. /**
  93379. * Define the refresh rate of the texture or the rendering frequency.
  93380. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93381. */
  93382. get refreshRate(): number;
  93383. set refreshRate(value: number);
  93384. /**
  93385. * Adds a post process to the render target rendering passes.
  93386. * @param postProcess define the post process to add
  93387. */
  93388. addPostProcess(postProcess: PostProcess): void;
  93389. /**
  93390. * Clear all the post processes attached to the render target
  93391. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93392. */
  93393. clearPostProcesses(dispose?: boolean): void;
  93394. /**
  93395. * Remove one of the post process from the list of attached post processes to the texture
  93396. * @param postProcess define the post process to remove from the list
  93397. */
  93398. removePostProcess(postProcess: PostProcess): void;
  93399. /** @hidden */
  93400. _shouldRender(): boolean;
  93401. /**
  93402. * Gets the actual render size of the texture.
  93403. * @returns the width of the render size
  93404. */
  93405. getRenderSize(): number;
  93406. /**
  93407. * Gets the actual render width of the texture.
  93408. * @returns the width of the render size
  93409. */
  93410. getRenderWidth(): number;
  93411. /**
  93412. * Gets the actual render height of the texture.
  93413. * @returns the height of the render size
  93414. */
  93415. getRenderHeight(): number;
  93416. /**
  93417. * Gets the actual number of layers of the texture.
  93418. * @returns the number of layers
  93419. */
  93420. getRenderLayers(): number;
  93421. /**
  93422. * Get if the texture can be rescaled or not.
  93423. */
  93424. get canRescale(): boolean;
  93425. /**
  93426. * Resize the texture using a ratio.
  93427. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93428. */
  93429. scale(ratio: number): void;
  93430. /**
  93431. * Get the texture reflection matrix used to rotate/transform the reflection.
  93432. * @returns the reflection matrix
  93433. */
  93434. getReflectionTextureMatrix(): Matrix;
  93435. /**
  93436. * Resize the texture to a new desired size.
  93437. * Be carrefull as it will recreate all the data in the new texture.
  93438. * @param size Define the new size. It can be:
  93439. * - a number for squared texture,
  93440. * - an object containing { width: number, height: number }
  93441. * - or an object containing a ratio { ratio: number }
  93442. */
  93443. resize(size: number | {
  93444. width: number;
  93445. height: number;
  93446. } | {
  93447. ratio: number;
  93448. }): void;
  93449. private _defaultRenderListPrepared;
  93450. /**
  93451. * Renders all the objects from the render list into the texture.
  93452. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93453. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93454. */
  93455. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93456. private _bestReflectionRenderTargetDimension;
  93457. private _prepareRenderingManager;
  93458. /**
  93459. * @hidden
  93460. * @param faceIndex face index to bind to if this is a cubetexture
  93461. * @param layer defines the index of the texture to bind in the array
  93462. */
  93463. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93464. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93465. private renderToTarget;
  93466. /**
  93467. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93468. * This allowed control for front to back rendering or reversly depending of the special needs.
  93469. *
  93470. * @param renderingGroupId The rendering group id corresponding to its index
  93471. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93472. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93473. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93474. */
  93475. 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;
  93476. /**
  93477. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93478. *
  93479. * @param renderingGroupId The rendering group id corresponding to its index
  93480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93481. */
  93482. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93483. /**
  93484. * Clones the texture.
  93485. * @returns the cloned texture
  93486. */
  93487. clone(): RenderTargetTexture;
  93488. /**
  93489. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93490. * @returns The JSON representation of the texture
  93491. */
  93492. serialize(): any;
  93493. /**
  93494. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93495. */
  93496. disposeFramebufferObjects(): void;
  93497. /**
  93498. * Dispose the texture and release its associated resources.
  93499. */
  93500. dispose(): void;
  93501. /** @hidden */
  93502. _rebuild(): void;
  93503. /**
  93504. * Clear the info related to rendering groups preventing retention point in material dispose.
  93505. */
  93506. freeRenderingGroups(): void;
  93507. /**
  93508. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93509. * @returns the view count
  93510. */
  93511. getViewCount(): number;
  93512. }
  93513. }
  93514. declare module BABYLON {
  93515. /**
  93516. * Options for compiling materials.
  93517. */
  93518. export interface IMaterialCompilationOptions {
  93519. /**
  93520. * Defines whether clip planes are enabled.
  93521. */
  93522. clipPlane: boolean;
  93523. /**
  93524. * Defines whether instances are enabled.
  93525. */
  93526. useInstances: boolean;
  93527. }
  93528. /**
  93529. * Base class for the main features of a material in Babylon.js
  93530. */
  93531. export class Material implements IAnimatable {
  93532. /**
  93533. * Returns the triangle fill mode
  93534. */
  93535. static readonly TriangleFillMode: number;
  93536. /**
  93537. * Returns the wireframe mode
  93538. */
  93539. static readonly WireFrameFillMode: number;
  93540. /**
  93541. * Returns the point fill mode
  93542. */
  93543. static readonly PointFillMode: number;
  93544. /**
  93545. * Returns the point list draw mode
  93546. */
  93547. static readonly PointListDrawMode: number;
  93548. /**
  93549. * Returns the line list draw mode
  93550. */
  93551. static readonly LineListDrawMode: number;
  93552. /**
  93553. * Returns the line loop draw mode
  93554. */
  93555. static readonly LineLoopDrawMode: number;
  93556. /**
  93557. * Returns the line strip draw mode
  93558. */
  93559. static readonly LineStripDrawMode: number;
  93560. /**
  93561. * Returns the triangle strip draw mode
  93562. */
  93563. static readonly TriangleStripDrawMode: number;
  93564. /**
  93565. * Returns the triangle fan draw mode
  93566. */
  93567. static readonly TriangleFanDrawMode: number;
  93568. /**
  93569. * Stores the clock-wise side orientation
  93570. */
  93571. static readonly ClockWiseSideOrientation: number;
  93572. /**
  93573. * Stores the counter clock-wise side orientation
  93574. */
  93575. static readonly CounterClockWiseSideOrientation: number;
  93576. /**
  93577. * The dirty texture flag value
  93578. */
  93579. static readonly TextureDirtyFlag: number;
  93580. /**
  93581. * The dirty light flag value
  93582. */
  93583. static readonly LightDirtyFlag: number;
  93584. /**
  93585. * The dirty fresnel flag value
  93586. */
  93587. static readonly FresnelDirtyFlag: number;
  93588. /**
  93589. * The dirty attribute flag value
  93590. */
  93591. static readonly AttributesDirtyFlag: number;
  93592. /**
  93593. * The dirty misc flag value
  93594. */
  93595. static readonly MiscDirtyFlag: number;
  93596. /**
  93597. * The all dirty flag value
  93598. */
  93599. static readonly AllDirtyFlag: number;
  93600. /**
  93601. * The ID of the material
  93602. */
  93603. id: string;
  93604. /**
  93605. * Gets or sets the unique id of the material
  93606. */
  93607. uniqueId: number;
  93608. /**
  93609. * The name of the material
  93610. */
  93611. name: string;
  93612. /**
  93613. * Gets or sets user defined metadata
  93614. */
  93615. metadata: any;
  93616. /**
  93617. * For internal use only. Please do not use.
  93618. */
  93619. reservedDataStore: any;
  93620. /**
  93621. * Specifies if the ready state should be checked on each call
  93622. */
  93623. checkReadyOnEveryCall: boolean;
  93624. /**
  93625. * Specifies if the ready state should be checked once
  93626. */
  93627. checkReadyOnlyOnce: boolean;
  93628. /**
  93629. * The state of the material
  93630. */
  93631. state: string;
  93632. /**
  93633. * The alpha value of the material
  93634. */
  93635. protected _alpha: number;
  93636. /**
  93637. * List of inspectable custom properties (used by the Inspector)
  93638. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93639. */
  93640. inspectableCustomProperties: IInspectable[];
  93641. /**
  93642. * Sets the alpha value of the material
  93643. */
  93644. set alpha(value: number);
  93645. /**
  93646. * Gets the alpha value of the material
  93647. */
  93648. get alpha(): number;
  93649. /**
  93650. * Specifies if back face culling is enabled
  93651. */
  93652. protected _backFaceCulling: boolean;
  93653. /**
  93654. * Sets the back-face culling state
  93655. */
  93656. set backFaceCulling(value: boolean);
  93657. /**
  93658. * Gets the back-face culling state
  93659. */
  93660. get backFaceCulling(): boolean;
  93661. /**
  93662. * Stores the value for side orientation
  93663. */
  93664. sideOrientation: number;
  93665. /**
  93666. * Callback triggered when the material is compiled
  93667. */
  93668. onCompiled: Nullable<(effect: Effect) => void>;
  93669. /**
  93670. * Callback triggered when an error occurs
  93671. */
  93672. onError: Nullable<(effect: Effect, errors: string) => void>;
  93673. /**
  93674. * Callback triggered to get the render target textures
  93675. */
  93676. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  93677. /**
  93678. * Gets a boolean indicating that current material needs to register RTT
  93679. */
  93680. get hasRenderTargetTextures(): boolean;
  93681. /**
  93682. * Specifies if the material should be serialized
  93683. */
  93684. doNotSerialize: boolean;
  93685. /**
  93686. * @hidden
  93687. */
  93688. _storeEffectOnSubMeshes: boolean;
  93689. /**
  93690. * Stores the animations for the material
  93691. */
  93692. animations: Nullable<Array<Animation>>;
  93693. /**
  93694. * An event triggered when the material is disposed
  93695. */
  93696. onDisposeObservable: Observable<Material>;
  93697. /**
  93698. * An observer which watches for dispose events
  93699. */
  93700. private _onDisposeObserver;
  93701. private _onUnBindObservable;
  93702. /**
  93703. * Called during a dispose event
  93704. */
  93705. set onDispose(callback: () => void);
  93706. private _onBindObservable;
  93707. /**
  93708. * An event triggered when the material is bound
  93709. */
  93710. get onBindObservable(): Observable<AbstractMesh>;
  93711. /**
  93712. * An observer which watches for bind events
  93713. */
  93714. private _onBindObserver;
  93715. /**
  93716. * Called during a bind event
  93717. */
  93718. set onBind(callback: (Mesh: AbstractMesh) => void);
  93719. /**
  93720. * An event triggered when the material is unbound
  93721. */
  93722. get onUnBindObservable(): Observable<Material>;
  93723. /**
  93724. * Stores the value of the alpha mode
  93725. */
  93726. private _alphaMode;
  93727. /**
  93728. * Sets the value of the alpha mode.
  93729. *
  93730. * | Value | Type | Description |
  93731. * | --- | --- | --- |
  93732. * | 0 | ALPHA_DISABLE | |
  93733. * | 1 | ALPHA_ADD | |
  93734. * | 2 | ALPHA_COMBINE | |
  93735. * | 3 | ALPHA_SUBTRACT | |
  93736. * | 4 | ALPHA_MULTIPLY | |
  93737. * | 5 | ALPHA_MAXIMIZED | |
  93738. * | 6 | ALPHA_ONEONE | |
  93739. * | 7 | ALPHA_PREMULTIPLIED | |
  93740. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  93741. * | 9 | ALPHA_INTERPOLATE | |
  93742. * | 10 | ALPHA_SCREENMODE | |
  93743. *
  93744. */
  93745. set alphaMode(value: number);
  93746. /**
  93747. * Gets the value of the alpha mode
  93748. */
  93749. get alphaMode(): number;
  93750. /**
  93751. * Stores the state of the need depth pre-pass value
  93752. */
  93753. private _needDepthPrePass;
  93754. /**
  93755. * Sets the need depth pre-pass value
  93756. */
  93757. set needDepthPrePass(value: boolean);
  93758. /**
  93759. * Gets the depth pre-pass value
  93760. */
  93761. get needDepthPrePass(): boolean;
  93762. /**
  93763. * Specifies if depth writing should be disabled
  93764. */
  93765. disableDepthWrite: boolean;
  93766. /**
  93767. * Specifies if depth writing should be forced
  93768. */
  93769. forceDepthWrite: boolean;
  93770. /**
  93771. * Specifies the depth function that should be used. 0 means the default engine function
  93772. */
  93773. depthFunction: number;
  93774. /**
  93775. * Specifies if there should be a separate pass for culling
  93776. */
  93777. separateCullingPass: boolean;
  93778. /**
  93779. * Stores the state specifing if fog should be enabled
  93780. */
  93781. private _fogEnabled;
  93782. /**
  93783. * Sets the state for enabling fog
  93784. */
  93785. set fogEnabled(value: boolean);
  93786. /**
  93787. * Gets the value of the fog enabled state
  93788. */
  93789. get fogEnabled(): boolean;
  93790. /**
  93791. * Stores the size of points
  93792. */
  93793. pointSize: number;
  93794. /**
  93795. * Stores the z offset value
  93796. */
  93797. zOffset: number;
  93798. /**
  93799. * Gets a value specifying if wireframe mode is enabled
  93800. */
  93801. get wireframe(): boolean;
  93802. /**
  93803. * Sets the state of wireframe mode
  93804. */
  93805. set wireframe(value: boolean);
  93806. /**
  93807. * Gets the value specifying if point clouds are enabled
  93808. */
  93809. get pointsCloud(): boolean;
  93810. /**
  93811. * Sets the state of point cloud mode
  93812. */
  93813. set pointsCloud(value: boolean);
  93814. /**
  93815. * Gets the material fill mode
  93816. */
  93817. get fillMode(): number;
  93818. /**
  93819. * Sets the material fill mode
  93820. */
  93821. set fillMode(value: number);
  93822. /**
  93823. * @hidden
  93824. * Stores the effects for the material
  93825. */
  93826. _effect: Nullable<Effect>;
  93827. /**
  93828. * Specifies if uniform buffers should be used
  93829. */
  93830. private _useUBO;
  93831. /**
  93832. * Stores a reference to the scene
  93833. */
  93834. private _scene;
  93835. /**
  93836. * Stores the fill mode state
  93837. */
  93838. private _fillMode;
  93839. /**
  93840. * Specifies if the depth write state should be cached
  93841. */
  93842. private _cachedDepthWriteState;
  93843. /**
  93844. * Specifies if the depth function state should be cached
  93845. */
  93846. private _cachedDepthFunctionState;
  93847. /**
  93848. * Stores the uniform buffer
  93849. */
  93850. protected _uniformBuffer: UniformBuffer;
  93851. /** @hidden */
  93852. _indexInSceneMaterialArray: number;
  93853. /** @hidden */
  93854. meshMap: Nullable<{
  93855. [id: string]: AbstractMesh | undefined;
  93856. }>;
  93857. /**
  93858. * Creates a material instance
  93859. * @param name defines the name of the material
  93860. * @param scene defines the scene to reference
  93861. * @param doNotAdd specifies if the material should be added to the scene
  93862. */
  93863. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  93864. /**
  93865. * Returns a string representation of the current material
  93866. * @param fullDetails defines a boolean indicating which levels of logging is desired
  93867. * @returns a string with material information
  93868. */
  93869. toString(fullDetails?: boolean): string;
  93870. /**
  93871. * Gets the class name of the material
  93872. * @returns a string with the class name of the material
  93873. */
  93874. getClassName(): string;
  93875. /**
  93876. * Specifies if updates for the material been locked
  93877. */
  93878. get isFrozen(): boolean;
  93879. /**
  93880. * Locks updates for the material
  93881. */
  93882. freeze(): void;
  93883. /**
  93884. * Unlocks updates for the material
  93885. */
  93886. unfreeze(): void;
  93887. /**
  93888. * Specifies if the material is ready to be used
  93889. * @param mesh defines the mesh to check
  93890. * @param useInstances specifies if instances should be used
  93891. * @returns a boolean indicating if the material is ready to be used
  93892. */
  93893. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93894. /**
  93895. * Specifies that the submesh is ready to be used
  93896. * @param mesh defines the mesh to check
  93897. * @param subMesh defines which submesh to check
  93898. * @param useInstances specifies that instances should be used
  93899. * @returns a boolean indicating that the submesh is ready or not
  93900. */
  93901. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93902. /**
  93903. * Returns the material effect
  93904. * @returns the effect associated with the material
  93905. */
  93906. getEffect(): Nullable<Effect>;
  93907. /**
  93908. * Returns the current scene
  93909. * @returns a Scene
  93910. */
  93911. getScene(): Scene;
  93912. /**
  93913. * Specifies if the material will require alpha blending
  93914. * @returns a boolean specifying if alpha blending is needed
  93915. */
  93916. needAlphaBlending(): boolean;
  93917. /**
  93918. * Specifies if the mesh will require alpha blending
  93919. * @param mesh defines the mesh to check
  93920. * @returns a boolean specifying if alpha blending is needed for the mesh
  93921. */
  93922. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  93923. /**
  93924. * Specifies if this material should be rendered in alpha test mode
  93925. * @returns a boolean specifying if an alpha test is needed.
  93926. */
  93927. needAlphaTesting(): boolean;
  93928. /**
  93929. * Gets the texture used for the alpha test
  93930. * @returns the texture to use for alpha testing
  93931. */
  93932. getAlphaTestTexture(): Nullable<BaseTexture>;
  93933. /**
  93934. * Marks the material to indicate that it needs to be re-calculated
  93935. */
  93936. markDirty(): void;
  93937. /** @hidden */
  93938. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  93939. /**
  93940. * Binds the material to the mesh
  93941. * @param world defines the world transformation matrix
  93942. * @param mesh defines the mesh to bind the material to
  93943. */
  93944. bind(world: Matrix, mesh?: Mesh): void;
  93945. /**
  93946. * Binds the submesh to the material
  93947. * @param world defines the world transformation matrix
  93948. * @param mesh defines the mesh containing the submesh
  93949. * @param subMesh defines the submesh to bind the material to
  93950. */
  93951. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93952. /**
  93953. * Binds the world matrix to the material
  93954. * @param world defines the world transformation matrix
  93955. */
  93956. bindOnlyWorldMatrix(world: Matrix): void;
  93957. /**
  93958. * Binds the scene's uniform buffer to the effect.
  93959. * @param effect defines the effect to bind to the scene uniform buffer
  93960. * @param sceneUbo defines the uniform buffer storing scene data
  93961. */
  93962. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  93963. /**
  93964. * Binds the view matrix to the effect
  93965. * @param effect defines the effect to bind the view matrix to
  93966. */
  93967. bindView(effect: Effect): void;
  93968. /**
  93969. * Binds the view projection matrix to the effect
  93970. * @param effect defines the effect to bind the view projection matrix to
  93971. */
  93972. bindViewProjection(effect: Effect): void;
  93973. /**
  93974. * Specifies if material alpha testing should be turned on for the mesh
  93975. * @param mesh defines the mesh to check
  93976. */
  93977. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  93978. /**
  93979. * Processes to execute after binding the material to a mesh
  93980. * @param mesh defines the rendered mesh
  93981. */
  93982. protected _afterBind(mesh?: Mesh): void;
  93983. /**
  93984. * Unbinds the material from the mesh
  93985. */
  93986. unbind(): void;
  93987. /**
  93988. * Gets the active textures from the material
  93989. * @returns an array of textures
  93990. */
  93991. getActiveTextures(): BaseTexture[];
  93992. /**
  93993. * Specifies if the material uses a texture
  93994. * @param texture defines the texture to check against the material
  93995. * @returns a boolean specifying if the material uses the texture
  93996. */
  93997. hasTexture(texture: BaseTexture): boolean;
  93998. /**
  93999. * Makes a duplicate of the material, and gives it a new name
  94000. * @param name defines the new name for the duplicated material
  94001. * @returns the cloned material
  94002. */
  94003. clone(name: string): Nullable<Material>;
  94004. /**
  94005. * Gets the meshes bound to the material
  94006. * @returns an array of meshes bound to the material
  94007. */
  94008. getBindedMeshes(): AbstractMesh[];
  94009. /**
  94010. * Force shader compilation
  94011. * @param mesh defines the mesh associated with this material
  94012. * @param onCompiled defines a function to execute once the material is compiled
  94013. * @param options defines the options to configure the compilation
  94014. * @param onError defines a function to execute if the material fails compiling
  94015. */
  94016. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94017. /**
  94018. * Force shader compilation
  94019. * @param mesh defines the mesh that will use this material
  94020. * @param options defines additional options for compiling the shaders
  94021. * @returns a promise that resolves when the compilation completes
  94022. */
  94023. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94024. private static readonly _AllDirtyCallBack;
  94025. private static readonly _ImageProcessingDirtyCallBack;
  94026. private static readonly _TextureDirtyCallBack;
  94027. private static readonly _FresnelDirtyCallBack;
  94028. private static readonly _MiscDirtyCallBack;
  94029. private static readonly _LightsDirtyCallBack;
  94030. private static readonly _AttributeDirtyCallBack;
  94031. private static _FresnelAndMiscDirtyCallBack;
  94032. private static _TextureAndMiscDirtyCallBack;
  94033. private static readonly _DirtyCallbackArray;
  94034. private static readonly _RunDirtyCallBacks;
  94035. /**
  94036. * Marks a define in the material to indicate that it needs to be re-computed
  94037. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94038. */
  94039. markAsDirty(flag: number): void;
  94040. /**
  94041. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94042. * @param func defines a function which checks material defines against the submeshes
  94043. */
  94044. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94045. /**
  94046. * Indicates that we need to re-calculated for all submeshes
  94047. */
  94048. protected _markAllSubMeshesAsAllDirty(): void;
  94049. /**
  94050. * Indicates that image processing needs to be re-calculated for all submeshes
  94051. */
  94052. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94053. /**
  94054. * Indicates that textures need to be re-calculated for all submeshes
  94055. */
  94056. protected _markAllSubMeshesAsTexturesDirty(): void;
  94057. /**
  94058. * Indicates that fresnel needs to be re-calculated for all submeshes
  94059. */
  94060. protected _markAllSubMeshesAsFresnelDirty(): void;
  94061. /**
  94062. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94063. */
  94064. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94065. /**
  94066. * Indicates that lights need to be re-calculated for all submeshes
  94067. */
  94068. protected _markAllSubMeshesAsLightsDirty(): void;
  94069. /**
  94070. * Indicates that attributes need to be re-calculated for all submeshes
  94071. */
  94072. protected _markAllSubMeshesAsAttributesDirty(): void;
  94073. /**
  94074. * Indicates that misc needs to be re-calculated for all submeshes
  94075. */
  94076. protected _markAllSubMeshesAsMiscDirty(): void;
  94077. /**
  94078. * Indicates that textures and misc need to be re-calculated for all submeshes
  94079. */
  94080. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94081. /**
  94082. * Disposes the material
  94083. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94084. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94085. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94086. */
  94087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94088. /** @hidden */
  94089. private releaseVertexArrayObject;
  94090. /**
  94091. * Serializes this material
  94092. * @returns the serialized material object
  94093. */
  94094. serialize(): any;
  94095. /**
  94096. * Creates a material from parsed material data
  94097. * @param parsedMaterial defines parsed material data
  94098. * @param scene defines the hosting scene
  94099. * @param rootUrl defines the root URL to use to load textures
  94100. * @returns a new material
  94101. */
  94102. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94103. }
  94104. }
  94105. declare module BABYLON {
  94106. /**
  94107. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94108. * separate meshes. This can be use to improve performances.
  94109. * @see http://doc.babylonjs.com/how_to/multi_materials
  94110. */
  94111. export class MultiMaterial extends Material {
  94112. private _subMaterials;
  94113. /**
  94114. * Gets or Sets the list of Materials used within the multi material.
  94115. * They need to be ordered according to the submeshes order in the associated mesh
  94116. */
  94117. get subMaterials(): Nullable<Material>[];
  94118. set subMaterials(value: Nullable<Material>[]);
  94119. /**
  94120. * Function used to align with Node.getChildren()
  94121. * @returns the list of Materials used within the multi material
  94122. */
  94123. getChildren(): Nullable<Material>[];
  94124. /**
  94125. * Instantiates a new Multi Material
  94126. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94127. * separate meshes. This can be use to improve performances.
  94128. * @see http://doc.babylonjs.com/how_to/multi_materials
  94129. * @param name Define the name in the scene
  94130. * @param scene Define the scene the material belongs to
  94131. */
  94132. constructor(name: string, scene: Scene);
  94133. private _hookArray;
  94134. /**
  94135. * Get one of the submaterial by its index in the submaterials array
  94136. * @param index The index to look the sub material at
  94137. * @returns The Material if the index has been defined
  94138. */
  94139. getSubMaterial(index: number): Nullable<Material>;
  94140. /**
  94141. * Get the list of active textures for the whole sub materials list.
  94142. * @returns All the textures that will be used during the rendering
  94143. */
  94144. getActiveTextures(): BaseTexture[];
  94145. /**
  94146. * Gets the current class name of the material e.g. "MultiMaterial"
  94147. * Mainly use in serialization.
  94148. * @returns the class name
  94149. */
  94150. getClassName(): string;
  94151. /**
  94152. * Checks if the material is ready to render the requested sub mesh
  94153. * @param mesh Define the mesh the submesh belongs to
  94154. * @param subMesh Define the sub mesh to look readyness for
  94155. * @param useInstances Define whether or not the material is used with instances
  94156. * @returns true if ready, otherwise false
  94157. */
  94158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94159. /**
  94160. * Clones the current material and its related sub materials
  94161. * @param name Define the name of the newly cloned material
  94162. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94163. * @returns the cloned material
  94164. */
  94165. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94166. /**
  94167. * Serializes the materials into a JSON representation.
  94168. * @returns the JSON representation
  94169. */
  94170. serialize(): any;
  94171. /**
  94172. * Dispose the material and release its associated resources
  94173. * @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)
  94174. * @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)
  94175. * @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)
  94176. */
  94177. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94178. /**
  94179. * Creates a MultiMaterial from parsed MultiMaterial data.
  94180. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94181. * @param scene defines the hosting scene
  94182. * @returns a new MultiMaterial
  94183. */
  94184. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94185. }
  94186. }
  94187. declare module BABYLON {
  94188. /**
  94189. * Base class for submeshes
  94190. */
  94191. export class BaseSubMesh {
  94192. /** @hidden */
  94193. _materialDefines: Nullable<MaterialDefines>;
  94194. /** @hidden */
  94195. _materialEffect: Nullable<Effect>;
  94196. /**
  94197. * Gets material defines used by the effect associated to the sub mesh
  94198. */
  94199. get materialDefines(): Nullable<MaterialDefines>;
  94200. /**
  94201. * Sets material defines used by the effect associated to the sub mesh
  94202. */
  94203. set materialDefines(defines: Nullable<MaterialDefines>);
  94204. /**
  94205. * Gets associated effect
  94206. */
  94207. get effect(): Nullable<Effect>;
  94208. /**
  94209. * Sets associated effect (effect used to render this submesh)
  94210. * @param effect defines the effect to associate with
  94211. * @param defines defines the set of defines used to compile this effect
  94212. */
  94213. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94214. }
  94215. /**
  94216. * Defines a subdivision inside a mesh
  94217. */
  94218. export class SubMesh extends BaseSubMesh implements ICullable {
  94219. /** the material index to use */
  94220. materialIndex: number;
  94221. /** vertex index start */
  94222. verticesStart: number;
  94223. /** vertices count */
  94224. verticesCount: number;
  94225. /** index start */
  94226. indexStart: number;
  94227. /** indices count */
  94228. indexCount: number;
  94229. /** @hidden */
  94230. _linesIndexCount: number;
  94231. private _mesh;
  94232. private _renderingMesh;
  94233. private _boundingInfo;
  94234. private _linesIndexBuffer;
  94235. /** @hidden */
  94236. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94237. /** @hidden */
  94238. _trianglePlanes: Plane[];
  94239. /** @hidden */
  94240. _lastColliderTransformMatrix: Nullable<Matrix>;
  94241. /** @hidden */
  94242. _renderId: number;
  94243. /** @hidden */
  94244. _alphaIndex: number;
  94245. /** @hidden */
  94246. _distanceToCamera: number;
  94247. /** @hidden */
  94248. _id: number;
  94249. private _currentMaterial;
  94250. /**
  94251. * Add a new submesh to a mesh
  94252. * @param materialIndex defines the material index to use
  94253. * @param verticesStart defines vertex index start
  94254. * @param verticesCount defines vertices count
  94255. * @param indexStart defines index start
  94256. * @param indexCount defines indices count
  94257. * @param mesh defines the parent mesh
  94258. * @param renderingMesh defines an optional rendering mesh
  94259. * @param createBoundingBox defines if bounding box should be created for this submesh
  94260. * @returns the new submesh
  94261. */
  94262. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94263. /**
  94264. * Creates a new submesh
  94265. * @param materialIndex defines the material index to use
  94266. * @param verticesStart defines vertex index start
  94267. * @param verticesCount defines vertices count
  94268. * @param indexStart defines index start
  94269. * @param indexCount defines indices count
  94270. * @param mesh defines the parent mesh
  94271. * @param renderingMesh defines an optional rendering mesh
  94272. * @param createBoundingBox defines if bounding box should be created for this submesh
  94273. */
  94274. constructor(
  94275. /** the material index to use */
  94276. materialIndex: number,
  94277. /** vertex index start */
  94278. verticesStart: number,
  94279. /** vertices count */
  94280. verticesCount: number,
  94281. /** index start */
  94282. indexStart: number,
  94283. /** indices count */
  94284. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94285. /**
  94286. * Returns true if this submesh covers the entire parent mesh
  94287. * @ignorenaming
  94288. */
  94289. get IsGlobal(): boolean;
  94290. /**
  94291. * Returns the submesh BoudingInfo object
  94292. * @returns current bounding info (or mesh's one if the submesh is global)
  94293. */
  94294. getBoundingInfo(): BoundingInfo;
  94295. /**
  94296. * Sets the submesh BoundingInfo
  94297. * @param boundingInfo defines the new bounding info to use
  94298. * @returns the SubMesh
  94299. */
  94300. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94301. /**
  94302. * Returns the mesh of the current submesh
  94303. * @return the parent mesh
  94304. */
  94305. getMesh(): AbstractMesh;
  94306. /**
  94307. * Returns the rendering mesh of the submesh
  94308. * @returns the rendering mesh (could be different from parent mesh)
  94309. */
  94310. getRenderingMesh(): Mesh;
  94311. /**
  94312. * Returns the submesh material
  94313. * @returns null or the current material
  94314. */
  94315. getMaterial(): Nullable<Material>;
  94316. /**
  94317. * Sets a new updated BoundingInfo object to the submesh
  94318. * @param data defines an optional position array to use to determine the bounding info
  94319. * @returns the SubMesh
  94320. */
  94321. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94322. /** @hidden */
  94323. _checkCollision(collider: Collider): boolean;
  94324. /**
  94325. * Updates the submesh BoundingInfo
  94326. * @param world defines the world matrix to use to update the bounding info
  94327. * @returns the submesh
  94328. */
  94329. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94330. /**
  94331. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94332. * @param frustumPlanes defines the frustum planes
  94333. * @returns true if the submesh is intersecting with the frustum
  94334. */
  94335. isInFrustum(frustumPlanes: Plane[]): boolean;
  94336. /**
  94337. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94338. * @param frustumPlanes defines the frustum planes
  94339. * @returns true if the submesh is inside the frustum
  94340. */
  94341. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94342. /**
  94343. * Renders the submesh
  94344. * @param enableAlphaMode defines if alpha needs to be used
  94345. * @returns the submesh
  94346. */
  94347. render(enableAlphaMode: boolean): SubMesh;
  94348. /**
  94349. * @hidden
  94350. */
  94351. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94352. /**
  94353. * Checks if the submesh intersects with a ray
  94354. * @param ray defines the ray to test
  94355. * @returns true is the passed ray intersects the submesh bounding box
  94356. */
  94357. canIntersects(ray: Ray): boolean;
  94358. /**
  94359. * Intersects current submesh with a ray
  94360. * @param ray defines the ray to test
  94361. * @param positions defines mesh's positions array
  94362. * @param indices defines mesh's indices array
  94363. * @param fastCheck defines if only bounding info should be used
  94364. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94365. * @returns intersection info or null if no intersection
  94366. */
  94367. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94368. /** @hidden */
  94369. private _intersectLines;
  94370. /** @hidden */
  94371. private _intersectUnIndexedLines;
  94372. /** @hidden */
  94373. private _intersectTriangles;
  94374. /** @hidden */
  94375. private _intersectUnIndexedTriangles;
  94376. /** @hidden */
  94377. _rebuild(): void;
  94378. /**
  94379. * Creates a new submesh from the passed mesh
  94380. * @param newMesh defines the new hosting mesh
  94381. * @param newRenderingMesh defines an optional rendering mesh
  94382. * @returns the new submesh
  94383. */
  94384. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94385. /**
  94386. * Release associated resources
  94387. */
  94388. dispose(): void;
  94389. /**
  94390. * Gets the class name
  94391. * @returns the string "SubMesh".
  94392. */
  94393. getClassName(): string;
  94394. /**
  94395. * Creates a new submesh from indices data
  94396. * @param materialIndex the index of the main mesh material
  94397. * @param startIndex the index where to start the copy in the mesh indices array
  94398. * @param indexCount the number of indices to copy then from the startIndex
  94399. * @param mesh the main mesh to create the submesh from
  94400. * @param renderingMesh the optional rendering mesh
  94401. * @returns a new submesh
  94402. */
  94403. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94404. }
  94405. }
  94406. declare module BABYLON {
  94407. /**
  94408. * Class used to represent data loading progression
  94409. */
  94410. export class SceneLoaderFlags {
  94411. private static _ForceFullSceneLoadingForIncremental;
  94412. private static _ShowLoadingScreen;
  94413. private static _CleanBoneMatrixWeights;
  94414. private static _loggingLevel;
  94415. /**
  94416. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94417. */
  94418. static get ForceFullSceneLoadingForIncremental(): boolean;
  94419. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94420. /**
  94421. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94422. */
  94423. static get ShowLoadingScreen(): boolean;
  94424. static set ShowLoadingScreen(value: boolean);
  94425. /**
  94426. * Defines the current logging level (while loading the scene)
  94427. * @ignorenaming
  94428. */
  94429. static get loggingLevel(): number;
  94430. static set loggingLevel(value: number);
  94431. /**
  94432. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94433. */
  94434. static get CleanBoneMatrixWeights(): boolean;
  94435. static set CleanBoneMatrixWeights(value: boolean);
  94436. }
  94437. }
  94438. declare module BABYLON {
  94439. /**
  94440. * Class used to store geometry data (vertex buffers + index buffer)
  94441. */
  94442. export class Geometry implements IGetSetVerticesData {
  94443. /**
  94444. * Gets or sets the ID of the geometry
  94445. */
  94446. id: string;
  94447. /**
  94448. * Gets or sets the unique ID of the geometry
  94449. */
  94450. uniqueId: number;
  94451. /**
  94452. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94453. */
  94454. delayLoadState: number;
  94455. /**
  94456. * Gets the file containing the data to load when running in delay load state
  94457. */
  94458. delayLoadingFile: Nullable<string>;
  94459. /**
  94460. * Callback called when the geometry is updated
  94461. */
  94462. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94463. private _scene;
  94464. private _engine;
  94465. private _meshes;
  94466. private _totalVertices;
  94467. /** @hidden */
  94468. _indices: IndicesArray;
  94469. /** @hidden */
  94470. _vertexBuffers: {
  94471. [key: string]: VertexBuffer;
  94472. };
  94473. private _isDisposed;
  94474. private _extend;
  94475. private _boundingBias;
  94476. /** @hidden */
  94477. _delayInfo: Array<string>;
  94478. private _indexBuffer;
  94479. private _indexBufferIsUpdatable;
  94480. /** @hidden */
  94481. _boundingInfo: Nullable<BoundingInfo>;
  94482. /** @hidden */
  94483. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94484. /** @hidden */
  94485. _softwareSkinningFrameId: number;
  94486. private _vertexArrayObjects;
  94487. private _updatable;
  94488. /** @hidden */
  94489. _positions: Nullable<Vector3[]>;
  94490. /**
  94491. * 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
  94492. */
  94493. get boundingBias(): Vector2;
  94494. /**
  94495. * 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
  94496. */
  94497. set boundingBias(value: Vector2);
  94498. /**
  94499. * Static function used to attach a new empty geometry to a mesh
  94500. * @param mesh defines the mesh to attach the geometry to
  94501. * @returns the new Geometry
  94502. */
  94503. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94504. /**
  94505. * Creates a new geometry
  94506. * @param id defines the unique ID
  94507. * @param scene defines the hosting scene
  94508. * @param vertexData defines the VertexData used to get geometry data
  94509. * @param updatable defines if geometry must be updatable (false by default)
  94510. * @param mesh defines the mesh that will be associated with the geometry
  94511. */
  94512. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94513. /**
  94514. * Gets the current extend of the geometry
  94515. */
  94516. get extend(): {
  94517. minimum: Vector3;
  94518. maximum: Vector3;
  94519. };
  94520. /**
  94521. * Gets the hosting scene
  94522. * @returns the hosting Scene
  94523. */
  94524. getScene(): Scene;
  94525. /**
  94526. * Gets the hosting engine
  94527. * @returns the hosting Engine
  94528. */
  94529. getEngine(): Engine;
  94530. /**
  94531. * Defines if the geometry is ready to use
  94532. * @returns true if the geometry is ready to be used
  94533. */
  94534. isReady(): boolean;
  94535. /**
  94536. * Gets a value indicating that the geometry should not be serialized
  94537. */
  94538. get doNotSerialize(): boolean;
  94539. /** @hidden */
  94540. _rebuild(): void;
  94541. /**
  94542. * Affects all geometry data in one call
  94543. * @param vertexData defines the geometry data
  94544. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94545. */
  94546. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94547. /**
  94548. * Set specific vertex data
  94549. * @param kind defines the data kind (Position, normal, etc...)
  94550. * @param data defines the vertex data to use
  94551. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94552. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94553. */
  94554. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94555. /**
  94556. * Removes a specific vertex data
  94557. * @param kind defines the data kind (Position, normal, etc...)
  94558. */
  94559. removeVerticesData(kind: string): void;
  94560. /**
  94561. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  94562. * @param buffer defines the vertex buffer to use
  94563. * @param totalVertices defines the total number of vertices for position kind (could be null)
  94564. */
  94565. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  94566. /**
  94567. * Update a specific vertex buffer
  94568. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  94569. * It will do nothing if the buffer is not updatable
  94570. * @param kind defines the data kind (Position, normal, etc...)
  94571. * @param data defines the data to use
  94572. * @param offset defines the offset in the target buffer where to store the data
  94573. * @param useBytes set to true if the offset is in bytes
  94574. */
  94575. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  94576. /**
  94577. * Update a specific vertex buffer
  94578. * This function will create a new buffer if the current one is not updatable
  94579. * @param kind defines the data kind (Position, normal, etc...)
  94580. * @param data defines the data to use
  94581. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  94582. */
  94583. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  94584. private _updateBoundingInfo;
  94585. /** @hidden */
  94586. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  94587. /**
  94588. * Gets total number of vertices
  94589. * @returns the total number of vertices
  94590. */
  94591. getTotalVertices(): number;
  94592. /**
  94593. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94594. * @param kind defines the data kind (Position, normal, etc...)
  94595. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94596. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94597. * @returns a float array containing vertex data
  94598. */
  94599. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94600. /**
  94601. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  94602. * @param kind defines the data kind (Position, normal, etc...)
  94603. * @returns true if the vertex buffer with the specified kind is updatable
  94604. */
  94605. isVertexBufferUpdatable(kind: string): boolean;
  94606. /**
  94607. * Gets a specific vertex buffer
  94608. * @param kind defines the data kind (Position, normal, etc...)
  94609. * @returns a VertexBuffer
  94610. */
  94611. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94612. /**
  94613. * Returns all vertex buffers
  94614. * @return an object holding all vertex buffers indexed by kind
  94615. */
  94616. getVertexBuffers(): Nullable<{
  94617. [key: string]: VertexBuffer;
  94618. }>;
  94619. /**
  94620. * Gets a boolean indicating if specific vertex buffer is present
  94621. * @param kind defines the data kind (Position, normal, etc...)
  94622. * @returns true if data is present
  94623. */
  94624. isVerticesDataPresent(kind: string): boolean;
  94625. /**
  94626. * Gets a list of all attached data kinds (Position, normal, etc...)
  94627. * @returns a list of string containing all kinds
  94628. */
  94629. getVerticesDataKinds(): string[];
  94630. /**
  94631. * Update index buffer
  94632. * @param indices defines the indices to store in the index buffer
  94633. * @param offset defines the offset in the target buffer where to store the data
  94634. * @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)
  94635. */
  94636. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  94637. /**
  94638. * Creates a new index buffer
  94639. * @param indices defines the indices to store in the index buffer
  94640. * @param totalVertices defines the total number of vertices (could be null)
  94641. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94642. */
  94643. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  94644. /**
  94645. * Return the total number of indices
  94646. * @returns the total number of indices
  94647. */
  94648. getTotalIndices(): number;
  94649. /**
  94650. * Gets the index buffer array
  94651. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94652. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94653. * @returns the index buffer array
  94654. */
  94655. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94656. /**
  94657. * Gets the index buffer
  94658. * @return the index buffer
  94659. */
  94660. getIndexBuffer(): Nullable<DataBuffer>;
  94661. /** @hidden */
  94662. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  94663. /**
  94664. * Release the associated resources for a specific mesh
  94665. * @param mesh defines the source mesh
  94666. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  94667. */
  94668. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  94669. /**
  94670. * Apply current geometry to a given mesh
  94671. * @param mesh defines the mesh to apply geometry to
  94672. */
  94673. applyToMesh(mesh: Mesh): void;
  94674. private _updateExtend;
  94675. private _applyToMesh;
  94676. private notifyUpdate;
  94677. /**
  94678. * Load the geometry if it was flagged as delay loaded
  94679. * @param scene defines the hosting scene
  94680. * @param onLoaded defines a callback called when the geometry is loaded
  94681. */
  94682. load(scene: Scene, onLoaded?: () => void): void;
  94683. private _queueLoad;
  94684. /**
  94685. * Invert the geometry to move from a right handed system to a left handed one.
  94686. */
  94687. toLeftHanded(): void;
  94688. /** @hidden */
  94689. _resetPointsArrayCache(): void;
  94690. /** @hidden */
  94691. _generatePointsArray(): boolean;
  94692. /**
  94693. * Gets a value indicating if the geometry is disposed
  94694. * @returns true if the geometry was disposed
  94695. */
  94696. isDisposed(): boolean;
  94697. private _disposeVertexArrayObjects;
  94698. /**
  94699. * Free all associated resources
  94700. */
  94701. dispose(): void;
  94702. /**
  94703. * Clone the current geometry into a new geometry
  94704. * @param id defines the unique ID of the new geometry
  94705. * @returns a new geometry object
  94706. */
  94707. copy(id: string): Geometry;
  94708. /**
  94709. * Serialize the current geometry info (and not the vertices data) into a JSON object
  94710. * @return a JSON representation of the current geometry data (without the vertices data)
  94711. */
  94712. serialize(): any;
  94713. private toNumberArray;
  94714. /**
  94715. * Serialize all vertices data into a JSON oject
  94716. * @returns a JSON representation of the current geometry data
  94717. */
  94718. serializeVerticeData(): any;
  94719. /**
  94720. * Extracts a clone of a mesh geometry
  94721. * @param mesh defines the source mesh
  94722. * @param id defines the unique ID of the new geometry object
  94723. * @returns the new geometry object
  94724. */
  94725. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  94726. /**
  94727. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  94728. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94729. * Be aware Math.random() could cause collisions, but:
  94730. * "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"
  94731. * @returns a string containing a new GUID
  94732. */
  94733. static RandomId(): string;
  94734. /** @hidden */
  94735. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  94736. private static _CleanMatricesWeights;
  94737. /**
  94738. * Create a new geometry from persisted data (Using .babylon file format)
  94739. * @param parsedVertexData defines the persisted data
  94740. * @param scene defines the hosting scene
  94741. * @param rootUrl defines the root url to use to load assets (like delayed data)
  94742. * @returns the new geometry object
  94743. */
  94744. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  94745. }
  94746. }
  94747. declare module BABYLON {
  94748. /**
  94749. * Define an interface for all classes that will get and set the data on vertices
  94750. */
  94751. export interface IGetSetVerticesData {
  94752. /**
  94753. * Gets a boolean indicating if specific vertex data is present
  94754. * @param kind defines the vertex data kind to use
  94755. * @returns true is data kind is present
  94756. */
  94757. isVerticesDataPresent(kind: string): boolean;
  94758. /**
  94759. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94760. * @param kind defines the data kind (Position, normal, etc...)
  94761. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94762. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94763. * @returns a float array containing vertex data
  94764. */
  94765. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94766. /**
  94767. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94768. * @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.
  94769. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94770. * @returns the indices array or an empty array if the mesh has no geometry
  94771. */
  94772. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94773. /**
  94774. * Set specific vertex data
  94775. * @param kind defines the data kind (Position, normal, etc...)
  94776. * @param data defines the vertex data to use
  94777. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94778. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94779. */
  94780. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  94781. /**
  94782. * Update a specific associated vertex buffer
  94783. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94784. * - VertexBuffer.PositionKind
  94785. * - VertexBuffer.UVKind
  94786. * - VertexBuffer.UV2Kind
  94787. * - VertexBuffer.UV3Kind
  94788. * - VertexBuffer.UV4Kind
  94789. * - VertexBuffer.UV5Kind
  94790. * - VertexBuffer.UV6Kind
  94791. * - VertexBuffer.ColorKind
  94792. * - VertexBuffer.MatricesIndicesKind
  94793. * - VertexBuffer.MatricesIndicesExtraKind
  94794. * - VertexBuffer.MatricesWeightsKind
  94795. * - VertexBuffer.MatricesWeightsExtraKind
  94796. * @param data defines the data source
  94797. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  94798. * @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)
  94799. */
  94800. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  94801. /**
  94802. * Creates a new index buffer
  94803. * @param indices defines the indices to store in the index buffer
  94804. * @param totalVertices defines the total number of vertices (could be null)
  94805. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94806. */
  94807. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  94808. }
  94809. /**
  94810. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  94811. */
  94812. export class VertexData {
  94813. /**
  94814. * Mesh side orientation : usually the external or front surface
  94815. */
  94816. static readonly FRONTSIDE: number;
  94817. /**
  94818. * Mesh side orientation : usually the internal or back surface
  94819. */
  94820. static readonly BACKSIDE: number;
  94821. /**
  94822. * Mesh side orientation : both internal and external or front and back surfaces
  94823. */
  94824. static readonly DOUBLESIDE: number;
  94825. /**
  94826. * Mesh side orientation : by default, `FRONTSIDE`
  94827. */
  94828. static readonly DEFAULTSIDE: number;
  94829. /**
  94830. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  94831. */
  94832. positions: Nullable<FloatArray>;
  94833. /**
  94834. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  94835. */
  94836. normals: Nullable<FloatArray>;
  94837. /**
  94838. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  94839. */
  94840. tangents: Nullable<FloatArray>;
  94841. /**
  94842. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94843. */
  94844. uvs: Nullable<FloatArray>;
  94845. /**
  94846. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94847. */
  94848. uvs2: Nullable<FloatArray>;
  94849. /**
  94850. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94851. */
  94852. uvs3: Nullable<FloatArray>;
  94853. /**
  94854. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94855. */
  94856. uvs4: Nullable<FloatArray>;
  94857. /**
  94858. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94859. */
  94860. uvs5: Nullable<FloatArray>;
  94861. /**
  94862. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94863. */
  94864. uvs6: Nullable<FloatArray>;
  94865. /**
  94866. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  94867. */
  94868. colors: Nullable<FloatArray>;
  94869. /**
  94870. * 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).
  94871. */
  94872. matricesIndices: Nullable<FloatArray>;
  94873. /**
  94874. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  94875. */
  94876. matricesWeights: Nullable<FloatArray>;
  94877. /**
  94878. * An array extending the number of possible indices
  94879. */
  94880. matricesIndicesExtra: Nullable<FloatArray>;
  94881. /**
  94882. * An array extending the number of possible weights when the number of indices is extended
  94883. */
  94884. matricesWeightsExtra: Nullable<FloatArray>;
  94885. /**
  94886. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  94887. */
  94888. indices: Nullable<IndicesArray>;
  94889. /**
  94890. * Uses the passed data array to set the set the values for the specified kind of data
  94891. * @param data a linear array of floating numbers
  94892. * @param kind the type of data that is being set, eg positions, colors etc
  94893. */
  94894. set(data: FloatArray, kind: string): void;
  94895. /**
  94896. * Associates the vertexData to the passed Mesh.
  94897. * Sets it as updatable or not (default `false`)
  94898. * @param mesh the mesh the vertexData is applied to
  94899. * @param updatable when used and having the value true allows new data to update the vertexData
  94900. * @returns the VertexData
  94901. */
  94902. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  94903. /**
  94904. * Associates the vertexData to the passed Geometry.
  94905. * Sets it as updatable or not (default `false`)
  94906. * @param geometry the geometry the vertexData is applied to
  94907. * @param updatable when used and having the value true allows new data to update the vertexData
  94908. * @returns VertexData
  94909. */
  94910. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  94911. /**
  94912. * Updates the associated mesh
  94913. * @param mesh the mesh to be updated
  94914. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94915. * @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
  94916. * @returns VertexData
  94917. */
  94918. updateMesh(mesh: Mesh): VertexData;
  94919. /**
  94920. * Updates the associated geometry
  94921. * @param geometry the geometry to be updated
  94922. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94923. * @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
  94924. * @returns VertexData.
  94925. */
  94926. updateGeometry(geometry: Geometry): VertexData;
  94927. private _applyTo;
  94928. private _update;
  94929. /**
  94930. * Transforms each position and each normal of the vertexData according to the passed Matrix
  94931. * @param matrix the transforming matrix
  94932. * @returns the VertexData
  94933. */
  94934. transform(matrix: Matrix): VertexData;
  94935. /**
  94936. * Merges the passed VertexData into the current one
  94937. * @param other the VertexData to be merged into the current one
  94938. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  94939. * @returns the modified VertexData
  94940. */
  94941. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  94942. private _mergeElement;
  94943. private _validate;
  94944. /**
  94945. * Serializes the VertexData
  94946. * @returns a serialized object
  94947. */
  94948. serialize(): any;
  94949. /**
  94950. * Extracts the vertexData from a mesh
  94951. * @param mesh the mesh from which to extract the VertexData
  94952. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  94953. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94954. * @returns the object VertexData associated to the passed mesh
  94955. */
  94956. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94957. /**
  94958. * Extracts the vertexData from the geometry
  94959. * @param geometry the geometry from which to extract the VertexData
  94960. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  94961. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94962. * @returns the object VertexData associated to the passed mesh
  94963. */
  94964. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94965. private static _ExtractFrom;
  94966. /**
  94967. * Creates the VertexData for a Ribbon
  94968. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  94969. * * pathArray array of paths, each of which an array of successive Vector3
  94970. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  94971. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  94972. * * 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
  94973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94974. * * 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)
  94975. * * 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)
  94976. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  94977. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  94978. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  94979. * @returns the VertexData of the ribbon
  94980. */
  94981. static CreateRibbon(options: {
  94982. pathArray: Vector3[][];
  94983. closeArray?: boolean;
  94984. closePath?: boolean;
  94985. offset?: number;
  94986. sideOrientation?: number;
  94987. frontUVs?: Vector4;
  94988. backUVs?: Vector4;
  94989. invertUV?: boolean;
  94990. uvs?: Vector2[];
  94991. colors?: Color4[];
  94992. }): VertexData;
  94993. /**
  94994. * Creates the VertexData for a box
  94995. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94996. * * size sets the width, height and depth of the box to the value of size, optional default 1
  94997. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  94998. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  94999. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95000. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95001. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95003. * * 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)
  95004. * * 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)
  95005. * @returns the VertexData of the box
  95006. */
  95007. static CreateBox(options: {
  95008. size?: number;
  95009. width?: number;
  95010. height?: number;
  95011. depth?: number;
  95012. faceUV?: Vector4[];
  95013. faceColors?: Color4[];
  95014. sideOrientation?: number;
  95015. frontUVs?: Vector4;
  95016. backUVs?: Vector4;
  95017. }): VertexData;
  95018. /**
  95019. * Creates the VertexData for a tiled box
  95020. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95021. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95022. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95023. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95025. * @returns the VertexData of the box
  95026. */
  95027. static CreateTiledBox(options: {
  95028. pattern?: number;
  95029. width?: number;
  95030. height?: number;
  95031. depth?: number;
  95032. tileSize?: number;
  95033. tileWidth?: number;
  95034. tileHeight?: number;
  95035. alignHorizontal?: number;
  95036. alignVertical?: number;
  95037. faceUV?: Vector4[];
  95038. faceColors?: Color4[];
  95039. sideOrientation?: number;
  95040. }): VertexData;
  95041. /**
  95042. * Creates the VertexData for a tiled plane
  95043. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95044. * * pattern a limited pattern arrangement depending on the number
  95045. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95046. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95047. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95048. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95049. * * 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)
  95050. * * 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)
  95051. * @returns the VertexData of the tiled plane
  95052. */
  95053. static CreateTiledPlane(options: {
  95054. pattern?: number;
  95055. tileSize?: number;
  95056. tileWidth?: number;
  95057. tileHeight?: number;
  95058. size?: number;
  95059. width?: number;
  95060. height?: number;
  95061. alignHorizontal?: number;
  95062. alignVertical?: number;
  95063. sideOrientation?: number;
  95064. frontUVs?: Vector4;
  95065. backUVs?: Vector4;
  95066. }): VertexData;
  95067. /**
  95068. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95069. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95070. * * segments sets the number of horizontal strips optional, default 32
  95071. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95072. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95073. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95074. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95075. * * 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
  95076. * * 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
  95077. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95078. * * 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)
  95079. * * 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)
  95080. * @returns the VertexData of the ellipsoid
  95081. */
  95082. static CreateSphere(options: {
  95083. segments?: number;
  95084. diameter?: number;
  95085. diameterX?: number;
  95086. diameterY?: number;
  95087. diameterZ?: number;
  95088. arc?: number;
  95089. slice?: number;
  95090. sideOrientation?: number;
  95091. frontUVs?: Vector4;
  95092. backUVs?: Vector4;
  95093. }): VertexData;
  95094. /**
  95095. * Creates the VertexData for a cylinder, cone or prism
  95096. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95097. * * height sets the height (y direction) of the cylinder, optional, default 2
  95098. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95099. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95100. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95101. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95102. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95103. * * 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
  95104. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95105. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95106. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95107. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95109. * * 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)
  95110. * * 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)
  95111. * @returns the VertexData of the cylinder, cone or prism
  95112. */
  95113. static CreateCylinder(options: {
  95114. height?: number;
  95115. diameterTop?: number;
  95116. diameterBottom?: number;
  95117. diameter?: number;
  95118. tessellation?: number;
  95119. subdivisions?: number;
  95120. arc?: number;
  95121. faceColors?: Color4[];
  95122. faceUV?: Vector4[];
  95123. hasRings?: boolean;
  95124. enclose?: boolean;
  95125. sideOrientation?: number;
  95126. frontUVs?: Vector4;
  95127. backUVs?: Vector4;
  95128. }): VertexData;
  95129. /**
  95130. * Creates the VertexData for a torus
  95131. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95132. * * diameter the diameter of the torus, optional default 1
  95133. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95134. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95136. * * 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)
  95137. * * 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)
  95138. * @returns the VertexData of the torus
  95139. */
  95140. static CreateTorus(options: {
  95141. diameter?: number;
  95142. thickness?: number;
  95143. tessellation?: number;
  95144. sideOrientation?: number;
  95145. frontUVs?: Vector4;
  95146. backUVs?: Vector4;
  95147. }): VertexData;
  95148. /**
  95149. * Creates the VertexData of the LineSystem
  95150. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95151. * - lines an array of lines, each line being an array of successive Vector3
  95152. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95153. * @returns the VertexData of the LineSystem
  95154. */
  95155. static CreateLineSystem(options: {
  95156. lines: Vector3[][];
  95157. colors?: Nullable<Color4[][]>;
  95158. }): VertexData;
  95159. /**
  95160. * Create the VertexData for a DashedLines
  95161. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95162. * - points an array successive Vector3
  95163. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95164. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95165. * - dashNb the intended total number of dashes, optional, default 200
  95166. * @returns the VertexData for the DashedLines
  95167. */
  95168. static CreateDashedLines(options: {
  95169. points: Vector3[];
  95170. dashSize?: number;
  95171. gapSize?: number;
  95172. dashNb?: number;
  95173. }): VertexData;
  95174. /**
  95175. * Creates the VertexData for a Ground
  95176. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95177. * - width the width (x direction) of the ground, optional, default 1
  95178. * - height the height (z direction) of the ground, optional, default 1
  95179. * - subdivisions the number of subdivisions per side, optional, default 1
  95180. * @returns the VertexData of the Ground
  95181. */
  95182. static CreateGround(options: {
  95183. width?: number;
  95184. height?: number;
  95185. subdivisions?: number;
  95186. subdivisionsX?: number;
  95187. subdivisionsY?: number;
  95188. }): VertexData;
  95189. /**
  95190. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95191. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95192. * * xmin the ground minimum X coordinate, optional, default -1
  95193. * * zmin the ground minimum Z coordinate, optional, default -1
  95194. * * xmax the ground maximum X coordinate, optional, default 1
  95195. * * zmax the ground maximum Z coordinate, optional, default 1
  95196. * * 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}
  95197. * * 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}
  95198. * @returns the VertexData of the TiledGround
  95199. */
  95200. static CreateTiledGround(options: {
  95201. xmin: number;
  95202. zmin: number;
  95203. xmax: number;
  95204. zmax: number;
  95205. subdivisions?: {
  95206. w: number;
  95207. h: number;
  95208. };
  95209. precision?: {
  95210. w: number;
  95211. h: number;
  95212. };
  95213. }): VertexData;
  95214. /**
  95215. * Creates the VertexData of the Ground designed from a heightmap
  95216. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95217. * * width the width (x direction) of the ground
  95218. * * height the height (z direction) of the ground
  95219. * * subdivisions the number of subdivisions per side
  95220. * * minHeight the minimum altitude on the ground, optional, default 0
  95221. * * maxHeight the maximum altitude on the ground, optional default 1
  95222. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95223. * * buffer the array holding the image color data
  95224. * * bufferWidth the width of image
  95225. * * bufferHeight the height of image
  95226. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95227. * @returns the VertexData of the Ground designed from a heightmap
  95228. */
  95229. static CreateGroundFromHeightMap(options: {
  95230. width: number;
  95231. height: number;
  95232. subdivisions: number;
  95233. minHeight: number;
  95234. maxHeight: number;
  95235. colorFilter: Color3;
  95236. buffer: Uint8Array;
  95237. bufferWidth: number;
  95238. bufferHeight: number;
  95239. alphaFilter: number;
  95240. }): VertexData;
  95241. /**
  95242. * Creates the VertexData for a Plane
  95243. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95244. * * size sets the width and height of the plane to the value of size, optional default 1
  95245. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95246. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95248. * * 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)
  95249. * * 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)
  95250. * @returns the VertexData of the box
  95251. */
  95252. static CreatePlane(options: {
  95253. size?: number;
  95254. width?: number;
  95255. height?: number;
  95256. sideOrientation?: number;
  95257. frontUVs?: Vector4;
  95258. backUVs?: Vector4;
  95259. }): VertexData;
  95260. /**
  95261. * Creates the VertexData of the Disc or regular Polygon
  95262. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95263. * * radius the radius of the disc, optional default 0.5
  95264. * * tessellation the number of polygon sides, optional, default 64
  95265. * * 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
  95266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95267. * * 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)
  95268. * * 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)
  95269. * @returns the VertexData of the box
  95270. */
  95271. static CreateDisc(options: {
  95272. radius?: number;
  95273. tessellation?: number;
  95274. arc?: number;
  95275. sideOrientation?: number;
  95276. frontUVs?: Vector4;
  95277. backUVs?: Vector4;
  95278. }): VertexData;
  95279. /**
  95280. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95281. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95282. * @param polygon a mesh built from polygonTriangulation.build()
  95283. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95284. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95285. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95286. * @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)
  95287. * @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)
  95288. * @returns the VertexData of the Polygon
  95289. */
  95290. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95291. /**
  95292. * Creates the VertexData of the IcoSphere
  95293. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95294. * * radius the radius of the IcoSphere, optional default 1
  95295. * * radiusX allows stretching in the x direction, optional, default radius
  95296. * * radiusY allows stretching in the y direction, optional, default radius
  95297. * * radiusZ allows stretching in the z direction, optional, default radius
  95298. * * flat when true creates a flat shaded mesh, optional, default true
  95299. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95301. * * 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)
  95302. * * 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)
  95303. * @returns the VertexData of the IcoSphere
  95304. */
  95305. static CreateIcoSphere(options: {
  95306. radius?: number;
  95307. radiusX?: number;
  95308. radiusY?: number;
  95309. radiusZ?: number;
  95310. flat?: boolean;
  95311. subdivisions?: number;
  95312. sideOrientation?: number;
  95313. frontUVs?: Vector4;
  95314. backUVs?: Vector4;
  95315. }): VertexData;
  95316. /**
  95317. * Creates the VertexData for a Polyhedron
  95318. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95319. * * type provided types are:
  95320. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95321. * * 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)
  95322. * * size the size of the IcoSphere, optional default 1
  95323. * * sizeX allows stretching in the x direction, optional, default size
  95324. * * sizeY allows stretching in the y direction, optional, default size
  95325. * * sizeZ allows stretching in the z direction, optional, default size
  95326. * * 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
  95327. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95328. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95329. * * flat when true creates a flat shaded mesh, optional, default true
  95330. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95331. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95332. * * 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)
  95333. * * 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)
  95334. * @returns the VertexData of the Polyhedron
  95335. */
  95336. static CreatePolyhedron(options: {
  95337. type?: number;
  95338. size?: number;
  95339. sizeX?: number;
  95340. sizeY?: number;
  95341. sizeZ?: number;
  95342. custom?: any;
  95343. faceUV?: Vector4[];
  95344. faceColors?: Color4[];
  95345. flat?: boolean;
  95346. sideOrientation?: number;
  95347. frontUVs?: Vector4;
  95348. backUVs?: Vector4;
  95349. }): VertexData;
  95350. /**
  95351. * Creates the VertexData for a TorusKnot
  95352. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95353. * * radius the radius of the torus knot, optional, default 2
  95354. * * tube the thickness of the tube, optional, default 0.5
  95355. * * radialSegments the number of sides on each tube segments, optional, default 32
  95356. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95357. * * p the number of windings around the z axis, optional, default 2
  95358. * * q the number of windings around the x axis, optional, default 3
  95359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95360. * * 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)
  95361. * * 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)
  95362. * @returns the VertexData of the Torus Knot
  95363. */
  95364. static CreateTorusKnot(options: {
  95365. radius?: number;
  95366. tube?: number;
  95367. radialSegments?: number;
  95368. tubularSegments?: number;
  95369. p?: number;
  95370. q?: number;
  95371. sideOrientation?: number;
  95372. frontUVs?: Vector4;
  95373. backUVs?: Vector4;
  95374. }): VertexData;
  95375. /**
  95376. * Compute normals for given positions and indices
  95377. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95378. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95379. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95380. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95381. * * facetNormals : optional array of facet normals (vector3)
  95382. * * facetPositions : optional array of facet positions (vector3)
  95383. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95384. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95385. * * bInfo : optional bounding info, required for facetPartitioning computation
  95386. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95387. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95388. * * useRightHandedSystem: optional boolean to for right handed system computation
  95389. * * depthSort : optional boolean to enable the facet depth sort computation
  95390. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95391. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95392. */
  95393. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95394. facetNormals?: any;
  95395. facetPositions?: any;
  95396. facetPartitioning?: any;
  95397. ratio?: number;
  95398. bInfo?: any;
  95399. bbSize?: Vector3;
  95400. subDiv?: any;
  95401. useRightHandedSystem?: boolean;
  95402. depthSort?: boolean;
  95403. distanceTo?: Vector3;
  95404. depthSortedFacets?: any;
  95405. }): void;
  95406. /** @hidden */
  95407. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95408. /**
  95409. * Applies VertexData created from the imported parameters to the geometry
  95410. * @param parsedVertexData the parsed data from an imported file
  95411. * @param geometry the geometry to apply the VertexData to
  95412. */
  95413. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95414. }
  95415. }
  95416. declare module BABYLON {
  95417. /**
  95418. * Defines a target to use with MorphTargetManager
  95419. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95420. */
  95421. export class MorphTarget implements IAnimatable {
  95422. /** defines the name of the target */
  95423. name: string;
  95424. /**
  95425. * Gets or sets the list of animations
  95426. */
  95427. animations: Animation[];
  95428. private _scene;
  95429. private _positions;
  95430. private _normals;
  95431. private _tangents;
  95432. private _uvs;
  95433. private _influence;
  95434. private _uniqueId;
  95435. /**
  95436. * Observable raised when the influence changes
  95437. */
  95438. onInfluenceChanged: Observable<boolean>;
  95439. /** @hidden */
  95440. _onDataLayoutChanged: Observable<void>;
  95441. /**
  95442. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95443. */
  95444. get influence(): number;
  95445. set influence(influence: number);
  95446. /**
  95447. * Gets or sets the id of the morph Target
  95448. */
  95449. id: string;
  95450. private _animationPropertiesOverride;
  95451. /**
  95452. * Gets or sets the animation properties override
  95453. */
  95454. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95455. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95456. /**
  95457. * Creates a new MorphTarget
  95458. * @param name defines the name of the target
  95459. * @param influence defines the influence to use
  95460. * @param scene defines the scene the morphtarget belongs to
  95461. */
  95462. constructor(
  95463. /** defines the name of the target */
  95464. name: string, influence?: number, scene?: Nullable<Scene>);
  95465. /**
  95466. * Gets the unique ID of this manager
  95467. */
  95468. get uniqueId(): number;
  95469. /**
  95470. * Gets a boolean defining if the target contains position data
  95471. */
  95472. get hasPositions(): boolean;
  95473. /**
  95474. * Gets a boolean defining if the target contains normal data
  95475. */
  95476. get hasNormals(): boolean;
  95477. /**
  95478. * Gets a boolean defining if the target contains tangent data
  95479. */
  95480. get hasTangents(): boolean;
  95481. /**
  95482. * Gets a boolean defining if the target contains texture coordinates data
  95483. */
  95484. get hasUVs(): boolean;
  95485. /**
  95486. * Affects position data to this target
  95487. * @param data defines the position data to use
  95488. */
  95489. setPositions(data: Nullable<FloatArray>): void;
  95490. /**
  95491. * Gets the position data stored in this target
  95492. * @returns a FloatArray containing the position data (or null if not present)
  95493. */
  95494. getPositions(): Nullable<FloatArray>;
  95495. /**
  95496. * Affects normal data to this target
  95497. * @param data defines the normal data to use
  95498. */
  95499. setNormals(data: Nullable<FloatArray>): void;
  95500. /**
  95501. * Gets the normal data stored in this target
  95502. * @returns a FloatArray containing the normal data (or null if not present)
  95503. */
  95504. getNormals(): Nullable<FloatArray>;
  95505. /**
  95506. * Affects tangent data to this target
  95507. * @param data defines the tangent data to use
  95508. */
  95509. setTangents(data: Nullable<FloatArray>): void;
  95510. /**
  95511. * Gets the tangent data stored in this target
  95512. * @returns a FloatArray containing the tangent data (or null if not present)
  95513. */
  95514. getTangents(): Nullable<FloatArray>;
  95515. /**
  95516. * Affects texture coordinates data to this target
  95517. * @param data defines the texture coordinates data to use
  95518. */
  95519. setUVs(data: Nullable<FloatArray>): void;
  95520. /**
  95521. * Gets the texture coordinates data stored in this target
  95522. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95523. */
  95524. getUVs(): Nullable<FloatArray>;
  95525. /**
  95526. * Clone the current target
  95527. * @returns a new MorphTarget
  95528. */
  95529. clone(): MorphTarget;
  95530. /**
  95531. * Serializes the current target into a Serialization object
  95532. * @returns the serialized object
  95533. */
  95534. serialize(): any;
  95535. /**
  95536. * Returns the string "MorphTarget"
  95537. * @returns "MorphTarget"
  95538. */
  95539. getClassName(): string;
  95540. /**
  95541. * Creates a new target from serialized data
  95542. * @param serializationObject defines the serialized data to use
  95543. * @returns a new MorphTarget
  95544. */
  95545. static Parse(serializationObject: any): MorphTarget;
  95546. /**
  95547. * Creates a MorphTarget from mesh data
  95548. * @param mesh defines the source mesh
  95549. * @param name defines the name to use for the new target
  95550. * @param influence defines the influence to attach to the target
  95551. * @returns a new MorphTarget
  95552. */
  95553. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95554. }
  95555. }
  95556. declare module BABYLON {
  95557. /**
  95558. * This class is used to deform meshes using morphing between different targets
  95559. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95560. */
  95561. export class MorphTargetManager {
  95562. private _targets;
  95563. private _targetInfluenceChangedObservers;
  95564. private _targetDataLayoutChangedObservers;
  95565. private _activeTargets;
  95566. private _scene;
  95567. private _influences;
  95568. private _supportsNormals;
  95569. private _supportsTangents;
  95570. private _supportsUVs;
  95571. private _vertexCount;
  95572. private _uniqueId;
  95573. private _tempInfluences;
  95574. /**
  95575. * Gets or sets a boolean indicating if normals must be morphed
  95576. */
  95577. enableNormalMorphing: boolean;
  95578. /**
  95579. * Gets or sets a boolean indicating if tangents must be morphed
  95580. */
  95581. enableTangentMorphing: boolean;
  95582. /**
  95583. * Gets or sets a boolean indicating if UV must be morphed
  95584. */
  95585. enableUVMorphing: boolean;
  95586. /**
  95587. * Creates a new MorphTargetManager
  95588. * @param scene defines the current scene
  95589. */
  95590. constructor(scene?: Nullable<Scene>);
  95591. /**
  95592. * Gets the unique ID of this manager
  95593. */
  95594. get uniqueId(): number;
  95595. /**
  95596. * Gets the number of vertices handled by this manager
  95597. */
  95598. get vertexCount(): number;
  95599. /**
  95600. * Gets a boolean indicating if this manager supports morphing of normals
  95601. */
  95602. get supportsNormals(): boolean;
  95603. /**
  95604. * Gets a boolean indicating if this manager supports morphing of tangents
  95605. */
  95606. get supportsTangents(): boolean;
  95607. /**
  95608. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  95609. */
  95610. get supportsUVs(): boolean;
  95611. /**
  95612. * Gets the number of targets stored in this manager
  95613. */
  95614. get numTargets(): number;
  95615. /**
  95616. * Gets the number of influencers (ie. the number of targets with influences > 0)
  95617. */
  95618. get numInfluencers(): number;
  95619. /**
  95620. * Gets the list of influences (one per target)
  95621. */
  95622. get influences(): Float32Array;
  95623. /**
  95624. * Gets the active target at specified index. An active target is a target with an influence > 0
  95625. * @param index defines the index to check
  95626. * @returns the requested target
  95627. */
  95628. getActiveTarget(index: number): MorphTarget;
  95629. /**
  95630. * Gets the target at specified index
  95631. * @param index defines the index to check
  95632. * @returns the requested target
  95633. */
  95634. getTarget(index: number): MorphTarget;
  95635. /**
  95636. * Add a new target to this manager
  95637. * @param target defines the target to add
  95638. */
  95639. addTarget(target: MorphTarget): void;
  95640. /**
  95641. * Removes a target from the manager
  95642. * @param target defines the target to remove
  95643. */
  95644. removeTarget(target: MorphTarget): void;
  95645. /**
  95646. * Clone the current manager
  95647. * @returns a new MorphTargetManager
  95648. */
  95649. clone(): MorphTargetManager;
  95650. /**
  95651. * Serializes the current manager into a Serialization object
  95652. * @returns the serialized object
  95653. */
  95654. serialize(): any;
  95655. private _syncActiveTargets;
  95656. /**
  95657. * Syncrhonize the targets with all the meshes using this morph target manager
  95658. */
  95659. synchronize(): void;
  95660. /**
  95661. * Creates a new MorphTargetManager from serialized data
  95662. * @param serializationObject defines the serialized data
  95663. * @param scene defines the hosting scene
  95664. * @returns the new MorphTargetManager
  95665. */
  95666. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  95667. }
  95668. }
  95669. declare module BABYLON {
  95670. /**
  95671. * Class used to represent a specific level of detail of a mesh
  95672. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95673. */
  95674. export class MeshLODLevel {
  95675. /** Defines the distance where this level should start being displayed */
  95676. distance: number;
  95677. /** Defines the mesh to use to render this level */
  95678. mesh: Nullable<Mesh>;
  95679. /**
  95680. * Creates a new LOD level
  95681. * @param distance defines the distance where this level should star being displayed
  95682. * @param mesh defines the mesh to use to render this level
  95683. */
  95684. constructor(
  95685. /** Defines the distance where this level should start being displayed */
  95686. distance: number,
  95687. /** Defines the mesh to use to render this level */
  95688. mesh: Nullable<Mesh>);
  95689. }
  95690. }
  95691. declare module BABYLON {
  95692. /**
  95693. * Mesh representing the gorund
  95694. */
  95695. export class GroundMesh extends Mesh {
  95696. /** If octree should be generated */
  95697. generateOctree: boolean;
  95698. private _heightQuads;
  95699. /** @hidden */
  95700. _subdivisionsX: number;
  95701. /** @hidden */
  95702. _subdivisionsY: number;
  95703. /** @hidden */
  95704. _width: number;
  95705. /** @hidden */
  95706. _height: number;
  95707. /** @hidden */
  95708. _minX: number;
  95709. /** @hidden */
  95710. _maxX: number;
  95711. /** @hidden */
  95712. _minZ: number;
  95713. /** @hidden */
  95714. _maxZ: number;
  95715. constructor(name: string, scene: Scene);
  95716. /**
  95717. * "GroundMesh"
  95718. * @returns "GroundMesh"
  95719. */
  95720. getClassName(): string;
  95721. /**
  95722. * The minimum of x and y subdivisions
  95723. */
  95724. get subdivisions(): number;
  95725. /**
  95726. * X subdivisions
  95727. */
  95728. get subdivisionsX(): number;
  95729. /**
  95730. * Y subdivisions
  95731. */
  95732. get subdivisionsY(): number;
  95733. /**
  95734. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  95735. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95736. * @param chunksCount the number of subdivisions for x and y
  95737. * @param octreeBlocksSize (Default: 32)
  95738. */
  95739. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  95740. /**
  95741. * Returns a height (y) value in the Worl system :
  95742. * the ground altitude at the coordinates (x, z) expressed in the World system.
  95743. * @param x x coordinate
  95744. * @param z z coordinate
  95745. * @returns the ground y position if (x, z) are outside the ground surface.
  95746. */
  95747. getHeightAtCoordinates(x: number, z: number): number;
  95748. /**
  95749. * Returns a normalized vector (Vector3) orthogonal to the ground
  95750. * at the ground coordinates (x, z) expressed in the World system.
  95751. * @param x x coordinate
  95752. * @param z z coordinate
  95753. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  95754. */
  95755. getNormalAtCoordinates(x: number, z: number): Vector3;
  95756. /**
  95757. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  95758. * at the ground coordinates (x, z) expressed in the World system.
  95759. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  95760. * @param x x coordinate
  95761. * @param z z coordinate
  95762. * @param ref vector to store the result
  95763. * @returns the GroundMesh.
  95764. */
  95765. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  95766. /**
  95767. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  95768. * if the ground has been updated.
  95769. * This can be used in the render loop.
  95770. * @returns the GroundMesh.
  95771. */
  95772. updateCoordinateHeights(): GroundMesh;
  95773. private _getFacetAt;
  95774. private _initHeightQuads;
  95775. private _computeHeightQuads;
  95776. /**
  95777. * Serializes this ground mesh
  95778. * @param serializationObject object to write serialization to
  95779. */
  95780. serialize(serializationObject: any): void;
  95781. /**
  95782. * Parses a serialized ground mesh
  95783. * @param parsedMesh the serialized mesh
  95784. * @param scene the scene to create the ground mesh in
  95785. * @returns the created ground mesh
  95786. */
  95787. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  95788. }
  95789. }
  95790. declare module BABYLON {
  95791. /**
  95792. * Interface for Physics-Joint data
  95793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95794. */
  95795. export interface PhysicsJointData {
  95796. /**
  95797. * The main pivot of the joint
  95798. */
  95799. mainPivot?: Vector3;
  95800. /**
  95801. * The connected pivot of the joint
  95802. */
  95803. connectedPivot?: Vector3;
  95804. /**
  95805. * The main axis of the joint
  95806. */
  95807. mainAxis?: Vector3;
  95808. /**
  95809. * The connected axis of the joint
  95810. */
  95811. connectedAxis?: Vector3;
  95812. /**
  95813. * The collision of the joint
  95814. */
  95815. collision?: boolean;
  95816. /**
  95817. * Native Oimo/Cannon/Energy data
  95818. */
  95819. nativeParams?: any;
  95820. }
  95821. /**
  95822. * This is a holder class for the physics joint created by the physics plugin
  95823. * It holds a set of functions to control the underlying joint
  95824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95825. */
  95826. export class PhysicsJoint {
  95827. /**
  95828. * The type of the physics joint
  95829. */
  95830. type: number;
  95831. /**
  95832. * The data for the physics joint
  95833. */
  95834. jointData: PhysicsJointData;
  95835. private _physicsJoint;
  95836. protected _physicsPlugin: IPhysicsEnginePlugin;
  95837. /**
  95838. * Initializes the physics joint
  95839. * @param type The type of the physics joint
  95840. * @param jointData The data for the physics joint
  95841. */
  95842. constructor(
  95843. /**
  95844. * The type of the physics joint
  95845. */
  95846. type: number,
  95847. /**
  95848. * The data for the physics joint
  95849. */
  95850. jointData: PhysicsJointData);
  95851. /**
  95852. * Gets the physics joint
  95853. */
  95854. get physicsJoint(): any;
  95855. /**
  95856. * Sets the physics joint
  95857. */
  95858. set physicsJoint(newJoint: any);
  95859. /**
  95860. * Sets the physics plugin
  95861. */
  95862. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  95863. /**
  95864. * Execute a function that is physics-plugin specific.
  95865. * @param {Function} func the function that will be executed.
  95866. * It accepts two parameters: the physics world and the physics joint
  95867. */
  95868. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  95869. /**
  95870. * Distance-Joint type
  95871. */
  95872. static DistanceJoint: number;
  95873. /**
  95874. * Hinge-Joint type
  95875. */
  95876. static HingeJoint: number;
  95877. /**
  95878. * Ball-and-Socket joint type
  95879. */
  95880. static BallAndSocketJoint: number;
  95881. /**
  95882. * Wheel-Joint type
  95883. */
  95884. static WheelJoint: number;
  95885. /**
  95886. * Slider-Joint type
  95887. */
  95888. static SliderJoint: number;
  95889. /**
  95890. * Prismatic-Joint type
  95891. */
  95892. static PrismaticJoint: number;
  95893. /**
  95894. * Universal-Joint type
  95895. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  95896. */
  95897. static UniversalJoint: number;
  95898. /**
  95899. * Hinge-Joint 2 type
  95900. */
  95901. static Hinge2Joint: number;
  95902. /**
  95903. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  95904. */
  95905. static PointToPointJoint: number;
  95906. /**
  95907. * Spring-Joint type
  95908. */
  95909. static SpringJoint: number;
  95910. /**
  95911. * Lock-Joint type
  95912. */
  95913. static LockJoint: number;
  95914. }
  95915. /**
  95916. * A class representing a physics distance joint
  95917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95918. */
  95919. export class DistanceJoint extends PhysicsJoint {
  95920. /**
  95921. *
  95922. * @param jointData The data for the Distance-Joint
  95923. */
  95924. constructor(jointData: DistanceJointData);
  95925. /**
  95926. * Update the predefined distance.
  95927. * @param maxDistance The maximum preferred distance
  95928. * @param minDistance The minimum preferred distance
  95929. */
  95930. updateDistance(maxDistance: number, minDistance?: number): void;
  95931. }
  95932. /**
  95933. * Represents a Motor-Enabled Joint
  95934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95935. */
  95936. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  95937. /**
  95938. * Initializes the Motor-Enabled Joint
  95939. * @param type The type of the joint
  95940. * @param jointData The physica joint data for the joint
  95941. */
  95942. constructor(type: number, jointData: PhysicsJointData);
  95943. /**
  95944. * Set the motor values.
  95945. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95946. * @param force the force to apply
  95947. * @param maxForce max force for this motor.
  95948. */
  95949. setMotor(force?: number, maxForce?: number): void;
  95950. /**
  95951. * Set the motor's limits.
  95952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95953. * @param upperLimit The upper limit of the motor
  95954. * @param lowerLimit The lower limit of the motor
  95955. */
  95956. setLimit(upperLimit: number, lowerLimit?: number): void;
  95957. }
  95958. /**
  95959. * This class represents a single physics Hinge-Joint
  95960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95961. */
  95962. export class HingeJoint extends MotorEnabledJoint {
  95963. /**
  95964. * Initializes the Hinge-Joint
  95965. * @param jointData The joint data for the Hinge-Joint
  95966. */
  95967. constructor(jointData: PhysicsJointData);
  95968. /**
  95969. * Set the motor values.
  95970. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95971. * @param {number} force the force to apply
  95972. * @param {number} maxForce max force for this motor.
  95973. */
  95974. setMotor(force?: number, maxForce?: number): void;
  95975. /**
  95976. * Set the motor's limits.
  95977. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95978. * @param upperLimit The upper limit of the motor
  95979. * @param lowerLimit The lower limit of the motor
  95980. */
  95981. setLimit(upperLimit: number, lowerLimit?: number): void;
  95982. }
  95983. /**
  95984. * This class represents a dual hinge physics joint (same as wheel joint)
  95985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95986. */
  95987. export class Hinge2Joint extends MotorEnabledJoint {
  95988. /**
  95989. * Initializes the Hinge2-Joint
  95990. * @param jointData The joint data for the Hinge2-Joint
  95991. */
  95992. constructor(jointData: PhysicsJointData);
  95993. /**
  95994. * Set the motor values.
  95995. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95996. * @param {number} targetSpeed the speed the motor is to reach
  95997. * @param {number} maxForce max force for this motor.
  95998. * @param {motorIndex} the motor's index, 0 or 1.
  95999. */
  96000. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96001. /**
  96002. * Set the motor limits.
  96003. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96004. * @param {number} upperLimit the upper limit
  96005. * @param {number} lowerLimit lower limit
  96006. * @param {motorIndex} the motor's index, 0 or 1.
  96007. */
  96008. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96009. }
  96010. /**
  96011. * Interface for a motor enabled joint
  96012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96013. */
  96014. export interface IMotorEnabledJoint {
  96015. /**
  96016. * Physics joint
  96017. */
  96018. physicsJoint: any;
  96019. /**
  96020. * Sets the motor of the motor-enabled joint
  96021. * @param force The force of the motor
  96022. * @param maxForce The maximum force of the motor
  96023. * @param motorIndex The index of the motor
  96024. */
  96025. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96026. /**
  96027. * Sets the limit of the motor
  96028. * @param upperLimit The upper limit of the motor
  96029. * @param lowerLimit The lower limit of the motor
  96030. * @param motorIndex The index of the motor
  96031. */
  96032. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96033. }
  96034. /**
  96035. * Joint data for a Distance-Joint
  96036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96037. */
  96038. export interface DistanceJointData extends PhysicsJointData {
  96039. /**
  96040. * Max distance the 2 joint objects can be apart
  96041. */
  96042. maxDistance: number;
  96043. }
  96044. /**
  96045. * Joint data from a spring joint
  96046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96047. */
  96048. export interface SpringJointData extends PhysicsJointData {
  96049. /**
  96050. * Length of the spring
  96051. */
  96052. length: number;
  96053. /**
  96054. * Stiffness of the spring
  96055. */
  96056. stiffness: number;
  96057. /**
  96058. * Damping of the spring
  96059. */
  96060. damping: number;
  96061. /** this callback will be called when applying the force to the impostors. */
  96062. forceApplicationCallback: () => void;
  96063. }
  96064. }
  96065. declare module BABYLON {
  96066. /**
  96067. * Holds the data for the raycast result
  96068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96069. */
  96070. export class PhysicsRaycastResult {
  96071. private _hasHit;
  96072. private _hitDistance;
  96073. private _hitNormalWorld;
  96074. private _hitPointWorld;
  96075. private _rayFromWorld;
  96076. private _rayToWorld;
  96077. /**
  96078. * Gets if there was a hit
  96079. */
  96080. get hasHit(): boolean;
  96081. /**
  96082. * Gets the distance from the hit
  96083. */
  96084. get hitDistance(): number;
  96085. /**
  96086. * Gets the hit normal/direction in the world
  96087. */
  96088. get hitNormalWorld(): Vector3;
  96089. /**
  96090. * Gets the hit point in the world
  96091. */
  96092. get hitPointWorld(): Vector3;
  96093. /**
  96094. * Gets the ray "start point" of the ray in the world
  96095. */
  96096. get rayFromWorld(): Vector3;
  96097. /**
  96098. * Gets the ray "end point" of the ray in the world
  96099. */
  96100. get rayToWorld(): Vector3;
  96101. /**
  96102. * Sets the hit data (normal & point in world space)
  96103. * @param hitNormalWorld defines the normal in world space
  96104. * @param hitPointWorld defines the point in world space
  96105. */
  96106. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96107. /**
  96108. * Sets the distance from the start point to the hit point
  96109. * @param distance
  96110. */
  96111. setHitDistance(distance: number): void;
  96112. /**
  96113. * Calculates the distance manually
  96114. */
  96115. calculateHitDistance(): void;
  96116. /**
  96117. * Resets all the values to default
  96118. * @param from The from point on world space
  96119. * @param to The to point on world space
  96120. */
  96121. reset(from?: Vector3, to?: Vector3): void;
  96122. }
  96123. /**
  96124. * Interface for the size containing width and height
  96125. */
  96126. interface IXYZ {
  96127. /**
  96128. * X
  96129. */
  96130. x: number;
  96131. /**
  96132. * Y
  96133. */
  96134. y: number;
  96135. /**
  96136. * Z
  96137. */
  96138. z: number;
  96139. }
  96140. }
  96141. declare module BABYLON {
  96142. /**
  96143. * Interface used to describe a physics joint
  96144. */
  96145. export interface PhysicsImpostorJoint {
  96146. /** Defines the main impostor to which the joint is linked */
  96147. mainImpostor: PhysicsImpostor;
  96148. /** Defines the impostor that is connected to the main impostor using this joint */
  96149. connectedImpostor: PhysicsImpostor;
  96150. /** Defines the joint itself */
  96151. joint: PhysicsJoint;
  96152. }
  96153. /** @hidden */
  96154. export interface IPhysicsEnginePlugin {
  96155. world: any;
  96156. name: string;
  96157. setGravity(gravity: Vector3): void;
  96158. setTimeStep(timeStep: number): void;
  96159. getTimeStep(): number;
  96160. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96161. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96162. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96163. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96164. removePhysicsBody(impostor: PhysicsImpostor): void;
  96165. generateJoint(joint: PhysicsImpostorJoint): void;
  96166. removeJoint(joint: PhysicsImpostorJoint): void;
  96167. isSupported(): boolean;
  96168. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96169. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96170. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96171. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96172. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96173. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96174. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96175. getBodyMass(impostor: PhysicsImpostor): number;
  96176. getBodyFriction(impostor: PhysicsImpostor): number;
  96177. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96178. getBodyRestitution(impostor: PhysicsImpostor): number;
  96179. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96180. getBodyPressure?(impostor: PhysicsImpostor): number;
  96181. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96182. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96183. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96184. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96185. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96186. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96187. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96188. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96189. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96190. sleepBody(impostor: PhysicsImpostor): void;
  96191. wakeUpBody(impostor: PhysicsImpostor): void;
  96192. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96193. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96194. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96195. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96196. getRadius(impostor: PhysicsImpostor): number;
  96197. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96198. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96199. dispose(): void;
  96200. }
  96201. /**
  96202. * Interface used to define a physics engine
  96203. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96204. */
  96205. export interface IPhysicsEngine {
  96206. /**
  96207. * Gets the gravity vector used by the simulation
  96208. */
  96209. gravity: Vector3;
  96210. /**
  96211. * Sets the gravity vector used by the simulation
  96212. * @param gravity defines the gravity vector to use
  96213. */
  96214. setGravity(gravity: Vector3): void;
  96215. /**
  96216. * Set the time step of the physics engine.
  96217. * Default is 1/60.
  96218. * To slow it down, enter 1/600 for example.
  96219. * To speed it up, 1/30
  96220. * @param newTimeStep the new timestep to apply to this world.
  96221. */
  96222. setTimeStep(newTimeStep: number): void;
  96223. /**
  96224. * Get the time step of the physics engine.
  96225. * @returns the current time step
  96226. */
  96227. getTimeStep(): number;
  96228. /**
  96229. * Set the sub time step of the physics engine.
  96230. * Default is 0 meaning there is no sub steps
  96231. * To increase physics resolution precision, set a small value (like 1 ms)
  96232. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96233. */
  96234. setSubTimeStep(subTimeStep: number): void;
  96235. /**
  96236. * Get the sub time step of the physics engine.
  96237. * @returns the current sub time step
  96238. */
  96239. getSubTimeStep(): number;
  96240. /**
  96241. * Release all resources
  96242. */
  96243. dispose(): void;
  96244. /**
  96245. * Gets the name of the current physics plugin
  96246. * @returns the name of the plugin
  96247. */
  96248. getPhysicsPluginName(): string;
  96249. /**
  96250. * Adding a new impostor for the impostor tracking.
  96251. * This will be done by the impostor itself.
  96252. * @param impostor the impostor to add
  96253. */
  96254. addImpostor(impostor: PhysicsImpostor): void;
  96255. /**
  96256. * Remove an impostor from the engine.
  96257. * This impostor and its mesh will not longer be updated by the physics engine.
  96258. * @param impostor the impostor to remove
  96259. */
  96260. removeImpostor(impostor: PhysicsImpostor): void;
  96261. /**
  96262. * Add a joint to the physics engine
  96263. * @param mainImpostor defines the main impostor to which the joint is added.
  96264. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96265. * @param joint defines the joint that will connect both impostors.
  96266. */
  96267. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96268. /**
  96269. * Removes a joint from the simulation
  96270. * @param mainImpostor defines the impostor used with the joint
  96271. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96272. * @param joint defines the joint to remove
  96273. */
  96274. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96275. /**
  96276. * Gets the current plugin used to run the simulation
  96277. * @returns current plugin
  96278. */
  96279. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96280. /**
  96281. * Gets the list of physic impostors
  96282. * @returns an array of PhysicsImpostor
  96283. */
  96284. getImpostors(): Array<PhysicsImpostor>;
  96285. /**
  96286. * Gets the impostor for a physics enabled object
  96287. * @param object defines the object impersonated by the impostor
  96288. * @returns the PhysicsImpostor or null if not found
  96289. */
  96290. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96291. /**
  96292. * Gets the impostor for a physics body object
  96293. * @param body defines physics body used by the impostor
  96294. * @returns the PhysicsImpostor or null if not found
  96295. */
  96296. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96297. /**
  96298. * Does a raycast in the physics world
  96299. * @param from when should the ray start?
  96300. * @param to when should the ray end?
  96301. * @returns PhysicsRaycastResult
  96302. */
  96303. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96304. /**
  96305. * Called by the scene. No need to call it.
  96306. * @param delta defines the timespam between frames
  96307. */
  96308. _step(delta: number): void;
  96309. }
  96310. }
  96311. declare module BABYLON {
  96312. /**
  96313. * The interface for the physics imposter parameters
  96314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96315. */
  96316. export interface PhysicsImpostorParameters {
  96317. /**
  96318. * The mass of the physics imposter
  96319. */
  96320. mass: number;
  96321. /**
  96322. * The friction of the physics imposter
  96323. */
  96324. friction?: number;
  96325. /**
  96326. * The coefficient of restitution of the physics imposter
  96327. */
  96328. restitution?: number;
  96329. /**
  96330. * The native options of the physics imposter
  96331. */
  96332. nativeOptions?: any;
  96333. /**
  96334. * Specifies if the parent should be ignored
  96335. */
  96336. ignoreParent?: boolean;
  96337. /**
  96338. * Specifies if bi-directional transformations should be disabled
  96339. */
  96340. disableBidirectionalTransformation?: boolean;
  96341. /**
  96342. * The pressure inside the physics imposter, soft object only
  96343. */
  96344. pressure?: number;
  96345. /**
  96346. * The stiffness the physics imposter, soft object only
  96347. */
  96348. stiffness?: number;
  96349. /**
  96350. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96351. */
  96352. velocityIterations?: number;
  96353. /**
  96354. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96355. */
  96356. positionIterations?: number;
  96357. /**
  96358. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96359. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96360. * Add to fix multiple points
  96361. */
  96362. fixedPoints?: number;
  96363. /**
  96364. * The collision margin around a soft object
  96365. */
  96366. margin?: number;
  96367. /**
  96368. * The collision margin around a soft object
  96369. */
  96370. damping?: number;
  96371. /**
  96372. * The path for a rope based on an extrusion
  96373. */
  96374. path?: any;
  96375. /**
  96376. * The shape of an extrusion used for a rope based on an extrusion
  96377. */
  96378. shape?: any;
  96379. }
  96380. /**
  96381. * Interface for a physics-enabled object
  96382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96383. */
  96384. export interface IPhysicsEnabledObject {
  96385. /**
  96386. * The position of the physics-enabled object
  96387. */
  96388. position: Vector3;
  96389. /**
  96390. * The rotation of the physics-enabled object
  96391. */
  96392. rotationQuaternion: Nullable<Quaternion>;
  96393. /**
  96394. * The scale of the physics-enabled object
  96395. */
  96396. scaling: Vector3;
  96397. /**
  96398. * The rotation of the physics-enabled object
  96399. */
  96400. rotation?: Vector3;
  96401. /**
  96402. * The parent of the physics-enabled object
  96403. */
  96404. parent?: any;
  96405. /**
  96406. * The bounding info of the physics-enabled object
  96407. * @returns The bounding info of the physics-enabled object
  96408. */
  96409. getBoundingInfo(): BoundingInfo;
  96410. /**
  96411. * Computes the world matrix
  96412. * @param force Specifies if the world matrix should be computed by force
  96413. * @returns A world matrix
  96414. */
  96415. computeWorldMatrix(force: boolean): Matrix;
  96416. /**
  96417. * Gets the world matrix
  96418. * @returns A world matrix
  96419. */
  96420. getWorldMatrix?(): Matrix;
  96421. /**
  96422. * Gets the child meshes
  96423. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96424. * @returns An array of abstract meshes
  96425. */
  96426. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96427. /**
  96428. * Gets the vertex data
  96429. * @param kind The type of vertex data
  96430. * @returns A nullable array of numbers, or a float32 array
  96431. */
  96432. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96433. /**
  96434. * Gets the indices from the mesh
  96435. * @returns A nullable array of index arrays
  96436. */
  96437. getIndices?(): Nullable<IndicesArray>;
  96438. /**
  96439. * Gets the scene from the mesh
  96440. * @returns the indices array or null
  96441. */
  96442. getScene?(): Scene;
  96443. /**
  96444. * Gets the absolute position from the mesh
  96445. * @returns the absolute position
  96446. */
  96447. getAbsolutePosition(): Vector3;
  96448. /**
  96449. * Gets the absolute pivot point from the mesh
  96450. * @returns the absolute pivot point
  96451. */
  96452. getAbsolutePivotPoint(): Vector3;
  96453. /**
  96454. * Rotates the mesh
  96455. * @param axis The axis of rotation
  96456. * @param amount The amount of rotation
  96457. * @param space The space of the rotation
  96458. * @returns The rotation transform node
  96459. */
  96460. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96461. /**
  96462. * Translates the mesh
  96463. * @param axis The axis of translation
  96464. * @param distance The distance of translation
  96465. * @param space The space of the translation
  96466. * @returns The transform node
  96467. */
  96468. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96469. /**
  96470. * Sets the absolute position of the mesh
  96471. * @param absolutePosition The absolute position of the mesh
  96472. * @returns The transform node
  96473. */
  96474. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96475. /**
  96476. * Gets the class name of the mesh
  96477. * @returns The class name
  96478. */
  96479. getClassName(): string;
  96480. }
  96481. /**
  96482. * Represents a physics imposter
  96483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96484. */
  96485. export class PhysicsImpostor {
  96486. /**
  96487. * The physics-enabled object used as the physics imposter
  96488. */
  96489. object: IPhysicsEnabledObject;
  96490. /**
  96491. * The type of the physics imposter
  96492. */
  96493. type: number;
  96494. private _options;
  96495. private _scene?;
  96496. /**
  96497. * The default object size of the imposter
  96498. */
  96499. static DEFAULT_OBJECT_SIZE: Vector3;
  96500. /**
  96501. * The identity quaternion of the imposter
  96502. */
  96503. static IDENTITY_QUATERNION: Quaternion;
  96504. /** @hidden */
  96505. _pluginData: any;
  96506. private _physicsEngine;
  96507. private _physicsBody;
  96508. private _bodyUpdateRequired;
  96509. private _onBeforePhysicsStepCallbacks;
  96510. private _onAfterPhysicsStepCallbacks;
  96511. /** @hidden */
  96512. _onPhysicsCollideCallbacks: Array<{
  96513. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96514. otherImpostors: Array<PhysicsImpostor>;
  96515. }>;
  96516. private _deltaPosition;
  96517. private _deltaRotation;
  96518. private _deltaRotationConjugated;
  96519. /** @hidden */
  96520. _isFromLine: boolean;
  96521. private _parent;
  96522. private _isDisposed;
  96523. private static _tmpVecs;
  96524. private static _tmpQuat;
  96525. /**
  96526. * Specifies if the physics imposter is disposed
  96527. */
  96528. get isDisposed(): boolean;
  96529. /**
  96530. * Gets the mass of the physics imposter
  96531. */
  96532. get mass(): number;
  96533. set mass(value: number);
  96534. /**
  96535. * Gets the coefficient of friction
  96536. */
  96537. get friction(): number;
  96538. /**
  96539. * Sets the coefficient of friction
  96540. */
  96541. set friction(value: number);
  96542. /**
  96543. * Gets the coefficient of restitution
  96544. */
  96545. get restitution(): number;
  96546. /**
  96547. * Sets the coefficient of restitution
  96548. */
  96549. set restitution(value: number);
  96550. /**
  96551. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96552. */
  96553. get pressure(): number;
  96554. /**
  96555. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96556. */
  96557. set pressure(value: number);
  96558. /**
  96559. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96560. */
  96561. get stiffness(): number;
  96562. /**
  96563. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96564. */
  96565. set stiffness(value: number);
  96566. /**
  96567. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96568. */
  96569. get velocityIterations(): number;
  96570. /**
  96571. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96572. */
  96573. set velocityIterations(value: number);
  96574. /**
  96575. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96576. */
  96577. get positionIterations(): number;
  96578. /**
  96579. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96580. */
  96581. set positionIterations(value: number);
  96582. /**
  96583. * The unique id of the physics imposter
  96584. * set by the physics engine when adding this impostor to the array
  96585. */
  96586. uniqueId: number;
  96587. /**
  96588. * @hidden
  96589. */
  96590. soft: boolean;
  96591. /**
  96592. * @hidden
  96593. */
  96594. segments: number;
  96595. private _joints;
  96596. /**
  96597. * Initializes the physics imposter
  96598. * @param object The physics-enabled object used as the physics imposter
  96599. * @param type The type of the physics imposter
  96600. * @param _options The options for the physics imposter
  96601. * @param _scene The Babylon scene
  96602. */
  96603. constructor(
  96604. /**
  96605. * The physics-enabled object used as the physics imposter
  96606. */
  96607. object: IPhysicsEnabledObject,
  96608. /**
  96609. * The type of the physics imposter
  96610. */
  96611. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  96612. /**
  96613. * This function will completly initialize this impostor.
  96614. * It will create a new body - but only if this mesh has no parent.
  96615. * If it has, this impostor will not be used other than to define the impostor
  96616. * of the child mesh.
  96617. * @hidden
  96618. */
  96619. _init(): void;
  96620. private _getPhysicsParent;
  96621. /**
  96622. * Should a new body be generated.
  96623. * @returns boolean specifying if body initialization is required
  96624. */
  96625. isBodyInitRequired(): boolean;
  96626. /**
  96627. * Sets the updated scaling
  96628. * @param updated Specifies if the scaling is updated
  96629. */
  96630. setScalingUpdated(): void;
  96631. /**
  96632. * Force a regeneration of this or the parent's impostor's body.
  96633. * Use under cautious - This will remove all joints already implemented.
  96634. */
  96635. forceUpdate(): void;
  96636. /**
  96637. * Gets the body that holds this impostor. Either its own, or its parent.
  96638. */
  96639. get physicsBody(): any;
  96640. /**
  96641. * Get the parent of the physics imposter
  96642. * @returns Physics imposter or null
  96643. */
  96644. get parent(): Nullable<PhysicsImpostor>;
  96645. /**
  96646. * Sets the parent of the physics imposter
  96647. */
  96648. set parent(value: Nullable<PhysicsImpostor>);
  96649. /**
  96650. * Set the physics body. Used mainly by the physics engine/plugin
  96651. */
  96652. set physicsBody(physicsBody: any);
  96653. /**
  96654. * Resets the update flags
  96655. */
  96656. resetUpdateFlags(): void;
  96657. /**
  96658. * Gets the object extend size
  96659. * @returns the object extend size
  96660. */
  96661. getObjectExtendSize(): Vector3;
  96662. /**
  96663. * Gets the object center
  96664. * @returns The object center
  96665. */
  96666. getObjectCenter(): Vector3;
  96667. /**
  96668. * Get a specific parameter from the options parameters
  96669. * @param paramName The object parameter name
  96670. * @returns The object parameter
  96671. */
  96672. getParam(paramName: string): any;
  96673. /**
  96674. * Sets a specific parameter in the options given to the physics plugin
  96675. * @param paramName The parameter name
  96676. * @param value The value of the parameter
  96677. */
  96678. setParam(paramName: string, value: number): void;
  96679. /**
  96680. * Specifically change the body's mass option. Won't recreate the physics body object
  96681. * @param mass The mass of the physics imposter
  96682. */
  96683. setMass(mass: number): void;
  96684. /**
  96685. * Gets the linear velocity
  96686. * @returns linear velocity or null
  96687. */
  96688. getLinearVelocity(): Nullable<Vector3>;
  96689. /**
  96690. * Sets the linear velocity
  96691. * @param velocity linear velocity or null
  96692. */
  96693. setLinearVelocity(velocity: Nullable<Vector3>): void;
  96694. /**
  96695. * Gets the angular velocity
  96696. * @returns angular velocity or null
  96697. */
  96698. getAngularVelocity(): Nullable<Vector3>;
  96699. /**
  96700. * Sets the angular velocity
  96701. * @param velocity The velocity or null
  96702. */
  96703. setAngularVelocity(velocity: Nullable<Vector3>): void;
  96704. /**
  96705. * Execute a function with the physics plugin native code
  96706. * Provide a function the will have two variables - the world object and the physics body object
  96707. * @param func The function to execute with the physics plugin native code
  96708. */
  96709. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  96710. /**
  96711. * Register a function that will be executed before the physics world is stepping forward
  96712. * @param func The function to execute before the physics world is stepped forward
  96713. */
  96714. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96715. /**
  96716. * Unregister a function that will be executed before the physics world is stepping forward
  96717. * @param func The function to execute before the physics world is stepped forward
  96718. */
  96719. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96720. /**
  96721. * Register a function that will be executed after the physics step
  96722. * @param func The function to execute after physics step
  96723. */
  96724. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96725. /**
  96726. * Unregisters a function that will be executed after the physics step
  96727. * @param func The function to execute after physics step
  96728. */
  96729. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96730. /**
  96731. * register a function that will be executed when this impostor collides against a different body
  96732. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  96733. * @param func Callback that is executed on collision
  96734. */
  96735. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  96736. /**
  96737. * Unregisters the physics imposter on contact
  96738. * @param collideAgainst The physics object to collide against
  96739. * @param func Callback to execute on collision
  96740. */
  96741. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  96742. private _tmpQuat;
  96743. private _tmpQuat2;
  96744. /**
  96745. * Get the parent rotation
  96746. * @returns The parent rotation
  96747. */
  96748. getParentsRotation(): Quaternion;
  96749. /**
  96750. * this function is executed by the physics engine.
  96751. */
  96752. beforeStep: () => void;
  96753. /**
  96754. * this function is executed by the physics engine
  96755. */
  96756. afterStep: () => void;
  96757. /**
  96758. * Legacy collision detection event support
  96759. */
  96760. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  96761. /**
  96762. * event and body object due to cannon's event-based architecture.
  96763. */
  96764. onCollide: (e: {
  96765. body: any;
  96766. }) => void;
  96767. /**
  96768. * Apply a force
  96769. * @param force The force to apply
  96770. * @param contactPoint The contact point for the force
  96771. * @returns The physics imposter
  96772. */
  96773. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96774. /**
  96775. * Apply an impulse
  96776. * @param force The impulse force
  96777. * @param contactPoint The contact point for the impulse force
  96778. * @returns The physics imposter
  96779. */
  96780. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96781. /**
  96782. * A help function to create a joint
  96783. * @param otherImpostor A physics imposter used to create a joint
  96784. * @param jointType The type of joint
  96785. * @param jointData The data for the joint
  96786. * @returns The physics imposter
  96787. */
  96788. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  96789. /**
  96790. * Add a joint to this impostor with a different impostor
  96791. * @param otherImpostor A physics imposter used to add a joint
  96792. * @param joint The joint to add
  96793. * @returns The physics imposter
  96794. */
  96795. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  96796. /**
  96797. * Add an anchor to a cloth impostor
  96798. * @param otherImpostor rigid impostor to anchor to
  96799. * @param width ratio across width from 0 to 1
  96800. * @param height ratio up height from 0 to 1
  96801. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  96802. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  96803. * @returns impostor the soft imposter
  96804. */
  96805. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96806. /**
  96807. * Add a hook to a rope impostor
  96808. * @param otherImpostor rigid impostor to anchor to
  96809. * @param length ratio across rope from 0 to 1
  96810. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  96811. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  96812. * @returns impostor the rope imposter
  96813. */
  96814. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96815. /**
  96816. * Will keep this body still, in a sleep mode.
  96817. * @returns the physics imposter
  96818. */
  96819. sleep(): PhysicsImpostor;
  96820. /**
  96821. * Wake the body up.
  96822. * @returns The physics imposter
  96823. */
  96824. wakeUp(): PhysicsImpostor;
  96825. /**
  96826. * Clones the physics imposter
  96827. * @param newObject The physics imposter clones to this physics-enabled object
  96828. * @returns A nullable physics imposter
  96829. */
  96830. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96831. /**
  96832. * Disposes the physics imposter
  96833. */
  96834. dispose(): void;
  96835. /**
  96836. * Sets the delta position
  96837. * @param position The delta position amount
  96838. */
  96839. setDeltaPosition(position: Vector3): void;
  96840. /**
  96841. * Sets the delta rotation
  96842. * @param rotation The delta rotation amount
  96843. */
  96844. setDeltaRotation(rotation: Quaternion): void;
  96845. /**
  96846. * Gets the box size of the physics imposter and stores the result in the input parameter
  96847. * @param result Stores the box size
  96848. * @returns The physics imposter
  96849. */
  96850. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  96851. /**
  96852. * Gets the radius of the physics imposter
  96853. * @returns Radius of the physics imposter
  96854. */
  96855. getRadius(): number;
  96856. /**
  96857. * Sync a bone with this impostor
  96858. * @param bone The bone to sync to the impostor.
  96859. * @param boneMesh The mesh that the bone is influencing.
  96860. * @param jointPivot The pivot of the joint / bone in local space.
  96861. * @param distToJoint Optional distance from the impostor to the joint.
  96862. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96863. */
  96864. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  96865. /**
  96866. * Sync impostor to a bone
  96867. * @param bone The bone that the impostor will be synced to.
  96868. * @param boneMesh The mesh that the bone is influencing.
  96869. * @param jointPivot The pivot of the joint / bone in local space.
  96870. * @param distToJoint Optional distance from the impostor to the joint.
  96871. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96872. * @param boneAxis Optional vector3 axis the bone is aligned with
  96873. */
  96874. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  96875. /**
  96876. * No-Imposter type
  96877. */
  96878. static NoImpostor: number;
  96879. /**
  96880. * Sphere-Imposter type
  96881. */
  96882. static SphereImpostor: number;
  96883. /**
  96884. * Box-Imposter type
  96885. */
  96886. static BoxImpostor: number;
  96887. /**
  96888. * Plane-Imposter type
  96889. */
  96890. static PlaneImpostor: number;
  96891. /**
  96892. * Mesh-imposter type
  96893. */
  96894. static MeshImpostor: number;
  96895. /**
  96896. * Capsule-Impostor type (Ammo.js plugin only)
  96897. */
  96898. static CapsuleImpostor: number;
  96899. /**
  96900. * Cylinder-Imposter type
  96901. */
  96902. static CylinderImpostor: number;
  96903. /**
  96904. * Particle-Imposter type
  96905. */
  96906. static ParticleImpostor: number;
  96907. /**
  96908. * Heightmap-Imposter type
  96909. */
  96910. static HeightmapImpostor: number;
  96911. /**
  96912. * ConvexHull-Impostor type (Ammo.js plugin only)
  96913. */
  96914. static ConvexHullImpostor: number;
  96915. /**
  96916. * Custom-Imposter type (Ammo.js plugin only)
  96917. */
  96918. static CustomImpostor: number;
  96919. /**
  96920. * Rope-Imposter type
  96921. */
  96922. static RopeImpostor: number;
  96923. /**
  96924. * Cloth-Imposter type
  96925. */
  96926. static ClothImpostor: number;
  96927. /**
  96928. * Softbody-Imposter type
  96929. */
  96930. static SoftbodyImpostor: number;
  96931. }
  96932. }
  96933. declare module BABYLON {
  96934. /**
  96935. * @hidden
  96936. **/
  96937. export class _CreationDataStorage {
  96938. closePath?: boolean;
  96939. closeArray?: boolean;
  96940. idx: number[];
  96941. dashSize: number;
  96942. gapSize: number;
  96943. path3D: Path3D;
  96944. pathArray: Vector3[][];
  96945. arc: number;
  96946. radius: number;
  96947. cap: number;
  96948. tessellation: number;
  96949. }
  96950. /**
  96951. * @hidden
  96952. **/
  96953. class _InstanceDataStorage {
  96954. visibleInstances: any;
  96955. batchCache: _InstancesBatch;
  96956. instancesBufferSize: number;
  96957. instancesBuffer: Nullable<Buffer>;
  96958. instancesData: Float32Array;
  96959. overridenInstanceCount: number;
  96960. isFrozen: boolean;
  96961. previousBatch: Nullable<_InstancesBatch>;
  96962. hardwareInstancedRendering: boolean;
  96963. sideOrientation: number;
  96964. manualUpdate: boolean;
  96965. }
  96966. /**
  96967. * @hidden
  96968. **/
  96969. export class _InstancesBatch {
  96970. mustReturn: boolean;
  96971. visibleInstances: Nullable<InstancedMesh[]>[];
  96972. renderSelf: boolean[];
  96973. hardwareInstancedRendering: boolean[];
  96974. }
  96975. /**
  96976. * Class used to represent renderable models
  96977. */
  96978. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  96979. /**
  96980. * Mesh side orientation : usually the external or front surface
  96981. */
  96982. static readonly FRONTSIDE: number;
  96983. /**
  96984. * Mesh side orientation : usually the internal or back surface
  96985. */
  96986. static readonly BACKSIDE: number;
  96987. /**
  96988. * Mesh side orientation : both internal and external or front and back surfaces
  96989. */
  96990. static readonly DOUBLESIDE: number;
  96991. /**
  96992. * Mesh side orientation : by default, `FRONTSIDE`
  96993. */
  96994. static readonly DEFAULTSIDE: number;
  96995. /**
  96996. * Mesh cap setting : no cap
  96997. */
  96998. static readonly NO_CAP: number;
  96999. /**
  97000. * Mesh cap setting : one cap at the beginning of the mesh
  97001. */
  97002. static readonly CAP_START: number;
  97003. /**
  97004. * Mesh cap setting : one cap at the end of the mesh
  97005. */
  97006. static readonly CAP_END: number;
  97007. /**
  97008. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97009. */
  97010. static readonly CAP_ALL: number;
  97011. /**
  97012. * Mesh pattern setting : no flip or rotate
  97013. */
  97014. static readonly NO_FLIP: number;
  97015. /**
  97016. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97017. */
  97018. static readonly FLIP_TILE: number;
  97019. /**
  97020. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97021. */
  97022. static readonly ROTATE_TILE: number;
  97023. /**
  97024. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97025. */
  97026. static readonly FLIP_ROW: number;
  97027. /**
  97028. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97029. */
  97030. static readonly ROTATE_ROW: number;
  97031. /**
  97032. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97033. */
  97034. static readonly FLIP_N_ROTATE_TILE: number;
  97035. /**
  97036. * Mesh pattern setting : rotate pattern and rotate
  97037. */
  97038. static readonly FLIP_N_ROTATE_ROW: number;
  97039. /**
  97040. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97041. */
  97042. static readonly CENTER: number;
  97043. /**
  97044. * Mesh tile positioning : part tiles on left
  97045. */
  97046. static readonly LEFT: number;
  97047. /**
  97048. * Mesh tile positioning : part tiles on right
  97049. */
  97050. static readonly RIGHT: number;
  97051. /**
  97052. * Mesh tile positioning : part tiles on top
  97053. */
  97054. static readonly TOP: number;
  97055. /**
  97056. * Mesh tile positioning : part tiles on bottom
  97057. */
  97058. static readonly BOTTOM: number;
  97059. /**
  97060. * Gets the default side orientation.
  97061. * @param orientation the orientation to value to attempt to get
  97062. * @returns the default orientation
  97063. * @hidden
  97064. */
  97065. static _GetDefaultSideOrientation(orientation?: number): number;
  97066. private _internalMeshDataInfo;
  97067. /**
  97068. * An event triggered before rendering the mesh
  97069. */
  97070. get onBeforeRenderObservable(): Observable<Mesh>;
  97071. /**
  97072. * An event triggered before binding the mesh
  97073. */
  97074. get onBeforeBindObservable(): Observable<Mesh>;
  97075. /**
  97076. * An event triggered after rendering the mesh
  97077. */
  97078. get onAfterRenderObservable(): Observable<Mesh>;
  97079. /**
  97080. * An event triggered before drawing the mesh
  97081. */
  97082. get onBeforeDrawObservable(): Observable<Mesh>;
  97083. private _onBeforeDrawObserver;
  97084. /**
  97085. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97086. */
  97087. set onBeforeDraw(callback: () => void);
  97088. get hasInstances(): boolean;
  97089. /**
  97090. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97091. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97092. */
  97093. delayLoadState: number;
  97094. /**
  97095. * Gets the list of instances created from this mesh
  97096. * it is not supposed to be modified manually.
  97097. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97098. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97099. */
  97100. instances: InstancedMesh[];
  97101. /**
  97102. * Gets the file containing delay loading data for this mesh
  97103. */
  97104. delayLoadingFile: string;
  97105. /** @hidden */
  97106. _binaryInfo: any;
  97107. /**
  97108. * User defined function used to change how LOD level selection is done
  97109. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97110. */
  97111. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97112. /**
  97113. * Gets or sets the morph target manager
  97114. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97115. */
  97116. get morphTargetManager(): Nullable<MorphTargetManager>;
  97117. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97118. /** @hidden */
  97119. _creationDataStorage: Nullable<_CreationDataStorage>;
  97120. /** @hidden */
  97121. _geometry: Nullable<Geometry>;
  97122. /** @hidden */
  97123. _delayInfo: Array<string>;
  97124. /** @hidden */
  97125. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97126. /** @hidden */
  97127. _instanceDataStorage: _InstanceDataStorage;
  97128. private _effectiveMaterial;
  97129. /** @hidden */
  97130. _shouldGenerateFlatShading: boolean;
  97131. /** @hidden */
  97132. _originalBuilderSideOrientation: number;
  97133. /**
  97134. * Use this property to change the original side orientation defined at construction time
  97135. */
  97136. overrideMaterialSideOrientation: Nullable<number>;
  97137. /**
  97138. * Gets the source mesh (the one used to clone this one from)
  97139. */
  97140. get source(): Nullable<Mesh>;
  97141. /**
  97142. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97143. */
  97144. get isUnIndexed(): boolean;
  97145. set isUnIndexed(value: boolean);
  97146. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97147. get worldMatrixInstancedBuffer(): Float32Array;
  97148. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97149. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97150. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97151. /**
  97152. * @constructor
  97153. * @param name The value used by scene.getMeshByName() to do a lookup.
  97154. * @param scene The scene to add this mesh to.
  97155. * @param parent The parent of this mesh, if it has one
  97156. * @param source An optional Mesh from which geometry is shared, cloned.
  97157. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97158. * When false, achieved by calling a clone(), also passing False.
  97159. * This will make creation of children, recursive.
  97160. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97161. */
  97162. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97163. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97164. doNotInstantiate: boolean;
  97165. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97166. /**
  97167. * Gets the class name
  97168. * @returns the string "Mesh".
  97169. */
  97170. getClassName(): string;
  97171. /** @hidden */
  97172. get _isMesh(): boolean;
  97173. /**
  97174. * Returns a description of this mesh
  97175. * @param fullDetails define if full details about this mesh must be used
  97176. * @returns a descriptive string representing this mesh
  97177. */
  97178. toString(fullDetails?: boolean): string;
  97179. /** @hidden */
  97180. _unBindEffect(): void;
  97181. /**
  97182. * Gets a boolean indicating if this mesh has LOD
  97183. */
  97184. get hasLODLevels(): boolean;
  97185. /**
  97186. * Gets the list of MeshLODLevel associated with the current mesh
  97187. * @returns an array of MeshLODLevel
  97188. */
  97189. getLODLevels(): MeshLODLevel[];
  97190. private _sortLODLevels;
  97191. /**
  97192. * Add a mesh as LOD level triggered at the given distance.
  97193. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97194. * @param distance The distance from the center of the object to show this level
  97195. * @param mesh The mesh to be added as LOD level (can be null)
  97196. * @return This mesh (for chaining)
  97197. */
  97198. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97199. /**
  97200. * Returns the LOD level mesh at the passed distance or null if not found.
  97201. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97202. * @param distance The distance from the center of the object to show this level
  97203. * @returns a Mesh or `null`
  97204. */
  97205. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97206. /**
  97207. * Remove a mesh from the LOD array
  97208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97209. * @param mesh defines the mesh to be removed
  97210. * @return This mesh (for chaining)
  97211. */
  97212. removeLODLevel(mesh: Mesh): Mesh;
  97213. /**
  97214. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97215. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97216. * @param camera defines the camera to use to compute distance
  97217. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97218. * @return This mesh (for chaining)
  97219. */
  97220. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97221. /**
  97222. * Gets the mesh internal Geometry object
  97223. */
  97224. get geometry(): Nullable<Geometry>;
  97225. /**
  97226. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97227. * @returns the total number of vertices
  97228. */
  97229. getTotalVertices(): number;
  97230. /**
  97231. * Returns the content of an associated vertex buffer
  97232. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97233. * - VertexBuffer.PositionKind
  97234. * - VertexBuffer.UVKind
  97235. * - VertexBuffer.UV2Kind
  97236. * - VertexBuffer.UV3Kind
  97237. * - VertexBuffer.UV4Kind
  97238. * - VertexBuffer.UV5Kind
  97239. * - VertexBuffer.UV6Kind
  97240. * - VertexBuffer.ColorKind
  97241. * - VertexBuffer.MatricesIndicesKind
  97242. * - VertexBuffer.MatricesIndicesExtraKind
  97243. * - VertexBuffer.MatricesWeightsKind
  97244. * - VertexBuffer.MatricesWeightsExtraKind
  97245. * @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
  97246. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97247. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97248. */
  97249. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97250. /**
  97251. * Returns the mesh VertexBuffer object from the requested `kind`
  97252. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97253. * - VertexBuffer.PositionKind
  97254. * - VertexBuffer.NormalKind
  97255. * - VertexBuffer.UVKind
  97256. * - VertexBuffer.UV2Kind
  97257. * - VertexBuffer.UV3Kind
  97258. * - VertexBuffer.UV4Kind
  97259. * - VertexBuffer.UV5Kind
  97260. * - VertexBuffer.UV6Kind
  97261. * - VertexBuffer.ColorKind
  97262. * - VertexBuffer.MatricesIndicesKind
  97263. * - VertexBuffer.MatricesIndicesExtraKind
  97264. * - VertexBuffer.MatricesWeightsKind
  97265. * - VertexBuffer.MatricesWeightsExtraKind
  97266. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97267. */
  97268. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97269. /**
  97270. * Tests if a specific vertex buffer is associated with this mesh
  97271. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97272. * - VertexBuffer.PositionKind
  97273. * - VertexBuffer.NormalKind
  97274. * - VertexBuffer.UVKind
  97275. * - VertexBuffer.UV2Kind
  97276. * - VertexBuffer.UV3Kind
  97277. * - VertexBuffer.UV4Kind
  97278. * - VertexBuffer.UV5Kind
  97279. * - VertexBuffer.UV6Kind
  97280. * - VertexBuffer.ColorKind
  97281. * - VertexBuffer.MatricesIndicesKind
  97282. * - VertexBuffer.MatricesIndicesExtraKind
  97283. * - VertexBuffer.MatricesWeightsKind
  97284. * - VertexBuffer.MatricesWeightsExtraKind
  97285. * @returns a boolean
  97286. */
  97287. isVerticesDataPresent(kind: string): boolean;
  97288. /**
  97289. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97290. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97291. * - VertexBuffer.PositionKind
  97292. * - VertexBuffer.UVKind
  97293. * - VertexBuffer.UV2Kind
  97294. * - VertexBuffer.UV3Kind
  97295. * - VertexBuffer.UV4Kind
  97296. * - VertexBuffer.UV5Kind
  97297. * - VertexBuffer.UV6Kind
  97298. * - VertexBuffer.ColorKind
  97299. * - VertexBuffer.MatricesIndicesKind
  97300. * - VertexBuffer.MatricesIndicesExtraKind
  97301. * - VertexBuffer.MatricesWeightsKind
  97302. * - VertexBuffer.MatricesWeightsExtraKind
  97303. * @returns a boolean
  97304. */
  97305. isVertexBufferUpdatable(kind: string): boolean;
  97306. /**
  97307. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97308. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97309. * - VertexBuffer.PositionKind
  97310. * - VertexBuffer.NormalKind
  97311. * - VertexBuffer.UVKind
  97312. * - VertexBuffer.UV2Kind
  97313. * - VertexBuffer.UV3Kind
  97314. * - VertexBuffer.UV4Kind
  97315. * - VertexBuffer.UV5Kind
  97316. * - VertexBuffer.UV6Kind
  97317. * - VertexBuffer.ColorKind
  97318. * - VertexBuffer.MatricesIndicesKind
  97319. * - VertexBuffer.MatricesIndicesExtraKind
  97320. * - VertexBuffer.MatricesWeightsKind
  97321. * - VertexBuffer.MatricesWeightsExtraKind
  97322. * @returns an array of strings
  97323. */
  97324. getVerticesDataKinds(): string[];
  97325. /**
  97326. * Returns a positive integer : the total number of indices in this mesh geometry.
  97327. * @returns the numner of indices or zero if the mesh has no geometry.
  97328. */
  97329. getTotalIndices(): number;
  97330. /**
  97331. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97332. * @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.
  97333. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97334. * @returns the indices array or an empty array if the mesh has no geometry
  97335. */
  97336. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97337. get isBlocked(): boolean;
  97338. /**
  97339. * Determine if the current mesh is ready to be rendered
  97340. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97341. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97342. * @returns true if all associated assets are ready (material, textures, shaders)
  97343. */
  97344. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97345. /**
  97346. * 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.
  97347. */
  97348. get areNormalsFrozen(): boolean;
  97349. /**
  97350. * 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.
  97351. * @returns the current mesh
  97352. */
  97353. freezeNormals(): Mesh;
  97354. /**
  97355. * 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
  97356. * @returns the current mesh
  97357. */
  97358. unfreezeNormals(): Mesh;
  97359. /**
  97360. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97361. */
  97362. set overridenInstanceCount(count: number);
  97363. /** @hidden */
  97364. _preActivate(): Mesh;
  97365. /** @hidden */
  97366. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97367. /** @hidden */
  97368. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97369. /**
  97370. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97371. * This means the mesh underlying bounding box and sphere are recomputed.
  97372. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97373. * @returns the current mesh
  97374. */
  97375. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97376. /** @hidden */
  97377. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97378. /**
  97379. * This function will subdivide the mesh into multiple submeshes
  97380. * @param count defines the expected number of submeshes
  97381. */
  97382. subdivide(count: number): void;
  97383. /**
  97384. * Copy a FloatArray into a specific associated vertex buffer
  97385. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97386. * - VertexBuffer.PositionKind
  97387. * - VertexBuffer.UVKind
  97388. * - VertexBuffer.UV2Kind
  97389. * - VertexBuffer.UV3Kind
  97390. * - VertexBuffer.UV4Kind
  97391. * - VertexBuffer.UV5Kind
  97392. * - VertexBuffer.UV6Kind
  97393. * - VertexBuffer.ColorKind
  97394. * - VertexBuffer.MatricesIndicesKind
  97395. * - VertexBuffer.MatricesIndicesExtraKind
  97396. * - VertexBuffer.MatricesWeightsKind
  97397. * - VertexBuffer.MatricesWeightsExtraKind
  97398. * @param data defines the data source
  97399. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97400. * @param stride defines the data stride size (can be null)
  97401. * @returns the current mesh
  97402. */
  97403. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97404. /**
  97405. * Delete a vertex buffer associated with this mesh
  97406. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97407. * - VertexBuffer.PositionKind
  97408. * - VertexBuffer.UVKind
  97409. * - VertexBuffer.UV2Kind
  97410. * - VertexBuffer.UV3Kind
  97411. * - VertexBuffer.UV4Kind
  97412. * - VertexBuffer.UV5Kind
  97413. * - VertexBuffer.UV6Kind
  97414. * - VertexBuffer.ColorKind
  97415. * - VertexBuffer.MatricesIndicesKind
  97416. * - VertexBuffer.MatricesIndicesExtraKind
  97417. * - VertexBuffer.MatricesWeightsKind
  97418. * - VertexBuffer.MatricesWeightsExtraKind
  97419. */
  97420. removeVerticesData(kind: string): void;
  97421. /**
  97422. * Flags an associated vertex buffer as updatable
  97423. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97424. * - VertexBuffer.PositionKind
  97425. * - VertexBuffer.UVKind
  97426. * - VertexBuffer.UV2Kind
  97427. * - VertexBuffer.UV3Kind
  97428. * - VertexBuffer.UV4Kind
  97429. * - VertexBuffer.UV5Kind
  97430. * - VertexBuffer.UV6Kind
  97431. * - VertexBuffer.ColorKind
  97432. * - VertexBuffer.MatricesIndicesKind
  97433. * - VertexBuffer.MatricesIndicesExtraKind
  97434. * - VertexBuffer.MatricesWeightsKind
  97435. * - VertexBuffer.MatricesWeightsExtraKind
  97436. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97437. */
  97438. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97439. /**
  97440. * Sets the mesh global Vertex Buffer
  97441. * @param buffer defines the buffer to use
  97442. * @returns the current mesh
  97443. */
  97444. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97445. /**
  97446. * Update a specific associated vertex buffer
  97447. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97448. * - VertexBuffer.PositionKind
  97449. * - VertexBuffer.UVKind
  97450. * - VertexBuffer.UV2Kind
  97451. * - VertexBuffer.UV3Kind
  97452. * - VertexBuffer.UV4Kind
  97453. * - VertexBuffer.UV5Kind
  97454. * - VertexBuffer.UV6Kind
  97455. * - VertexBuffer.ColorKind
  97456. * - VertexBuffer.MatricesIndicesKind
  97457. * - VertexBuffer.MatricesIndicesExtraKind
  97458. * - VertexBuffer.MatricesWeightsKind
  97459. * - VertexBuffer.MatricesWeightsExtraKind
  97460. * @param data defines the data source
  97461. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97462. * @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)
  97463. * @returns the current mesh
  97464. */
  97465. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97466. /**
  97467. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97468. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97469. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97470. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97471. * @returns the current mesh
  97472. */
  97473. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97474. /**
  97475. * Creates a un-shared specific occurence of the geometry for the mesh.
  97476. * @returns the current mesh
  97477. */
  97478. makeGeometryUnique(): Mesh;
  97479. /**
  97480. * Set the index buffer of this mesh
  97481. * @param indices defines the source data
  97482. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97483. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97484. * @returns the current mesh
  97485. */
  97486. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97487. /**
  97488. * Update the current index buffer
  97489. * @param indices defines the source data
  97490. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97491. * @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)
  97492. * @returns the current mesh
  97493. */
  97494. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97495. /**
  97496. * Invert the geometry to move from a right handed system to a left handed one.
  97497. * @returns the current mesh
  97498. */
  97499. toLeftHanded(): Mesh;
  97500. /** @hidden */
  97501. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97502. /** @hidden */
  97503. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97504. /**
  97505. * Registers for this mesh a javascript function called just before the rendering process
  97506. * @param func defines the function to call before rendering this mesh
  97507. * @returns the current mesh
  97508. */
  97509. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97510. /**
  97511. * Disposes a previously registered javascript function called before the rendering
  97512. * @param func defines the function to remove
  97513. * @returns the current mesh
  97514. */
  97515. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97516. /**
  97517. * Registers for this mesh a javascript function called just after the rendering is complete
  97518. * @param func defines the function to call after rendering this mesh
  97519. * @returns the current mesh
  97520. */
  97521. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97522. /**
  97523. * Disposes a previously registered javascript function called after the rendering.
  97524. * @param func defines the function to remove
  97525. * @returns the current mesh
  97526. */
  97527. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97528. /** @hidden */
  97529. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97530. /** @hidden */
  97531. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97532. /** @hidden */
  97533. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97534. /** @hidden */
  97535. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97536. /** @hidden */
  97537. _rebuild(): void;
  97538. /** @hidden */
  97539. _freeze(): void;
  97540. /** @hidden */
  97541. _unFreeze(): void;
  97542. /**
  97543. * 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
  97544. * @param subMesh defines the subMesh to render
  97545. * @param enableAlphaMode defines if alpha mode can be changed
  97546. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97547. * @returns the current mesh
  97548. */
  97549. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97550. private _onBeforeDraw;
  97551. /**
  97552. * Renormalize the mesh and patch it up if there are no weights
  97553. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97554. * However in the case of zero weights then we set just a single influence to 1.
  97555. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97556. */
  97557. cleanMatrixWeights(): void;
  97558. private normalizeSkinFourWeights;
  97559. private normalizeSkinWeightsAndExtra;
  97560. /**
  97561. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  97562. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  97563. * the user know there was an issue with importing the mesh
  97564. * @returns a validation object with skinned, valid and report string
  97565. */
  97566. validateSkinning(): {
  97567. skinned: boolean;
  97568. valid: boolean;
  97569. report: string;
  97570. };
  97571. /** @hidden */
  97572. _checkDelayState(): Mesh;
  97573. private _queueLoad;
  97574. /**
  97575. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97576. * A mesh is in the frustum if its bounding box intersects the frustum
  97577. * @param frustumPlanes defines the frustum to test
  97578. * @returns true if the mesh is in the frustum planes
  97579. */
  97580. isInFrustum(frustumPlanes: Plane[]): boolean;
  97581. /**
  97582. * Sets the mesh material by the material or multiMaterial `id` property
  97583. * @param id is a string identifying the material or the multiMaterial
  97584. * @returns the current mesh
  97585. */
  97586. setMaterialByID(id: string): Mesh;
  97587. /**
  97588. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  97589. * @returns an array of IAnimatable
  97590. */
  97591. getAnimatables(): IAnimatable[];
  97592. /**
  97593. * Modifies the mesh geometry according to the passed transformation matrix.
  97594. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  97595. * The mesh normals are modified using the same transformation.
  97596. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97597. * @param transform defines the transform matrix to use
  97598. * @see http://doc.babylonjs.com/resources/baking_transformations
  97599. * @returns the current mesh
  97600. */
  97601. bakeTransformIntoVertices(transform: Matrix): Mesh;
  97602. /**
  97603. * Modifies the mesh geometry according to its own current World Matrix.
  97604. * The mesh World Matrix is then reset.
  97605. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  97606. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97607. * @see http://doc.babylonjs.com/resources/baking_transformations
  97608. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  97609. * @returns the current mesh
  97610. */
  97611. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  97612. /** @hidden */
  97613. get _positions(): Nullable<Vector3[]>;
  97614. /** @hidden */
  97615. _resetPointsArrayCache(): Mesh;
  97616. /** @hidden */
  97617. _generatePointsArray(): boolean;
  97618. /**
  97619. * Returns a new Mesh object generated from the current mesh properties.
  97620. * This method must not get confused with createInstance()
  97621. * @param name is a string, the name given to the new mesh
  97622. * @param newParent can be any Node object (default `null`)
  97623. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  97624. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  97625. * @returns a new mesh
  97626. */
  97627. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  97628. /**
  97629. * Releases resources associated with this mesh.
  97630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97632. */
  97633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97634. /** @hidden */
  97635. _disposeInstanceSpecificData(): void;
  97636. /**
  97637. * Modifies the mesh geometry according to a displacement map.
  97638. * 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.
  97639. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97640. * @param url is a string, the URL from the image file is to be downloaded.
  97641. * @param minHeight is the lower limit of the displacement.
  97642. * @param maxHeight is the upper limit of the displacement.
  97643. * @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.
  97644. * @param uvOffset is an optional vector2 used to offset UV.
  97645. * @param uvScale is an optional vector2 used to scale UV.
  97646. * @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.
  97647. * @returns the Mesh.
  97648. */
  97649. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97650. /**
  97651. * Modifies the mesh geometry according to a displacementMap buffer.
  97652. * 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.
  97653. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97654. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  97655. * @param heightMapWidth is the width of the buffer image.
  97656. * @param heightMapHeight is the height of the buffer image.
  97657. * @param minHeight is the lower limit of the displacement.
  97658. * @param maxHeight is the upper limit of the displacement.
  97659. * @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.
  97660. * @param uvOffset is an optional vector2 used to offset UV.
  97661. * @param uvScale is an optional vector2 used to scale UV.
  97662. * @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.
  97663. * @returns the Mesh.
  97664. */
  97665. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97666. /**
  97667. * Modify the mesh to get a flat shading rendering.
  97668. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  97669. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  97670. * @returns current mesh
  97671. */
  97672. convertToFlatShadedMesh(): Mesh;
  97673. /**
  97674. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  97675. * In other words, more vertices, no more indices and a single bigger VBO.
  97676. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  97677. * @returns current mesh
  97678. */
  97679. convertToUnIndexedMesh(): Mesh;
  97680. /**
  97681. * Inverses facet orientations.
  97682. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97683. * @param flipNormals will also inverts the normals
  97684. * @returns current mesh
  97685. */
  97686. flipFaces(flipNormals?: boolean): Mesh;
  97687. /**
  97688. * Increase the number of facets and hence vertices in a mesh
  97689. * Vertex normals are interpolated from existing vertex normals
  97690. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97691. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  97692. */
  97693. increaseVertices(numberPerEdge: number): void;
  97694. /**
  97695. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  97696. * This will undo any application of covertToFlatShadedMesh
  97697. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97698. */
  97699. forceSharedVertices(): void;
  97700. /** @hidden */
  97701. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  97702. /** @hidden */
  97703. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  97704. /**
  97705. * Creates a new InstancedMesh object from the mesh model.
  97706. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97707. * @param name defines the name of the new instance
  97708. * @returns a new InstancedMesh
  97709. */
  97710. createInstance(name: string): InstancedMesh;
  97711. /**
  97712. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  97713. * After this call, all the mesh instances have the same submeshes than the current mesh.
  97714. * @returns the current mesh
  97715. */
  97716. synchronizeInstances(): Mesh;
  97717. /**
  97718. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  97719. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  97720. * This should be used together with the simplification to avoid disappearing triangles.
  97721. * @param successCallback an optional success callback to be called after the optimization finished.
  97722. * @returns the current mesh
  97723. */
  97724. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  97725. /**
  97726. * Serialize current mesh
  97727. * @param serializationObject defines the object which will receive the serialization data
  97728. */
  97729. serialize(serializationObject: any): void;
  97730. /** @hidden */
  97731. _syncGeometryWithMorphTargetManager(): void;
  97732. /** @hidden */
  97733. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  97734. /**
  97735. * Returns a new Mesh object parsed from the source provided.
  97736. * @param parsedMesh is the source
  97737. * @param scene defines the hosting scene
  97738. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  97739. * @returns a new Mesh
  97740. */
  97741. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  97742. /**
  97743. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  97744. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97745. * @param name defines the name of the mesh to create
  97746. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  97747. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  97748. * @param closePath creates a seam between the first and the last points of each path of the path array
  97749. * @param offset is taken in account only if the `pathArray` is containing a single path
  97750. * @param scene defines the hosting scene
  97751. * @param updatable defines if the mesh must be flagged as updatable
  97752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97753. * @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)
  97754. * @returns a new Mesh
  97755. */
  97756. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97757. /**
  97758. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  97759. * @param name defines the name of the mesh to create
  97760. * @param radius sets the radius size (float) of the polygon (default 0.5)
  97761. * @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
  97762. * @param scene defines the hosting scene
  97763. * @param updatable defines if the mesh must be flagged as updatable
  97764. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97765. * @returns a new Mesh
  97766. */
  97767. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97768. /**
  97769. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  97770. * @param name defines the name of the mesh to create
  97771. * @param size sets the size (float) of each box side (default 1)
  97772. * @param scene defines the hosting scene
  97773. * @param updatable defines if the mesh must be flagged as updatable
  97774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97775. * @returns a new Mesh
  97776. */
  97777. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97778. /**
  97779. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  97780. * @param name defines the name of the mesh to create
  97781. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97782. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97783. * @param scene defines the hosting scene
  97784. * @param updatable defines if the mesh must be flagged as updatable
  97785. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97786. * @returns a new Mesh
  97787. */
  97788. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97789. /**
  97790. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  97791. * @param name defines the name of the mesh to create
  97792. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97793. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97794. * @param scene defines the hosting scene
  97795. * @returns a new Mesh
  97796. */
  97797. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  97798. /**
  97799. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  97800. * @param name defines the name of the mesh to create
  97801. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  97802. * @param diameterTop set the top cap diameter (floats, default 1)
  97803. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  97804. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  97805. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  97806. * @param scene defines the hosting scene
  97807. * @param updatable defines if the mesh must be flagged as updatable
  97808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97809. * @returns a new Mesh
  97810. */
  97811. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  97812. /**
  97813. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  97814. * @param name defines the name of the mesh to create
  97815. * @param diameter sets the diameter size (float) of the torus (default 1)
  97816. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  97817. * @param tessellation sets the number of torus sides (postive integer, default 16)
  97818. * @param scene defines the hosting scene
  97819. * @param updatable defines if the mesh must be flagged as updatable
  97820. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97821. * @returns a new Mesh
  97822. */
  97823. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97824. /**
  97825. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  97826. * @param name defines the name of the mesh to create
  97827. * @param radius sets the global radius size (float) of the torus knot (default 2)
  97828. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  97829. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  97830. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  97831. * @param p the number of windings on X axis (positive integers, default 2)
  97832. * @param q the number of windings on Y axis (positive integers, default 3)
  97833. * @param scene defines the hosting scene
  97834. * @param updatable defines if the mesh must be flagged as updatable
  97835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97836. * @returns a new Mesh
  97837. */
  97838. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97839. /**
  97840. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  97841. * @param name defines the name of the mesh to create
  97842. * @param points is an array successive Vector3
  97843. * @param scene defines the hosting scene
  97844. * @param updatable defines if the mesh must be flagged as updatable
  97845. * @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).
  97846. * @returns a new Mesh
  97847. */
  97848. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  97849. /**
  97850. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  97851. * @param name defines the name of the mesh to create
  97852. * @param points is an array successive Vector3
  97853. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  97854. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97855. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  97856. * @param scene defines the hosting scene
  97857. * @param updatable defines if the mesh must be flagged as updatable
  97858. * @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)
  97859. * @returns a new Mesh
  97860. */
  97861. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  97862. /**
  97863. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  97864. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  97865. * 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.
  97866. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97867. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97868. * Remember you can only change the shape positions, not their number when updating a polygon.
  97869. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  97870. * @param name defines the name of the mesh to create
  97871. * @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
  97872. * @param scene defines the hosting scene
  97873. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97874. * @param updatable defines if the mesh must be flagged as updatable
  97875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97876. * @param earcutInjection can be used to inject your own earcut reference
  97877. * @returns a new Mesh
  97878. */
  97879. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97880. /**
  97881. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  97882. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  97883. * @param name defines the name of the mesh to create
  97884. * @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
  97885. * @param depth defines the height of extrusion
  97886. * @param scene defines the hosting scene
  97887. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97888. * @param updatable defines if the mesh must be flagged as updatable
  97889. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97890. * @param earcutInjection can be used to inject your own earcut reference
  97891. * @returns a new Mesh
  97892. */
  97893. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97894. /**
  97895. * Creates an extruded shape mesh.
  97896. * 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
  97897. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97898. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97899. * @param name defines the name of the mesh to create
  97900. * @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
  97901. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97902. * @param scale is the value to scale the shape
  97903. * @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
  97904. * @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
  97905. * @param scene defines the hosting scene
  97906. * @param updatable defines if the mesh must be flagged as updatable
  97907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97908. * @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)
  97909. * @returns a new Mesh
  97910. */
  97911. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97912. /**
  97913. * Creates an custom extruded shape mesh.
  97914. * The custom extrusion is a parametric shape.
  97915. * It has no predefined shape. Its final shape will depend on the input parameters.
  97916. * Please consider using the same method from the MeshBuilder class instead
  97917. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97918. * @param name defines the name of the mesh to create
  97919. * @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
  97920. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97921. * @param scaleFunction is a custom Javascript function called on each path point
  97922. * @param rotationFunction is a custom Javascript function called on each path point
  97923. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  97924. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  97925. * @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
  97926. * @param scene defines the hosting scene
  97927. * @param updatable defines if the mesh must be flagged as updatable
  97928. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97929. * @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)
  97930. * @returns a new Mesh
  97931. */
  97932. 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;
  97933. /**
  97934. * Creates lathe mesh.
  97935. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  97936. * Please consider using the same method from the MeshBuilder class instead
  97937. * @param name defines the name of the mesh to create
  97938. * @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
  97939. * @param radius is the radius value of the lathe
  97940. * @param tessellation is the side number of the lathe.
  97941. * @param scene defines the hosting scene
  97942. * @param updatable defines if the mesh must be flagged as updatable
  97943. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97944. * @returns a new Mesh
  97945. */
  97946. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97947. /**
  97948. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  97949. * @param name defines the name of the mesh to create
  97950. * @param size sets the size (float) of both sides of the plane at once (default 1)
  97951. * @param scene defines the hosting scene
  97952. * @param updatable defines if the mesh must be flagged as updatable
  97953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97954. * @returns a new Mesh
  97955. */
  97956. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97957. /**
  97958. * Creates a ground mesh.
  97959. * Please consider using the same method from the MeshBuilder class instead
  97960. * @param name defines the name of the mesh to create
  97961. * @param width set the width of the ground
  97962. * @param height set the height of the ground
  97963. * @param subdivisions sets the number of subdivisions per side
  97964. * @param scene defines the hosting scene
  97965. * @param updatable defines if the mesh must be flagged as updatable
  97966. * @returns a new Mesh
  97967. */
  97968. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  97969. /**
  97970. * Creates a tiled ground mesh.
  97971. * Please consider using the same method from the MeshBuilder class instead
  97972. * @param name defines the name of the mesh to create
  97973. * @param xmin set the ground minimum X coordinate
  97974. * @param zmin set the ground minimum Y coordinate
  97975. * @param xmax set the ground maximum X coordinate
  97976. * @param zmax set the ground maximum Z coordinate
  97977. * @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
  97978. * @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
  97979. * @param scene defines the hosting scene
  97980. * @param updatable defines if the mesh must be flagged as updatable
  97981. * @returns a new Mesh
  97982. */
  97983. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  97984. w: number;
  97985. h: number;
  97986. }, precision: {
  97987. w: number;
  97988. h: number;
  97989. }, scene: Scene, updatable?: boolean): Mesh;
  97990. /**
  97991. * Creates a ground mesh from a height map.
  97992. * Please consider using the same method from the MeshBuilder class instead
  97993. * @see http://doc.babylonjs.com/babylon101/height_map
  97994. * @param name defines the name of the mesh to create
  97995. * @param url sets the URL of the height map image resource
  97996. * @param width set the ground width size
  97997. * @param height set the ground height size
  97998. * @param subdivisions sets the number of subdivision per side
  97999. * @param minHeight is the minimum altitude on the ground
  98000. * @param maxHeight is the maximum altitude on the ground
  98001. * @param scene defines the hosting scene
  98002. * @param updatable defines if the mesh must be flagged as updatable
  98003. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98004. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98005. * @returns a new Mesh
  98006. */
  98007. 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;
  98008. /**
  98009. * Creates a tube mesh.
  98010. * The tube is a parametric shape.
  98011. * It has no predefined shape. Its final shape will depend on the input parameters.
  98012. * Please consider using the same method from the MeshBuilder class instead
  98013. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98014. * @param name defines the name of the mesh to create
  98015. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98016. * @param radius sets the tube radius size
  98017. * @param tessellation is the number of sides on the tubular surface
  98018. * @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
  98019. * @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
  98020. * @param scene defines the hosting scene
  98021. * @param updatable defines if the mesh must be flagged as updatable
  98022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98023. * @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)
  98024. * @returns a new Mesh
  98025. */
  98026. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98027. (i: number, distance: number): number;
  98028. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98029. /**
  98030. * Creates a polyhedron mesh.
  98031. * Please consider using the same method from the MeshBuilder class instead.
  98032. * * 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
  98033. * * The parameter `size` (positive float, default 1) sets the polygon size
  98034. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98035. * * 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`
  98036. * * 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
  98037. * * 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)`)
  98038. * * 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
  98039. * * 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
  98040. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98041. * * If you create a double-sided mesh, you can choose what parts of 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
  98042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98043. * @param name defines the name of the mesh to create
  98044. * @param options defines the options used to create the mesh
  98045. * @param scene defines the hosting scene
  98046. * @returns a new Mesh
  98047. */
  98048. static CreatePolyhedron(name: string, options: {
  98049. type?: number;
  98050. size?: number;
  98051. sizeX?: number;
  98052. sizeY?: number;
  98053. sizeZ?: number;
  98054. custom?: any;
  98055. faceUV?: Vector4[];
  98056. faceColors?: Color4[];
  98057. updatable?: boolean;
  98058. sideOrientation?: number;
  98059. }, scene: Scene): Mesh;
  98060. /**
  98061. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98062. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98063. * * 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`)
  98064. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98065. * * 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
  98066. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98067. * * If you create a double-sided mesh, you can choose what parts of 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
  98068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98069. * @param name defines the name of the mesh
  98070. * @param options defines the options used to create the mesh
  98071. * @param scene defines the hosting scene
  98072. * @returns a new Mesh
  98073. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98074. */
  98075. static CreateIcoSphere(name: string, options: {
  98076. radius?: number;
  98077. flat?: boolean;
  98078. subdivisions?: number;
  98079. sideOrientation?: number;
  98080. updatable?: boolean;
  98081. }, scene: Scene): Mesh;
  98082. /**
  98083. * Creates a decal mesh.
  98084. * Please consider using the same method from the MeshBuilder class instead.
  98085. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98086. * @param name defines the name of the mesh
  98087. * @param sourceMesh defines the mesh receiving the decal
  98088. * @param position sets the position of the decal in world coordinates
  98089. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98090. * @param size sets the decal scaling
  98091. * @param angle sets the angle to rotate the decal
  98092. * @returns a new Mesh
  98093. */
  98094. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98095. /**
  98096. * Prepare internal position array for software CPU skinning
  98097. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98098. */
  98099. setPositionsForCPUSkinning(): Float32Array;
  98100. /**
  98101. * Prepare internal normal array for software CPU skinning
  98102. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98103. */
  98104. setNormalsForCPUSkinning(): Float32Array;
  98105. /**
  98106. * Updates the vertex buffer by applying transformation from the bones
  98107. * @param skeleton defines the skeleton to apply to current mesh
  98108. * @returns the current mesh
  98109. */
  98110. applySkeleton(skeleton: Skeleton): Mesh;
  98111. /**
  98112. * 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
  98113. * @param meshes defines the list of meshes to scan
  98114. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98115. */
  98116. static MinMax(meshes: AbstractMesh[]): {
  98117. min: Vector3;
  98118. max: Vector3;
  98119. };
  98120. /**
  98121. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98122. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98123. * @returns a vector3
  98124. */
  98125. static Center(meshesOrMinMaxVector: {
  98126. min: Vector3;
  98127. max: Vector3;
  98128. } | AbstractMesh[]): Vector3;
  98129. /**
  98130. * Merge the array of meshes into a single mesh for performance reasons.
  98131. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98132. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98133. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98134. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98135. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98136. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98137. * @returns a new mesh
  98138. */
  98139. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98140. /** @hidden */
  98141. addInstance(instance: InstancedMesh): void;
  98142. /** @hidden */
  98143. removeInstance(instance: InstancedMesh): void;
  98144. }
  98145. }
  98146. declare module BABYLON {
  98147. /**
  98148. * This is the base class of all the camera used in the application.
  98149. * @see http://doc.babylonjs.com/features/cameras
  98150. */
  98151. export class Camera extends Node {
  98152. /** @hidden */
  98153. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98154. /**
  98155. * This is the default projection mode used by the cameras.
  98156. * It helps recreating a feeling of perspective and better appreciate depth.
  98157. * This is the best way to simulate real life cameras.
  98158. */
  98159. static readonly PERSPECTIVE_CAMERA: number;
  98160. /**
  98161. * This helps creating camera with an orthographic mode.
  98162. * 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.
  98163. */
  98164. static readonly ORTHOGRAPHIC_CAMERA: number;
  98165. /**
  98166. * This is the default FOV mode for perspective cameras.
  98167. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98168. */
  98169. static readonly FOVMODE_VERTICAL_FIXED: number;
  98170. /**
  98171. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98172. */
  98173. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98174. /**
  98175. * This specifies ther is no need for a camera rig.
  98176. * Basically only one eye is rendered corresponding to the camera.
  98177. */
  98178. static readonly RIG_MODE_NONE: number;
  98179. /**
  98180. * Simulates a camera Rig with one blue eye and one red eye.
  98181. * This can be use with 3d blue and red glasses.
  98182. */
  98183. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98184. /**
  98185. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98186. */
  98187. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98188. /**
  98189. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98190. */
  98191. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98192. /**
  98193. * Defines that both eyes of the camera will be rendered over under each other.
  98194. */
  98195. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98196. /**
  98197. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98198. */
  98199. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98200. /**
  98201. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98202. */
  98203. static readonly RIG_MODE_VR: number;
  98204. /**
  98205. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98206. */
  98207. static readonly RIG_MODE_WEBVR: number;
  98208. /**
  98209. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98210. */
  98211. static readonly RIG_MODE_CUSTOM: number;
  98212. /**
  98213. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98214. */
  98215. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98216. /**
  98217. * Define the input manager associated with the camera.
  98218. */
  98219. inputs: CameraInputsManager<Camera>;
  98220. /** @hidden */
  98221. _position: Vector3;
  98222. /**
  98223. * Define the current local position of the camera in the scene
  98224. */
  98225. get position(): Vector3;
  98226. set position(newPosition: Vector3);
  98227. /**
  98228. * The vector the camera should consider as up.
  98229. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98230. */
  98231. upVector: Vector3;
  98232. /**
  98233. * Define the current limit on the left side for an orthographic camera
  98234. * In scene unit
  98235. */
  98236. orthoLeft: Nullable<number>;
  98237. /**
  98238. * Define the current limit on the right side for an orthographic camera
  98239. * In scene unit
  98240. */
  98241. orthoRight: Nullable<number>;
  98242. /**
  98243. * Define the current limit on the bottom side for an orthographic camera
  98244. * In scene unit
  98245. */
  98246. orthoBottom: Nullable<number>;
  98247. /**
  98248. * Define the current limit on the top side for an orthographic camera
  98249. * In scene unit
  98250. */
  98251. orthoTop: Nullable<number>;
  98252. /**
  98253. * Field Of View is set in Radians. (default is 0.8)
  98254. */
  98255. fov: number;
  98256. /**
  98257. * Define the minimum distance the camera can see from.
  98258. * This is important to note that the depth buffer are not infinite and the closer it starts
  98259. * the more your scene might encounter depth fighting issue.
  98260. */
  98261. minZ: number;
  98262. /**
  98263. * Define the maximum distance the camera can see to.
  98264. * This is important to note that the depth buffer are not infinite and the further it end
  98265. * the more your scene might encounter depth fighting issue.
  98266. */
  98267. maxZ: number;
  98268. /**
  98269. * Define the default inertia of the camera.
  98270. * This helps giving a smooth feeling to the camera movement.
  98271. */
  98272. inertia: number;
  98273. /**
  98274. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98275. */
  98276. mode: number;
  98277. /**
  98278. * Define whether the camera is intermediate.
  98279. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98280. */
  98281. isIntermediate: boolean;
  98282. /**
  98283. * Define the viewport of the camera.
  98284. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98285. */
  98286. viewport: Viewport;
  98287. /**
  98288. * Restricts the camera to viewing objects with the same layerMask.
  98289. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98290. */
  98291. layerMask: number;
  98292. /**
  98293. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98294. */
  98295. fovMode: number;
  98296. /**
  98297. * Rig mode of the camera.
  98298. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98299. * This is normally controlled byt the camera themselves as internal use.
  98300. */
  98301. cameraRigMode: number;
  98302. /**
  98303. * Defines the distance between both "eyes" in case of a RIG
  98304. */
  98305. interaxialDistance: number;
  98306. /**
  98307. * Defines if stereoscopic rendering is done side by side or over under.
  98308. */
  98309. isStereoscopicSideBySide: boolean;
  98310. /**
  98311. * 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
  98312. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98313. * else in the scene. (Eg. security camera)
  98314. *
  98315. * 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)
  98316. */
  98317. customRenderTargets: RenderTargetTexture[];
  98318. /**
  98319. * When set, the camera will render to this render target instead of the default canvas
  98320. *
  98321. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98322. */
  98323. outputRenderTarget: Nullable<RenderTargetTexture>;
  98324. /**
  98325. * Observable triggered when the camera view matrix has changed.
  98326. */
  98327. onViewMatrixChangedObservable: Observable<Camera>;
  98328. /**
  98329. * Observable triggered when the camera Projection matrix has changed.
  98330. */
  98331. onProjectionMatrixChangedObservable: Observable<Camera>;
  98332. /**
  98333. * Observable triggered when the inputs have been processed.
  98334. */
  98335. onAfterCheckInputsObservable: Observable<Camera>;
  98336. /**
  98337. * Observable triggered when reset has been called and applied to the camera.
  98338. */
  98339. onRestoreStateObservable: Observable<Camera>;
  98340. /**
  98341. * Is this camera a part of a rig system?
  98342. */
  98343. isRigCamera: boolean;
  98344. /**
  98345. * If isRigCamera set to true this will be set with the parent camera.
  98346. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98347. */
  98348. rigParent?: Camera;
  98349. /** @hidden */
  98350. _cameraRigParams: any;
  98351. /** @hidden */
  98352. _rigCameras: Camera[];
  98353. /** @hidden */
  98354. _rigPostProcess: Nullable<PostProcess>;
  98355. protected _webvrViewMatrix: Matrix;
  98356. /** @hidden */
  98357. _skipRendering: boolean;
  98358. /** @hidden */
  98359. _projectionMatrix: Matrix;
  98360. /** @hidden */
  98361. _postProcesses: Nullable<PostProcess>[];
  98362. /** @hidden */
  98363. _activeMeshes: SmartArray<AbstractMesh>;
  98364. protected _globalPosition: Vector3;
  98365. /** @hidden */
  98366. _computedViewMatrix: Matrix;
  98367. private _doNotComputeProjectionMatrix;
  98368. private _transformMatrix;
  98369. private _frustumPlanes;
  98370. private _refreshFrustumPlanes;
  98371. private _storedFov;
  98372. private _stateStored;
  98373. /**
  98374. * Instantiates a new camera object.
  98375. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98376. * @see http://doc.babylonjs.com/features/cameras
  98377. * @param name Defines the name of the camera in the scene
  98378. * @param position Defines the position of the camera
  98379. * @param scene Defines the scene the camera belongs too
  98380. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98381. */
  98382. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98383. /**
  98384. * Store current camera state (fov, position, etc..)
  98385. * @returns the camera
  98386. */
  98387. storeState(): Camera;
  98388. /**
  98389. * Restores the camera state values if it has been stored. You must call storeState() first
  98390. */
  98391. protected _restoreStateValues(): boolean;
  98392. /**
  98393. * Restored camera state. You must call storeState() first.
  98394. * @returns true if restored and false otherwise
  98395. */
  98396. restoreState(): boolean;
  98397. /**
  98398. * Gets the class name of the camera.
  98399. * @returns the class name
  98400. */
  98401. getClassName(): string;
  98402. /** @hidden */
  98403. readonly _isCamera: boolean;
  98404. /**
  98405. * Gets a string representation of the camera useful for debug purpose.
  98406. * @param fullDetails Defines that a more verboe level of logging is required
  98407. * @returns the string representation
  98408. */
  98409. toString(fullDetails?: boolean): string;
  98410. /**
  98411. * Gets the current world space position of the camera.
  98412. */
  98413. get globalPosition(): Vector3;
  98414. /**
  98415. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98416. * @returns the active meshe list
  98417. */
  98418. getActiveMeshes(): SmartArray<AbstractMesh>;
  98419. /**
  98420. * Check whether a mesh is part of the current active mesh list of the camera
  98421. * @param mesh Defines the mesh to check
  98422. * @returns true if active, false otherwise
  98423. */
  98424. isActiveMesh(mesh: Mesh): boolean;
  98425. /**
  98426. * Is this camera ready to be used/rendered
  98427. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98428. * @return true if the camera is ready
  98429. */
  98430. isReady(completeCheck?: boolean): boolean;
  98431. /** @hidden */
  98432. _initCache(): void;
  98433. /** @hidden */
  98434. _updateCache(ignoreParentClass?: boolean): void;
  98435. /** @hidden */
  98436. _isSynchronized(): boolean;
  98437. /** @hidden */
  98438. _isSynchronizedViewMatrix(): boolean;
  98439. /** @hidden */
  98440. _isSynchronizedProjectionMatrix(): boolean;
  98441. /**
  98442. * Attach the input controls to a specific dom element to get the input from.
  98443. * @param element Defines the element the controls should be listened from
  98444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98445. */
  98446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98447. /**
  98448. * Detach the current controls from the specified dom element.
  98449. * @param element Defines the element to stop listening the inputs from
  98450. */
  98451. detachControl(element: HTMLElement): void;
  98452. /**
  98453. * Update the camera state according to the different inputs gathered during the frame.
  98454. */
  98455. update(): void;
  98456. /** @hidden */
  98457. _checkInputs(): void;
  98458. /** @hidden */
  98459. get rigCameras(): Camera[];
  98460. /**
  98461. * Gets the post process used by the rig cameras
  98462. */
  98463. get rigPostProcess(): Nullable<PostProcess>;
  98464. /**
  98465. * Internal, gets the first post proces.
  98466. * @returns the first post process to be run on this camera.
  98467. */
  98468. _getFirstPostProcess(): Nullable<PostProcess>;
  98469. private _cascadePostProcessesToRigCams;
  98470. /**
  98471. * Attach a post process to the camera.
  98472. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98473. * @param postProcess The post process to attach to the camera
  98474. * @param insertAt The position of the post process in case several of them are in use in the scene
  98475. * @returns the position the post process has been inserted at
  98476. */
  98477. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98478. /**
  98479. * Detach a post process to the camera.
  98480. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98481. * @param postProcess The post process to detach from the camera
  98482. */
  98483. detachPostProcess(postProcess: PostProcess): void;
  98484. /**
  98485. * Gets the current world matrix of the camera
  98486. */
  98487. getWorldMatrix(): Matrix;
  98488. /** @hidden */
  98489. _getViewMatrix(): Matrix;
  98490. /**
  98491. * Gets the current view matrix of the camera.
  98492. * @param force forces the camera to recompute the matrix without looking at the cached state
  98493. * @returns the view matrix
  98494. */
  98495. getViewMatrix(force?: boolean): Matrix;
  98496. /**
  98497. * Freeze the projection matrix.
  98498. * It will prevent the cache check of the camera projection compute and can speed up perf
  98499. * if no parameter of the camera are meant to change
  98500. * @param projection Defines manually a projection if necessary
  98501. */
  98502. freezeProjectionMatrix(projection?: Matrix): void;
  98503. /**
  98504. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98505. */
  98506. unfreezeProjectionMatrix(): void;
  98507. /**
  98508. * Gets the current projection matrix of the camera.
  98509. * @param force forces the camera to recompute the matrix without looking at the cached state
  98510. * @returns the projection matrix
  98511. */
  98512. getProjectionMatrix(force?: boolean): Matrix;
  98513. /**
  98514. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98515. * @returns a Matrix
  98516. */
  98517. getTransformationMatrix(): Matrix;
  98518. private _updateFrustumPlanes;
  98519. /**
  98520. * Checks if a cullable object (mesh...) is in the camera frustum
  98521. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98522. * @param target The object to check
  98523. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98524. * @returns true if the object is in frustum otherwise false
  98525. */
  98526. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98527. /**
  98528. * Checks if a cullable object (mesh...) is in the camera frustum
  98529. * Unlike isInFrustum this cheks the full bounding box
  98530. * @param target The object to check
  98531. * @returns true if the object is in frustum otherwise false
  98532. */
  98533. isCompletelyInFrustum(target: ICullable): boolean;
  98534. /**
  98535. * Gets a ray in the forward direction from the camera.
  98536. * @param length Defines the length of the ray to create
  98537. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98538. * @param origin Defines the start point of the ray which defaults to the camera position
  98539. * @returns the forward ray
  98540. */
  98541. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98542. /**
  98543. * Releases resources associated with this node.
  98544. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98545. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98546. */
  98547. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98548. /** @hidden */
  98549. _isLeftCamera: boolean;
  98550. /**
  98551. * Gets the left camera of a rig setup in case of Rigged Camera
  98552. */
  98553. get isLeftCamera(): boolean;
  98554. /** @hidden */
  98555. _isRightCamera: boolean;
  98556. /**
  98557. * Gets the right camera of a rig setup in case of Rigged Camera
  98558. */
  98559. get isRightCamera(): boolean;
  98560. /**
  98561. * Gets the left camera of a rig setup in case of Rigged Camera
  98562. */
  98563. get leftCamera(): Nullable<FreeCamera>;
  98564. /**
  98565. * Gets the right camera of a rig setup in case of Rigged Camera
  98566. */
  98567. get rightCamera(): Nullable<FreeCamera>;
  98568. /**
  98569. * Gets the left camera target of a rig setup in case of Rigged Camera
  98570. * @returns the target position
  98571. */
  98572. getLeftTarget(): Nullable<Vector3>;
  98573. /**
  98574. * Gets the right camera target of a rig setup in case of Rigged Camera
  98575. * @returns the target position
  98576. */
  98577. getRightTarget(): Nullable<Vector3>;
  98578. /**
  98579. * @hidden
  98580. */
  98581. setCameraRigMode(mode: number, rigParams: any): void;
  98582. /** @hidden */
  98583. static _setStereoscopicRigMode(camera: Camera): void;
  98584. /** @hidden */
  98585. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  98586. /** @hidden */
  98587. static _setVRRigMode(camera: Camera, rigParams: any): void;
  98588. /** @hidden */
  98589. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  98590. /** @hidden */
  98591. _getVRProjectionMatrix(): Matrix;
  98592. protected _updateCameraRotationMatrix(): void;
  98593. protected _updateWebVRCameraRotationMatrix(): void;
  98594. /**
  98595. * This function MUST be overwritten by the different WebVR cameras available.
  98596. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98597. * @hidden
  98598. */
  98599. _getWebVRProjectionMatrix(): Matrix;
  98600. /**
  98601. * This function MUST be overwritten by the different WebVR cameras available.
  98602. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98603. * @hidden
  98604. */
  98605. _getWebVRViewMatrix(): Matrix;
  98606. /** @hidden */
  98607. setCameraRigParameter(name: string, value: any): void;
  98608. /**
  98609. * needs to be overridden by children so sub has required properties to be copied
  98610. * @hidden
  98611. */
  98612. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98613. /**
  98614. * May need to be overridden by children
  98615. * @hidden
  98616. */
  98617. _updateRigCameras(): void;
  98618. /** @hidden */
  98619. _setupInputs(): void;
  98620. /**
  98621. * Serialiaze the camera setup to a json represention
  98622. * @returns the JSON representation
  98623. */
  98624. serialize(): any;
  98625. /**
  98626. * Clones the current camera.
  98627. * @param name The cloned camera name
  98628. * @returns the cloned camera
  98629. */
  98630. clone(name: string): Camera;
  98631. /**
  98632. * Gets the direction of the camera relative to a given local axis.
  98633. * @param localAxis Defines the reference axis to provide a relative direction.
  98634. * @return the direction
  98635. */
  98636. getDirection(localAxis: Vector3): Vector3;
  98637. /**
  98638. * Returns the current camera absolute rotation
  98639. */
  98640. get absoluteRotation(): Quaternion;
  98641. /**
  98642. * Gets the direction of the camera relative to a given local axis into a passed vector.
  98643. * @param localAxis Defines the reference axis to provide a relative direction.
  98644. * @param result Defines the vector to store the result in
  98645. */
  98646. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  98647. /**
  98648. * Gets a camera constructor for a given camera type
  98649. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  98650. * @param name The name of the camera the result will be able to instantiate
  98651. * @param scene The scene the result will construct the camera in
  98652. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  98653. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  98654. * @returns a factory method to construc the camera
  98655. */
  98656. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  98657. /**
  98658. * Compute the world matrix of the camera.
  98659. * @returns the camera world matrix
  98660. */
  98661. computeWorldMatrix(): Matrix;
  98662. /**
  98663. * Parse a JSON and creates the camera from the parsed information
  98664. * @param parsedCamera The JSON to parse
  98665. * @param scene The scene to instantiate the camera in
  98666. * @returns the newly constructed camera
  98667. */
  98668. static Parse(parsedCamera: any, scene: Scene): Camera;
  98669. }
  98670. }
  98671. declare module BABYLON {
  98672. /**
  98673. * Class containing static functions to help procedurally build meshes
  98674. */
  98675. export class DiscBuilder {
  98676. /**
  98677. * Creates a plane polygonal mesh. By default, this is a disc
  98678. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  98679. * * 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
  98680. * * 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
  98681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98684. * @param name defines the name of the mesh
  98685. * @param options defines the options used to create the mesh
  98686. * @param scene defines the hosting scene
  98687. * @returns the plane polygonal mesh
  98688. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  98689. */
  98690. static CreateDisc(name: string, options: {
  98691. radius?: number;
  98692. tessellation?: number;
  98693. arc?: number;
  98694. updatable?: boolean;
  98695. sideOrientation?: number;
  98696. frontUVs?: Vector4;
  98697. backUVs?: Vector4;
  98698. }, scene?: Nullable<Scene>): Mesh;
  98699. }
  98700. }
  98701. declare module BABYLON {
  98702. /**
  98703. * This represents all the required information to add a fresnel effect on a material:
  98704. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98705. */
  98706. export class FresnelParameters {
  98707. private _isEnabled;
  98708. /**
  98709. * Define if the fresnel effect is enable or not.
  98710. */
  98711. get isEnabled(): boolean;
  98712. set isEnabled(value: boolean);
  98713. /**
  98714. * Define the color used on edges (grazing angle)
  98715. */
  98716. leftColor: Color3;
  98717. /**
  98718. * Define the color used on center
  98719. */
  98720. rightColor: Color3;
  98721. /**
  98722. * Define bias applied to computed fresnel term
  98723. */
  98724. bias: number;
  98725. /**
  98726. * Defined the power exponent applied to fresnel term
  98727. */
  98728. power: number;
  98729. /**
  98730. * Clones the current fresnel and its valuues
  98731. * @returns a clone fresnel configuration
  98732. */
  98733. clone(): FresnelParameters;
  98734. /**
  98735. * Serializes the current fresnel parameters to a JSON representation.
  98736. * @return the JSON serialization
  98737. */
  98738. serialize(): any;
  98739. /**
  98740. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  98741. * @param parsedFresnelParameters Define the JSON representation
  98742. * @returns the parsed parameters
  98743. */
  98744. static Parse(parsedFresnelParameters: any): FresnelParameters;
  98745. }
  98746. }
  98747. declare module BABYLON {
  98748. /**
  98749. * Base class of materials working in push mode in babylon JS
  98750. * @hidden
  98751. */
  98752. export class PushMaterial extends Material {
  98753. protected _activeEffect: Effect;
  98754. protected _normalMatrix: Matrix;
  98755. /**
  98756. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98757. * This means that the material can keep using a previous shader while a new one is being compiled.
  98758. * This is mostly used when shader parallel compilation is supported (true by default)
  98759. */
  98760. allowShaderHotSwapping: boolean;
  98761. constructor(name: string, scene: Scene);
  98762. getEffect(): Effect;
  98763. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98764. /**
  98765. * Binds the given world matrix to the active effect
  98766. *
  98767. * @param world the matrix to bind
  98768. */
  98769. bindOnlyWorldMatrix(world: Matrix): void;
  98770. /**
  98771. * Binds the given normal matrix to the active effect
  98772. *
  98773. * @param normalMatrix the matrix to bind
  98774. */
  98775. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98776. bind(world: Matrix, mesh?: Mesh): void;
  98777. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98778. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98779. }
  98780. }
  98781. declare module BABYLON {
  98782. /**
  98783. * This groups all the flags used to control the materials channel.
  98784. */
  98785. export class MaterialFlags {
  98786. private static _DiffuseTextureEnabled;
  98787. /**
  98788. * Are diffuse textures enabled in the application.
  98789. */
  98790. static get DiffuseTextureEnabled(): boolean;
  98791. static set DiffuseTextureEnabled(value: boolean);
  98792. private static _AmbientTextureEnabled;
  98793. /**
  98794. * Are ambient textures enabled in the application.
  98795. */
  98796. static get AmbientTextureEnabled(): boolean;
  98797. static set AmbientTextureEnabled(value: boolean);
  98798. private static _OpacityTextureEnabled;
  98799. /**
  98800. * Are opacity textures enabled in the application.
  98801. */
  98802. static get OpacityTextureEnabled(): boolean;
  98803. static set OpacityTextureEnabled(value: boolean);
  98804. private static _ReflectionTextureEnabled;
  98805. /**
  98806. * Are reflection textures enabled in the application.
  98807. */
  98808. static get ReflectionTextureEnabled(): boolean;
  98809. static set ReflectionTextureEnabled(value: boolean);
  98810. private static _EmissiveTextureEnabled;
  98811. /**
  98812. * Are emissive textures enabled in the application.
  98813. */
  98814. static get EmissiveTextureEnabled(): boolean;
  98815. static set EmissiveTextureEnabled(value: boolean);
  98816. private static _SpecularTextureEnabled;
  98817. /**
  98818. * Are specular textures enabled in the application.
  98819. */
  98820. static get SpecularTextureEnabled(): boolean;
  98821. static set SpecularTextureEnabled(value: boolean);
  98822. private static _BumpTextureEnabled;
  98823. /**
  98824. * Are bump textures enabled in the application.
  98825. */
  98826. static get BumpTextureEnabled(): boolean;
  98827. static set BumpTextureEnabled(value: boolean);
  98828. private static _LightmapTextureEnabled;
  98829. /**
  98830. * Are lightmap textures enabled in the application.
  98831. */
  98832. static get LightmapTextureEnabled(): boolean;
  98833. static set LightmapTextureEnabled(value: boolean);
  98834. private static _RefractionTextureEnabled;
  98835. /**
  98836. * Are refraction textures enabled in the application.
  98837. */
  98838. static get RefractionTextureEnabled(): boolean;
  98839. static set RefractionTextureEnabled(value: boolean);
  98840. private static _ColorGradingTextureEnabled;
  98841. /**
  98842. * Are color grading textures enabled in the application.
  98843. */
  98844. static get ColorGradingTextureEnabled(): boolean;
  98845. static set ColorGradingTextureEnabled(value: boolean);
  98846. private static _FresnelEnabled;
  98847. /**
  98848. * Are fresnels enabled in the application.
  98849. */
  98850. static get FresnelEnabled(): boolean;
  98851. static set FresnelEnabled(value: boolean);
  98852. private static _ClearCoatTextureEnabled;
  98853. /**
  98854. * Are clear coat textures enabled in the application.
  98855. */
  98856. static get ClearCoatTextureEnabled(): boolean;
  98857. static set ClearCoatTextureEnabled(value: boolean);
  98858. private static _ClearCoatBumpTextureEnabled;
  98859. /**
  98860. * Are clear coat bump textures enabled in the application.
  98861. */
  98862. static get ClearCoatBumpTextureEnabled(): boolean;
  98863. static set ClearCoatBumpTextureEnabled(value: boolean);
  98864. private static _ClearCoatTintTextureEnabled;
  98865. /**
  98866. * Are clear coat tint textures enabled in the application.
  98867. */
  98868. static get ClearCoatTintTextureEnabled(): boolean;
  98869. static set ClearCoatTintTextureEnabled(value: boolean);
  98870. private static _SheenTextureEnabled;
  98871. /**
  98872. * Are sheen textures enabled in the application.
  98873. */
  98874. static get SheenTextureEnabled(): boolean;
  98875. static set SheenTextureEnabled(value: boolean);
  98876. private static _AnisotropicTextureEnabled;
  98877. /**
  98878. * Are anisotropic textures enabled in the application.
  98879. */
  98880. static get AnisotropicTextureEnabled(): boolean;
  98881. static set AnisotropicTextureEnabled(value: boolean);
  98882. private static _ThicknessTextureEnabled;
  98883. /**
  98884. * Are thickness textures enabled in the application.
  98885. */
  98886. static get ThicknessTextureEnabled(): boolean;
  98887. static set ThicknessTextureEnabled(value: boolean);
  98888. }
  98889. }
  98890. declare module BABYLON {
  98891. /** @hidden */
  98892. export var defaultFragmentDeclaration: {
  98893. name: string;
  98894. shader: string;
  98895. };
  98896. }
  98897. declare module BABYLON {
  98898. /** @hidden */
  98899. export var defaultUboDeclaration: {
  98900. name: string;
  98901. shader: string;
  98902. };
  98903. }
  98904. declare module BABYLON {
  98905. /** @hidden */
  98906. export var lightFragmentDeclaration: {
  98907. name: string;
  98908. shader: string;
  98909. };
  98910. }
  98911. declare module BABYLON {
  98912. /** @hidden */
  98913. export var lightUboDeclaration: {
  98914. name: string;
  98915. shader: string;
  98916. };
  98917. }
  98918. declare module BABYLON {
  98919. /** @hidden */
  98920. export var lightsFragmentFunctions: {
  98921. name: string;
  98922. shader: string;
  98923. };
  98924. }
  98925. declare module BABYLON {
  98926. /** @hidden */
  98927. export var shadowsFragmentFunctions: {
  98928. name: string;
  98929. shader: string;
  98930. };
  98931. }
  98932. declare module BABYLON {
  98933. /** @hidden */
  98934. export var fresnelFunction: {
  98935. name: string;
  98936. shader: string;
  98937. };
  98938. }
  98939. declare module BABYLON {
  98940. /** @hidden */
  98941. export var reflectionFunction: {
  98942. name: string;
  98943. shader: string;
  98944. };
  98945. }
  98946. declare module BABYLON {
  98947. /** @hidden */
  98948. export var bumpFragmentFunctions: {
  98949. name: string;
  98950. shader: string;
  98951. };
  98952. }
  98953. declare module BABYLON {
  98954. /** @hidden */
  98955. export var logDepthDeclaration: {
  98956. name: string;
  98957. shader: string;
  98958. };
  98959. }
  98960. declare module BABYLON {
  98961. /** @hidden */
  98962. export var bumpFragment: {
  98963. name: string;
  98964. shader: string;
  98965. };
  98966. }
  98967. declare module BABYLON {
  98968. /** @hidden */
  98969. export var depthPrePass: {
  98970. name: string;
  98971. shader: string;
  98972. };
  98973. }
  98974. declare module BABYLON {
  98975. /** @hidden */
  98976. export var lightFragment: {
  98977. name: string;
  98978. shader: string;
  98979. };
  98980. }
  98981. declare module BABYLON {
  98982. /** @hidden */
  98983. export var logDepthFragment: {
  98984. name: string;
  98985. shader: string;
  98986. };
  98987. }
  98988. declare module BABYLON {
  98989. /** @hidden */
  98990. export var defaultPixelShader: {
  98991. name: string;
  98992. shader: string;
  98993. };
  98994. }
  98995. declare module BABYLON {
  98996. /** @hidden */
  98997. export var defaultVertexDeclaration: {
  98998. name: string;
  98999. shader: string;
  99000. };
  99001. }
  99002. declare module BABYLON {
  99003. /** @hidden */
  99004. export var bumpVertexDeclaration: {
  99005. name: string;
  99006. shader: string;
  99007. };
  99008. }
  99009. declare module BABYLON {
  99010. /** @hidden */
  99011. export var bumpVertex: {
  99012. name: string;
  99013. shader: string;
  99014. };
  99015. }
  99016. declare module BABYLON {
  99017. /** @hidden */
  99018. export var fogVertex: {
  99019. name: string;
  99020. shader: string;
  99021. };
  99022. }
  99023. declare module BABYLON {
  99024. /** @hidden */
  99025. export var shadowsVertex: {
  99026. name: string;
  99027. shader: string;
  99028. };
  99029. }
  99030. declare module BABYLON {
  99031. /** @hidden */
  99032. export var pointCloudVertex: {
  99033. name: string;
  99034. shader: string;
  99035. };
  99036. }
  99037. declare module BABYLON {
  99038. /** @hidden */
  99039. export var logDepthVertex: {
  99040. name: string;
  99041. shader: string;
  99042. };
  99043. }
  99044. declare module BABYLON {
  99045. /** @hidden */
  99046. export var defaultVertexShader: {
  99047. name: string;
  99048. shader: string;
  99049. };
  99050. }
  99051. declare module BABYLON {
  99052. /** @hidden */
  99053. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99054. MAINUV1: boolean;
  99055. MAINUV2: boolean;
  99056. DIFFUSE: boolean;
  99057. DIFFUSEDIRECTUV: number;
  99058. AMBIENT: boolean;
  99059. AMBIENTDIRECTUV: number;
  99060. OPACITY: boolean;
  99061. OPACITYDIRECTUV: number;
  99062. OPACITYRGB: boolean;
  99063. REFLECTION: boolean;
  99064. EMISSIVE: boolean;
  99065. EMISSIVEDIRECTUV: number;
  99066. SPECULAR: boolean;
  99067. SPECULARDIRECTUV: number;
  99068. BUMP: boolean;
  99069. BUMPDIRECTUV: number;
  99070. PARALLAX: boolean;
  99071. PARALLAXOCCLUSION: boolean;
  99072. SPECULAROVERALPHA: boolean;
  99073. CLIPPLANE: boolean;
  99074. CLIPPLANE2: boolean;
  99075. CLIPPLANE3: boolean;
  99076. CLIPPLANE4: boolean;
  99077. CLIPPLANE5: boolean;
  99078. CLIPPLANE6: boolean;
  99079. ALPHATEST: boolean;
  99080. DEPTHPREPASS: boolean;
  99081. ALPHAFROMDIFFUSE: boolean;
  99082. POINTSIZE: boolean;
  99083. FOG: boolean;
  99084. SPECULARTERM: boolean;
  99085. DIFFUSEFRESNEL: boolean;
  99086. OPACITYFRESNEL: boolean;
  99087. REFLECTIONFRESNEL: boolean;
  99088. REFRACTIONFRESNEL: boolean;
  99089. EMISSIVEFRESNEL: boolean;
  99090. FRESNEL: boolean;
  99091. NORMAL: boolean;
  99092. UV1: boolean;
  99093. UV2: boolean;
  99094. VERTEXCOLOR: boolean;
  99095. VERTEXALPHA: boolean;
  99096. NUM_BONE_INFLUENCERS: number;
  99097. BonesPerMesh: number;
  99098. BONETEXTURE: boolean;
  99099. INSTANCES: boolean;
  99100. GLOSSINESS: boolean;
  99101. ROUGHNESS: boolean;
  99102. EMISSIVEASILLUMINATION: boolean;
  99103. LINKEMISSIVEWITHDIFFUSE: boolean;
  99104. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99105. LIGHTMAP: boolean;
  99106. LIGHTMAPDIRECTUV: number;
  99107. OBJECTSPACE_NORMALMAP: boolean;
  99108. USELIGHTMAPASSHADOWMAP: boolean;
  99109. REFLECTIONMAP_3D: boolean;
  99110. REFLECTIONMAP_SPHERICAL: boolean;
  99111. REFLECTIONMAP_PLANAR: boolean;
  99112. REFLECTIONMAP_CUBIC: boolean;
  99113. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99114. REFLECTIONMAP_PROJECTION: boolean;
  99115. REFLECTIONMAP_SKYBOX: boolean;
  99116. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  99117. REFLECTIONMAP_EXPLICIT: boolean;
  99118. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99119. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99120. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99121. INVERTCUBICMAP: boolean;
  99122. LOGARITHMICDEPTH: boolean;
  99123. REFRACTION: boolean;
  99124. REFRACTIONMAP_3D: boolean;
  99125. REFLECTIONOVERALPHA: boolean;
  99126. TWOSIDEDLIGHTING: boolean;
  99127. SHADOWFLOAT: boolean;
  99128. MORPHTARGETS: boolean;
  99129. MORPHTARGETS_NORMAL: boolean;
  99130. MORPHTARGETS_TANGENT: boolean;
  99131. MORPHTARGETS_UV: boolean;
  99132. NUM_MORPH_INFLUENCERS: number;
  99133. NONUNIFORMSCALING: boolean;
  99134. PREMULTIPLYALPHA: boolean;
  99135. IMAGEPROCESSING: boolean;
  99136. VIGNETTE: boolean;
  99137. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99138. VIGNETTEBLENDMODEOPAQUE: boolean;
  99139. TONEMAPPING: boolean;
  99140. TONEMAPPING_ACES: boolean;
  99141. CONTRAST: boolean;
  99142. COLORCURVES: boolean;
  99143. COLORGRADING: boolean;
  99144. COLORGRADING3D: boolean;
  99145. SAMPLER3DGREENDEPTH: boolean;
  99146. SAMPLER3DBGRMAP: boolean;
  99147. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99148. MULTIVIEW: boolean;
  99149. /**
  99150. * If the reflection texture on this material is in linear color space
  99151. * @hidden
  99152. */
  99153. IS_REFLECTION_LINEAR: boolean;
  99154. /**
  99155. * If the refraction texture on this material is in linear color space
  99156. * @hidden
  99157. */
  99158. IS_REFRACTION_LINEAR: boolean;
  99159. EXPOSURE: boolean;
  99160. constructor();
  99161. setReflectionMode(modeToEnable: string): void;
  99162. }
  99163. /**
  99164. * This is the default material used in Babylon. It is the best trade off between quality
  99165. * and performances.
  99166. * @see http://doc.babylonjs.com/babylon101/materials
  99167. */
  99168. export class StandardMaterial extends PushMaterial {
  99169. private _diffuseTexture;
  99170. /**
  99171. * The basic texture of the material as viewed under a light.
  99172. */
  99173. diffuseTexture: Nullable<BaseTexture>;
  99174. private _ambientTexture;
  99175. /**
  99176. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99177. */
  99178. ambientTexture: Nullable<BaseTexture>;
  99179. private _opacityTexture;
  99180. /**
  99181. * Define the transparency of the material from a texture.
  99182. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99183. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99184. */
  99185. opacityTexture: Nullable<BaseTexture>;
  99186. private _reflectionTexture;
  99187. /**
  99188. * Define the texture used to display the reflection.
  99189. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99190. */
  99191. reflectionTexture: Nullable<BaseTexture>;
  99192. private _emissiveTexture;
  99193. /**
  99194. * Define texture of the material as if self lit.
  99195. * This will be mixed in the final result even in the absence of light.
  99196. */
  99197. emissiveTexture: Nullable<BaseTexture>;
  99198. private _specularTexture;
  99199. /**
  99200. * Define how the color and intensity of the highlight given by the light in the material.
  99201. */
  99202. specularTexture: Nullable<BaseTexture>;
  99203. private _bumpTexture;
  99204. /**
  99205. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99206. * 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.
  99207. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99208. */
  99209. bumpTexture: Nullable<BaseTexture>;
  99210. private _lightmapTexture;
  99211. /**
  99212. * Complex lighting can be computationally expensive to compute at runtime.
  99213. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99214. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99215. */
  99216. lightmapTexture: Nullable<BaseTexture>;
  99217. private _refractionTexture;
  99218. /**
  99219. * Define the texture used to display the refraction.
  99220. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99221. */
  99222. refractionTexture: Nullable<BaseTexture>;
  99223. /**
  99224. * The color of the material lit by the environmental background lighting.
  99225. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99226. */
  99227. ambientColor: Color3;
  99228. /**
  99229. * The basic color of the material as viewed under a light.
  99230. */
  99231. diffuseColor: Color3;
  99232. /**
  99233. * Define how the color and intensity of the highlight given by the light in the material.
  99234. */
  99235. specularColor: Color3;
  99236. /**
  99237. * Define the color of the material as if self lit.
  99238. * This will be mixed in the final result even in the absence of light.
  99239. */
  99240. emissiveColor: Color3;
  99241. /**
  99242. * Defines how sharp are the highlights in the material.
  99243. * The bigger the value the sharper giving a more glossy feeling to the result.
  99244. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99245. */
  99246. specularPower: number;
  99247. private _useAlphaFromDiffuseTexture;
  99248. /**
  99249. * Does the transparency come from the diffuse texture alpha channel.
  99250. */
  99251. useAlphaFromDiffuseTexture: boolean;
  99252. private _useEmissiveAsIllumination;
  99253. /**
  99254. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99255. */
  99256. useEmissiveAsIllumination: boolean;
  99257. private _linkEmissiveWithDiffuse;
  99258. /**
  99259. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99260. * the emissive level when the final color is close to one.
  99261. */
  99262. linkEmissiveWithDiffuse: boolean;
  99263. private _useSpecularOverAlpha;
  99264. /**
  99265. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99266. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99267. */
  99268. useSpecularOverAlpha: boolean;
  99269. private _useReflectionOverAlpha;
  99270. /**
  99271. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99272. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99273. */
  99274. useReflectionOverAlpha: boolean;
  99275. private _disableLighting;
  99276. /**
  99277. * Does lights from the scene impacts this material.
  99278. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99279. */
  99280. disableLighting: boolean;
  99281. private _useObjectSpaceNormalMap;
  99282. /**
  99283. * Allows using an object space normal map (instead of tangent space).
  99284. */
  99285. useObjectSpaceNormalMap: boolean;
  99286. private _useParallax;
  99287. /**
  99288. * Is parallax enabled or not.
  99289. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99290. */
  99291. useParallax: boolean;
  99292. private _useParallaxOcclusion;
  99293. /**
  99294. * Is parallax occlusion enabled or not.
  99295. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99296. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99297. */
  99298. useParallaxOcclusion: boolean;
  99299. /**
  99300. * 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.
  99301. */
  99302. parallaxScaleBias: number;
  99303. private _roughness;
  99304. /**
  99305. * Helps to define how blurry the reflections should appears in the material.
  99306. */
  99307. roughness: number;
  99308. /**
  99309. * In case of refraction, define the value of the index of refraction.
  99310. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99311. */
  99312. indexOfRefraction: number;
  99313. /**
  99314. * Invert the refraction texture alongside the y axis.
  99315. * It can be useful with procedural textures or probe for instance.
  99316. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99317. */
  99318. invertRefractionY: boolean;
  99319. /**
  99320. * Defines the alpha limits in alpha test mode.
  99321. */
  99322. alphaCutOff: number;
  99323. private _useLightmapAsShadowmap;
  99324. /**
  99325. * In case of light mapping, define whether the map contains light or shadow informations.
  99326. */
  99327. useLightmapAsShadowmap: boolean;
  99328. private _diffuseFresnelParameters;
  99329. /**
  99330. * Define the diffuse fresnel parameters of the material.
  99331. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99332. */
  99333. diffuseFresnelParameters: FresnelParameters;
  99334. private _opacityFresnelParameters;
  99335. /**
  99336. * Define the opacity fresnel parameters of the material.
  99337. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99338. */
  99339. opacityFresnelParameters: FresnelParameters;
  99340. private _reflectionFresnelParameters;
  99341. /**
  99342. * Define the reflection fresnel parameters of the material.
  99343. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99344. */
  99345. reflectionFresnelParameters: FresnelParameters;
  99346. private _refractionFresnelParameters;
  99347. /**
  99348. * Define the refraction fresnel parameters of the material.
  99349. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99350. */
  99351. refractionFresnelParameters: FresnelParameters;
  99352. private _emissiveFresnelParameters;
  99353. /**
  99354. * Define the emissive fresnel parameters of the material.
  99355. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99356. */
  99357. emissiveFresnelParameters: FresnelParameters;
  99358. private _useReflectionFresnelFromSpecular;
  99359. /**
  99360. * If true automatically deducts the fresnels values from the material specularity.
  99361. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99362. */
  99363. useReflectionFresnelFromSpecular: boolean;
  99364. private _useGlossinessFromSpecularMapAlpha;
  99365. /**
  99366. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99367. */
  99368. useGlossinessFromSpecularMapAlpha: boolean;
  99369. private _maxSimultaneousLights;
  99370. /**
  99371. * Defines the maximum number of lights that can be used in the material
  99372. */
  99373. maxSimultaneousLights: number;
  99374. private _invertNormalMapX;
  99375. /**
  99376. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99377. */
  99378. invertNormalMapX: boolean;
  99379. private _invertNormalMapY;
  99380. /**
  99381. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99382. */
  99383. invertNormalMapY: boolean;
  99384. private _twoSidedLighting;
  99385. /**
  99386. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99387. */
  99388. twoSidedLighting: boolean;
  99389. /**
  99390. * Default configuration related to image processing available in the standard Material.
  99391. */
  99392. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99393. /**
  99394. * Gets the image processing configuration used either in this material.
  99395. */
  99396. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99397. /**
  99398. * Sets the Default image processing configuration used either in the this material.
  99399. *
  99400. * If sets to null, the scene one is in use.
  99401. */
  99402. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99403. /**
  99404. * Keep track of the image processing observer to allow dispose and replace.
  99405. */
  99406. private _imageProcessingObserver;
  99407. /**
  99408. * Attaches a new image processing configuration to the Standard Material.
  99409. * @param configuration
  99410. */
  99411. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99412. /**
  99413. * Gets wether the color curves effect is enabled.
  99414. */
  99415. get cameraColorCurvesEnabled(): boolean;
  99416. /**
  99417. * Sets wether the color curves effect is enabled.
  99418. */
  99419. set cameraColorCurvesEnabled(value: boolean);
  99420. /**
  99421. * Gets wether the color grading effect is enabled.
  99422. */
  99423. get cameraColorGradingEnabled(): boolean;
  99424. /**
  99425. * Gets wether the color grading effect is enabled.
  99426. */
  99427. set cameraColorGradingEnabled(value: boolean);
  99428. /**
  99429. * Gets wether tonemapping is enabled or not.
  99430. */
  99431. get cameraToneMappingEnabled(): boolean;
  99432. /**
  99433. * Sets wether tonemapping is enabled or not
  99434. */
  99435. set cameraToneMappingEnabled(value: boolean);
  99436. /**
  99437. * The camera exposure used on this material.
  99438. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99439. * This corresponds to a photographic exposure.
  99440. */
  99441. get cameraExposure(): number;
  99442. /**
  99443. * The camera exposure used on this material.
  99444. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99445. * This corresponds to a photographic exposure.
  99446. */
  99447. set cameraExposure(value: number);
  99448. /**
  99449. * Gets The camera contrast used on this material.
  99450. */
  99451. get cameraContrast(): number;
  99452. /**
  99453. * Sets The camera contrast used on this material.
  99454. */
  99455. set cameraContrast(value: number);
  99456. /**
  99457. * Gets the Color Grading 2D Lookup Texture.
  99458. */
  99459. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99460. /**
  99461. * Sets the Color Grading 2D Lookup Texture.
  99462. */
  99463. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99464. /**
  99465. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99466. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99467. * 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;
  99468. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99469. */
  99470. get cameraColorCurves(): Nullable<ColorCurves>;
  99471. /**
  99472. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99473. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99474. * 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;
  99475. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99476. */
  99477. set cameraColorCurves(value: Nullable<ColorCurves>);
  99478. /**
  99479. * Custom callback helping to override the default shader used in the material.
  99480. */
  99481. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99482. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99483. protected _worldViewProjectionMatrix: Matrix;
  99484. protected _globalAmbientColor: Color3;
  99485. protected _useLogarithmicDepth: boolean;
  99486. protected _rebuildInParallel: boolean;
  99487. /**
  99488. * Instantiates a new standard material.
  99489. * This is the default material used in Babylon. It is the best trade off between quality
  99490. * and performances.
  99491. * @see http://doc.babylonjs.com/babylon101/materials
  99492. * @param name Define the name of the material in the scene
  99493. * @param scene Define the scene the material belong to
  99494. */
  99495. constructor(name: string, scene: Scene);
  99496. /**
  99497. * Gets a boolean indicating that current material needs to register RTT
  99498. */
  99499. get hasRenderTargetTextures(): boolean;
  99500. /**
  99501. * Gets the current class name of the material e.g. "StandardMaterial"
  99502. * Mainly use in serialization.
  99503. * @returns the class name
  99504. */
  99505. getClassName(): string;
  99506. /**
  99507. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99508. * You can try switching to logarithmic depth.
  99509. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99510. */
  99511. get useLogarithmicDepth(): boolean;
  99512. set useLogarithmicDepth(value: boolean);
  99513. /**
  99514. * Specifies if the material will require alpha blending
  99515. * @returns a boolean specifying if alpha blending is needed
  99516. */
  99517. needAlphaBlending(): boolean;
  99518. /**
  99519. * Specifies if this material should be rendered in alpha test mode
  99520. * @returns a boolean specifying if an alpha test is needed.
  99521. */
  99522. needAlphaTesting(): boolean;
  99523. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99524. /**
  99525. * Get the texture used for alpha test purpose.
  99526. * @returns the diffuse texture in case of the standard material.
  99527. */
  99528. getAlphaTestTexture(): Nullable<BaseTexture>;
  99529. /**
  99530. * Get if the submesh is ready to be used and all its information available.
  99531. * Child classes can use it to update shaders
  99532. * @param mesh defines the mesh to check
  99533. * @param subMesh defines which submesh to check
  99534. * @param useInstances specifies that instances should be used
  99535. * @returns a boolean indicating that the submesh is ready or not
  99536. */
  99537. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99538. /**
  99539. * Builds the material UBO layouts.
  99540. * Used internally during the effect preparation.
  99541. */
  99542. buildUniformLayout(): void;
  99543. /**
  99544. * Unbinds the material from the mesh
  99545. */
  99546. unbind(): void;
  99547. /**
  99548. * Binds the submesh to this material by preparing the effect and shader to draw
  99549. * @param world defines the world transformation matrix
  99550. * @param mesh defines the mesh containing the submesh
  99551. * @param subMesh defines the submesh to bind the material to
  99552. */
  99553. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99554. /**
  99555. * Get the list of animatables in the material.
  99556. * @returns the list of animatables object used in the material
  99557. */
  99558. getAnimatables(): IAnimatable[];
  99559. /**
  99560. * Gets the active textures from the material
  99561. * @returns an array of textures
  99562. */
  99563. getActiveTextures(): BaseTexture[];
  99564. /**
  99565. * Specifies if the material uses a texture
  99566. * @param texture defines the texture to check against the material
  99567. * @returns a boolean specifying if the material uses the texture
  99568. */
  99569. hasTexture(texture: BaseTexture): boolean;
  99570. /**
  99571. * Disposes the material
  99572. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99573. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99574. */
  99575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99576. /**
  99577. * Makes a duplicate of the material, and gives it a new name
  99578. * @param name defines the new name for the duplicated material
  99579. * @returns the cloned material
  99580. */
  99581. clone(name: string): StandardMaterial;
  99582. /**
  99583. * Serializes this material in a JSON representation
  99584. * @returns the serialized material object
  99585. */
  99586. serialize(): any;
  99587. /**
  99588. * Creates a standard material from parsed material data
  99589. * @param source defines the JSON representation of the material
  99590. * @param scene defines the hosting scene
  99591. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99592. * @returns a new standard material
  99593. */
  99594. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99595. /**
  99596. * Are diffuse textures enabled in the application.
  99597. */
  99598. static get DiffuseTextureEnabled(): boolean;
  99599. static set DiffuseTextureEnabled(value: boolean);
  99600. /**
  99601. * Are ambient textures enabled in the application.
  99602. */
  99603. static get AmbientTextureEnabled(): boolean;
  99604. static set AmbientTextureEnabled(value: boolean);
  99605. /**
  99606. * Are opacity textures enabled in the application.
  99607. */
  99608. static get OpacityTextureEnabled(): boolean;
  99609. static set OpacityTextureEnabled(value: boolean);
  99610. /**
  99611. * Are reflection textures enabled in the application.
  99612. */
  99613. static get ReflectionTextureEnabled(): boolean;
  99614. static set ReflectionTextureEnabled(value: boolean);
  99615. /**
  99616. * Are emissive textures enabled in the application.
  99617. */
  99618. static get EmissiveTextureEnabled(): boolean;
  99619. static set EmissiveTextureEnabled(value: boolean);
  99620. /**
  99621. * Are specular textures enabled in the application.
  99622. */
  99623. static get SpecularTextureEnabled(): boolean;
  99624. static set SpecularTextureEnabled(value: boolean);
  99625. /**
  99626. * Are bump textures enabled in the application.
  99627. */
  99628. static get BumpTextureEnabled(): boolean;
  99629. static set BumpTextureEnabled(value: boolean);
  99630. /**
  99631. * Are lightmap textures enabled in the application.
  99632. */
  99633. static get LightmapTextureEnabled(): boolean;
  99634. static set LightmapTextureEnabled(value: boolean);
  99635. /**
  99636. * Are refraction textures enabled in the application.
  99637. */
  99638. static get RefractionTextureEnabled(): boolean;
  99639. static set RefractionTextureEnabled(value: boolean);
  99640. /**
  99641. * Are color grading textures enabled in the application.
  99642. */
  99643. static get ColorGradingTextureEnabled(): boolean;
  99644. static set ColorGradingTextureEnabled(value: boolean);
  99645. /**
  99646. * Are fresnels enabled in the application.
  99647. */
  99648. static get FresnelEnabled(): boolean;
  99649. static set FresnelEnabled(value: boolean);
  99650. }
  99651. }
  99652. declare module BABYLON {
  99653. /**
  99654. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  99655. *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.
  99656. * The SPS is also a particle system. It provides some methods to manage the particles.
  99657. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  99658. *
  99659. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  99660. */
  99661. export class SolidParticleSystem implements IDisposable {
  99662. /**
  99663. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  99664. * Example : var p = SPS.particles[i];
  99665. */
  99666. particles: SolidParticle[];
  99667. /**
  99668. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  99669. */
  99670. nbParticles: number;
  99671. /**
  99672. * If the particles must ever face the camera (default false). Useful for planar particles.
  99673. */
  99674. billboard: boolean;
  99675. /**
  99676. * Recompute normals when adding a shape
  99677. */
  99678. recomputeNormals: boolean;
  99679. /**
  99680. * This a counter ofr your own usage. It's not set by any SPS functions.
  99681. */
  99682. counter: number;
  99683. /**
  99684. * The SPS name. This name is also given to the underlying mesh.
  99685. */
  99686. name: string;
  99687. /**
  99688. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  99689. */
  99690. mesh: Mesh;
  99691. /**
  99692. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  99693. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  99694. */
  99695. vars: any;
  99696. /**
  99697. * This array is populated when the SPS is set as 'pickable'.
  99698. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  99699. * Each element of this array is an object `{idx: int, faceId: int}`.
  99700. * `idx` is the picked particle index in the `SPS.particles` array
  99701. * `faceId` is the picked face index counted within this particle.
  99702. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  99703. */
  99704. pickedParticles: {
  99705. idx: number;
  99706. faceId: number;
  99707. }[];
  99708. /**
  99709. * This array is populated when `enableDepthSort` is set to true.
  99710. * Each element of this array is an instance of the class DepthSortedParticle.
  99711. */
  99712. depthSortedParticles: DepthSortedParticle[];
  99713. /**
  99714. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  99715. * @hidden
  99716. */
  99717. _bSphereOnly: boolean;
  99718. /**
  99719. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  99720. * @hidden
  99721. */
  99722. _bSphereRadiusFactor: number;
  99723. private _scene;
  99724. private _positions;
  99725. private _indices;
  99726. private _normals;
  99727. private _colors;
  99728. private _uvs;
  99729. private _indices32;
  99730. private _positions32;
  99731. private _normals32;
  99732. private _fixedNormal32;
  99733. private _colors32;
  99734. private _uvs32;
  99735. private _index;
  99736. private _updatable;
  99737. private _pickable;
  99738. private _isVisibilityBoxLocked;
  99739. private _alwaysVisible;
  99740. private _depthSort;
  99741. private _expandable;
  99742. private _shapeCounter;
  99743. private _copy;
  99744. private _color;
  99745. private _computeParticleColor;
  99746. private _computeParticleTexture;
  99747. private _computeParticleRotation;
  99748. private _computeParticleVertex;
  99749. private _computeBoundingBox;
  99750. private _depthSortParticles;
  99751. private _camera;
  99752. private _mustUnrotateFixedNormals;
  99753. private _particlesIntersect;
  99754. private _needs32Bits;
  99755. private _isNotBuilt;
  99756. private _lastParticleId;
  99757. private _idxOfId;
  99758. private _multimaterialEnabled;
  99759. private _useModelMaterial;
  99760. private _indicesByMaterial;
  99761. private _materialIndexes;
  99762. private _depthSortFunction;
  99763. private _materialSortFunction;
  99764. private _materials;
  99765. private _multimaterial;
  99766. private _materialIndexesById;
  99767. private _defaultMaterial;
  99768. private _autoUpdateSubMeshes;
  99769. /**
  99770. * Creates a SPS (Solid Particle System) object.
  99771. * @param name (String) is the SPS name, this will be the underlying mesh name.
  99772. * @param scene (Scene) is the scene in which the SPS is added.
  99773. * @param options defines the options of the sps e.g.
  99774. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  99775. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  99776. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  99777. * * 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.
  99778. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  99779. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  99780. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  99781. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  99782. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  99783. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  99784. */
  99785. constructor(name: string, scene: Scene, options?: {
  99786. updatable?: boolean;
  99787. isPickable?: boolean;
  99788. enableDepthSort?: boolean;
  99789. particleIntersection?: boolean;
  99790. boundingSphereOnly?: boolean;
  99791. bSphereRadiusFactor?: number;
  99792. expandable?: boolean;
  99793. useModelMaterial?: boolean;
  99794. enableMultiMaterial?: boolean;
  99795. });
  99796. /**
  99797. * Builds the SPS underlying mesh. Returns a standard Mesh.
  99798. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  99799. * @returns the created mesh
  99800. */
  99801. buildMesh(): Mesh;
  99802. /**
  99803. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  99804. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  99805. * Thus the particles generated from `digest()` have their property `position` set yet.
  99806. * @param mesh ( Mesh ) is the mesh to be digested
  99807. * @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
  99808. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  99809. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  99810. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99811. * @returns the current SPS
  99812. */
  99813. digest(mesh: Mesh, options?: {
  99814. facetNb?: number;
  99815. number?: number;
  99816. delta?: number;
  99817. storage?: [];
  99818. }): SolidParticleSystem;
  99819. /**
  99820. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  99821. * @hidden
  99822. */
  99823. private _unrotateFixedNormals;
  99824. /**
  99825. * Resets the temporary working copy particle
  99826. * @hidden
  99827. */
  99828. private _resetCopy;
  99829. /**
  99830. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  99831. * @param p the current index in the positions array to be updated
  99832. * @param ind the current index in the indices array
  99833. * @param shape a Vector3 array, the shape geometry
  99834. * @param positions the positions array to be updated
  99835. * @param meshInd the shape indices array
  99836. * @param indices the indices array to be updated
  99837. * @param meshUV the shape uv array
  99838. * @param uvs the uv array to be updated
  99839. * @param meshCol the shape color array
  99840. * @param colors the color array to be updated
  99841. * @param meshNor the shape normals array
  99842. * @param normals the normals array to be updated
  99843. * @param idx the particle index
  99844. * @param idxInShape the particle index in its shape
  99845. * @param options the addShape() method passed options
  99846. * @model the particle model
  99847. * @hidden
  99848. */
  99849. private _meshBuilder;
  99850. /**
  99851. * Returns a shape Vector3 array from positions float array
  99852. * @param positions float array
  99853. * @returns a vector3 array
  99854. * @hidden
  99855. */
  99856. private _posToShape;
  99857. /**
  99858. * Returns a shapeUV array from a float uvs (array deep copy)
  99859. * @param uvs as a float array
  99860. * @returns a shapeUV array
  99861. * @hidden
  99862. */
  99863. private _uvsToShapeUV;
  99864. /**
  99865. * Adds a new particle object in the particles array
  99866. * @param idx particle index in particles array
  99867. * @param id particle id
  99868. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  99869. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  99870. * @param model particle ModelShape object
  99871. * @param shapeId model shape identifier
  99872. * @param idxInShape index of the particle in the current model
  99873. * @param bInfo model bounding info object
  99874. * @param storage target storage array, if any
  99875. * @hidden
  99876. */
  99877. private _addParticle;
  99878. /**
  99879. * Adds some particles to the SPS from the model shape. Returns the shape id.
  99880. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  99881. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  99882. * @param nb (positive integer) the number of particles to be created from this model
  99883. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  99884. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  99885. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99886. * @returns the number of shapes in the system
  99887. */
  99888. addShape(mesh: Mesh, nb: number, options?: {
  99889. positionFunction?: any;
  99890. vertexFunction?: any;
  99891. storage?: [];
  99892. }): number;
  99893. /**
  99894. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  99895. * @hidden
  99896. */
  99897. private _rebuildParticle;
  99898. /**
  99899. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  99900. * @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.
  99901. * @returns the SPS.
  99902. */
  99903. rebuildMesh(reset?: boolean): SolidParticleSystem;
  99904. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  99905. * Returns an array with the removed particles.
  99906. * 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.
  99907. * The SPS can't be empty so at least one particle needs to remain in place.
  99908. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  99909. * @param start index of the first particle to remove
  99910. * @param end index of the last particle to remove (included)
  99911. * @returns an array populated with the removed particles
  99912. */
  99913. removeParticles(start: number, end: number): SolidParticle[];
  99914. /**
  99915. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  99916. * @param solidParticleArray an array populated with Solid Particles objects
  99917. * @returns the SPS
  99918. */
  99919. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  99920. /**
  99921. * Creates a new particle and modifies the SPS mesh geometry :
  99922. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  99923. * - calls _addParticle() to populate the particle array
  99924. * factorized code from addShape() and insertParticlesFromArray()
  99925. * @param idx particle index in the particles array
  99926. * @param i particle index in its shape
  99927. * @param modelShape particle ModelShape object
  99928. * @param shape shape vertex array
  99929. * @param meshInd shape indices array
  99930. * @param meshUV shape uv array
  99931. * @param meshCol shape color array
  99932. * @param meshNor shape normals array
  99933. * @param bbInfo shape bounding info
  99934. * @param storage target particle storage
  99935. * @options addShape() passed options
  99936. * @hidden
  99937. */
  99938. private _insertNewParticle;
  99939. /**
  99940. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  99941. * This method calls `updateParticle()` for each particle of the SPS.
  99942. * For an animated SPS, it is usually called within the render loop.
  99943. * 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.
  99944. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  99945. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  99946. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  99947. * @returns the SPS.
  99948. */
  99949. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  99950. /**
  99951. * Disposes the SPS.
  99952. */
  99953. dispose(): void;
  99954. /**
  99955. * Returns a SolidParticle object from its identifier : particle.id
  99956. * @param id (integer) the particle Id
  99957. * @returns the searched particle or null if not found in the SPS.
  99958. */
  99959. getParticleById(id: number): Nullable<SolidParticle>;
  99960. /**
  99961. * Returns a new array populated with the particles having the passed shapeId.
  99962. * @param shapeId (integer) the shape identifier
  99963. * @returns a new solid particle array
  99964. */
  99965. getParticlesByShapeId(shapeId: number): SolidParticle[];
  99966. /**
  99967. * Populates the passed array "ref" with the particles having the passed shapeId.
  99968. * @param shapeId the shape identifier
  99969. * @returns the SPS
  99970. * @param ref
  99971. */
  99972. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  99973. /**
  99974. * Computes the required SubMeshes according the materials assigned to the particles.
  99975. * @returns the solid particle system.
  99976. * Does nothing if called before the SPS mesh is built.
  99977. */
  99978. computeSubMeshes(): SolidParticleSystem;
  99979. /**
  99980. * Sorts the solid particles by material when MultiMaterial is enabled.
  99981. * Updates the indices32 array.
  99982. * Updates the indicesByMaterial array.
  99983. * Updates the mesh indices array.
  99984. * @returns the SPS
  99985. * @hidden
  99986. */
  99987. private _sortParticlesByMaterial;
  99988. /**
  99989. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  99990. * @hidden
  99991. */
  99992. private _setMaterialIndexesById;
  99993. /**
  99994. * Returns an array with unique values of Materials from the passed array
  99995. * @param array the material array to be checked and filtered
  99996. * @hidden
  99997. */
  99998. private _filterUniqueMaterialId;
  99999. /**
  100000. * Sets a new Standard Material as _defaultMaterial if not already set.
  100001. * @hidden
  100002. */
  100003. private _setDefaultMaterial;
  100004. /**
  100005. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100006. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100007. * @returns the SPS.
  100008. */
  100009. refreshVisibleSize(): SolidParticleSystem;
  100010. /**
  100011. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100012. * @param size the size (float) of the visibility box
  100013. * note : this doesn't lock the SPS mesh bounding box.
  100014. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100015. */
  100016. setVisibilityBox(size: number): void;
  100017. /**
  100018. * Gets whether the SPS as always visible or not
  100019. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100020. */
  100021. get isAlwaysVisible(): boolean;
  100022. /**
  100023. * Sets the SPS as always visible or not
  100024. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100025. */
  100026. set isAlwaysVisible(val: boolean);
  100027. /**
  100028. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100029. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100030. */
  100031. set isVisibilityBoxLocked(val: boolean);
  100032. /**
  100033. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100034. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100035. */
  100036. get isVisibilityBoxLocked(): boolean;
  100037. /**
  100038. * Tells to `setParticles()` to compute the particle rotations or not.
  100039. * Default value : true. The SPS is faster when it's set to false.
  100040. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100041. */
  100042. set computeParticleRotation(val: boolean);
  100043. /**
  100044. * Tells to `setParticles()` to compute the particle colors or not.
  100045. * Default value : true. The SPS is faster when it's set to false.
  100046. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100047. */
  100048. set computeParticleColor(val: boolean);
  100049. set computeParticleTexture(val: boolean);
  100050. /**
  100051. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100052. * Default value : false. The SPS is faster when it's set to false.
  100053. * Note : the particle custom vertex positions aren't stored values.
  100054. */
  100055. set computeParticleVertex(val: boolean);
  100056. /**
  100057. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100058. */
  100059. set computeBoundingBox(val: boolean);
  100060. /**
  100061. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100062. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100063. * Default : `true`
  100064. */
  100065. set depthSortParticles(val: boolean);
  100066. /**
  100067. * Gets if `setParticles()` computes the particle rotations or not.
  100068. * Default value : true. The SPS is faster when it's set to false.
  100069. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100070. */
  100071. get computeParticleRotation(): boolean;
  100072. /**
  100073. * Gets if `setParticles()` computes the particle colors or not.
  100074. * Default value : true. The SPS is faster when it's set to false.
  100075. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100076. */
  100077. get computeParticleColor(): boolean;
  100078. /**
  100079. * Gets if `setParticles()` computes the particle textures or not.
  100080. * Default value : true. The SPS is faster when it's set to false.
  100081. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100082. */
  100083. get computeParticleTexture(): boolean;
  100084. /**
  100085. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100086. * Default value : false. The SPS is faster when it's set to false.
  100087. * Note : the particle custom vertex positions aren't stored values.
  100088. */
  100089. get computeParticleVertex(): boolean;
  100090. /**
  100091. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100092. */
  100093. get computeBoundingBox(): boolean;
  100094. /**
  100095. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100096. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100097. * Default : `true`
  100098. */
  100099. get depthSortParticles(): boolean;
  100100. /**
  100101. * Gets if the SPS is created as expandable at construction time.
  100102. * Default : `false`
  100103. */
  100104. get expandable(): boolean;
  100105. /**
  100106. * Gets if the SPS supports the Multi Materials
  100107. */
  100108. get multimaterialEnabled(): boolean;
  100109. /**
  100110. * Gets if the SPS uses the model materials for its own multimaterial.
  100111. */
  100112. get useModelMaterial(): boolean;
  100113. /**
  100114. * The SPS used material array.
  100115. */
  100116. get materials(): Material[];
  100117. /**
  100118. * Sets the SPS MultiMaterial from the passed materials.
  100119. * Note : the passed array is internally copied and not used then by reference.
  100120. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100121. */
  100122. setMultiMaterial(materials: Material[]): void;
  100123. /**
  100124. * The SPS computed multimaterial object
  100125. */
  100126. get multimaterial(): MultiMaterial;
  100127. set multimaterial(mm: MultiMaterial);
  100128. /**
  100129. * If the subMeshes must be updated on the next call to setParticles()
  100130. */
  100131. get autoUpdateSubMeshes(): boolean;
  100132. set autoUpdateSubMeshes(val: boolean);
  100133. /**
  100134. * This function does nothing. It may be overwritten to set all the particle first values.
  100135. * The SPS doesn't call this function, you may have to call it by your own.
  100136. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100137. */
  100138. initParticles(): void;
  100139. /**
  100140. * This function does nothing. It may be overwritten to recycle a particle.
  100141. * The SPS doesn't call this function, you may have to call it by your own.
  100142. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100143. * @param particle The particle to recycle
  100144. * @returns the recycled particle
  100145. */
  100146. recycleParticle(particle: SolidParticle): SolidParticle;
  100147. /**
  100148. * Updates a particle : this function should be overwritten by the user.
  100149. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100150. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100151. * @example : just set a particle position or velocity and recycle conditions
  100152. * @param particle The particle to update
  100153. * @returns the updated particle
  100154. */
  100155. updateParticle(particle: SolidParticle): SolidParticle;
  100156. /**
  100157. * Updates a vertex of a particle : it can be overwritten by the user.
  100158. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100159. * @param particle the current particle
  100160. * @param vertex the current index of the current particle
  100161. * @param pt the index of the current vertex in the particle shape
  100162. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100163. * @example : just set a vertex particle position
  100164. * @returns the updated vertex
  100165. */
  100166. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100167. /**
  100168. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100169. * This does nothing and may be overwritten by the user.
  100170. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100171. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100172. * @param update the boolean update value actually passed to setParticles()
  100173. */
  100174. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100175. /**
  100176. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100177. * This will be passed three parameters.
  100178. * This does nothing and may be overwritten by the user.
  100179. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100180. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100181. * @param update the boolean update value actually passed to setParticles()
  100182. */
  100183. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100184. }
  100185. }
  100186. declare module BABYLON {
  100187. /**
  100188. * Represents one particle of a solid particle system.
  100189. */
  100190. export class SolidParticle {
  100191. /**
  100192. * particle global index
  100193. */
  100194. idx: number;
  100195. /**
  100196. * particle identifier
  100197. */
  100198. id: number;
  100199. /**
  100200. * The color of the particle
  100201. */
  100202. color: Nullable<Color4>;
  100203. /**
  100204. * The world space position of the particle.
  100205. */
  100206. position: Vector3;
  100207. /**
  100208. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100209. */
  100210. rotation: Vector3;
  100211. /**
  100212. * The world space rotation quaternion of the particle.
  100213. */
  100214. rotationQuaternion: Nullable<Quaternion>;
  100215. /**
  100216. * The scaling of the particle.
  100217. */
  100218. scaling: Vector3;
  100219. /**
  100220. * The uvs of the particle.
  100221. */
  100222. uvs: Vector4;
  100223. /**
  100224. * The current speed of the particle.
  100225. */
  100226. velocity: Vector3;
  100227. /**
  100228. * The pivot point in the particle local space.
  100229. */
  100230. pivot: Vector3;
  100231. /**
  100232. * Must the particle be translated from its pivot point in its local space ?
  100233. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100234. * Default : false
  100235. */
  100236. translateFromPivot: boolean;
  100237. /**
  100238. * Is the particle active or not ?
  100239. */
  100240. alive: boolean;
  100241. /**
  100242. * Is the particle visible or not ?
  100243. */
  100244. isVisible: boolean;
  100245. /**
  100246. * Index of this particle in the global "positions" array (Internal use)
  100247. * @hidden
  100248. */
  100249. _pos: number;
  100250. /**
  100251. * @hidden Index of this particle in the global "indices" array (Internal use)
  100252. */
  100253. _ind: number;
  100254. /**
  100255. * @hidden ModelShape of this particle (Internal use)
  100256. */
  100257. _model: ModelShape;
  100258. /**
  100259. * ModelShape id of this particle
  100260. */
  100261. shapeId: number;
  100262. /**
  100263. * Index of the particle in its shape id
  100264. */
  100265. idxInShape: number;
  100266. /**
  100267. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100268. */
  100269. _modelBoundingInfo: BoundingInfo;
  100270. /**
  100271. * @hidden Particle BoundingInfo object (Internal use)
  100272. */
  100273. _boundingInfo: BoundingInfo;
  100274. /**
  100275. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100276. */
  100277. _sps: SolidParticleSystem;
  100278. /**
  100279. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100280. */
  100281. _stillInvisible: boolean;
  100282. /**
  100283. * @hidden Last computed particle rotation matrix
  100284. */
  100285. _rotationMatrix: number[];
  100286. /**
  100287. * Parent particle Id, if any.
  100288. * Default null.
  100289. */
  100290. parentId: Nullable<number>;
  100291. /**
  100292. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100293. */
  100294. materialIndex: Nullable<number>;
  100295. /**
  100296. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100297. * The possible values are :
  100298. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100299. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100300. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100301. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100302. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100303. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100304. * */
  100305. cullingStrategy: number;
  100306. /**
  100307. * @hidden Internal global position in the SPS.
  100308. */
  100309. _globalPosition: Vector3;
  100310. /**
  100311. * Creates a Solid Particle object.
  100312. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100313. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100314. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100315. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100316. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100317. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100318. * @param shapeId (integer) is the model shape identifier in the SPS.
  100319. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100320. * @param sps defines the sps it is associated to
  100321. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100322. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100323. */
  100324. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100325. /**
  100326. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100327. * @param target the particle target
  100328. * @returns the current particle
  100329. */
  100330. copyToRef(target: SolidParticle): SolidParticle;
  100331. /**
  100332. * Legacy support, changed scale to scaling
  100333. */
  100334. get scale(): Vector3;
  100335. /**
  100336. * Legacy support, changed scale to scaling
  100337. */
  100338. set scale(scale: Vector3);
  100339. /**
  100340. * Legacy support, changed quaternion to rotationQuaternion
  100341. */
  100342. get quaternion(): Nullable<Quaternion>;
  100343. /**
  100344. * Legacy support, changed quaternion to rotationQuaternion
  100345. */
  100346. set quaternion(q: Nullable<Quaternion>);
  100347. /**
  100348. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100349. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100350. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100351. * @returns true if it intersects
  100352. */
  100353. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100354. /**
  100355. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100356. * A particle is in the frustum if its bounding box intersects the frustum
  100357. * @param frustumPlanes defines the frustum to test
  100358. * @returns true if the particle is in the frustum planes
  100359. */
  100360. isInFrustum(frustumPlanes: Plane[]): boolean;
  100361. /**
  100362. * get the rotation matrix of the particle
  100363. * @hidden
  100364. */
  100365. getRotationMatrix(m: Matrix): void;
  100366. }
  100367. /**
  100368. * Represents the shape of the model used by one particle of a solid particle system.
  100369. * SPS internal tool, don't use it manually.
  100370. */
  100371. export class ModelShape {
  100372. /**
  100373. * The shape id
  100374. * @hidden
  100375. */
  100376. shapeID: number;
  100377. /**
  100378. * flat array of model positions (internal use)
  100379. * @hidden
  100380. */
  100381. _shape: Vector3[];
  100382. /**
  100383. * flat array of model UVs (internal use)
  100384. * @hidden
  100385. */
  100386. _shapeUV: number[];
  100387. /**
  100388. * color array of the model
  100389. * @hidden
  100390. */
  100391. _shapeColors: number[];
  100392. /**
  100393. * indices array of the model
  100394. * @hidden
  100395. */
  100396. _indices: number[];
  100397. /**
  100398. * normals array of the model
  100399. * @hidden
  100400. */
  100401. _normals: number[];
  100402. /**
  100403. * length of the shape in the model indices array (internal use)
  100404. * @hidden
  100405. */
  100406. _indicesLength: number;
  100407. /**
  100408. * Custom position function (internal use)
  100409. * @hidden
  100410. */
  100411. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100412. /**
  100413. * Custom vertex function (internal use)
  100414. * @hidden
  100415. */
  100416. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100417. /**
  100418. * Model material (internal use)
  100419. * @hidden
  100420. */
  100421. _material: Nullable<Material>;
  100422. /**
  100423. * 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.
  100424. * SPS internal tool, don't use it manually.
  100425. * @hidden
  100426. */
  100427. 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>);
  100428. }
  100429. /**
  100430. * Represents a Depth Sorted Particle in the solid particle system.
  100431. * @hidden
  100432. */
  100433. export class DepthSortedParticle {
  100434. /**
  100435. * Index of the particle in the "indices" array
  100436. */
  100437. ind: number;
  100438. /**
  100439. * Length of the particle shape in the "indices" array
  100440. */
  100441. indicesLength: number;
  100442. /**
  100443. * Squared distance from the particle to the camera
  100444. */
  100445. sqDistance: number;
  100446. /**
  100447. * Material index when used with MultiMaterials
  100448. */
  100449. materialIndex: number;
  100450. /**
  100451. * Creates a new sorted particle
  100452. * @param materialIndex
  100453. */
  100454. constructor(ind: number, indLength: number, materialIndex: number);
  100455. }
  100456. }
  100457. declare module BABYLON {
  100458. /**
  100459. * @hidden
  100460. */
  100461. export class _MeshCollisionData {
  100462. _checkCollisions: boolean;
  100463. _collisionMask: number;
  100464. _collisionGroup: number;
  100465. _collider: Nullable<Collider>;
  100466. _oldPositionForCollisions: Vector3;
  100467. _diffPositionForCollisions: Vector3;
  100468. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100469. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100470. }
  100471. }
  100472. declare module BABYLON {
  100473. /** @hidden */
  100474. class _FacetDataStorage {
  100475. facetPositions: Vector3[];
  100476. facetNormals: Vector3[];
  100477. facetPartitioning: number[][];
  100478. facetNb: number;
  100479. partitioningSubdivisions: number;
  100480. partitioningBBoxRatio: number;
  100481. facetDataEnabled: boolean;
  100482. facetParameters: any;
  100483. bbSize: Vector3;
  100484. subDiv: {
  100485. max: number;
  100486. X: number;
  100487. Y: number;
  100488. Z: number;
  100489. };
  100490. facetDepthSort: boolean;
  100491. facetDepthSortEnabled: boolean;
  100492. depthSortedIndices: IndicesArray;
  100493. depthSortedFacets: {
  100494. ind: number;
  100495. sqDistance: number;
  100496. }[];
  100497. facetDepthSortFunction: (f1: {
  100498. ind: number;
  100499. sqDistance: number;
  100500. }, f2: {
  100501. ind: number;
  100502. sqDistance: number;
  100503. }) => number;
  100504. facetDepthSortFrom: Vector3;
  100505. facetDepthSortOrigin: Vector3;
  100506. invertedMatrix: Matrix;
  100507. }
  100508. /**
  100509. * @hidden
  100510. **/
  100511. class _InternalAbstractMeshDataInfo {
  100512. _hasVertexAlpha: boolean;
  100513. _useVertexColors: boolean;
  100514. _numBoneInfluencers: number;
  100515. _applyFog: boolean;
  100516. _receiveShadows: boolean;
  100517. _facetData: _FacetDataStorage;
  100518. _visibility: number;
  100519. _skeleton: Nullable<Skeleton>;
  100520. _layerMask: number;
  100521. _computeBonesUsingShaders: boolean;
  100522. _isActive: boolean;
  100523. _onlyForInstances: boolean;
  100524. _isActiveIntermediate: boolean;
  100525. _onlyForInstancesIntermediate: boolean;
  100526. _actAsRegularMesh: boolean;
  100527. }
  100528. /**
  100529. * Class used to store all common mesh properties
  100530. */
  100531. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100532. /** No occlusion */
  100533. static OCCLUSION_TYPE_NONE: number;
  100534. /** Occlusion set to optimisitic */
  100535. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100536. /** Occlusion set to strict */
  100537. static OCCLUSION_TYPE_STRICT: number;
  100538. /** Use an accurante occlusion algorithm */
  100539. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100540. /** Use a conservative occlusion algorithm */
  100541. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100542. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100543. * Test order :
  100544. * Is the bounding sphere outside the frustum ?
  100545. * If not, are the bounding box vertices outside the frustum ?
  100546. * It not, then the cullable object is in the frustum.
  100547. */
  100548. static readonly CULLINGSTRATEGY_STANDARD: number;
  100549. /** Culling strategy : Bounding Sphere Only.
  100550. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100551. * It's also less accurate than the standard because some not visible objects can still be selected.
  100552. * Test : is the bounding sphere outside the frustum ?
  100553. * If not, then the cullable object is in the frustum.
  100554. */
  100555. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100556. /** Culling strategy : Optimistic Inclusion.
  100557. * This in an inclusion test first, then the standard exclusion test.
  100558. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  100559. * 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.
  100560. * Anyway, it's as accurate as the standard strategy.
  100561. * Test :
  100562. * Is the cullable object bounding sphere center in the frustum ?
  100563. * If not, apply the default culling strategy.
  100564. */
  100565. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  100566. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  100567. * This in an inclusion test first, then the bounding sphere only exclusion test.
  100568. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  100569. * 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.
  100570. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  100571. * Test :
  100572. * Is the cullable object bounding sphere center in the frustum ?
  100573. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  100574. */
  100575. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  100576. /**
  100577. * No billboard
  100578. */
  100579. static get BILLBOARDMODE_NONE(): number;
  100580. /** Billboard on X axis */
  100581. static get BILLBOARDMODE_X(): number;
  100582. /** Billboard on Y axis */
  100583. static get BILLBOARDMODE_Y(): number;
  100584. /** Billboard on Z axis */
  100585. static get BILLBOARDMODE_Z(): number;
  100586. /** Billboard on all axes */
  100587. static get BILLBOARDMODE_ALL(): number;
  100588. /** Billboard on using position instead of orientation */
  100589. static get BILLBOARDMODE_USE_POSITION(): number;
  100590. /** @hidden */
  100591. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  100592. /**
  100593. * The culling strategy to use to check whether the mesh must be rendered or not.
  100594. * This value can be changed at any time and will be used on the next render mesh selection.
  100595. * The possible values are :
  100596. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100597. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100598. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100599. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100600. * Please read each static variable documentation to get details about the culling process.
  100601. * */
  100602. cullingStrategy: number;
  100603. /**
  100604. * Gets the number of facets in the mesh
  100605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100606. */
  100607. get facetNb(): number;
  100608. /**
  100609. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  100610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100611. */
  100612. get partitioningSubdivisions(): number;
  100613. set partitioningSubdivisions(nb: number);
  100614. /**
  100615. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  100616. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  100617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100618. */
  100619. get partitioningBBoxRatio(): number;
  100620. set partitioningBBoxRatio(ratio: number);
  100621. /**
  100622. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  100623. * Works only for updatable meshes.
  100624. * Doesn't work with multi-materials
  100625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100626. */
  100627. get mustDepthSortFacets(): boolean;
  100628. set mustDepthSortFacets(sort: boolean);
  100629. /**
  100630. * The location (Vector3) where the facet depth sort must be computed from.
  100631. * By default, the active camera position.
  100632. * Used only when facet depth sort is enabled
  100633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100634. */
  100635. get facetDepthSortFrom(): Vector3;
  100636. set facetDepthSortFrom(location: Vector3);
  100637. /**
  100638. * gets a boolean indicating if facetData is enabled
  100639. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100640. */
  100641. get isFacetDataEnabled(): boolean;
  100642. /** @hidden */
  100643. _updateNonUniformScalingState(value: boolean): boolean;
  100644. /**
  100645. * An event triggered when this mesh collides with another one
  100646. */
  100647. onCollideObservable: Observable<AbstractMesh>;
  100648. /** Set a function to call when this mesh collides with another one */
  100649. set onCollide(callback: () => void);
  100650. /**
  100651. * An event triggered when the collision's position changes
  100652. */
  100653. onCollisionPositionChangeObservable: Observable<Vector3>;
  100654. /** Set a function to call when the collision's position changes */
  100655. set onCollisionPositionChange(callback: () => void);
  100656. /**
  100657. * An event triggered when material is changed
  100658. */
  100659. onMaterialChangedObservable: Observable<AbstractMesh>;
  100660. /**
  100661. * Gets or sets the orientation for POV movement & rotation
  100662. */
  100663. definedFacingForward: boolean;
  100664. /** @hidden */
  100665. _occlusionQuery: Nullable<WebGLQuery>;
  100666. /** @hidden */
  100667. _renderingGroup: Nullable<RenderingGroup>;
  100668. /**
  100669. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100670. */
  100671. get visibility(): number;
  100672. /**
  100673. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100674. */
  100675. set visibility(value: number);
  100676. /** Gets or sets the alpha index used to sort transparent meshes
  100677. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  100678. */
  100679. alphaIndex: number;
  100680. /**
  100681. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  100682. */
  100683. isVisible: boolean;
  100684. /**
  100685. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  100686. */
  100687. isPickable: boolean;
  100688. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  100689. showSubMeshesBoundingBox: boolean;
  100690. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  100691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100692. */
  100693. isBlocker: boolean;
  100694. /**
  100695. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  100696. */
  100697. enablePointerMoveEvents: boolean;
  100698. /**
  100699. * Specifies the rendering group id for this mesh (0 by default)
  100700. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  100701. */
  100702. renderingGroupId: number;
  100703. private _material;
  100704. /** Gets or sets current material */
  100705. get material(): Nullable<Material>;
  100706. set material(value: Nullable<Material>);
  100707. /**
  100708. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  100709. * @see http://doc.babylonjs.com/babylon101/shadows
  100710. */
  100711. get receiveShadows(): boolean;
  100712. set receiveShadows(value: boolean);
  100713. /** Defines color to use when rendering outline */
  100714. outlineColor: Color3;
  100715. /** Define width to use when rendering outline */
  100716. outlineWidth: number;
  100717. /** Defines color to use when rendering overlay */
  100718. overlayColor: Color3;
  100719. /** Defines alpha to use when rendering overlay */
  100720. overlayAlpha: number;
  100721. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  100722. get hasVertexAlpha(): boolean;
  100723. set hasVertexAlpha(value: boolean);
  100724. /** 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) */
  100725. get useVertexColors(): boolean;
  100726. set useVertexColors(value: boolean);
  100727. /**
  100728. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  100729. */
  100730. get computeBonesUsingShaders(): boolean;
  100731. set computeBonesUsingShaders(value: boolean);
  100732. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  100733. get numBoneInfluencers(): number;
  100734. set numBoneInfluencers(value: number);
  100735. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  100736. get applyFog(): boolean;
  100737. set applyFog(value: boolean);
  100738. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  100739. useOctreeForRenderingSelection: boolean;
  100740. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  100741. useOctreeForPicking: boolean;
  100742. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  100743. useOctreeForCollisions: boolean;
  100744. /**
  100745. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  100746. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  100747. */
  100748. get layerMask(): number;
  100749. set layerMask(value: number);
  100750. /**
  100751. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  100752. */
  100753. alwaysSelectAsActiveMesh: boolean;
  100754. /**
  100755. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  100756. */
  100757. doNotSyncBoundingInfo: boolean;
  100758. /**
  100759. * Gets or sets the current action manager
  100760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100761. */
  100762. actionManager: Nullable<AbstractActionManager>;
  100763. private _meshCollisionData;
  100764. /**
  100765. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  100766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100767. */
  100768. ellipsoid: Vector3;
  100769. /**
  100770. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  100771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100772. */
  100773. ellipsoidOffset: Vector3;
  100774. /**
  100775. * Gets or sets a collision mask used to mask collisions (default is -1).
  100776. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100777. */
  100778. get collisionMask(): number;
  100779. set collisionMask(mask: number);
  100780. /**
  100781. * Gets or sets the current collision group mask (-1 by default).
  100782. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100783. */
  100784. get collisionGroup(): number;
  100785. set collisionGroup(mask: number);
  100786. /**
  100787. * Defines edge width used when edgesRenderer is enabled
  100788. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100789. */
  100790. edgesWidth: number;
  100791. /**
  100792. * Defines edge color used when edgesRenderer is enabled
  100793. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100794. */
  100795. edgesColor: Color4;
  100796. /** @hidden */
  100797. _edgesRenderer: Nullable<IEdgesRenderer>;
  100798. /** @hidden */
  100799. _masterMesh: Nullable<AbstractMesh>;
  100800. /** @hidden */
  100801. _boundingInfo: Nullable<BoundingInfo>;
  100802. /** @hidden */
  100803. _renderId: number;
  100804. /**
  100805. * Gets or sets the list of subMeshes
  100806. * @see http://doc.babylonjs.com/how_to/multi_materials
  100807. */
  100808. subMeshes: SubMesh[];
  100809. /** @hidden */
  100810. _intersectionsInProgress: AbstractMesh[];
  100811. /** @hidden */
  100812. _unIndexed: boolean;
  100813. /** @hidden */
  100814. _lightSources: Light[];
  100815. /** Gets the list of lights affecting that mesh */
  100816. get lightSources(): Light[];
  100817. /** @hidden */
  100818. get _positions(): Nullable<Vector3[]>;
  100819. /** @hidden */
  100820. _waitingData: {
  100821. lods: Nullable<any>;
  100822. actions: Nullable<any>;
  100823. freezeWorldMatrix: Nullable<boolean>;
  100824. };
  100825. /** @hidden */
  100826. _bonesTransformMatrices: Nullable<Float32Array>;
  100827. /** @hidden */
  100828. _transformMatrixTexture: Nullable<RawTexture>;
  100829. /**
  100830. * Gets or sets a skeleton to apply skining transformations
  100831. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100832. */
  100833. set skeleton(value: Nullable<Skeleton>);
  100834. get skeleton(): Nullable<Skeleton>;
  100835. /**
  100836. * An event triggered when the mesh is rebuilt.
  100837. */
  100838. onRebuildObservable: Observable<AbstractMesh>;
  100839. /**
  100840. * Creates a new AbstractMesh
  100841. * @param name defines the name of the mesh
  100842. * @param scene defines the hosting scene
  100843. */
  100844. constructor(name: string, scene?: Nullable<Scene>);
  100845. /**
  100846. * Returns the string "AbstractMesh"
  100847. * @returns "AbstractMesh"
  100848. */
  100849. getClassName(): string;
  100850. /**
  100851. * Gets a string representation of the current mesh
  100852. * @param fullDetails defines a boolean indicating if full details must be included
  100853. * @returns a string representation of the current mesh
  100854. */
  100855. toString(fullDetails?: boolean): string;
  100856. /**
  100857. * @hidden
  100858. */
  100859. protected _getEffectiveParent(): Nullable<Node>;
  100860. /** @hidden */
  100861. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100862. /** @hidden */
  100863. _rebuild(): void;
  100864. /** @hidden */
  100865. _resyncLightSources(): void;
  100866. /** @hidden */
  100867. _resyncLightSource(light: Light): void;
  100868. /** @hidden */
  100869. _unBindEffect(): void;
  100870. /** @hidden */
  100871. _removeLightSource(light: Light, dispose: boolean): void;
  100872. private _markSubMeshesAsDirty;
  100873. /** @hidden */
  100874. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  100875. /** @hidden */
  100876. _markSubMeshesAsAttributesDirty(): void;
  100877. /** @hidden */
  100878. _markSubMeshesAsMiscDirty(): void;
  100879. /**
  100880. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  100881. */
  100882. get scaling(): Vector3;
  100883. set scaling(newScaling: Vector3);
  100884. /**
  100885. * Returns true if the mesh is blocked. Implemented by child classes
  100886. */
  100887. get isBlocked(): boolean;
  100888. /**
  100889. * Returns the mesh itself by default. Implemented by child classes
  100890. * @param camera defines the camera to use to pick the right LOD level
  100891. * @returns the currentAbstractMesh
  100892. */
  100893. getLOD(camera: Camera): Nullable<AbstractMesh>;
  100894. /**
  100895. * Returns 0 by default. Implemented by child classes
  100896. * @returns an integer
  100897. */
  100898. getTotalVertices(): number;
  100899. /**
  100900. * Returns a positive integer : the total number of indices in this mesh geometry.
  100901. * @returns the numner of indices or zero if the mesh has no geometry.
  100902. */
  100903. getTotalIndices(): number;
  100904. /**
  100905. * Returns null by default. Implemented by child classes
  100906. * @returns null
  100907. */
  100908. getIndices(): Nullable<IndicesArray>;
  100909. /**
  100910. * Returns the array of the requested vertex data kind. Implemented by child classes
  100911. * @param kind defines the vertex data kind to use
  100912. * @returns null
  100913. */
  100914. getVerticesData(kind: string): Nullable<FloatArray>;
  100915. /**
  100916. * Sets the vertex data of the mesh geometry for the requested `kind`.
  100917. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  100918. * Note that a new underlying VertexBuffer object is created each call.
  100919. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  100920. * @param kind defines vertex data kind:
  100921. * * VertexBuffer.PositionKind
  100922. * * VertexBuffer.UVKind
  100923. * * VertexBuffer.UV2Kind
  100924. * * VertexBuffer.UV3Kind
  100925. * * VertexBuffer.UV4Kind
  100926. * * VertexBuffer.UV5Kind
  100927. * * VertexBuffer.UV6Kind
  100928. * * VertexBuffer.ColorKind
  100929. * * VertexBuffer.MatricesIndicesKind
  100930. * * VertexBuffer.MatricesIndicesExtraKind
  100931. * * VertexBuffer.MatricesWeightsKind
  100932. * * VertexBuffer.MatricesWeightsExtraKind
  100933. * @param data defines the data source
  100934. * @param updatable defines if the data must be flagged as updatable (or static)
  100935. * @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
  100936. * @returns the current mesh
  100937. */
  100938. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100939. /**
  100940. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  100941. * If the mesh has no geometry, it is simply returned as it is.
  100942. * @param kind defines vertex data kind:
  100943. * * VertexBuffer.PositionKind
  100944. * * VertexBuffer.UVKind
  100945. * * VertexBuffer.UV2Kind
  100946. * * VertexBuffer.UV3Kind
  100947. * * VertexBuffer.UV4Kind
  100948. * * VertexBuffer.UV5Kind
  100949. * * VertexBuffer.UV6Kind
  100950. * * VertexBuffer.ColorKind
  100951. * * VertexBuffer.MatricesIndicesKind
  100952. * * VertexBuffer.MatricesIndicesExtraKind
  100953. * * VertexBuffer.MatricesWeightsKind
  100954. * * VertexBuffer.MatricesWeightsExtraKind
  100955. * @param data defines the data source
  100956. * @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
  100957. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  100958. * @returns the current mesh
  100959. */
  100960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100961. /**
  100962. * Sets the mesh indices,
  100963. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  100964. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  100965. * @param totalVertices Defines the total number of vertices
  100966. * @returns the current mesh
  100967. */
  100968. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  100969. /**
  100970. * Gets a boolean indicating if specific vertex data is present
  100971. * @param kind defines the vertex data kind to use
  100972. * @returns true is data kind is present
  100973. */
  100974. isVerticesDataPresent(kind: string): boolean;
  100975. /**
  100976. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  100977. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  100978. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  100979. * @returns a BoundingInfo
  100980. */
  100981. getBoundingInfo(): BoundingInfo;
  100982. /**
  100983. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  100984. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  100985. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  100986. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  100987. * @returns the current mesh
  100988. */
  100989. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  100990. /**
  100991. * Overwrite the current bounding info
  100992. * @param boundingInfo defines the new bounding info
  100993. * @returns the current mesh
  100994. */
  100995. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  100996. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  100997. get useBones(): boolean;
  100998. /** @hidden */
  100999. _preActivate(): void;
  101000. /** @hidden */
  101001. _preActivateForIntermediateRendering(renderId: number): void;
  101002. /** @hidden */
  101003. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101004. /** @hidden */
  101005. _postActivate(): void;
  101006. /** @hidden */
  101007. _freeze(): void;
  101008. /** @hidden */
  101009. _unFreeze(): void;
  101010. /**
  101011. * Gets the current world matrix
  101012. * @returns a Matrix
  101013. */
  101014. getWorldMatrix(): Matrix;
  101015. /** @hidden */
  101016. _getWorldMatrixDeterminant(): number;
  101017. /**
  101018. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101019. */
  101020. get isAnInstance(): boolean;
  101021. /**
  101022. * Gets a boolean indicating if this mesh has instances
  101023. */
  101024. get hasInstances(): boolean;
  101025. /**
  101026. * Perform relative position change from the point of view of behind the front of the mesh.
  101027. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101028. * Supports definition of mesh facing forward or backward
  101029. * @param amountRight defines the distance on the right axis
  101030. * @param amountUp defines the distance on the up axis
  101031. * @param amountForward defines the distance on the forward axis
  101032. * @returns the current mesh
  101033. */
  101034. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101035. /**
  101036. * Calculate relative position change from the point of view of behind the front of the mesh.
  101037. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101038. * Supports definition of mesh facing forward or backward
  101039. * @param amountRight defines the distance on the right axis
  101040. * @param amountUp defines the distance on the up axis
  101041. * @param amountForward defines the distance on the forward axis
  101042. * @returns the new displacement vector
  101043. */
  101044. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101045. /**
  101046. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101047. * Supports definition of mesh facing forward or backward
  101048. * @param flipBack defines the flip
  101049. * @param twirlClockwise defines the twirl
  101050. * @param tiltRight defines the tilt
  101051. * @returns the current mesh
  101052. */
  101053. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101054. /**
  101055. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101056. * Supports definition of mesh facing forward or backward.
  101057. * @param flipBack defines the flip
  101058. * @param twirlClockwise defines the twirl
  101059. * @param tiltRight defines the tilt
  101060. * @returns the new rotation vector
  101061. */
  101062. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101063. /**
  101064. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101065. * This means the mesh underlying bounding box and sphere are recomputed.
  101066. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101067. * @returns the current mesh
  101068. */
  101069. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101070. /** @hidden */
  101071. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101072. /** @hidden */
  101073. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101074. /** @hidden */
  101075. _updateBoundingInfo(): AbstractMesh;
  101076. /** @hidden */
  101077. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101078. /** @hidden */
  101079. protected _afterComputeWorldMatrix(): void;
  101080. /** @hidden */
  101081. get _effectiveMesh(): AbstractMesh;
  101082. /**
  101083. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101084. * A mesh is in the frustum if its bounding box intersects the frustum
  101085. * @param frustumPlanes defines the frustum to test
  101086. * @returns true if the mesh is in the frustum planes
  101087. */
  101088. isInFrustum(frustumPlanes: Plane[]): boolean;
  101089. /**
  101090. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101091. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101092. * @param frustumPlanes defines the frustum to test
  101093. * @returns true if the mesh is completely in the frustum planes
  101094. */
  101095. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101096. /**
  101097. * True if the mesh intersects another mesh or a SolidParticle object
  101098. * @param mesh defines a target mesh or SolidParticle to test
  101099. * @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)
  101100. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101101. * @returns true if there is an intersection
  101102. */
  101103. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101104. /**
  101105. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101106. * @param point defines the point to test
  101107. * @returns true if there is an intersection
  101108. */
  101109. intersectsPoint(point: Vector3): boolean;
  101110. /**
  101111. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101112. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101113. */
  101114. get checkCollisions(): boolean;
  101115. set checkCollisions(collisionEnabled: boolean);
  101116. /**
  101117. * Gets Collider object used to compute collisions (not physics)
  101118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101119. */
  101120. get collider(): Nullable<Collider>;
  101121. /**
  101122. * Move the mesh using collision engine
  101123. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101124. * @param displacement defines the requested displacement vector
  101125. * @returns the current mesh
  101126. */
  101127. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101128. private _onCollisionPositionChange;
  101129. /** @hidden */
  101130. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101131. /** @hidden */
  101132. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101133. /** @hidden */
  101134. _checkCollision(collider: Collider): AbstractMesh;
  101135. /** @hidden */
  101136. _generatePointsArray(): boolean;
  101137. /**
  101138. * Checks if the passed Ray intersects with the mesh
  101139. * @param ray defines the ray to use
  101140. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101141. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101142. * @returns the picking info
  101143. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101144. */
  101145. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101146. /**
  101147. * Clones the current mesh
  101148. * @param name defines the mesh name
  101149. * @param newParent defines the new mesh parent
  101150. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101151. * @returns the new mesh
  101152. */
  101153. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101154. /**
  101155. * Disposes all the submeshes of the current meshnp
  101156. * @returns the current mesh
  101157. */
  101158. releaseSubMeshes(): AbstractMesh;
  101159. /**
  101160. * Releases resources associated with this abstract mesh.
  101161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101163. */
  101164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101165. /**
  101166. * Adds the passed mesh as a child to the current mesh
  101167. * @param mesh defines the child mesh
  101168. * @returns the current mesh
  101169. */
  101170. addChild(mesh: AbstractMesh): AbstractMesh;
  101171. /**
  101172. * Removes the passed mesh from the current mesh children list
  101173. * @param mesh defines the child mesh
  101174. * @returns the current mesh
  101175. */
  101176. removeChild(mesh: AbstractMesh): AbstractMesh;
  101177. /** @hidden */
  101178. private _initFacetData;
  101179. /**
  101180. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101181. * This method can be called within the render loop.
  101182. * 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
  101183. * @returns the current mesh
  101184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101185. */
  101186. updateFacetData(): AbstractMesh;
  101187. /**
  101188. * Returns the facetLocalNormals array.
  101189. * The normals are expressed in the mesh local spac
  101190. * @returns an array of Vector3
  101191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101192. */
  101193. getFacetLocalNormals(): Vector3[];
  101194. /**
  101195. * Returns the facetLocalPositions array.
  101196. * The facet positions are expressed in the mesh local space
  101197. * @returns an array of Vector3
  101198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101199. */
  101200. getFacetLocalPositions(): Vector3[];
  101201. /**
  101202. * Returns the facetLocalPartioning array
  101203. * @returns an array of array of numbers
  101204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101205. */
  101206. getFacetLocalPartitioning(): number[][];
  101207. /**
  101208. * Returns the i-th facet position in the world system.
  101209. * This method allocates a new Vector3 per call
  101210. * @param i defines the facet index
  101211. * @returns a new Vector3
  101212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101213. */
  101214. getFacetPosition(i: number): Vector3;
  101215. /**
  101216. * Sets the reference Vector3 with the i-th facet position in the world system
  101217. * @param i defines the facet index
  101218. * @param ref defines the target vector
  101219. * @returns the current mesh
  101220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101221. */
  101222. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101223. /**
  101224. * Returns the i-th facet normal in the world system.
  101225. * This method allocates a new Vector3 per call
  101226. * @param i defines the facet index
  101227. * @returns a new Vector3
  101228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101229. */
  101230. getFacetNormal(i: number): Vector3;
  101231. /**
  101232. * Sets the reference Vector3 with the i-th facet normal in the world system
  101233. * @param i defines the facet index
  101234. * @param ref defines the target vector
  101235. * @returns the current mesh
  101236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101237. */
  101238. getFacetNormalToRef(i: number, ref: Vector3): this;
  101239. /**
  101240. * 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)
  101241. * @param x defines x coordinate
  101242. * @param y defines y coordinate
  101243. * @param z defines z coordinate
  101244. * @returns the array of facet indexes
  101245. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101246. */
  101247. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101248. /**
  101249. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101250. * @param projected sets as the (x,y,z) world projection on the facet
  101251. * @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
  101252. * @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
  101253. * @param x defines x coordinate
  101254. * @param y defines y coordinate
  101255. * @param z defines z coordinate
  101256. * @returns the face index if found (or null instead)
  101257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101258. */
  101259. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101260. /**
  101261. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101262. * @param projected sets as the (x,y,z) local projection on the facet
  101263. * @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
  101264. * @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
  101265. * @param x defines x coordinate
  101266. * @param y defines y coordinate
  101267. * @param z defines z coordinate
  101268. * @returns the face index if found (or null instead)
  101269. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101270. */
  101271. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101272. /**
  101273. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101274. * @returns the parameters
  101275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101276. */
  101277. getFacetDataParameters(): any;
  101278. /**
  101279. * Disables the feature FacetData and frees the related memory
  101280. * @returns the current mesh
  101281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101282. */
  101283. disableFacetData(): AbstractMesh;
  101284. /**
  101285. * Updates the AbstractMesh indices array
  101286. * @param indices defines the data source
  101287. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101288. * @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)
  101289. * @returns the current mesh
  101290. */
  101291. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101292. /**
  101293. * Creates new normals data for the mesh
  101294. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101295. * @returns the current mesh
  101296. */
  101297. createNormals(updatable: boolean): AbstractMesh;
  101298. /**
  101299. * Align the mesh with a normal
  101300. * @param normal defines the normal to use
  101301. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101302. * @returns the current mesh
  101303. */
  101304. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101305. /** @hidden */
  101306. _checkOcclusionQuery(): boolean;
  101307. /**
  101308. * Disables the mesh edge rendering mode
  101309. * @returns the currentAbstractMesh
  101310. */
  101311. disableEdgesRendering(): AbstractMesh;
  101312. /**
  101313. * Enables the edge rendering mode on the mesh.
  101314. * This mode makes the mesh edges visible
  101315. * @param epsilon defines the maximal distance between two angles to detect a face
  101316. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101317. * @returns the currentAbstractMesh
  101318. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101319. */
  101320. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101321. }
  101322. }
  101323. declare module BABYLON {
  101324. /**
  101325. * Interface used to define ActionEvent
  101326. */
  101327. export interface IActionEvent {
  101328. /** The mesh or sprite that triggered the action */
  101329. source: any;
  101330. /** The X mouse cursor position at the time of the event */
  101331. pointerX: number;
  101332. /** The Y mouse cursor position at the time of the event */
  101333. pointerY: number;
  101334. /** The mesh that is currently pointed at (can be null) */
  101335. meshUnderPointer: Nullable<AbstractMesh>;
  101336. /** the original (browser) event that triggered the ActionEvent */
  101337. sourceEvent?: any;
  101338. /** additional data for the event */
  101339. additionalData?: any;
  101340. }
  101341. /**
  101342. * ActionEvent is the event being sent when an action is triggered.
  101343. */
  101344. export class ActionEvent implements IActionEvent {
  101345. /** The mesh or sprite that triggered the action */
  101346. source: any;
  101347. /** The X mouse cursor position at the time of the event */
  101348. pointerX: number;
  101349. /** The Y mouse cursor position at the time of the event */
  101350. pointerY: number;
  101351. /** The mesh that is currently pointed at (can be null) */
  101352. meshUnderPointer: Nullable<AbstractMesh>;
  101353. /** the original (browser) event that triggered the ActionEvent */
  101354. sourceEvent?: any;
  101355. /** additional data for the event */
  101356. additionalData?: any;
  101357. /**
  101358. * Creates a new ActionEvent
  101359. * @param source The mesh or sprite that triggered the action
  101360. * @param pointerX The X mouse cursor position at the time of the event
  101361. * @param pointerY The Y mouse cursor position at the time of the event
  101362. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101363. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101364. * @param additionalData additional data for the event
  101365. */
  101366. constructor(
  101367. /** The mesh or sprite that triggered the action */
  101368. source: any,
  101369. /** The X mouse cursor position at the time of the event */
  101370. pointerX: number,
  101371. /** The Y mouse cursor position at the time of the event */
  101372. pointerY: number,
  101373. /** The mesh that is currently pointed at (can be null) */
  101374. meshUnderPointer: Nullable<AbstractMesh>,
  101375. /** the original (browser) event that triggered the ActionEvent */
  101376. sourceEvent?: any,
  101377. /** additional data for the event */
  101378. additionalData?: any);
  101379. /**
  101380. * Helper function to auto-create an ActionEvent from a source mesh.
  101381. * @param source The source mesh that triggered the event
  101382. * @param evt The original (browser) event
  101383. * @param additionalData additional data for the event
  101384. * @returns the new ActionEvent
  101385. */
  101386. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101387. /**
  101388. * Helper function to auto-create an ActionEvent from a source sprite
  101389. * @param source The source sprite that triggered the event
  101390. * @param scene Scene associated with the sprite
  101391. * @param evt The original (browser) event
  101392. * @param additionalData additional data for the event
  101393. * @returns the new ActionEvent
  101394. */
  101395. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101396. /**
  101397. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101398. * @param scene the scene where the event occurred
  101399. * @param evt The original (browser) event
  101400. * @returns the new ActionEvent
  101401. */
  101402. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101403. /**
  101404. * Helper function to auto-create an ActionEvent from a primitive
  101405. * @param prim defines the target primitive
  101406. * @param pointerPos defines the pointer position
  101407. * @param evt The original (browser) event
  101408. * @param additionalData additional data for the event
  101409. * @returns the new ActionEvent
  101410. */
  101411. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101412. }
  101413. }
  101414. declare module BABYLON {
  101415. /**
  101416. * Abstract class used to decouple action Manager from scene and meshes.
  101417. * Do not instantiate.
  101418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101419. */
  101420. export abstract class AbstractActionManager implements IDisposable {
  101421. /** Gets the list of active triggers */
  101422. static Triggers: {
  101423. [key: string]: number;
  101424. };
  101425. /** Gets the cursor to use when hovering items */
  101426. hoverCursor: string;
  101427. /** Gets the list of actions */
  101428. actions: IAction[];
  101429. /**
  101430. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101431. */
  101432. isRecursive: boolean;
  101433. /**
  101434. * Releases all associated resources
  101435. */
  101436. abstract dispose(): void;
  101437. /**
  101438. * Does this action manager has pointer triggers
  101439. */
  101440. abstract get hasPointerTriggers(): boolean;
  101441. /**
  101442. * Does this action manager has pick triggers
  101443. */
  101444. abstract get hasPickTriggers(): boolean;
  101445. /**
  101446. * Process a specific trigger
  101447. * @param trigger defines the trigger to process
  101448. * @param evt defines the event details to be processed
  101449. */
  101450. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101451. /**
  101452. * Does this action manager handles actions of any of the given triggers
  101453. * @param triggers defines the triggers to be tested
  101454. * @return a boolean indicating whether one (or more) of the triggers is handled
  101455. */
  101456. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101457. /**
  101458. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101459. * speed.
  101460. * @param triggerA defines the trigger to be tested
  101461. * @param triggerB defines the trigger to be tested
  101462. * @return a boolean indicating whether one (or more) of the triggers is handled
  101463. */
  101464. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101465. /**
  101466. * Does this action manager handles actions of a given trigger
  101467. * @param trigger defines the trigger to be tested
  101468. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101469. * @return whether the trigger is handled
  101470. */
  101471. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101472. /**
  101473. * Serialize this manager to a JSON object
  101474. * @param name defines the property name to store this manager
  101475. * @returns a JSON representation of this manager
  101476. */
  101477. abstract serialize(name: string): any;
  101478. /**
  101479. * Registers an action to this action manager
  101480. * @param action defines the action to be registered
  101481. * @return the action amended (prepared) after registration
  101482. */
  101483. abstract registerAction(action: IAction): Nullable<IAction>;
  101484. /**
  101485. * Unregisters an action to this action manager
  101486. * @param action defines the action to be unregistered
  101487. * @return a boolean indicating whether the action has been unregistered
  101488. */
  101489. abstract unregisterAction(action: IAction): Boolean;
  101490. /**
  101491. * Does exist one action manager with at least one trigger
  101492. **/
  101493. static get HasTriggers(): boolean;
  101494. /**
  101495. * Does exist one action manager with at least one pick trigger
  101496. **/
  101497. static get HasPickTriggers(): boolean;
  101498. /**
  101499. * Does exist one action manager that handles actions of a given trigger
  101500. * @param trigger defines the trigger to be tested
  101501. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101502. **/
  101503. static HasSpecificTrigger(trigger: number): boolean;
  101504. }
  101505. }
  101506. declare module BABYLON {
  101507. /**
  101508. * Defines how a node can be built from a string name.
  101509. */
  101510. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101511. /**
  101512. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101513. */
  101514. export class Node implements IBehaviorAware<Node> {
  101515. /** @hidden */
  101516. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101517. private static _NodeConstructors;
  101518. /**
  101519. * Add a new node constructor
  101520. * @param type defines the type name of the node to construct
  101521. * @param constructorFunc defines the constructor function
  101522. */
  101523. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101524. /**
  101525. * Returns a node constructor based on type name
  101526. * @param type defines the type name
  101527. * @param name defines the new node name
  101528. * @param scene defines the hosting scene
  101529. * @param options defines optional options to transmit to constructors
  101530. * @returns the new constructor or null
  101531. */
  101532. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101533. /**
  101534. * Gets or sets the name of the node
  101535. */
  101536. name: string;
  101537. /**
  101538. * Gets or sets the id of the node
  101539. */
  101540. id: string;
  101541. /**
  101542. * Gets or sets the unique id of the node
  101543. */
  101544. uniqueId: number;
  101545. /**
  101546. * Gets or sets a string used to store user defined state for the node
  101547. */
  101548. state: string;
  101549. /**
  101550. * Gets or sets an object used to store user defined information for the node
  101551. */
  101552. metadata: any;
  101553. /**
  101554. * For internal use only. Please do not use.
  101555. */
  101556. reservedDataStore: any;
  101557. /**
  101558. * List of inspectable custom properties (used by the Inspector)
  101559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101560. */
  101561. inspectableCustomProperties: IInspectable[];
  101562. private _doNotSerialize;
  101563. /**
  101564. * Gets or sets a boolean used to define if the node must be serialized
  101565. */
  101566. get doNotSerialize(): boolean;
  101567. set doNotSerialize(value: boolean);
  101568. /** @hidden */
  101569. _isDisposed: boolean;
  101570. /**
  101571. * Gets a list of Animations associated with the node
  101572. */
  101573. animations: Animation[];
  101574. protected _ranges: {
  101575. [name: string]: Nullable<AnimationRange>;
  101576. };
  101577. /**
  101578. * Callback raised when the node is ready to be used
  101579. */
  101580. onReady: Nullable<(node: Node) => void>;
  101581. private _isEnabled;
  101582. private _isParentEnabled;
  101583. private _isReady;
  101584. /** @hidden */
  101585. _currentRenderId: number;
  101586. private _parentUpdateId;
  101587. /** @hidden */
  101588. _childUpdateId: number;
  101589. /** @hidden */
  101590. _waitingParentId: Nullable<string>;
  101591. /** @hidden */
  101592. _scene: Scene;
  101593. /** @hidden */
  101594. _cache: any;
  101595. private _parentNode;
  101596. private _children;
  101597. /** @hidden */
  101598. _worldMatrix: Matrix;
  101599. /** @hidden */
  101600. _worldMatrixDeterminant: number;
  101601. /** @hidden */
  101602. _worldMatrixDeterminantIsDirty: boolean;
  101603. /** @hidden */
  101604. private _sceneRootNodesIndex;
  101605. /**
  101606. * Gets a boolean indicating if the node has been disposed
  101607. * @returns true if the node was disposed
  101608. */
  101609. isDisposed(): boolean;
  101610. /**
  101611. * Gets or sets the parent of the node (without keeping the current position in the scene)
  101612. * @see https://doc.babylonjs.com/how_to/parenting
  101613. */
  101614. set parent(parent: Nullable<Node>);
  101615. get parent(): Nullable<Node>;
  101616. /** @hidden */
  101617. _addToSceneRootNodes(): void;
  101618. /** @hidden */
  101619. _removeFromSceneRootNodes(): void;
  101620. private _animationPropertiesOverride;
  101621. /**
  101622. * Gets or sets the animation properties override
  101623. */
  101624. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  101625. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  101626. /**
  101627. * Gets a string idenfifying the name of the class
  101628. * @returns "Node" string
  101629. */
  101630. getClassName(): string;
  101631. /** @hidden */
  101632. readonly _isNode: boolean;
  101633. /**
  101634. * An event triggered when the mesh is disposed
  101635. */
  101636. onDisposeObservable: Observable<Node>;
  101637. private _onDisposeObserver;
  101638. /**
  101639. * Sets a callback that will be raised when the node will be disposed
  101640. */
  101641. set onDispose(callback: () => void);
  101642. /**
  101643. * Creates a new Node
  101644. * @param name the name and id to be given to this node
  101645. * @param scene the scene this node will be added to
  101646. */
  101647. constructor(name: string, scene?: Nullable<Scene>);
  101648. /**
  101649. * Gets the scene of the node
  101650. * @returns a scene
  101651. */
  101652. getScene(): Scene;
  101653. /**
  101654. * Gets the engine of the node
  101655. * @returns a Engine
  101656. */
  101657. getEngine(): Engine;
  101658. private _behaviors;
  101659. /**
  101660. * Attach a behavior to the node
  101661. * @see http://doc.babylonjs.com/features/behaviour
  101662. * @param behavior defines the behavior to attach
  101663. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  101664. * @returns the current Node
  101665. */
  101666. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  101667. /**
  101668. * Remove an attached behavior
  101669. * @see http://doc.babylonjs.com/features/behaviour
  101670. * @param behavior defines the behavior to attach
  101671. * @returns the current Node
  101672. */
  101673. removeBehavior(behavior: Behavior<Node>): Node;
  101674. /**
  101675. * Gets the list of attached behaviors
  101676. * @see http://doc.babylonjs.com/features/behaviour
  101677. */
  101678. get behaviors(): Behavior<Node>[];
  101679. /**
  101680. * Gets an attached behavior by name
  101681. * @param name defines the name of the behavior to look for
  101682. * @see http://doc.babylonjs.com/features/behaviour
  101683. * @returns null if behavior was not found else the requested behavior
  101684. */
  101685. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  101686. /**
  101687. * Returns the latest update of the World matrix
  101688. * @returns a Matrix
  101689. */
  101690. getWorldMatrix(): Matrix;
  101691. /** @hidden */
  101692. _getWorldMatrixDeterminant(): number;
  101693. /**
  101694. * Returns directly the latest state of the mesh World matrix.
  101695. * A Matrix is returned.
  101696. */
  101697. get worldMatrixFromCache(): Matrix;
  101698. /** @hidden */
  101699. _initCache(): void;
  101700. /** @hidden */
  101701. updateCache(force?: boolean): void;
  101702. /** @hidden */
  101703. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101704. /** @hidden */
  101705. _updateCache(ignoreParentClass?: boolean): void;
  101706. /** @hidden */
  101707. _isSynchronized(): boolean;
  101708. /** @hidden */
  101709. _markSyncedWithParent(): void;
  101710. /** @hidden */
  101711. isSynchronizedWithParent(): boolean;
  101712. /** @hidden */
  101713. isSynchronized(): boolean;
  101714. /**
  101715. * Is this node ready to be used/rendered
  101716. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101717. * @return true if the node is ready
  101718. */
  101719. isReady(completeCheck?: boolean): boolean;
  101720. /**
  101721. * Is this node enabled?
  101722. * 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
  101723. * @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
  101724. * @return whether this node (and its parent) is enabled
  101725. */
  101726. isEnabled(checkAncestors?: boolean): boolean;
  101727. /** @hidden */
  101728. protected _syncParentEnabledState(): void;
  101729. /**
  101730. * Set the enabled state of this node
  101731. * @param value defines the new enabled state
  101732. */
  101733. setEnabled(value: boolean): void;
  101734. /**
  101735. * Is this node a descendant of the given node?
  101736. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  101737. * @param ancestor defines the parent node to inspect
  101738. * @returns a boolean indicating if this node is a descendant of the given node
  101739. */
  101740. isDescendantOf(ancestor: Node): boolean;
  101741. /** @hidden */
  101742. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  101743. /**
  101744. * Will return all nodes that have this node as ascendant
  101745. * @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
  101746. * @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
  101747. * @return all children nodes of all types
  101748. */
  101749. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  101750. /**
  101751. * Get all child-meshes of this node
  101752. * @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)
  101753. * @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
  101754. * @returns an array of AbstractMesh
  101755. */
  101756. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  101757. /**
  101758. * Get all direct children of this node
  101759. * @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
  101760. * @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)
  101761. * @returns an array of Node
  101762. */
  101763. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  101764. /** @hidden */
  101765. _setReady(state: boolean): void;
  101766. /**
  101767. * Get an animation by name
  101768. * @param name defines the name of the animation to look for
  101769. * @returns null if not found else the requested animation
  101770. */
  101771. getAnimationByName(name: string): Nullable<Animation>;
  101772. /**
  101773. * Creates an animation range for this node
  101774. * @param name defines the name of the range
  101775. * @param from defines the starting key
  101776. * @param to defines the end key
  101777. */
  101778. createAnimationRange(name: string, from: number, to: number): void;
  101779. /**
  101780. * Delete a specific animation range
  101781. * @param name defines the name of the range to delete
  101782. * @param deleteFrames defines if animation frames from the range must be deleted as well
  101783. */
  101784. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  101785. /**
  101786. * Get an animation range by name
  101787. * @param name defines the name of the animation range to look for
  101788. * @returns null if not found else the requested animation range
  101789. */
  101790. getAnimationRange(name: string): Nullable<AnimationRange>;
  101791. /**
  101792. * Gets the list of all animation ranges defined on this node
  101793. * @returns an array
  101794. */
  101795. getAnimationRanges(): Nullable<AnimationRange>[];
  101796. /**
  101797. * Will start the animation sequence
  101798. * @param name defines the range frames for animation sequence
  101799. * @param loop defines if the animation should loop (false by default)
  101800. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  101801. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  101802. * @returns the object created for this animation. If range does not exist, it will return null
  101803. */
  101804. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  101805. /**
  101806. * Serialize animation ranges into a JSON compatible object
  101807. * @returns serialization object
  101808. */
  101809. serializeAnimationRanges(): any;
  101810. /**
  101811. * Computes the world matrix of the node
  101812. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101813. * @returns the world matrix
  101814. */
  101815. computeWorldMatrix(force?: boolean): Matrix;
  101816. /**
  101817. * Releases resources associated with this node.
  101818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101820. */
  101821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101822. /**
  101823. * Parse animation range data from a serialization object and store them into a given node
  101824. * @param node defines where to store the animation ranges
  101825. * @param parsedNode defines the serialization object to read data from
  101826. * @param scene defines the hosting scene
  101827. */
  101828. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  101829. /**
  101830. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  101831. * @param includeDescendants Include bounding info from descendants as well (true by default)
  101832. * @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
  101833. * @returns the new bounding vectors
  101834. */
  101835. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  101836. min: Vector3;
  101837. max: Vector3;
  101838. };
  101839. }
  101840. }
  101841. declare module BABYLON {
  101842. /**
  101843. * @hidden
  101844. */
  101845. export class _IAnimationState {
  101846. key: number;
  101847. repeatCount: number;
  101848. workValue?: any;
  101849. loopMode?: number;
  101850. offsetValue?: any;
  101851. highLimitValue?: any;
  101852. }
  101853. /**
  101854. * Class used to store any kind of animation
  101855. */
  101856. export class Animation {
  101857. /**Name of the animation */
  101858. name: string;
  101859. /**Property to animate */
  101860. targetProperty: string;
  101861. /**The frames per second of the animation */
  101862. framePerSecond: number;
  101863. /**The data type of the animation */
  101864. dataType: number;
  101865. /**The loop mode of the animation */
  101866. loopMode?: number | undefined;
  101867. /**Specifies if blending should be enabled */
  101868. enableBlending?: boolean | undefined;
  101869. /**
  101870. * Use matrix interpolation instead of using direct key value when animating matrices
  101871. */
  101872. static AllowMatricesInterpolation: boolean;
  101873. /**
  101874. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  101875. */
  101876. static AllowMatrixDecomposeForInterpolation: boolean;
  101877. /**
  101878. * Stores the key frames of the animation
  101879. */
  101880. private _keys;
  101881. /**
  101882. * Stores the easing function of the animation
  101883. */
  101884. private _easingFunction;
  101885. /**
  101886. * @hidden Internal use only
  101887. */
  101888. _runtimeAnimations: RuntimeAnimation[];
  101889. /**
  101890. * The set of event that will be linked to this animation
  101891. */
  101892. private _events;
  101893. /**
  101894. * Stores an array of target property paths
  101895. */
  101896. targetPropertyPath: string[];
  101897. /**
  101898. * Stores the blending speed of the animation
  101899. */
  101900. blendingSpeed: number;
  101901. /**
  101902. * Stores the animation ranges for the animation
  101903. */
  101904. private _ranges;
  101905. /**
  101906. * @hidden Internal use
  101907. */
  101908. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  101909. /**
  101910. * Sets up an animation
  101911. * @param property The property to animate
  101912. * @param animationType The animation type to apply
  101913. * @param framePerSecond The frames per second of the animation
  101914. * @param easingFunction The easing function used in the animation
  101915. * @returns The created animation
  101916. */
  101917. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  101918. /**
  101919. * Create and start an animation on a node
  101920. * @param name defines the name of the global animation that will be run on all nodes
  101921. * @param node defines the root node where the animation will take place
  101922. * @param targetProperty defines property to animate
  101923. * @param framePerSecond defines the number of frame per second yo use
  101924. * @param totalFrame defines the number of frames in total
  101925. * @param from defines the initial value
  101926. * @param to defines the final value
  101927. * @param loopMode defines which loop mode you want to use (off by default)
  101928. * @param easingFunction defines the easing function to use (linear by default)
  101929. * @param onAnimationEnd defines the callback to call when animation end
  101930. * @returns the animatable created for this animation
  101931. */
  101932. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101933. /**
  101934. * Create and start an animation on a node and its descendants
  101935. * @param name defines the name of the global animation that will be run on all nodes
  101936. * @param node defines the root node where the animation will take place
  101937. * @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
  101938. * @param targetProperty defines property to animate
  101939. * @param framePerSecond defines the number of frame per second to use
  101940. * @param totalFrame defines the number of frames in total
  101941. * @param from defines the initial value
  101942. * @param to defines the final value
  101943. * @param loopMode defines which loop mode you want to use (off by default)
  101944. * @param easingFunction defines the easing function to use (linear by default)
  101945. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  101946. * @returns the list of animatables created for all nodes
  101947. * @example https://www.babylonjs-playground.com/#MH0VLI
  101948. */
  101949. 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[]>;
  101950. /**
  101951. * Creates a new animation, merges it with the existing animations and starts it
  101952. * @param name Name of the animation
  101953. * @param node Node which contains the scene that begins the animations
  101954. * @param targetProperty Specifies which property to animate
  101955. * @param framePerSecond The frames per second of the animation
  101956. * @param totalFrame The total number of frames
  101957. * @param from The frame at the beginning of the animation
  101958. * @param to The frame at the end of the animation
  101959. * @param loopMode Specifies the loop mode of the animation
  101960. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  101961. * @param onAnimationEnd Callback to run once the animation is complete
  101962. * @returns Nullable animation
  101963. */
  101964. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101965. /**
  101966. * Transition property of an host to the target Value
  101967. * @param property The property to transition
  101968. * @param targetValue The target Value of the property
  101969. * @param host The object where the property to animate belongs
  101970. * @param scene Scene used to run the animation
  101971. * @param frameRate Framerate (in frame/s) to use
  101972. * @param transition The transition type we want to use
  101973. * @param duration The duration of the animation, in milliseconds
  101974. * @param onAnimationEnd Callback trigger at the end of the animation
  101975. * @returns Nullable animation
  101976. */
  101977. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  101978. /**
  101979. * Return the array of runtime animations currently using this animation
  101980. */
  101981. get runtimeAnimations(): RuntimeAnimation[];
  101982. /**
  101983. * Specifies if any of the runtime animations are currently running
  101984. */
  101985. get hasRunningRuntimeAnimations(): boolean;
  101986. /**
  101987. * Initializes the animation
  101988. * @param name Name of the animation
  101989. * @param targetProperty Property to animate
  101990. * @param framePerSecond The frames per second of the animation
  101991. * @param dataType The data type of the animation
  101992. * @param loopMode The loop mode of the animation
  101993. * @param enableBlending Specifies if blending should be enabled
  101994. */
  101995. constructor(
  101996. /**Name of the animation */
  101997. name: string,
  101998. /**Property to animate */
  101999. targetProperty: string,
  102000. /**The frames per second of the animation */
  102001. framePerSecond: number,
  102002. /**The data type of the animation */
  102003. dataType: number,
  102004. /**The loop mode of the animation */
  102005. loopMode?: number | undefined,
  102006. /**Specifies if blending should be enabled */
  102007. enableBlending?: boolean | undefined);
  102008. /**
  102009. * Converts the animation to a string
  102010. * @param fullDetails support for multiple levels of logging within scene loading
  102011. * @returns String form of the animation
  102012. */
  102013. toString(fullDetails?: boolean): string;
  102014. /**
  102015. * Add an event to this animation
  102016. * @param event Event to add
  102017. */
  102018. addEvent(event: AnimationEvent): void;
  102019. /**
  102020. * Remove all events found at the given frame
  102021. * @param frame The frame to remove events from
  102022. */
  102023. removeEvents(frame: number): void;
  102024. /**
  102025. * Retrieves all the events from the animation
  102026. * @returns Events from the animation
  102027. */
  102028. getEvents(): AnimationEvent[];
  102029. /**
  102030. * Creates an animation range
  102031. * @param name Name of the animation range
  102032. * @param from Starting frame of the animation range
  102033. * @param to Ending frame of the animation
  102034. */
  102035. createRange(name: string, from: number, to: number): void;
  102036. /**
  102037. * Deletes an animation range by name
  102038. * @param name Name of the animation range to delete
  102039. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102040. */
  102041. deleteRange(name: string, deleteFrames?: boolean): void;
  102042. /**
  102043. * Gets the animation range by name, or null if not defined
  102044. * @param name Name of the animation range
  102045. * @returns Nullable animation range
  102046. */
  102047. getRange(name: string): Nullable<AnimationRange>;
  102048. /**
  102049. * Gets the key frames from the animation
  102050. * @returns The key frames of the animation
  102051. */
  102052. getKeys(): Array<IAnimationKey>;
  102053. /**
  102054. * Gets the highest frame rate of the animation
  102055. * @returns Highest frame rate of the animation
  102056. */
  102057. getHighestFrame(): number;
  102058. /**
  102059. * Gets the easing function of the animation
  102060. * @returns Easing function of the animation
  102061. */
  102062. getEasingFunction(): IEasingFunction;
  102063. /**
  102064. * Sets the easing function of the animation
  102065. * @param easingFunction A custom mathematical formula for animation
  102066. */
  102067. setEasingFunction(easingFunction: EasingFunction): void;
  102068. /**
  102069. * Interpolates a scalar linearly
  102070. * @param startValue Start value of the animation curve
  102071. * @param endValue End value of the animation curve
  102072. * @param gradient Scalar amount to interpolate
  102073. * @returns Interpolated scalar value
  102074. */
  102075. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102076. /**
  102077. * Interpolates a scalar cubically
  102078. * @param startValue Start value of the animation curve
  102079. * @param outTangent End tangent of the animation
  102080. * @param endValue End value of the animation curve
  102081. * @param inTangent Start tangent of the animation curve
  102082. * @param gradient Scalar amount to interpolate
  102083. * @returns Interpolated scalar value
  102084. */
  102085. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102086. /**
  102087. * Interpolates a quaternion using a spherical linear interpolation
  102088. * @param startValue Start value of the animation curve
  102089. * @param endValue End value of the animation curve
  102090. * @param gradient Scalar amount to interpolate
  102091. * @returns Interpolated quaternion value
  102092. */
  102093. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102094. /**
  102095. * Interpolates a quaternion cubically
  102096. * @param startValue Start value of the animation curve
  102097. * @param outTangent End tangent of the animation curve
  102098. * @param endValue End value of the animation curve
  102099. * @param inTangent Start tangent of the animation curve
  102100. * @param gradient Scalar amount to interpolate
  102101. * @returns Interpolated quaternion value
  102102. */
  102103. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102104. /**
  102105. * Interpolates a Vector3 linearl
  102106. * @param startValue Start value of the animation curve
  102107. * @param endValue End value of the animation curve
  102108. * @param gradient Scalar amount to interpolate
  102109. * @returns Interpolated scalar value
  102110. */
  102111. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102112. /**
  102113. * Interpolates a Vector3 cubically
  102114. * @param startValue Start value of the animation curve
  102115. * @param outTangent End tangent of the animation
  102116. * @param endValue End value of the animation curve
  102117. * @param inTangent Start tangent of the animation curve
  102118. * @param gradient Scalar amount to interpolate
  102119. * @returns InterpolatedVector3 value
  102120. */
  102121. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102122. /**
  102123. * Interpolates a Vector2 linearly
  102124. * @param startValue Start value of the animation curve
  102125. * @param endValue End value of the animation curve
  102126. * @param gradient Scalar amount to interpolate
  102127. * @returns Interpolated Vector2 value
  102128. */
  102129. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102130. /**
  102131. * Interpolates a Vector2 cubically
  102132. * @param startValue Start value of the animation curve
  102133. * @param outTangent End tangent of the animation
  102134. * @param endValue End value of the animation curve
  102135. * @param inTangent Start tangent of the animation curve
  102136. * @param gradient Scalar amount to interpolate
  102137. * @returns Interpolated Vector2 value
  102138. */
  102139. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102140. /**
  102141. * Interpolates a size linearly
  102142. * @param startValue Start value of the animation curve
  102143. * @param endValue End value of the animation curve
  102144. * @param gradient Scalar amount to interpolate
  102145. * @returns Interpolated Size value
  102146. */
  102147. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102148. /**
  102149. * Interpolates a Color3 linearly
  102150. * @param startValue Start value of the animation curve
  102151. * @param endValue End value of the animation curve
  102152. * @param gradient Scalar amount to interpolate
  102153. * @returns Interpolated Color3 value
  102154. */
  102155. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102156. /**
  102157. * Interpolates a Color4 linearly
  102158. * @param startValue Start value of the animation curve
  102159. * @param endValue End value of the animation curve
  102160. * @param gradient Scalar amount to interpolate
  102161. * @returns Interpolated Color3 value
  102162. */
  102163. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102164. /**
  102165. * @hidden Internal use only
  102166. */
  102167. _getKeyValue(value: any): any;
  102168. /**
  102169. * @hidden Internal use only
  102170. */
  102171. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102172. /**
  102173. * Defines the function to use to interpolate matrices
  102174. * @param startValue defines the start matrix
  102175. * @param endValue defines the end matrix
  102176. * @param gradient defines the gradient between both matrices
  102177. * @param result defines an optional target matrix where to store the interpolation
  102178. * @returns the interpolated matrix
  102179. */
  102180. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102181. /**
  102182. * Makes a copy of the animation
  102183. * @returns Cloned animation
  102184. */
  102185. clone(): Animation;
  102186. /**
  102187. * Sets the key frames of the animation
  102188. * @param values The animation key frames to set
  102189. */
  102190. setKeys(values: Array<IAnimationKey>): void;
  102191. /**
  102192. * Serializes the animation to an object
  102193. * @returns Serialized object
  102194. */
  102195. serialize(): any;
  102196. /**
  102197. * Float animation type
  102198. */
  102199. static readonly ANIMATIONTYPE_FLOAT: number;
  102200. /**
  102201. * Vector3 animation type
  102202. */
  102203. static readonly ANIMATIONTYPE_VECTOR3: number;
  102204. /**
  102205. * Quaternion animation type
  102206. */
  102207. static readonly ANIMATIONTYPE_QUATERNION: number;
  102208. /**
  102209. * Matrix animation type
  102210. */
  102211. static readonly ANIMATIONTYPE_MATRIX: number;
  102212. /**
  102213. * Color3 animation type
  102214. */
  102215. static readonly ANIMATIONTYPE_COLOR3: number;
  102216. /**
  102217. * Color3 animation type
  102218. */
  102219. static readonly ANIMATIONTYPE_COLOR4: number;
  102220. /**
  102221. * Vector2 animation type
  102222. */
  102223. static readonly ANIMATIONTYPE_VECTOR2: number;
  102224. /**
  102225. * Size animation type
  102226. */
  102227. static readonly ANIMATIONTYPE_SIZE: number;
  102228. /**
  102229. * Relative Loop Mode
  102230. */
  102231. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102232. /**
  102233. * Cycle Loop Mode
  102234. */
  102235. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102236. /**
  102237. * Constant Loop Mode
  102238. */
  102239. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102240. /** @hidden */
  102241. static _UniversalLerp(left: any, right: any, amount: number): any;
  102242. /**
  102243. * Parses an animation object and creates an animation
  102244. * @param parsedAnimation Parsed animation object
  102245. * @returns Animation object
  102246. */
  102247. static Parse(parsedAnimation: any): Animation;
  102248. /**
  102249. * Appends the serialized animations from the source animations
  102250. * @param source Source containing the animations
  102251. * @param destination Target to store the animations
  102252. */
  102253. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102254. }
  102255. }
  102256. declare module BABYLON {
  102257. /**
  102258. * Interface containing an array of animations
  102259. */
  102260. export interface IAnimatable {
  102261. /**
  102262. * Array of animations
  102263. */
  102264. animations: Nullable<Array<Animation>>;
  102265. }
  102266. }
  102267. declare module BABYLON {
  102268. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102269. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102270. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102271. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102272. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102273. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102274. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102275. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102276. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102277. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102278. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102279. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102280. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102281. /**
  102282. * Decorator used to define property that can be serialized as reference to a camera
  102283. * @param sourceName defines the name of the property to decorate
  102284. */
  102285. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102286. /**
  102287. * Class used to help serialization objects
  102288. */
  102289. export class SerializationHelper {
  102290. /** @hidden */
  102291. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102292. /** @hidden */
  102293. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102294. /** @hidden */
  102295. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102296. /** @hidden */
  102297. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102298. /**
  102299. * Appends the serialized animations from the source animations
  102300. * @param source Source containing the animations
  102301. * @param destination Target to store the animations
  102302. */
  102303. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102304. /**
  102305. * Static function used to serialized a specific entity
  102306. * @param entity defines the entity to serialize
  102307. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102308. * @returns a JSON compatible object representing the serialization of the entity
  102309. */
  102310. static Serialize<T>(entity: T, serializationObject?: any): any;
  102311. /**
  102312. * Creates a new entity from a serialization data object
  102313. * @param creationFunction defines a function used to instanciated the new entity
  102314. * @param source defines the source serialization data
  102315. * @param scene defines the hosting scene
  102316. * @param rootUrl defines the root url for resources
  102317. * @returns a new entity
  102318. */
  102319. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102320. /**
  102321. * Clones an object
  102322. * @param creationFunction defines the function used to instanciate the new object
  102323. * @param source defines the source object
  102324. * @returns the cloned object
  102325. */
  102326. static Clone<T>(creationFunction: () => T, source: T): T;
  102327. /**
  102328. * Instanciates a new object based on a source one (some data will be shared between both object)
  102329. * @param creationFunction defines the function used to instanciate the new object
  102330. * @param source defines the source object
  102331. * @returns the new object
  102332. */
  102333. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102334. }
  102335. }
  102336. declare module BABYLON {
  102337. /**
  102338. * Class used to manipulate GUIDs
  102339. */
  102340. export class GUID {
  102341. /**
  102342. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102343. * Be aware Math.random() could cause collisions, but:
  102344. * "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"
  102345. * @returns a pseudo random id
  102346. */
  102347. static RandomId(): string;
  102348. }
  102349. }
  102350. declare module BABYLON {
  102351. /**
  102352. * Base class of all the textures in babylon.
  102353. * It groups all the common properties the materials, post process, lights... might need
  102354. * in order to make a correct use of the texture.
  102355. */
  102356. export class BaseTexture implements IAnimatable {
  102357. /**
  102358. * Default anisotropic filtering level for the application.
  102359. * It is set to 4 as a good tradeoff between perf and quality.
  102360. */
  102361. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102362. /**
  102363. * Gets or sets the unique id of the texture
  102364. */
  102365. uniqueId: number;
  102366. /**
  102367. * Define the name of the texture.
  102368. */
  102369. name: string;
  102370. /**
  102371. * Gets or sets an object used to store user defined information.
  102372. */
  102373. metadata: any;
  102374. /**
  102375. * For internal use only. Please do not use.
  102376. */
  102377. reservedDataStore: any;
  102378. private _hasAlpha;
  102379. /**
  102380. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102381. */
  102382. set hasAlpha(value: boolean);
  102383. get hasAlpha(): boolean;
  102384. /**
  102385. * Defines if the alpha value should be determined via the rgb values.
  102386. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102387. */
  102388. getAlphaFromRGB: boolean;
  102389. /**
  102390. * Intensity or strength of the texture.
  102391. * It is commonly used by materials to fine tune the intensity of the texture
  102392. */
  102393. level: number;
  102394. /**
  102395. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102396. * This is part of the texture as textures usually maps to one uv set.
  102397. */
  102398. coordinatesIndex: number;
  102399. private _coordinatesMode;
  102400. /**
  102401. * How a texture is mapped.
  102402. *
  102403. * | Value | Type | Description |
  102404. * | ----- | ----------------------------------- | ----------- |
  102405. * | 0 | EXPLICIT_MODE | |
  102406. * | 1 | SPHERICAL_MODE | |
  102407. * | 2 | PLANAR_MODE | |
  102408. * | 3 | CUBIC_MODE | |
  102409. * | 4 | PROJECTION_MODE | |
  102410. * | 5 | SKYBOX_MODE | |
  102411. * | 6 | INVCUBIC_MODE | |
  102412. * | 7 | EQUIRECTANGULAR_MODE | |
  102413. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102414. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102415. */
  102416. set coordinatesMode(value: number);
  102417. get coordinatesMode(): number;
  102418. /**
  102419. * | Value | Type | Description |
  102420. * | ----- | ------------------ | ----------- |
  102421. * | 0 | CLAMP_ADDRESSMODE | |
  102422. * | 1 | WRAP_ADDRESSMODE | |
  102423. * | 2 | MIRROR_ADDRESSMODE | |
  102424. */
  102425. wrapU: number;
  102426. /**
  102427. * | Value | Type | Description |
  102428. * | ----- | ------------------ | ----------- |
  102429. * | 0 | CLAMP_ADDRESSMODE | |
  102430. * | 1 | WRAP_ADDRESSMODE | |
  102431. * | 2 | MIRROR_ADDRESSMODE | |
  102432. */
  102433. wrapV: number;
  102434. /**
  102435. * | Value | Type | Description |
  102436. * | ----- | ------------------ | ----------- |
  102437. * | 0 | CLAMP_ADDRESSMODE | |
  102438. * | 1 | WRAP_ADDRESSMODE | |
  102439. * | 2 | MIRROR_ADDRESSMODE | |
  102440. */
  102441. wrapR: number;
  102442. /**
  102443. * With compliant hardware and browser (supporting anisotropic filtering)
  102444. * this defines the level of anisotropic filtering in the texture.
  102445. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102446. */
  102447. anisotropicFilteringLevel: number;
  102448. /**
  102449. * Define if the texture is a cube texture or if false a 2d texture.
  102450. */
  102451. get isCube(): boolean;
  102452. set isCube(value: boolean);
  102453. /**
  102454. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102455. */
  102456. get is3D(): boolean;
  102457. set is3D(value: boolean);
  102458. /**
  102459. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102460. */
  102461. get is2DArray(): boolean;
  102462. set is2DArray(value: boolean);
  102463. /**
  102464. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102465. * HDR texture are usually stored in linear space.
  102466. * This only impacts the PBR and Background materials
  102467. */
  102468. gammaSpace: boolean;
  102469. /**
  102470. * Gets or sets whether or not the texture contains RGBD data.
  102471. */
  102472. get isRGBD(): boolean;
  102473. set isRGBD(value: boolean);
  102474. /**
  102475. * Is Z inverted in the texture (useful in a cube texture).
  102476. */
  102477. invertZ: boolean;
  102478. /**
  102479. * Are mip maps generated for this texture or not.
  102480. */
  102481. get noMipmap(): boolean;
  102482. /**
  102483. * @hidden
  102484. */
  102485. lodLevelInAlpha: boolean;
  102486. /**
  102487. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102488. */
  102489. get lodGenerationOffset(): number;
  102490. set lodGenerationOffset(value: number);
  102491. /**
  102492. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102493. */
  102494. get lodGenerationScale(): number;
  102495. set lodGenerationScale(value: number);
  102496. /**
  102497. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102498. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102499. * average roughness values.
  102500. */
  102501. get linearSpecularLOD(): boolean;
  102502. set linearSpecularLOD(value: boolean);
  102503. /**
  102504. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102505. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102506. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102507. */
  102508. get irradianceTexture(): Nullable<BaseTexture>;
  102509. set irradianceTexture(value: Nullable<BaseTexture>);
  102510. /**
  102511. * Define if the texture is a render target.
  102512. */
  102513. isRenderTarget: boolean;
  102514. /**
  102515. * Define the unique id of the texture in the scene.
  102516. */
  102517. get uid(): string;
  102518. /**
  102519. * Return a string representation of the texture.
  102520. * @returns the texture as a string
  102521. */
  102522. toString(): string;
  102523. /**
  102524. * Get the class name of the texture.
  102525. * @returns "BaseTexture"
  102526. */
  102527. getClassName(): string;
  102528. /**
  102529. * Define the list of animation attached to the texture.
  102530. */
  102531. animations: Animation[];
  102532. /**
  102533. * An event triggered when the texture is disposed.
  102534. */
  102535. onDisposeObservable: Observable<BaseTexture>;
  102536. private _onDisposeObserver;
  102537. /**
  102538. * Callback triggered when the texture has been disposed.
  102539. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102540. */
  102541. set onDispose(callback: () => void);
  102542. /**
  102543. * Define the current state of the loading sequence when in delayed load mode.
  102544. */
  102545. delayLoadState: number;
  102546. private _scene;
  102547. /** @hidden */
  102548. _texture: Nullable<InternalTexture>;
  102549. private _uid;
  102550. /**
  102551. * Define if the texture is preventinga material to render or not.
  102552. * If not and the texture is not ready, the engine will use a default black texture instead.
  102553. */
  102554. get isBlocking(): boolean;
  102555. /**
  102556. * Instantiates a new BaseTexture.
  102557. * Base class of all the textures in babylon.
  102558. * It groups all the common properties the materials, post process, lights... might need
  102559. * in order to make a correct use of the texture.
  102560. * @param scene Define the scene the texture blongs to
  102561. */
  102562. constructor(scene: Nullable<Scene>);
  102563. /**
  102564. * Get the scene the texture belongs to.
  102565. * @returns the scene or null if undefined
  102566. */
  102567. getScene(): Nullable<Scene>;
  102568. /**
  102569. * Get the texture transform matrix used to offset tile the texture for istance.
  102570. * @returns the transformation matrix
  102571. */
  102572. getTextureMatrix(): Matrix;
  102573. /**
  102574. * Get the texture reflection matrix used to rotate/transform the reflection.
  102575. * @returns the reflection matrix
  102576. */
  102577. getReflectionTextureMatrix(): Matrix;
  102578. /**
  102579. * Get the underlying lower level texture from Babylon.
  102580. * @returns the insternal texture
  102581. */
  102582. getInternalTexture(): Nullable<InternalTexture>;
  102583. /**
  102584. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  102585. * @returns true if ready or not blocking
  102586. */
  102587. isReadyOrNotBlocking(): boolean;
  102588. /**
  102589. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  102590. * @returns true if fully ready
  102591. */
  102592. isReady(): boolean;
  102593. private _cachedSize;
  102594. /**
  102595. * Get the size of the texture.
  102596. * @returns the texture size.
  102597. */
  102598. getSize(): ISize;
  102599. /**
  102600. * Get the base size of the texture.
  102601. * It can be different from the size if the texture has been resized for POT for instance
  102602. * @returns the base size
  102603. */
  102604. getBaseSize(): ISize;
  102605. /**
  102606. * Update the sampling mode of the texture.
  102607. * Default is Trilinear mode.
  102608. *
  102609. * | Value | Type | Description |
  102610. * | ----- | ------------------ | ----------- |
  102611. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  102612. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  102613. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  102614. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  102615. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  102616. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  102617. * | 7 | NEAREST_LINEAR | |
  102618. * | 8 | NEAREST_NEAREST | |
  102619. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  102620. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  102621. * | 11 | LINEAR_LINEAR | |
  102622. * | 12 | LINEAR_NEAREST | |
  102623. *
  102624. * > _mag_: magnification filter (close to the viewer)
  102625. * > _min_: minification filter (far from the viewer)
  102626. * > _mip_: filter used between mip map levels
  102627. *@param samplingMode Define the new sampling mode of the texture
  102628. */
  102629. updateSamplingMode(samplingMode: number): void;
  102630. /**
  102631. * Scales the texture if is `canRescale()`
  102632. * @param ratio the resize factor we want to use to rescale
  102633. */
  102634. scale(ratio: number): void;
  102635. /**
  102636. * Get if the texture can rescale.
  102637. */
  102638. get canRescale(): boolean;
  102639. /** @hidden */
  102640. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  102641. /** @hidden */
  102642. _rebuild(): void;
  102643. /**
  102644. * Triggers the load sequence in delayed load mode.
  102645. */
  102646. delayLoad(): void;
  102647. /**
  102648. * Clones the texture.
  102649. * @returns the cloned texture
  102650. */
  102651. clone(): Nullable<BaseTexture>;
  102652. /**
  102653. * Get the texture underlying type (INT, FLOAT...)
  102654. */
  102655. get textureType(): number;
  102656. /**
  102657. * Get the texture underlying format (RGB, RGBA...)
  102658. */
  102659. get textureFormat(): number;
  102660. /**
  102661. * Indicates that textures need to be re-calculated for all materials
  102662. */
  102663. protected _markAllSubMeshesAsTexturesDirty(): void;
  102664. /**
  102665. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  102666. * This will returns an RGBA array buffer containing either in values (0-255) or
  102667. * float values (0-1) depending of the underlying buffer type.
  102668. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  102669. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  102670. * @param buffer defines a user defined buffer to fill with data (can be null)
  102671. * @returns The Array buffer containing the pixels data.
  102672. */
  102673. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  102674. /**
  102675. * Release and destroy the underlying lower level texture aka internalTexture.
  102676. */
  102677. releaseInternalTexture(): void;
  102678. /** @hidden */
  102679. get _lodTextureHigh(): Nullable<BaseTexture>;
  102680. /** @hidden */
  102681. get _lodTextureMid(): Nullable<BaseTexture>;
  102682. /** @hidden */
  102683. get _lodTextureLow(): Nullable<BaseTexture>;
  102684. /**
  102685. * Dispose the texture and release its associated resources.
  102686. */
  102687. dispose(): void;
  102688. /**
  102689. * Serialize the texture into a JSON representation that can be parsed later on.
  102690. * @returns the JSON representation of the texture
  102691. */
  102692. serialize(): any;
  102693. /**
  102694. * Helper function to be called back once a list of texture contains only ready textures.
  102695. * @param textures Define the list of textures to wait for
  102696. * @param callback Define the callback triggered once the entire list will be ready
  102697. */
  102698. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  102699. }
  102700. }
  102701. declare module BABYLON {
  102702. /**
  102703. * Options to be used when creating an effect.
  102704. */
  102705. export interface IEffectCreationOptions {
  102706. /**
  102707. * Atrributes that will be used in the shader.
  102708. */
  102709. attributes: string[];
  102710. /**
  102711. * Uniform varible names that will be set in the shader.
  102712. */
  102713. uniformsNames: string[];
  102714. /**
  102715. * Uniform buffer variable names that will be set in the shader.
  102716. */
  102717. uniformBuffersNames: string[];
  102718. /**
  102719. * Sampler texture variable names that will be set in the shader.
  102720. */
  102721. samplers: string[];
  102722. /**
  102723. * Define statements that will be set in the shader.
  102724. */
  102725. defines: any;
  102726. /**
  102727. * Possible fallbacks for this effect to improve performance when needed.
  102728. */
  102729. fallbacks: Nullable<IEffectFallbacks>;
  102730. /**
  102731. * Callback that will be called when the shader is compiled.
  102732. */
  102733. onCompiled: Nullable<(effect: Effect) => void>;
  102734. /**
  102735. * Callback that will be called if an error occurs during shader compilation.
  102736. */
  102737. onError: Nullable<(effect: Effect, errors: string) => void>;
  102738. /**
  102739. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102740. */
  102741. indexParameters?: any;
  102742. /**
  102743. * Max number of lights that can be used in the shader.
  102744. */
  102745. maxSimultaneousLights?: number;
  102746. /**
  102747. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  102748. */
  102749. transformFeedbackVaryings?: Nullable<string[]>;
  102750. }
  102751. /**
  102752. * Effect containing vertex and fragment shader that can be executed on an object.
  102753. */
  102754. export class Effect implements IDisposable {
  102755. /**
  102756. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102757. */
  102758. static ShadersRepository: string;
  102759. /**
  102760. * Name of the effect.
  102761. */
  102762. name: any;
  102763. /**
  102764. * String container all the define statements that should be set on the shader.
  102765. */
  102766. defines: string;
  102767. /**
  102768. * Callback that will be called when the shader is compiled.
  102769. */
  102770. onCompiled: Nullable<(effect: Effect) => void>;
  102771. /**
  102772. * Callback that will be called if an error occurs during shader compilation.
  102773. */
  102774. onError: Nullable<(effect: Effect, errors: string) => void>;
  102775. /**
  102776. * Callback that will be called when effect is bound.
  102777. */
  102778. onBind: Nullable<(effect: Effect) => void>;
  102779. /**
  102780. * Unique ID of the effect.
  102781. */
  102782. uniqueId: number;
  102783. /**
  102784. * Observable that will be called when the shader is compiled.
  102785. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  102786. */
  102787. onCompileObservable: Observable<Effect>;
  102788. /**
  102789. * Observable that will be called if an error occurs during shader compilation.
  102790. */
  102791. onErrorObservable: Observable<Effect>;
  102792. /** @hidden */
  102793. _onBindObservable: Nullable<Observable<Effect>>;
  102794. /**
  102795. * @hidden
  102796. * Specifies if the effect was previously ready
  102797. */
  102798. _wasPreviouslyReady: boolean;
  102799. /**
  102800. * Observable that will be called when effect is bound.
  102801. */
  102802. get onBindObservable(): Observable<Effect>;
  102803. /** @hidden */
  102804. _bonesComputationForcedToCPU: boolean;
  102805. private static _uniqueIdSeed;
  102806. private _engine;
  102807. private _uniformBuffersNames;
  102808. private _uniformsNames;
  102809. private _samplerList;
  102810. private _samplers;
  102811. private _isReady;
  102812. private _compilationError;
  102813. private _allFallbacksProcessed;
  102814. private _attributesNames;
  102815. private _attributes;
  102816. private _attributeLocationByName;
  102817. private _uniforms;
  102818. /**
  102819. * Key for the effect.
  102820. * @hidden
  102821. */
  102822. _key: string;
  102823. private _indexParameters;
  102824. private _fallbacks;
  102825. private _vertexSourceCode;
  102826. private _fragmentSourceCode;
  102827. private _vertexSourceCodeOverride;
  102828. private _fragmentSourceCodeOverride;
  102829. private _transformFeedbackVaryings;
  102830. /**
  102831. * Compiled shader to webGL program.
  102832. * @hidden
  102833. */
  102834. _pipelineContext: Nullable<IPipelineContext>;
  102835. private _valueCache;
  102836. private static _baseCache;
  102837. /**
  102838. * Instantiates an effect.
  102839. * An effect can be used to create/manage/execute vertex and fragment shaders.
  102840. * @param baseName Name of the effect.
  102841. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  102842. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  102843. * @param samplers List of sampler variables that will be passed to the shader.
  102844. * @param engine Engine to be used to render the effect
  102845. * @param defines Define statements to be added to the shader.
  102846. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  102847. * @param onCompiled Callback that will be called when the shader is compiled.
  102848. * @param onError Callback that will be called if an error occurs during shader compilation.
  102849. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102850. */
  102851. 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);
  102852. private _useFinalCode;
  102853. /**
  102854. * Unique key for this effect
  102855. */
  102856. get key(): string;
  102857. /**
  102858. * If the effect has been compiled and prepared.
  102859. * @returns if the effect is compiled and prepared.
  102860. */
  102861. isReady(): boolean;
  102862. private _isReadyInternal;
  102863. /**
  102864. * The engine the effect was initialized with.
  102865. * @returns the engine.
  102866. */
  102867. getEngine(): Engine;
  102868. /**
  102869. * The pipeline context for this effect
  102870. * @returns the associated pipeline context
  102871. */
  102872. getPipelineContext(): Nullable<IPipelineContext>;
  102873. /**
  102874. * The set of names of attribute variables for the shader.
  102875. * @returns An array of attribute names.
  102876. */
  102877. getAttributesNames(): string[];
  102878. /**
  102879. * Returns the attribute at the given index.
  102880. * @param index The index of the attribute.
  102881. * @returns The location of the attribute.
  102882. */
  102883. getAttributeLocation(index: number): number;
  102884. /**
  102885. * Returns the attribute based on the name of the variable.
  102886. * @param name of the attribute to look up.
  102887. * @returns the attribute location.
  102888. */
  102889. getAttributeLocationByName(name: string): number;
  102890. /**
  102891. * The number of attributes.
  102892. * @returns the numnber of attributes.
  102893. */
  102894. getAttributesCount(): number;
  102895. /**
  102896. * Gets the index of a uniform variable.
  102897. * @param uniformName of the uniform to look up.
  102898. * @returns the index.
  102899. */
  102900. getUniformIndex(uniformName: string): number;
  102901. /**
  102902. * Returns the attribute based on the name of the variable.
  102903. * @param uniformName of the uniform to look up.
  102904. * @returns the location of the uniform.
  102905. */
  102906. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  102907. /**
  102908. * Returns an array of sampler variable names
  102909. * @returns The array of sampler variable neames.
  102910. */
  102911. getSamplers(): string[];
  102912. /**
  102913. * The error from the last compilation.
  102914. * @returns the error string.
  102915. */
  102916. getCompilationError(): string;
  102917. /**
  102918. * Gets a boolean indicating that all fallbacks were used during compilation
  102919. * @returns true if all fallbacks were used
  102920. */
  102921. allFallbacksProcessed(): boolean;
  102922. /**
  102923. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  102924. * @param func The callback to be used.
  102925. */
  102926. executeWhenCompiled(func: (effect: Effect) => void): void;
  102927. private _checkIsReady;
  102928. private _loadShader;
  102929. /**
  102930. * Recompiles the webGL program
  102931. * @param vertexSourceCode The source code for the vertex shader.
  102932. * @param fragmentSourceCode The source code for the fragment shader.
  102933. * @param onCompiled Callback called when completed.
  102934. * @param onError Callback called on error.
  102935. * @hidden
  102936. */
  102937. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  102938. /**
  102939. * Prepares the effect
  102940. * @hidden
  102941. */
  102942. _prepareEffect(): void;
  102943. private _processCompilationErrors;
  102944. /**
  102945. * Checks if the effect is supported. (Must be called after compilation)
  102946. */
  102947. get isSupported(): boolean;
  102948. /**
  102949. * Binds a texture to the engine to be used as output of the shader.
  102950. * @param channel Name of the output variable.
  102951. * @param texture Texture to bind.
  102952. * @hidden
  102953. */
  102954. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  102955. /**
  102956. * Sets a texture on the engine to be used in the shader.
  102957. * @param channel Name of the sampler variable.
  102958. * @param texture Texture to set.
  102959. */
  102960. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  102961. /**
  102962. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  102963. * @param channel Name of the sampler variable.
  102964. * @param texture Texture to set.
  102965. */
  102966. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  102967. /**
  102968. * Sets an array of textures on the engine to be used in the shader.
  102969. * @param channel Name of the variable.
  102970. * @param textures Textures to set.
  102971. */
  102972. setTextureArray(channel: string, textures: BaseTexture[]): void;
  102973. /**
  102974. * 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)
  102975. * @param channel Name of the sampler variable.
  102976. * @param postProcess Post process to get the input texture from.
  102977. */
  102978. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  102979. /**
  102980. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  102981. * 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)
  102982. * @param channel Name of the sampler variable.
  102983. * @param postProcess Post process to get the output texture from.
  102984. */
  102985. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  102986. /** @hidden */
  102987. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  102988. /** @hidden */
  102989. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  102990. /** @hidden */
  102991. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  102992. /** @hidden */
  102993. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  102994. /**
  102995. * Binds a buffer to a uniform.
  102996. * @param buffer Buffer to bind.
  102997. * @param name Name of the uniform variable to bind to.
  102998. */
  102999. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103000. /**
  103001. * Binds block to a uniform.
  103002. * @param blockName Name of the block to bind.
  103003. * @param index Index to bind.
  103004. */
  103005. bindUniformBlock(blockName: string, index: number): void;
  103006. /**
  103007. * Sets an interger value on a uniform variable.
  103008. * @param uniformName Name of the variable.
  103009. * @param value Value to be set.
  103010. * @returns this effect.
  103011. */
  103012. setInt(uniformName: string, value: number): Effect;
  103013. /**
  103014. * Sets an int array on a uniform variable.
  103015. * @param uniformName Name of the variable.
  103016. * @param array array to be set.
  103017. * @returns this effect.
  103018. */
  103019. setIntArray(uniformName: string, array: Int32Array): Effect;
  103020. /**
  103021. * 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)
  103022. * @param uniformName Name of the variable.
  103023. * @param array array to be set.
  103024. * @returns this effect.
  103025. */
  103026. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103027. /**
  103028. * 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)
  103029. * @param uniformName Name of the variable.
  103030. * @param array array to be set.
  103031. * @returns this effect.
  103032. */
  103033. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103034. /**
  103035. * 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)
  103036. * @param uniformName Name of the variable.
  103037. * @param array array to be set.
  103038. * @returns this effect.
  103039. */
  103040. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103041. /**
  103042. * Sets an float array on a uniform variable.
  103043. * @param uniformName Name of the variable.
  103044. * @param array array to be set.
  103045. * @returns this effect.
  103046. */
  103047. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103048. /**
  103049. * 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)
  103050. * @param uniformName Name of the variable.
  103051. * @param array array to be set.
  103052. * @returns this effect.
  103053. */
  103054. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103055. /**
  103056. * 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)
  103057. * @param uniformName Name of the variable.
  103058. * @param array array to be set.
  103059. * @returns this effect.
  103060. */
  103061. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103062. /**
  103063. * 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)
  103064. * @param uniformName Name of the variable.
  103065. * @param array array to be set.
  103066. * @returns this effect.
  103067. */
  103068. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103069. /**
  103070. * Sets an array on a uniform variable.
  103071. * @param uniformName Name of the variable.
  103072. * @param array array to be set.
  103073. * @returns this effect.
  103074. */
  103075. setArray(uniformName: string, array: number[]): Effect;
  103076. /**
  103077. * 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)
  103078. * @param uniformName Name of the variable.
  103079. * @param array array to be set.
  103080. * @returns this effect.
  103081. */
  103082. setArray2(uniformName: string, array: number[]): Effect;
  103083. /**
  103084. * 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)
  103085. * @param uniformName Name of the variable.
  103086. * @param array array to be set.
  103087. * @returns this effect.
  103088. */
  103089. setArray3(uniformName: string, array: number[]): Effect;
  103090. /**
  103091. * 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)
  103092. * @param uniformName Name of the variable.
  103093. * @param array array to be set.
  103094. * @returns this effect.
  103095. */
  103096. setArray4(uniformName: string, array: number[]): Effect;
  103097. /**
  103098. * Sets matrices on a uniform variable.
  103099. * @param uniformName Name of the variable.
  103100. * @param matrices matrices to be set.
  103101. * @returns this effect.
  103102. */
  103103. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103104. /**
  103105. * Sets matrix on a uniform variable.
  103106. * @param uniformName Name of the variable.
  103107. * @param matrix matrix to be set.
  103108. * @returns this effect.
  103109. */
  103110. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103111. /**
  103112. * 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)
  103113. * @param uniformName Name of the variable.
  103114. * @param matrix matrix to be set.
  103115. * @returns this effect.
  103116. */
  103117. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103118. /**
  103119. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103120. * @param uniformName Name of the variable.
  103121. * @param matrix matrix to be set.
  103122. * @returns this effect.
  103123. */
  103124. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103125. /**
  103126. * Sets a float on a uniform variable.
  103127. * @param uniformName Name of the variable.
  103128. * @param value value to be set.
  103129. * @returns this effect.
  103130. */
  103131. setFloat(uniformName: string, value: number): Effect;
  103132. /**
  103133. * Sets a boolean on a uniform variable.
  103134. * @param uniformName Name of the variable.
  103135. * @param bool value to be set.
  103136. * @returns this effect.
  103137. */
  103138. setBool(uniformName: string, bool: boolean): Effect;
  103139. /**
  103140. * Sets a Vector2 on a uniform variable.
  103141. * @param uniformName Name of the variable.
  103142. * @param vector2 vector2 to be set.
  103143. * @returns this effect.
  103144. */
  103145. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103146. /**
  103147. * Sets a float2 on a uniform variable.
  103148. * @param uniformName Name of the variable.
  103149. * @param x First float in float2.
  103150. * @param y Second float in float2.
  103151. * @returns this effect.
  103152. */
  103153. setFloat2(uniformName: string, x: number, y: number): Effect;
  103154. /**
  103155. * Sets a Vector3 on a uniform variable.
  103156. * @param uniformName Name of the variable.
  103157. * @param vector3 Value to be set.
  103158. * @returns this effect.
  103159. */
  103160. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103161. /**
  103162. * Sets a float3 on a uniform variable.
  103163. * @param uniformName Name of the variable.
  103164. * @param x First float in float3.
  103165. * @param y Second float in float3.
  103166. * @param z Third float in float3.
  103167. * @returns this effect.
  103168. */
  103169. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103170. /**
  103171. * Sets a Vector4 on a uniform variable.
  103172. * @param uniformName Name of the variable.
  103173. * @param vector4 Value to be set.
  103174. * @returns this effect.
  103175. */
  103176. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103177. /**
  103178. * Sets a float4 on a uniform variable.
  103179. * @param uniformName Name of the variable.
  103180. * @param x First float in float4.
  103181. * @param y Second float in float4.
  103182. * @param z Third float in float4.
  103183. * @param w Fourth float in float4.
  103184. * @returns this effect.
  103185. */
  103186. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103187. /**
  103188. * Sets a Color3 on a uniform variable.
  103189. * @param uniformName Name of the variable.
  103190. * @param color3 Value to be set.
  103191. * @returns this effect.
  103192. */
  103193. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103194. /**
  103195. * Sets a Color4 on a uniform variable.
  103196. * @param uniformName Name of the variable.
  103197. * @param color3 Value to be set.
  103198. * @param alpha Alpha value to be set.
  103199. * @returns this effect.
  103200. */
  103201. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103202. /**
  103203. * Sets a Color4 on a uniform variable
  103204. * @param uniformName defines the name of the variable
  103205. * @param color4 defines the value to be set
  103206. * @returns this effect.
  103207. */
  103208. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103209. /** Release all associated resources */
  103210. dispose(): void;
  103211. /**
  103212. * This function will add a new shader to the shader store
  103213. * @param name the name of the shader
  103214. * @param pixelShader optional pixel shader content
  103215. * @param vertexShader optional vertex shader content
  103216. */
  103217. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103218. /**
  103219. * Store of each shader (The can be looked up using effect.key)
  103220. */
  103221. static ShadersStore: {
  103222. [key: string]: string;
  103223. };
  103224. /**
  103225. * Store of each included file for a shader (The can be looked up using effect.key)
  103226. */
  103227. static IncludesShadersStore: {
  103228. [key: string]: string;
  103229. };
  103230. /**
  103231. * Resets the cache of effects.
  103232. */
  103233. static ResetCache(): void;
  103234. }
  103235. }
  103236. declare module BABYLON {
  103237. /**
  103238. * Interface used to describe the capabilities of the engine relatively to the current browser
  103239. */
  103240. export interface EngineCapabilities {
  103241. /** Maximum textures units per fragment shader */
  103242. maxTexturesImageUnits: number;
  103243. /** Maximum texture units per vertex shader */
  103244. maxVertexTextureImageUnits: number;
  103245. /** Maximum textures units in the entire pipeline */
  103246. maxCombinedTexturesImageUnits: number;
  103247. /** Maximum texture size */
  103248. maxTextureSize: number;
  103249. /** Maximum texture samples */
  103250. maxSamples?: number;
  103251. /** Maximum cube texture size */
  103252. maxCubemapTextureSize: number;
  103253. /** Maximum render texture size */
  103254. maxRenderTextureSize: number;
  103255. /** Maximum number of vertex attributes */
  103256. maxVertexAttribs: number;
  103257. /** Maximum number of varyings */
  103258. maxVaryingVectors: number;
  103259. /** Maximum number of uniforms per vertex shader */
  103260. maxVertexUniformVectors: number;
  103261. /** Maximum number of uniforms per fragment shader */
  103262. maxFragmentUniformVectors: number;
  103263. /** Defines if standard derivates (dx/dy) are supported */
  103264. standardDerivatives: boolean;
  103265. /** Defines if s3tc texture compression is supported */
  103266. s3tc?: WEBGL_compressed_texture_s3tc;
  103267. /** Defines if pvrtc texture compression is supported */
  103268. pvrtc: any;
  103269. /** Defines if etc1 texture compression is supported */
  103270. etc1: any;
  103271. /** Defines if etc2 texture compression is supported */
  103272. etc2: any;
  103273. /** Defines if astc texture compression is supported */
  103274. astc: any;
  103275. /** Defines if float textures are supported */
  103276. textureFloat: boolean;
  103277. /** Defines if vertex array objects are supported */
  103278. vertexArrayObject: boolean;
  103279. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103280. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103281. /** Gets the maximum level of anisotropy supported */
  103282. maxAnisotropy: number;
  103283. /** Defines if instancing is supported */
  103284. instancedArrays: boolean;
  103285. /** Defines if 32 bits indices are supported */
  103286. uintIndices: boolean;
  103287. /** Defines if high precision shaders are supported */
  103288. highPrecisionShaderSupported: boolean;
  103289. /** Defines if depth reading in the fragment shader is supported */
  103290. fragmentDepthSupported: boolean;
  103291. /** Defines if float texture linear filtering is supported*/
  103292. textureFloatLinearFiltering: boolean;
  103293. /** Defines if rendering to float textures is supported */
  103294. textureFloatRender: boolean;
  103295. /** Defines if half float textures are supported*/
  103296. textureHalfFloat: boolean;
  103297. /** Defines if half float texture linear filtering is supported*/
  103298. textureHalfFloatLinearFiltering: boolean;
  103299. /** Defines if rendering to half float textures is supported */
  103300. textureHalfFloatRender: boolean;
  103301. /** Defines if textureLOD shader command is supported */
  103302. textureLOD: boolean;
  103303. /** Defines if draw buffers extension is supported */
  103304. drawBuffersExtension: boolean;
  103305. /** Defines if depth textures are supported */
  103306. depthTextureExtension: boolean;
  103307. /** Defines if float color buffer are supported */
  103308. colorBufferFloat: boolean;
  103309. /** Gets disjoint timer query extension (null if not supported) */
  103310. timerQuery?: EXT_disjoint_timer_query;
  103311. /** Defines if timestamp can be used with timer query */
  103312. canUseTimestampForTimerQuery: boolean;
  103313. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103314. multiview?: any;
  103315. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103316. oculusMultiview?: any;
  103317. /** Function used to let the system compiles shaders in background */
  103318. parallelShaderCompile?: {
  103319. COMPLETION_STATUS_KHR: number;
  103320. };
  103321. /** Max number of texture samples for MSAA */
  103322. maxMSAASamples: number;
  103323. /** Defines if the blend min max extension is supported */
  103324. blendMinMax: boolean;
  103325. }
  103326. }
  103327. declare module BABYLON {
  103328. /**
  103329. * @hidden
  103330. **/
  103331. export class DepthCullingState {
  103332. private _isDepthTestDirty;
  103333. private _isDepthMaskDirty;
  103334. private _isDepthFuncDirty;
  103335. private _isCullFaceDirty;
  103336. private _isCullDirty;
  103337. private _isZOffsetDirty;
  103338. private _isFrontFaceDirty;
  103339. private _depthTest;
  103340. private _depthMask;
  103341. private _depthFunc;
  103342. private _cull;
  103343. private _cullFace;
  103344. private _zOffset;
  103345. private _frontFace;
  103346. /**
  103347. * Initializes the state.
  103348. */
  103349. constructor();
  103350. get isDirty(): boolean;
  103351. get zOffset(): number;
  103352. set zOffset(value: number);
  103353. get cullFace(): Nullable<number>;
  103354. set cullFace(value: Nullable<number>);
  103355. get cull(): Nullable<boolean>;
  103356. set cull(value: Nullable<boolean>);
  103357. get depthFunc(): Nullable<number>;
  103358. set depthFunc(value: Nullable<number>);
  103359. get depthMask(): boolean;
  103360. set depthMask(value: boolean);
  103361. get depthTest(): boolean;
  103362. set depthTest(value: boolean);
  103363. get frontFace(): Nullable<number>;
  103364. set frontFace(value: Nullable<number>);
  103365. reset(): void;
  103366. apply(gl: WebGLRenderingContext): void;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * @hidden
  103372. **/
  103373. export class StencilState {
  103374. /** 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 */
  103375. static readonly ALWAYS: number;
  103376. /** Passed to stencilOperation to specify that stencil value must be kept */
  103377. static readonly KEEP: number;
  103378. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103379. static readonly REPLACE: number;
  103380. private _isStencilTestDirty;
  103381. private _isStencilMaskDirty;
  103382. private _isStencilFuncDirty;
  103383. private _isStencilOpDirty;
  103384. private _stencilTest;
  103385. private _stencilMask;
  103386. private _stencilFunc;
  103387. private _stencilFuncRef;
  103388. private _stencilFuncMask;
  103389. private _stencilOpStencilFail;
  103390. private _stencilOpDepthFail;
  103391. private _stencilOpStencilDepthPass;
  103392. get isDirty(): boolean;
  103393. get stencilFunc(): number;
  103394. set stencilFunc(value: number);
  103395. get stencilFuncRef(): number;
  103396. set stencilFuncRef(value: number);
  103397. get stencilFuncMask(): number;
  103398. set stencilFuncMask(value: number);
  103399. get stencilOpStencilFail(): number;
  103400. set stencilOpStencilFail(value: number);
  103401. get stencilOpDepthFail(): number;
  103402. set stencilOpDepthFail(value: number);
  103403. get stencilOpStencilDepthPass(): number;
  103404. set stencilOpStencilDepthPass(value: number);
  103405. get stencilMask(): number;
  103406. set stencilMask(value: number);
  103407. get stencilTest(): boolean;
  103408. set stencilTest(value: boolean);
  103409. constructor();
  103410. reset(): void;
  103411. apply(gl: WebGLRenderingContext): void;
  103412. }
  103413. }
  103414. declare module BABYLON {
  103415. /**
  103416. * @hidden
  103417. **/
  103418. export class AlphaState {
  103419. private _isAlphaBlendDirty;
  103420. private _isBlendFunctionParametersDirty;
  103421. private _isBlendEquationParametersDirty;
  103422. private _isBlendConstantsDirty;
  103423. private _alphaBlend;
  103424. private _blendFunctionParameters;
  103425. private _blendEquationParameters;
  103426. private _blendConstants;
  103427. /**
  103428. * Initializes the state.
  103429. */
  103430. constructor();
  103431. get isDirty(): boolean;
  103432. get alphaBlend(): boolean;
  103433. set alphaBlend(value: boolean);
  103434. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103435. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103436. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103437. reset(): void;
  103438. apply(gl: WebGLRenderingContext): void;
  103439. }
  103440. }
  103441. declare module BABYLON {
  103442. /** @hidden */
  103443. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103444. attributeProcessor(attribute: string): string;
  103445. varyingProcessor(varying: string, isFragment: boolean): string;
  103446. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103447. }
  103448. }
  103449. declare module BABYLON {
  103450. /**
  103451. * Interface for attribute information associated with buffer instanciation
  103452. */
  103453. export interface InstancingAttributeInfo {
  103454. /**
  103455. * Name of the GLSL attribute
  103456. * if attribute index is not specified, this is used to retrieve the index from the effect
  103457. */
  103458. attributeName: string;
  103459. /**
  103460. * Index/offset of the attribute in the vertex shader
  103461. * if not specified, this will be computes from the name.
  103462. */
  103463. index?: number;
  103464. /**
  103465. * size of the attribute, 1, 2, 3 or 4
  103466. */
  103467. attributeSize: number;
  103468. /**
  103469. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103470. */
  103471. offset: number;
  103472. /**
  103473. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103474. * default to 1
  103475. */
  103476. divisor?: number;
  103477. /**
  103478. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103479. * default is FLOAT
  103480. */
  103481. attributeType?: number;
  103482. /**
  103483. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103484. */
  103485. normalized?: boolean;
  103486. }
  103487. }
  103488. declare module BABYLON {
  103489. interface ThinEngine {
  103490. /**
  103491. * Update a video texture
  103492. * @param texture defines the texture to update
  103493. * @param video defines the video element to use
  103494. * @param invertY defines if data must be stored with Y axis inverted
  103495. */
  103496. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103497. }
  103498. }
  103499. declare module BABYLON {
  103500. /**
  103501. * Settings for finer control over video usage
  103502. */
  103503. export interface VideoTextureSettings {
  103504. /**
  103505. * Applies `autoplay` to video, if specified
  103506. */
  103507. autoPlay?: boolean;
  103508. /**
  103509. * Applies `loop` to video, if specified
  103510. */
  103511. loop?: boolean;
  103512. /**
  103513. * Automatically updates internal texture from video at every frame in the render loop
  103514. */
  103515. autoUpdateTexture: boolean;
  103516. /**
  103517. * Image src displayed during the video loading or until the user interacts with the video.
  103518. */
  103519. poster?: string;
  103520. }
  103521. /**
  103522. * If you want to display a video in your scene, this is the special texture for that.
  103523. * This special texture works similar to other textures, with the exception of a few parameters.
  103524. * @see https://doc.babylonjs.com/how_to/video_texture
  103525. */
  103526. export class VideoTexture extends Texture {
  103527. /**
  103528. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103529. */
  103530. readonly autoUpdateTexture: boolean;
  103531. /**
  103532. * The video instance used by the texture internally
  103533. */
  103534. readonly video: HTMLVideoElement;
  103535. private _onUserActionRequestedObservable;
  103536. /**
  103537. * Event triggerd when a dom action is required by the user to play the video.
  103538. * This happens due to recent changes in browser policies preventing video to auto start.
  103539. */
  103540. get onUserActionRequestedObservable(): Observable<Texture>;
  103541. private _generateMipMaps;
  103542. private _engine;
  103543. private _stillImageCaptured;
  103544. private _displayingPosterTexture;
  103545. private _settings;
  103546. private _createInternalTextureOnEvent;
  103547. private _frameId;
  103548. private _currentSrc;
  103549. /**
  103550. * Creates a video texture.
  103551. * If you want to display a video in your scene, this is the special texture for that.
  103552. * This special texture works similar to other textures, with the exception of a few parameters.
  103553. * @see https://doc.babylonjs.com/how_to/video_texture
  103554. * @param name optional name, will detect from video source, if not defined
  103555. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103556. * @param scene is obviously the current scene.
  103557. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  103558. * @param invertY is false by default but can be used to invert video on Y axis
  103559. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  103560. * @param settings allows finer control over video usage
  103561. */
  103562. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  103563. private _getName;
  103564. private _getVideo;
  103565. private _createInternalTexture;
  103566. private reset;
  103567. /**
  103568. * @hidden Internal method to initiate `update`.
  103569. */
  103570. _rebuild(): void;
  103571. /**
  103572. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  103573. */
  103574. update(): void;
  103575. /**
  103576. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  103577. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  103578. */
  103579. updateTexture(isVisible: boolean): void;
  103580. protected _updateInternalTexture: () => void;
  103581. /**
  103582. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  103583. * @param url New url.
  103584. */
  103585. updateURL(url: string): void;
  103586. /**
  103587. * Clones the texture.
  103588. * @returns the cloned texture
  103589. */
  103590. clone(): VideoTexture;
  103591. /**
  103592. * Dispose the texture and release its associated resources.
  103593. */
  103594. dispose(): void;
  103595. /**
  103596. * Creates a video texture straight from a stream.
  103597. * @param scene Define the scene the texture should be created in
  103598. * @param stream Define the stream the texture should be created from
  103599. * @returns The created video texture as a promise
  103600. */
  103601. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  103602. /**
  103603. * Creates a video texture straight from your WebCam video feed.
  103604. * @param scene Define the scene the texture should be created in
  103605. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103606. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103607. * @returns The created video texture as a promise
  103608. */
  103609. static CreateFromWebCamAsync(scene: Scene, constraints: {
  103610. minWidth: number;
  103611. maxWidth: number;
  103612. minHeight: number;
  103613. maxHeight: number;
  103614. deviceId: string;
  103615. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  103616. /**
  103617. * Creates a video texture straight from your WebCam video feed.
  103618. * @param scene Define the scene the texture should be created in
  103619. * @param onReady Define a callback to triggered once the texture will be ready
  103620. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103621. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103622. */
  103623. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  103624. minWidth: number;
  103625. maxWidth: number;
  103626. minHeight: number;
  103627. maxHeight: number;
  103628. deviceId: string;
  103629. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  103630. }
  103631. }
  103632. declare module BABYLON {
  103633. /**
  103634. * Defines the interface used by objects working like Scene
  103635. * @hidden
  103636. */
  103637. interface ISceneLike {
  103638. _addPendingData(data: any): void;
  103639. _removePendingData(data: any): void;
  103640. offlineProvider: IOfflineProvider;
  103641. }
  103642. /** Interface defining initialization parameters for Engine class */
  103643. export interface EngineOptions extends WebGLContextAttributes {
  103644. /**
  103645. * Defines if the engine should no exceed a specified device ratio
  103646. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  103647. */
  103648. limitDeviceRatio?: number;
  103649. /**
  103650. * Defines if webvr should be enabled automatically
  103651. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103652. */
  103653. autoEnableWebVR?: boolean;
  103654. /**
  103655. * Defines if webgl2 should be turned off even if supported
  103656. * @see http://doc.babylonjs.com/features/webgl2
  103657. */
  103658. disableWebGL2Support?: boolean;
  103659. /**
  103660. * Defines if webaudio should be initialized as well
  103661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103662. */
  103663. audioEngine?: boolean;
  103664. /**
  103665. * Defines if animations should run using a deterministic lock step
  103666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103667. */
  103668. deterministicLockstep?: boolean;
  103669. /** Defines the maximum steps to use with deterministic lock step mode */
  103670. lockstepMaxSteps?: number;
  103671. /** Defines the seconds between each deterministic lock step */
  103672. timeStep?: number;
  103673. /**
  103674. * Defines that engine should ignore context lost events
  103675. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  103676. */
  103677. doNotHandleContextLost?: boolean;
  103678. /**
  103679. * Defines that engine should ignore modifying touch action attribute and style
  103680. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  103681. */
  103682. doNotHandleTouchAction?: boolean;
  103683. /**
  103684. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  103685. */
  103686. useHighPrecisionFloats?: boolean;
  103687. }
  103688. /**
  103689. * The base engine class (root of all engines)
  103690. */
  103691. export class ThinEngine {
  103692. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  103693. static ExceptionList: ({
  103694. key: string;
  103695. capture: string;
  103696. captureConstraint: number;
  103697. targets: string[];
  103698. } | {
  103699. key: string;
  103700. capture: null;
  103701. captureConstraint: null;
  103702. targets: string[];
  103703. })[];
  103704. /** @hidden */
  103705. static _TextureLoaders: IInternalTextureLoader[];
  103706. /**
  103707. * Returns the current npm package of the sdk
  103708. */
  103709. static get NpmPackage(): string;
  103710. /**
  103711. * Returns the current version of the framework
  103712. */
  103713. static get Version(): string;
  103714. /**
  103715. * Returns a string describing the current engine
  103716. */
  103717. get description(): string;
  103718. /**
  103719. * Gets or sets the epsilon value used by collision engine
  103720. */
  103721. static CollisionsEpsilon: number;
  103722. /**
  103723. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103724. */
  103725. static get ShadersRepository(): string;
  103726. static set ShadersRepository(value: string);
  103727. /**
  103728. * Gets or sets the textures that the engine should not attempt to load as compressed
  103729. */
  103730. protected _excludedCompressedTextures: string[];
  103731. /**
  103732. * Filters the compressed texture formats to only include
  103733. * files that are not included in the skippable list
  103734. *
  103735. * @param url the current extension
  103736. * @param textureFormatInUse the current compressed texture format
  103737. * @returns "format" string
  103738. */
  103739. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  103740. /** @hidden */
  103741. _shaderProcessor: IShaderProcessor;
  103742. /**
  103743. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  103744. */
  103745. forcePOTTextures: boolean;
  103746. /**
  103747. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  103748. */
  103749. isFullscreen: boolean;
  103750. /**
  103751. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  103752. */
  103753. cullBackFaces: boolean;
  103754. /**
  103755. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  103756. */
  103757. renderEvenInBackground: boolean;
  103758. /**
  103759. * Gets or sets a boolean indicating that cache can be kept between frames
  103760. */
  103761. preventCacheWipeBetweenFrames: boolean;
  103762. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  103763. validateShaderPrograms: boolean;
  103764. /**
  103765. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  103766. * This can provide greater z depth for distant objects.
  103767. */
  103768. useReverseDepthBuffer: boolean;
  103769. /**
  103770. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  103771. */
  103772. disableUniformBuffers: boolean;
  103773. /** @hidden */
  103774. _uniformBuffers: UniformBuffer[];
  103775. /**
  103776. * Gets a boolean indicating that the engine supports uniform buffers
  103777. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  103778. */
  103779. get supportsUniformBuffers(): boolean;
  103780. /** @hidden */
  103781. _gl: WebGLRenderingContext;
  103782. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  103783. protected _windowIsBackground: boolean;
  103784. protected _webGLVersion: number;
  103785. protected _creationOptions: EngineOptions;
  103786. protected _highPrecisionShadersAllowed: boolean;
  103787. /** @hidden */
  103788. get _shouldUseHighPrecisionShader(): boolean;
  103789. /**
  103790. * Gets a boolean indicating that only power of 2 textures are supported
  103791. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  103792. */
  103793. get needPOTTextures(): boolean;
  103794. /** @hidden */
  103795. _badOS: boolean;
  103796. /** @hidden */
  103797. _badDesktopOS: boolean;
  103798. private _hardwareScalingLevel;
  103799. /** @hidden */
  103800. _caps: EngineCapabilities;
  103801. private _isStencilEnable;
  103802. private _glVersion;
  103803. private _glRenderer;
  103804. private _glVendor;
  103805. /** @hidden */
  103806. _videoTextureSupported: boolean;
  103807. protected _renderingQueueLaunched: boolean;
  103808. protected _activeRenderLoops: (() => void)[];
  103809. /**
  103810. * Observable signaled when a context lost event is raised
  103811. */
  103812. onContextLostObservable: Observable<ThinEngine>;
  103813. /**
  103814. * Observable signaled when a context restored event is raised
  103815. */
  103816. onContextRestoredObservable: Observable<ThinEngine>;
  103817. private _onContextLost;
  103818. private _onContextRestored;
  103819. protected _contextWasLost: boolean;
  103820. /** @hidden */
  103821. _doNotHandleContextLost: boolean;
  103822. /**
  103823. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  103824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  103825. */
  103826. get doNotHandleContextLost(): boolean;
  103827. set doNotHandleContextLost(value: boolean);
  103828. /**
  103829. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  103830. */
  103831. disableVertexArrayObjects: boolean;
  103832. /** @hidden */
  103833. protected _colorWrite: boolean;
  103834. /** @hidden */
  103835. protected _colorWriteChanged: boolean;
  103836. /** @hidden */
  103837. protected _depthCullingState: DepthCullingState;
  103838. /** @hidden */
  103839. protected _stencilState: StencilState;
  103840. /** @hidden */
  103841. _alphaState: AlphaState;
  103842. /** @hidden */
  103843. _alphaMode: number;
  103844. /** @hidden */
  103845. _alphaEquation: number;
  103846. /** @hidden */
  103847. _internalTexturesCache: InternalTexture[];
  103848. /** @hidden */
  103849. protected _activeChannel: number;
  103850. private _currentTextureChannel;
  103851. /** @hidden */
  103852. protected _boundTexturesCache: {
  103853. [key: string]: Nullable<InternalTexture>;
  103854. };
  103855. /** @hidden */
  103856. protected _currentEffect: Nullable<Effect>;
  103857. /** @hidden */
  103858. protected _currentProgram: Nullable<WebGLProgram>;
  103859. private _compiledEffects;
  103860. private _vertexAttribArraysEnabled;
  103861. /** @hidden */
  103862. protected _cachedViewport: Nullable<IViewportLike>;
  103863. private _cachedVertexArrayObject;
  103864. /** @hidden */
  103865. protected _cachedVertexBuffers: any;
  103866. /** @hidden */
  103867. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  103868. /** @hidden */
  103869. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  103870. /** @hidden */
  103871. _currentRenderTarget: Nullable<InternalTexture>;
  103872. private _uintIndicesCurrentlySet;
  103873. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  103874. /** @hidden */
  103875. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  103876. private _currentBufferPointers;
  103877. private _currentInstanceLocations;
  103878. private _currentInstanceBuffers;
  103879. private _textureUnits;
  103880. /** @hidden */
  103881. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103882. /** @hidden */
  103883. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103884. /** @hidden */
  103885. _boundRenderFunction: any;
  103886. private _vaoRecordInProgress;
  103887. private _mustWipeVertexAttributes;
  103888. private _emptyTexture;
  103889. private _emptyCubeTexture;
  103890. private _emptyTexture3D;
  103891. private _emptyTexture2DArray;
  103892. /** @hidden */
  103893. _frameHandler: number;
  103894. private _nextFreeTextureSlots;
  103895. private _maxSimultaneousTextures;
  103896. private _activeRequests;
  103897. protected _texturesSupported: string[];
  103898. /** @hidden */
  103899. _textureFormatInUse: Nullable<string>;
  103900. protected get _supportsHardwareTextureRescaling(): boolean;
  103901. /**
  103902. * Gets the list of texture formats supported
  103903. */
  103904. get texturesSupported(): Array<string>;
  103905. /**
  103906. * Gets the list of texture formats in use
  103907. */
  103908. get textureFormatInUse(): Nullable<string>;
  103909. /**
  103910. * Gets the current viewport
  103911. */
  103912. get currentViewport(): Nullable<IViewportLike>;
  103913. /**
  103914. * Gets the default empty texture
  103915. */
  103916. get emptyTexture(): InternalTexture;
  103917. /**
  103918. * Gets the default empty 3D texture
  103919. */
  103920. get emptyTexture3D(): InternalTexture;
  103921. /**
  103922. * Gets the default empty 2D array texture
  103923. */
  103924. get emptyTexture2DArray(): InternalTexture;
  103925. /**
  103926. * Gets the default empty cube texture
  103927. */
  103928. get emptyCubeTexture(): InternalTexture;
  103929. /**
  103930. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  103931. */
  103932. readonly premultipliedAlpha: boolean;
  103933. /**
  103934. * Observable event triggered before each texture is initialized
  103935. */
  103936. onBeforeTextureInitObservable: Observable<Texture>;
  103937. /**
  103938. * Creates a new engine
  103939. * @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
  103940. * @param antialias defines enable antialiasing (default: false)
  103941. * @param options defines further options to be sent to the getContext() function
  103942. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103943. */
  103944. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103945. private _rebuildInternalTextures;
  103946. private _rebuildEffects;
  103947. /**
  103948. * Gets a boolean indicating if all created effects are ready
  103949. * @returns true if all effects are ready
  103950. */
  103951. areAllEffectsReady(): boolean;
  103952. protected _rebuildBuffers(): void;
  103953. private _initGLContext;
  103954. /**
  103955. * Gets version of the current webGL context
  103956. */
  103957. get webGLVersion(): number;
  103958. /**
  103959. * Gets a string idenfifying the name of the class
  103960. * @returns "Engine" string
  103961. */
  103962. getClassName(): string;
  103963. /**
  103964. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  103965. */
  103966. get isStencilEnable(): boolean;
  103967. /** @hidden */
  103968. _prepareWorkingCanvas(): void;
  103969. /**
  103970. * Reset the texture cache to empty state
  103971. */
  103972. resetTextureCache(): void;
  103973. /**
  103974. * Gets an object containing information about the current webGL context
  103975. * @returns an object containing the vender, the renderer and the version of the current webGL context
  103976. */
  103977. getGlInfo(): {
  103978. vendor: string;
  103979. renderer: string;
  103980. version: string;
  103981. };
  103982. /**
  103983. * Defines the hardware scaling level.
  103984. * By default the hardware scaling level is computed from the window device ratio.
  103985. * 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.
  103986. * @param level defines the level to use
  103987. */
  103988. setHardwareScalingLevel(level: number): void;
  103989. /**
  103990. * Gets the current hardware scaling level.
  103991. * By default the hardware scaling level is computed from the window device ratio.
  103992. * 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.
  103993. * @returns a number indicating the current hardware scaling level
  103994. */
  103995. getHardwareScalingLevel(): number;
  103996. /**
  103997. * Gets the list of loaded textures
  103998. * @returns an array containing all loaded textures
  103999. */
  104000. getLoadedTexturesCache(): InternalTexture[];
  104001. /**
  104002. * Gets the object containing all engine capabilities
  104003. * @returns the EngineCapabilities object
  104004. */
  104005. getCaps(): EngineCapabilities;
  104006. /**
  104007. * stop executing a render loop function and remove it from the execution array
  104008. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104009. */
  104010. stopRenderLoop(renderFunction?: () => void): void;
  104011. /** @hidden */
  104012. _renderLoop(): void;
  104013. /**
  104014. * Gets the HTML canvas attached with the current webGL context
  104015. * @returns a HTML canvas
  104016. */
  104017. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104018. /**
  104019. * Gets host window
  104020. * @returns the host window object
  104021. */
  104022. getHostWindow(): Nullable<Window>;
  104023. /**
  104024. * Gets the current render width
  104025. * @param useScreen defines if screen size must be used (or the current render target if any)
  104026. * @returns a number defining the current render width
  104027. */
  104028. getRenderWidth(useScreen?: boolean): number;
  104029. /**
  104030. * Gets the current render height
  104031. * @param useScreen defines if screen size must be used (or the current render target if any)
  104032. * @returns a number defining the current render height
  104033. */
  104034. getRenderHeight(useScreen?: boolean): number;
  104035. /**
  104036. * Can be used to override the current requestAnimationFrame requester.
  104037. * @hidden
  104038. */
  104039. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104040. /**
  104041. * Register and execute a render loop. The engine can have more than one render function
  104042. * @param renderFunction defines the function to continuously execute
  104043. */
  104044. runRenderLoop(renderFunction: () => void): void;
  104045. /**
  104046. * Clear the current render buffer or the current render target (if any is set up)
  104047. * @param color defines the color to use
  104048. * @param backBuffer defines if the back buffer must be cleared
  104049. * @param depth defines if the depth buffer must be cleared
  104050. * @param stencil defines if the stencil buffer must be cleared
  104051. */
  104052. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104053. private _viewportCached;
  104054. /** @hidden */
  104055. _viewport(x: number, y: number, width: number, height: number): void;
  104056. /**
  104057. * Set the WebGL's viewport
  104058. * @param viewport defines the viewport element to be used
  104059. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104060. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104061. */
  104062. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104063. /**
  104064. * Begin a new frame
  104065. */
  104066. beginFrame(): void;
  104067. /**
  104068. * Enf the current frame
  104069. */
  104070. endFrame(): void;
  104071. /**
  104072. * Resize the view according to the canvas' size
  104073. */
  104074. resize(): void;
  104075. /**
  104076. * Force a specific size of the canvas
  104077. * @param width defines the new canvas' width
  104078. * @param height defines the new canvas' height
  104079. */
  104080. setSize(width: number, height: number): void;
  104081. /**
  104082. * Binds the frame buffer to the specified texture.
  104083. * @param texture The texture to render to or null for the default canvas
  104084. * @param faceIndex The face of the texture to render to in case of cube texture
  104085. * @param requiredWidth The width of the target to render to
  104086. * @param requiredHeight The height of the target to render to
  104087. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104088. * @param lodLevel defines the lod level to bind to the frame buffer
  104089. * @param layer defines the 2d array index to bind to frame buffer to
  104090. */
  104091. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104092. /** @hidden */
  104093. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104094. /**
  104095. * Unbind the current render target texture from the webGL context
  104096. * @param texture defines the render target texture to unbind
  104097. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104098. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104099. */
  104100. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104101. /**
  104102. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104103. */
  104104. flushFramebuffer(): void;
  104105. /**
  104106. * Unbind the current render target and bind the default framebuffer
  104107. */
  104108. restoreDefaultFramebuffer(): void;
  104109. /** @hidden */
  104110. protected _resetVertexBufferBinding(): void;
  104111. /**
  104112. * Creates a vertex buffer
  104113. * @param data the data for the vertex buffer
  104114. * @returns the new WebGL static buffer
  104115. */
  104116. createVertexBuffer(data: DataArray): DataBuffer;
  104117. private _createVertexBuffer;
  104118. /**
  104119. * Creates a dynamic vertex buffer
  104120. * @param data the data for the dynamic vertex buffer
  104121. * @returns the new WebGL dynamic buffer
  104122. */
  104123. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104124. protected _resetIndexBufferBinding(): void;
  104125. /**
  104126. * Creates a new index buffer
  104127. * @param indices defines the content of the index buffer
  104128. * @param updatable defines if the index buffer must be updatable
  104129. * @returns a new webGL buffer
  104130. */
  104131. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104132. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104133. /**
  104134. * Bind a webGL buffer to the webGL context
  104135. * @param buffer defines the buffer to bind
  104136. */
  104137. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104138. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104139. private bindBuffer;
  104140. /**
  104141. * update the bound buffer with the given data
  104142. * @param data defines the data to update
  104143. */
  104144. updateArrayBuffer(data: Float32Array): void;
  104145. private _vertexAttribPointer;
  104146. /** @hidden */
  104147. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104148. private _bindVertexBuffersAttributes;
  104149. /**
  104150. * Records a vertex array object
  104151. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104152. * @param vertexBuffers defines the list of vertex buffers to store
  104153. * @param indexBuffer defines the index buffer to store
  104154. * @param effect defines the effect to store
  104155. * @returns the new vertex array object
  104156. */
  104157. recordVertexArrayObject(vertexBuffers: {
  104158. [key: string]: VertexBuffer;
  104159. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104160. /**
  104161. * Bind a specific vertex array object
  104162. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104163. * @param vertexArrayObject defines the vertex array object to bind
  104164. * @param indexBuffer defines the index buffer to bind
  104165. */
  104166. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104167. /**
  104168. * Bind webGl buffers directly to the webGL context
  104169. * @param vertexBuffer defines the vertex buffer to bind
  104170. * @param indexBuffer defines the index buffer to bind
  104171. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104172. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104173. * @param effect defines the effect associated with the vertex buffer
  104174. */
  104175. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104176. private _unbindVertexArrayObject;
  104177. /**
  104178. * Bind a list of vertex buffers to the webGL context
  104179. * @param vertexBuffers defines the list of vertex buffers to bind
  104180. * @param indexBuffer defines the index buffer to bind
  104181. * @param effect defines the effect associated with the vertex buffers
  104182. */
  104183. bindBuffers(vertexBuffers: {
  104184. [key: string]: Nullable<VertexBuffer>;
  104185. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104186. /**
  104187. * Unbind all instance attributes
  104188. */
  104189. unbindInstanceAttributes(): void;
  104190. /**
  104191. * Release and free the memory of a vertex array object
  104192. * @param vao defines the vertex array object to delete
  104193. */
  104194. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104195. /** @hidden */
  104196. _releaseBuffer(buffer: DataBuffer): boolean;
  104197. protected _deleteBuffer(buffer: DataBuffer): void;
  104198. /**
  104199. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104200. * @param instancesBuffer defines the webGL buffer to update and bind
  104201. * @param data defines the data to store in the buffer
  104202. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104203. */
  104204. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104205. /**
  104206. * Bind the content of a webGL buffer used with instantiation
  104207. * @param instancesBuffer defines the webGL buffer to bind
  104208. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104209. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104210. */
  104211. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104212. /**
  104213. * Disable the instance attribute corresponding to the name in parameter
  104214. * @param name defines the name of the attribute to disable
  104215. */
  104216. disableInstanceAttributeByName(name: string): void;
  104217. /**
  104218. * Disable the instance attribute corresponding to the location in parameter
  104219. * @param attributeLocation defines the attribute location of the attribute to disable
  104220. */
  104221. disableInstanceAttribute(attributeLocation: number): void;
  104222. /**
  104223. * Disable the attribute corresponding to the location in parameter
  104224. * @param attributeLocation defines the attribute location of the attribute to disable
  104225. */
  104226. disableAttributeByIndex(attributeLocation: number): void;
  104227. /**
  104228. * Send a draw order
  104229. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104230. * @param indexStart defines the starting index
  104231. * @param indexCount defines the number of index to draw
  104232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104233. */
  104234. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104235. /**
  104236. * Draw a list of points
  104237. * @param verticesStart defines the index of first vertex to draw
  104238. * @param verticesCount defines the count of vertices to draw
  104239. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104240. */
  104241. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104242. /**
  104243. * Draw a list of unindexed primitives
  104244. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104245. * @param verticesStart defines the index of first vertex to draw
  104246. * @param verticesCount defines the count of vertices to draw
  104247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104248. */
  104249. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104250. /**
  104251. * Draw a list of indexed primitives
  104252. * @param fillMode defines the primitive to use
  104253. * @param indexStart defines the starting index
  104254. * @param indexCount defines the number of index to draw
  104255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104256. */
  104257. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104258. /**
  104259. * Draw a list of unindexed primitives
  104260. * @param fillMode defines the primitive to use
  104261. * @param verticesStart defines the index of first vertex to draw
  104262. * @param verticesCount defines the count of vertices to draw
  104263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104264. */
  104265. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104266. private _drawMode;
  104267. /** @hidden */
  104268. protected _reportDrawCall(): void;
  104269. /** @hidden */
  104270. _releaseEffect(effect: Effect): void;
  104271. /** @hidden */
  104272. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104273. /**
  104274. * Create a new effect (used to store vertex/fragment shaders)
  104275. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104276. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104277. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104278. * @param samplers defines an array of string used to represent textures
  104279. * @param defines defines the string containing the defines to use to compile the shaders
  104280. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104281. * @param onCompiled defines a function to call when the effect creation is successful
  104282. * @param onError defines a function to call when the effect creation has failed
  104283. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104284. * @returns the new Effect
  104285. */
  104286. 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;
  104287. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104288. private _compileShader;
  104289. private _compileRawShader;
  104290. /**
  104291. * Directly creates a webGL program
  104292. * @param pipelineContext defines the pipeline context to attach to
  104293. * @param vertexCode defines the vertex shader code to use
  104294. * @param fragmentCode defines the fragment shader code to use
  104295. * @param context defines the webGL context to use (if not set, the current one will be used)
  104296. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104297. * @returns the new webGL program
  104298. */
  104299. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104300. /**
  104301. * Creates a webGL program
  104302. * @param pipelineContext defines the pipeline context to attach to
  104303. * @param vertexCode defines the vertex shader code to use
  104304. * @param fragmentCode defines the fragment shader code to use
  104305. * @param defines defines the string containing the defines to use to compile the shaders
  104306. * @param context defines the webGL context to use (if not set, the current one will be used)
  104307. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104308. * @returns the new webGL program
  104309. */
  104310. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104311. /**
  104312. * Creates a new pipeline context
  104313. * @returns the new pipeline
  104314. */
  104315. createPipelineContext(): IPipelineContext;
  104316. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104317. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104318. /** @hidden */
  104319. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104320. /** @hidden */
  104321. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104322. /** @hidden */
  104323. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104324. /**
  104325. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104326. * @param pipelineContext defines the pipeline context to use
  104327. * @param uniformsNames defines the list of uniform names
  104328. * @returns an array of webGL uniform locations
  104329. */
  104330. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104331. /**
  104332. * Gets the lsit of active attributes for a given webGL program
  104333. * @param pipelineContext defines the pipeline context to use
  104334. * @param attributesNames defines the list of attribute names to get
  104335. * @returns an array of indices indicating the offset of each attribute
  104336. */
  104337. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104338. /**
  104339. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104340. * @param effect defines the effect to activate
  104341. */
  104342. enableEffect(effect: Nullable<Effect>): void;
  104343. /**
  104344. * Set the value of an uniform to a number (int)
  104345. * @param uniform defines the webGL uniform location where to store the value
  104346. * @param value defines the int number to store
  104347. */
  104348. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104349. /**
  104350. * Set the value of an uniform to an array of int32
  104351. * @param uniform defines the webGL uniform location where to store the value
  104352. * @param array defines the array of int32 to store
  104353. */
  104354. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104355. /**
  104356. * Set the value of an uniform to an array of int32 (stored as vec2)
  104357. * @param uniform defines the webGL uniform location where to store the value
  104358. * @param array defines the array of int32 to store
  104359. */
  104360. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104361. /**
  104362. * Set the value of an uniform to an array of int32 (stored as vec3)
  104363. * @param uniform defines the webGL uniform location where to store the value
  104364. * @param array defines the array of int32 to store
  104365. */
  104366. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104367. /**
  104368. * Set the value of an uniform to an array of int32 (stored as vec4)
  104369. * @param uniform defines the webGL uniform location where to store the value
  104370. * @param array defines the array of int32 to store
  104371. */
  104372. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104373. /**
  104374. * Set the value of an uniform to an array of number
  104375. * @param uniform defines the webGL uniform location where to store the value
  104376. * @param array defines the array of number to store
  104377. */
  104378. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104379. /**
  104380. * Set the value of an uniform to an array of number (stored as vec2)
  104381. * @param uniform defines the webGL uniform location where to store the value
  104382. * @param array defines the array of number to store
  104383. */
  104384. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104385. /**
  104386. * Set the value of an uniform to an array of number (stored as vec3)
  104387. * @param uniform defines the webGL uniform location where to store the value
  104388. * @param array defines the array of number to store
  104389. */
  104390. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104391. /**
  104392. * Set the value of an uniform to an array of number (stored as vec4)
  104393. * @param uniform defines the webGL uniform location where to store the value
  104394. * @param array defines the array of number to store
  104395. */
  104396. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104397. /**
  104398. * Set the value of an uniform to an array of float32 (stored as matrices)
  104399. * @param uniform defines the webGL uniform location where to store the value
  104400. * @param matrices defines the array of float32 to store
  104401. */
  104402. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104403. /**
  104404. * Set the value of an uniform to a matrix (3x3)
  104405. * @param uniform defines the webGL uniform location where to store the value
  104406. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104407. */
  104408. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104409. /**
  104410. * Set the value of an uniform to a matrix (2x2)
  104411. * @param uniform defines the webGL uniform location where to store the value
  104412. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104413. */
  104414. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104415. /**
  104416. * Set the value of an uniform to a number (float)
  104417. * @param uniform defines the webGL uniform location where to store the value
  104418. * @param value defines the float number to store
  104419. */
  104420. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104421. /**
  104422. * Set the value of an uniform to a vec2
  104423. * @param uniform defines the webGL uniform location where to store the value
  104424. * @param x defines the 1st component of the value
  104425. * @param y defines the 2nd component of the value
  104426. */
  104427. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104428. /**
  104429. * Set the value of an uniform to a vec3
  104430. * @param uniform defines the webGL uniform location where to store the value
  104431. * @param x defines the 1st component of the value
  104432. * @param y defines the 2nd component of the value
  104433. * @param z defines the 3rd component of the value
  104434. */
  104435. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104436. /**
  104437. * Set the value of an uniform to a vec4
  104438. * @param uniform defines the webGL uniform location where to store the value
  104439. * @param x defines the 1st component of the value
  104440. * @param y defines the 2nd component of the value
  104441. * @param z defines the 3rd component of the value
  104442. * @param w defines the 4th component of the value
  104443. */
  104444. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104445. /**
  104446. * Apply all cached states (depth, culling, stencil and alpha)
  104447. */
  104448. applyStates(): void;
  104449. /**
  104450. * Enable or disable color writing
  104451. * @param enable defines the state to set
  104452. */
  104453. setColorWrite(enable: boolean): void;
  104454. /**
  104455. * Gets a boolean indicating if color writing is enabled
  104456. * @returns the current color writing state
  104457. */
  104458. getColorWrite(): boolean;
  104459. /**
  104460. * Gets the depth culling state manager
  104461. */
  104462. get depthCullingState(): DepthCullingState;
  104463. /**
  104464. * Gets the alpha state manager
  104465. */
  104466. get alphaState(): AlphaState;
  104467. /**
  104468. * Gets the stencil state manager
  104469. */
  104470. get stencilState(): StencilState;
  104471. /**
  104472. * Clears the list of texture accessible through engine.
  104473. * This can help preventing texture load conflict due to name collision.
  104474. */
  104475. clearInternalTexturesCache(): void;
  104476. /**
  104477. * Force the entire cache to be cleared
  104478. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104479. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104480. */
  104481. wipeCaches(bruteForce?: boolean): void;
  104482. /** @hidden */
  104483. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104484. min: number;
  104485. mag: number;
  104486. };
  104487. /** @hidden */
  104488. _createTexture(): WebGLTexture;
  104489. /**
  104490. * Usually called from Texture.ts.
  104491. * Passed information to create a WebGLTexture
  104492. * @param urlArg defines a value which contains one of the following:
  104493. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104494. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104495. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104496. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104497. * @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)
  104498. * @param scene needed for loading to the correct scene
  104499. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104500. * @param onLoad optional callback to be called upon successful completion
  104501. * @param onError optional callback to be called upon failure
  104502. * @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
  104503. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104504. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104505. * @param forcedExtension defines the extension to use to pick the right loader
  104506. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  104507. * @param mimeType defines an optional mime type
  104508. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104509. */
  104510. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  104511. /**
  104512. * Loads an image as an HTMLImageElement.
  104513. * @param input url string, ArrayBuffer, or Blob to load
  104514. * @param onLoad callback called when the image successfully loads
  104515. * @param onError callback called when the image fails to load
  104516. * @param offlineProvider offline provider for caching
  104517. * @param mimeType optional mime type
  104518. * @returns the HTMLImageElement of the loaded image
  104519. * @hidden
  104520. */
  104521. 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>;
  104522. /**
  104523. * @hidden
  104524. */
  104525. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104526. /**
  104527. * Creates a raw texture
  104528. * @param data defines the data to store in the texture
  104529. * @param width defines the width of the texture
  104530. * @param height defines the height of the texture
  104531. * @param format defines the format of the data
  104532. * @param generateMipMaps defines if the engine should generate the mip levels
  104533. * @param invertY defines if data must be stored with Y axis inverted
  104534. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104535. * @param compression defines the compression used (null by default)
  104536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104537. * @returns the raw texture inside an InternalTexture
  104538. */
  104539. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104540. /**
  104541. * Creates a new raw cube texture
  104542. * @param data defines the array of data to use to create each face
  104543. * @param size defines the size of the textures
  104544. * @param format defines the format of the data
  104545. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104546. * @param generateMipMaps defines if the engine should generate the mip levels
  104547. * @param invertY defines if data must be stored with Y axis inverted
  104548. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104549. * @param compression defines the compression used (null by default)
  104550. * @returns the cube texture as an InternalTexture
  104551. */
  104552. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104553. /**
  104554. * Creates a new raw 3D texture
  104555. * @param data defines the data used to create the texture
  104556. * @param width defines the width of the texture
  104557. * @param height defines the height of the texture
  104558. * @param depth defines the depth of the texture
  104559. * @param format defines the format of the texture
  104560. * @param generateMipMaps defines if the engine must generate mip levels
  104561. * @param invertY defines if data must be stored with Y axis inverted
  104562. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104563. * @param compression defines the compressed used (can be null)
  104564. * @param textureType defines the compressed used (can be null)
  104565. * @returns a new raw 3D texture (stored in an InternalTexture)
  104566. */
  104567. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104568. /**
  104569. * Creates a new raw 2D array texture
  104570. * @param data defines the data used to create the texture
  104571. * @param width defines the width of the texture
  104572. * @param height defines the height of the texture
  104573. * @param depth defines the number of layers of the texture
  104574. * @param format defines the format of the texture
  104575. * @param generateMipMaps defines if the engine must generate mip levels
  104576. * @param invertY defines if data must be stored with Y axis inverted
  104577. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104578. * @param compression defines the compressed used (can be null)
  104579. * @param textureType defines the compressed used (can be null)
  104580. * @returns a new raw 2D array texture (stored in an InternalTexture)
  104581. */
  104582. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104583. private _unpackFlipYCached;
  104584. /**
  104585. * In case you are sharing the context with other applications, it might
  104586. * be interested to not cache the unpack flip y state to ensure a consistent
  104587. * value would be set.
  104588. */
  104589. enableUnpackFlipYCached: boolean;
  104590. /** @hidden */
  104591. _unpackFlipY(value: boolean): void;
  104592. /** @hidden */
  104593. _getUnpackAlignement(): number;
  104594. private _getTextureTarget;
  104595. /**
  104596. * Update the sampling mode of a given texture
  104597. * @param samplingMode defines the required sampling mode
  104598. * @param texture defines the texture to update
  104599. * @param generateMipMaps defines whether to generate mipmaps for the texture
  104600. */
  104601. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  104602. /**
  104603. * Update the sampling mode of a given texture
  104604. * @param texture defines the texture to update
  104605. * @param wrapU defines the texture wrap mode of the u coordinates
  104606. * @param wrapV defines the texture wrap mode of the v coordinates
  104607. * @param wrapR defines the texture wrap mode of the r coordinates
  104608. */
  104609. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  104610. /** @hidden */
  104611. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  104612. width: number;
  104613. height: number;
  104614. layers?: number;
  104615. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  104616. /** @hidden */
  104617. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104618. /** @hidden */
  104619. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  104620. /**
  104621. * Update a portion of an internal texture
  104622. * @param texture defines the texture to update
  104623. * @param imageData defines the data to store into the texture
  104624. * @param xOffset defines the x coordinates of the update rectangle
  104625. * @param yOffset defines the y coordinates of the update rectangle
  104626. * @param width defines the width of the update rectangle
  104627. * @param height defines the height of the update rectangle
  104628. * @param faceIndex defines the face index if texture is a cube (0 by default)
  104629. * @param lod defines the lod level to update (0 by default)
  104630. */
  104631. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  104632. /** @hidden */
  104633. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104634. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  104635. private _prepareWebGLTexture;
  104636. /** @hidden */
  104637. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  104638. private _getDepthStencilBuffer;
  104639. /** @hidden */
  104640. _releaseFramebufferObjects(texture: InternalTexture): void;
  104641. /** @hidden */
  104642. _releaseTexture(texture: InternalTexture): void;
  104643. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  104644. protected _setProgram(program: WebGLProgram): void;
  104645. protected _boundUniforms: {
  104646. [key: number]: WebGLUniformLocation;
  104647. };
  104648. /**
  104649. * Binds an effect to the webGL context
  104650. * @param effect defines the effect to bind
  104651. */
  104652. bindSamplers(effect: Effect): void;
  104653. private _activateCurrentTexture;
  104654. /** @hidden */
  104655. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  104656. /** @hidden */
  104657. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  104658. /**
  104659. * Unbind all textures from the webGL context
  104660. */
  104661. unbindAllTextures(): void;
  104662. /**
  104663. * Sets a texture to the according uniform.
  104664. * @param channel The texture channel
  104665. * @param uniform The uniform to set
  104666. * @param texture The texture to apply
  104667. */
  104668. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  104669. private _bindSamplerUniformToChannel;
  104670. private _getTextureWrapMode;
  104671. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  104672. /**
  104673. * Sets an array of texture to the webGL context
  104674. * @param channel defines the channel where the texture array must be set
  104675. * @param uniform defines the associated uniform location
  104676. * @param textures defines the array of textures to bind
  104677. */
  104678. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  104679. /** @hidden */
  104680. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  104681. private _setTextureParameterFloat;
  104682. private _setTextureParameterInteger;
  104683. /**
  104684. * Unbind all vertex attributes from the webGL context
  104685. */
  104686. unbindAllAttributes(): void;
  104687. /**
  104688. * 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
  104689. */
  104690. releaseEffects(): void;
  104691. /**
  104692. * Dispose and release all associated resources
  104693. */
  104694. dispose(): void;
  104695. /**
  104696. * Attach a new callback raised when context lost event is fired
  104697. * @param callback defines the callback to call
  104698. */
  104699. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104700. /**
  104701. * Attach a new callback raised when context restored event is fired
  104702. * @param callback defines the callback to call
  104703. */
  104704. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104705. /**
  104706. * Get the current error code of the webGL context
  104707. * @returns the error code
  104708. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104709. */
  104710. getError(): number;
  104711. private _canRenderToFloatFramebuffer;
  104712. private _canRenderToHalfFloatFramebuffer;
  104713. private _canRenderToFramebuffer;
  104714. /** @hidden */
  104715. _getWebGLTextureType(type: number): number;
  104716. /** @hidden */
  104717. _getInternalFormat(format: number): number;
  104718. /** @hidden */
  104719. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  104720. /** @hidden */
  104721. _getRGBAMultiSampleBufferFormat(type: number): number;
  104722. /** @hidden */
  104723. _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;
  104724. /**
  104725. * Loads a file from a url
  104726. * @param url url to load
  104727. * @param onSuccess callback called when the file successfully loads
  104728. * @param onProgress callback called while file is loading (if the server supports this mode)
  104729. * @param offlineProvider defines the offline provider for caching
  104730. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104731. * @param onError callback called when the file fails to load
  104732. * @returns a file request object
  104733. * @hidden
  104734. */
  104735. 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;
  104736. /**
  104737. * Reads pixels from the current frame buffer. Please note that this function can be slow
  104738. * @param x defines the x coordinate of the rectangle where pixels must be read
  104739. * @param y defines the y coordinate of the rectangle where pixels must be read
  104740. * @param width defines the width of the rectangle where pixels must be read
  104741. * @param height defines the height of the rectangle where pixels must be read
  104742. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  104743. * @returns a Uint8Array containing RGBA colors
  104744. */
  104745. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  104746. private static _isSupported;
  104747. /**
  104748. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  104749. * @returns true if the engine can be created
  104750. * @ignorenaming
  104751. */
  104752. static isSupported(): boolean;
  104753. /**
  104754. * Find the next highest power of two.
  104755. * @param x Number to start search from.
  104756. * @return Next highest power of two.
  104757. */
  104758. static CeilingPOT(x: number): number;
  104759. /**
  104760. * Find the next lowest power of two.
  104761. * @param x Number to start search from.
  104762. * @return Next lowest power of two.
  104763. */
  104764. static FloorPOT(x: number): number;
  104765. /**
  104766. * Find the nearest power of two.
  104767. * @param x Number to start search from.
  104768. * @return Next nearest power of two.
  104769. */
  104770. static NearestPOT(x: number): number;
  104771. /**
  104772. * Get the closest exponent of two
  104773. * @param value defines the value to approximate
  104774. * @param max defines the maximum value to return
  104775. * @param mode defines how to define the closest value
  104776. * @returns closest exponent of two of the given value
  104777. */
  104778. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  104779. /**
  104780. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  104781. * @param func - the function to be called
  104782. * @param requester - the object that will request the next frame. Falls back to window.
  104783. * @returns frame number
  104784. */
  104785. static QueueNewFrame(func: () => void, requester?: any): number;
  104786. /**
  104787. * Gets host document
  104788. * @returns the host document object
  104789. */
  104790. getHostDocument(): Nullable<Document>;
  104791. }
  104792. }
  104793. declare module BABYLON {
  104794. /**
  104795. * Class representing spherical harmonics coefficients to the 3rd degree
  104796. */
  104797. export class SphericalHarmonics {
  104798. /**
  104799. * Defines whether or not the harmonics have been prescaled for rendering.
  104800. */
  104801. preScaled: boolean;
  104802. /**
  104803. * The l0,0 coefficients of the spherical harmonics
  104804. */
  104805. l00: Vector3;
  104806. /**
  104807. * The l1,-1 coefficients of the spherical harmonics
  104808. */
  104809. l1_1: Vector3;
  104810. /**
  104811. * The l1,0 coefficients of the spherical harmonics
  104812. */
  104813. l10: Vector3;
  104814. /**
  104815. * The l1,1 coefficients of the spherical harmonics
  104816. */
  104817. l11: Vector3;
  104818. /**
  104819. * The l2,-2 coefficients of the spherical harmonics
  104820. */
  104821. l2_2: Vector3;
  104822. /**
  104823. * The l2,-1 coefficients of the spherical harmonics
  104824. */
  104825. l2_1: Vector3;
  104826. /**
  104827. * The l2,0 coefficients of the spherical harmonics
  104828. */
  104829. l20: Vector3;
  104830. /**
  104831. * The l2,1 coefficients of the spherical harmonics
  104832. */
  104833. l21: Vector3;
  104834. /**
  104835. * The l2,2 coefficients of the spherical harmonics
  104836. */
  104837. l22: Vector3;
  104838. /**
  104839. * Adds a light to the spherical harmonics
  104840. * @param direction the direction of the light
  104841. * @param color the color of the light
  104842. * @param deltaSolidAngle the delta solid angle of the light
  104843. */
  104844. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  104845. /**
  104846. * Scales the spherical harmonics by the given amount
  104847. * @param scale the amount to scale
  104848. */
  104849. scaleInPlace(scale: number): void;
  104850. /**
  104851. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  104852. *
  104853. * ```
  104854. * E_lm = A_l * L_lm
  104855. * ```
  104856. *
  104857. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  104858. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  104859. * the scaling factors are given in equation 9.
  104860. */
  104861. convertIncidentRadianceToIrradiance(): void;
  104862. /**
  104863. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  104864. *
  104865. * ```
  104866. * L = (1/pi) * E * rho
  104867. * ```
  104868. *
  104869. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  104870. */
  104871. convertIrradianceToLambertianRadiance(): void;
  104872. /**
  104873. * Integrates the reconstruction coefficients directly in to the SH preventing further
  104874. * required operations at run time.
  104875. *
  104876. * This is simply done by scaling back the SH with Ylm constants parameter.
  104877. * The trigonometric part being applied by the shader at run time.
  104878. */
  104879. preScaleForRendering(): void;
  104880. /**
  104881. * Constructs a spherical harmonics from an array.
  104882. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  104883. * @returns the spherical harmonics
  104884. */
  104885. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  104886. /**
  104887. * Gets the spherical harmonics from polynomial
  104888. * @param polynomial the spherical polynomial
  104889. * @returns the spherical harmonics
  104890. */
  104891. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  104892. }
  104893. /**
  104894. * Class representing spherical polynomial coefficients to the 3rd degree
  104895. */
  104896. export class SphericalPolynomial {
  104897. private _harmonics;
  104898. /**
  104899. * The spherical harmonics used to create the polynomials.
  104900. */
  104901. get preScaledHarmonics(): SphericalHarmonics;
  104902. /**
  104903. * The x coefficients of the spherical polynomial
  104904. */
  104905. x: Vector3;
  104906. /**
  104907. * The y coefficients of the spherical polynomial
  104908. */
  104909. y: Vector3;
  104910. /**
  104911. * The z coefficients of the spherical polynomial
  104912. */
  104913. z: Vector3;
  104914. /**
  104915. * The xx coefficients of the spherical polynomial
  104916. */
  104917. xx: Vector3;
  104918. /**
  104919. * The yy coefficients of the spherical polynomial
  104920. */
  104921. yy: Vector3;
  104922. /**
  104923. * The zz coefficients of the spherical polynomial
  104924. */
  104925. zz: Vector3;
  104926. /**
  104927. * The xy coefficients of the spherical polynomial
  104928. */
  104929. xy: Vector3;
  104930. /**
  104931. * The yz coefficients of the spherical polynomial
  104932. */
  104933. yz: Vector3;
  104934. /**
  104935. * The zx coefficients of the spherical polynomial
  104936. */
  104937. zx: Vector3;
  104938. /**
  104939. * Adds an ambient color to the spherical polynomial
  104940. * @param color the color to add
  104941. */
  104942. addAmbient(color: Color3): void;
  104943. /**
  104944. * Scales the spherical polynomial by the given amount
  104945. * @param scale the amount to scale
  104946. */
  104947. scaleInPlace(scale: number): void;
  104948. /**
  104949. * Gets the spherical polynomial from harmonics
  104950. * @param harmonics the spherical harmonics
  104951. * @returns the spherical polynomial
  104952. */
  104953. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  104954. /**
  104955. * Constructs a spherical polynomial from an array.
  104956. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  104957. * @returns the spherical polynomial
  104958. */
  104959. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  104960. }
  104961. }
  104962. declare module BABYLON {
  104963. /**
  104964. * Defines the source of the internal texture
  104965. */
  104966. export enum InternalTextureSource {
  104967. /**
  104968. * The source of the texture data is unknown
  104969. */
  104970. Unknown = 0,
  104971. /**
  104972. * Texture data comes from an URL
  104973. */
  104974. Url = 1,
  104975. /**
  104976. * Texture data is only used for temporary storage
  104977. */
  104978. Temp = 2,
  104979. /**
  104980. * Texture data comes from raw data (ArrayBuffer)
  104981. */
  104982. Raw = 3,
  104983. /**
  104984. * Texture content is dynamic (video or dynamic texture)
  104985. */
  104986. Dynamic = 4,
  104987. /**
  104988. * Texture content is generated by rendering to it
  104989. */
  104990. RenderTarget = 5,
  104991. /**
  104992. * Texture content is part of a multi render target process
  104993. */
  104994. MultiRenderTarget = 6,
  104995. /**
  104996. * Texture data comes from a cube data file
  104997. */
  104998. Cube = 7,
  104999. /**
  105000. * Texture data comes from a raw cube data
  105001. */
  105002. CubeRaw = 8,
  105003. /**
  105004. * Texture data come from a prefiltered cube data file
  105005. */
  105006. CubePrefiltered = 9,
  105007. /**
  105008. * Texture content is raw 3D data
  105009. */
  105010. Raw3D = 10,
  105011. /**
  105012. * Texture content is raw 2D array data
  105013. */
  105014. Raw2DArray = 11,
  105015. /**
  105016. * Texture content is a depth texture
  105017. */
  105018. Depth = 12,
  105019. /**
  105020. * Texture data comes from a raw cube data encoded with RGBD
  105021. */
  105022. CubeRawRGBD = 13
  105023. }
  105024. /**
  105025. * Class used to store data associated with WebGL texture data for the engine
  105026. * This class should not be used directly
  105027. */
  105028. export class InternalTexture {
  105029. /** @hidden */
  105030. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105031. /**
  105032. * Defines if the texture is ready
  105033. */
  105034. isReady: boolean;
  105035. /**
  105036. * Defines if the texture is a cube texture
  105037. */
  105038. isCube: boolean;
  105039. /**
  105040. * Defines if the texture contains 3D data
  105041. */
  105042. is3D: boolean;
  105043. /**
  105044. * Defines if the texture contains 2D array data
  105045. */
  105046. is2DArray: boolean;
  105047. /**
  105048. * Defines if the texture contains multiview data
  105049. */
  105050. isMultiview: boolean;
  105051. /**
  105052. * Gets the URL used to load this texture
  105053. */
  105054. url: string;
  105055. /**
  105056. * Gets the sampling mode of the texture
  105057. */
  105058. samplingMode: number;
  105059. /**
  105060. * Gets a boolean indicating if the texture needs mipmaps generation
  105061. */
  105062. generateMipMaps: boolean;
  105063. /**
  105064. * Gets the number of samples used by the texture (WebGL2+ only)
  105065. */
  105066. samples: number;
  105067. /**
  105068. * Gets the type of the texture (int, float...)
  105069. */
  105070. type: number;
  105071. /**
  105072. * Gets the format of the texture (RGB, RGBA...)
  105073. */
  105074. format: number;
  105075. /**
  105076. * Observable called when the texture is loaded
  105077. */
  105078. onLoadedObservable: Observable<InternalTexture>;
  105079. /**
  105080. * Gets the width of the texture
  105081. */
  105082. width: number;
  105083. /**
  105084. * Gets the height of the texture
  105085. */
  105086. height: number;
  105087. /**
  105088. * Gets the depth of the texture
  105089. */
  105090. depth: number;
  105091. /**
  105092. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105093. */
  105094. baseWidth: number;
  105095. /**
  105096. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105097. */
  105098. baseHeight: number;
  105099. /**
  105100. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105101. */
  105102. baseDepth: number;
  105103. /**
  105104. * Gets a boolean indicating if the texture is inverted on Y axis
  105105. */
  105106. invertY: boolean;
  105107. /** @hidden */
  105108. _invertVScale: boolean;
  105109. /** @hidden */
  105110. _associatedChannel: number;
  105111. /** @hidden */
  105112. _source: InternalTextureSource;
  105113. /** @hidden */
  105114. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105115. /** @hidden */
  105116. _bufferView: Nullable<ArrayBufferView>;
  105117. /** @hidden */
  105118. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105119. /** @hidden */
  105120. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105121. /** @hidden */
  105122. _size: number;
  105123. /** @hidden */
  105124. _extension: string;
  105125. /** @hidden */
  105126. _files: Nullable<string[]>;
  105127. /** @hidden */
  105128. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105129. /** @hidden */
  105130. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105131. /** @hidden */
  105132. _framebuffer: Nullable<WebGLFramebuffer>;
  105133. /** @hidden */
  105134. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105135. /** @hidden */
  105136. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105137. /** @hidden */
  105138. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105139. /** @hidden */
  105140. _attachments: Nullable<number[]>;
  105141. /** @hidden */
  105142. _cachedCoordinatesMode: Nullable<number>;
  105143. /** @hidden */
  105144. _cachedWrapU: Nullable<number>;
  105145. /** @hidden */
  105146. _cachedWrapV: Nullable<number>;
  105147. /** @hidden */
  105148. _cachedWrapR: Nullable<number>;
  105149. /** @hidden */
  105150. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105151. /** @hidden */
  105152. _isDisabled: boolean;
  105153. /** @hidden */
  105154. _compression: Nullable<string>;
  105155. /** @hidden */
  105156. _generateStencilBuffer: boolean;
  105157. /** @hidden */
  105158. _generateDepthBuffer: boolean;
  105159. /** @hidden */
  105160. _comparisonFunction: number;
  105161. /** @hidden */
  105162. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105163. /** @hidden */
  105164. _lodGenerationScale: number;
  105165. /** @hidden */
  105166. _lodGenerationOffset: number;
  105167. /** @hidden */
  105168. _depthStencilTexture: Nullable<InternalTexture>;
  105169. /** @hidden */
  105170. _colorTextureArray: Nullable<WebGLTexture>;
  105171. /** @hidden */
  105172. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105173. /** @hidden */
  105174. _lodTextureHigh: Nullable<BaseTexture>;
  105175. /** @hidden */
  105176. _lodTextureMid: Nullable<BaseTexture>;
  105177. /** @hidden */
  105178. _lodTextureLow: Nullable<BaseTexture>;
  105179. /** @hidden */
  105180. _isRGBD: boolean;
  105181. /** @hidden */
  105182. _linearSpecularLOD: boolean;
  105183. /** @hidden */
  105184. _irradianceTexture: Nullable<BaseTexture>;
  105185. /** @hidden */
  105186. _webGLTexture: Nullable<WebGLTexture>;
  105187. /** @hidden */
  105188. _references: number;
  105189. private _engine;
  105190. /**
  105191. * Gets the Engine the texture belongs to.
  105192. * @returns The babylon engine
  105193. */
  105194. getEngine(): ThinEngine;
  105195. /**
  105196. * Gets the data source type of the texture
  105197. */
  105198. get source(): InternalTextureSource;
  105199. /**
  105200. * Creates a new InternalTexture
  105201. * @param engine defines the engine to use
  105202. * @param source defines the type of data that will be used
  105203. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105204. */
  105205. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105206. /**
  105207. * Increments the number of references (ie. the number of Texture that point to it)
  105208. */
  105209. incrementReferences(): void;
  105210. /**
  105211. * Change the size of the texture (not the size of the content)
  105212. * @param width defines the new width
  105213. * @param height defines the new height
  105214. * @param depth defines the new depth (1 by default)
  105215. */
  105216. updateSize(width: int, height: int, depth?: int): void;
  105217. /** @hidden */
  105218. _rebuild(): void;
  105219. /** @hidden */
  105220. _swapAndDie(target: InternalTexture): void;
  105221. /**
  105222. * Dispose the current allocated resources
  105223. */
  105224. dispose(): void;
  105225. }
  105226. }
  105227. declare module BABYLON {
  105228. /**
  105229. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105231. */
  105232. export class Analyser {
  105233. /**
  105234. * Gets or sets the smoothing
  105235. * @ignorenaming
  105236. */
  105237. SMOOTHING: number;
  105238. /**
  105239. * Gets or sets the FFT table size
  105240. * @ignorenaming
  105241. */
  105242. FFT_SIZE: number;
  105243. /**
  105244. * Gets or sets the bar graph amplitude
  105245. * @ignorenaming
  105246. */
  105247. BARGRAPHAMPLITUDE: number;
  105248. /**
  105249. * Gets or sets the position of the debug canvas
  105250. * @ignorenaming
  105251. */
  105252. DEBUGCANVASPOS: {
  105253. x: number;
  105254. y: number;
  105255. };
  105256. /**
  105257. * Gets or sets the debug canvas size
  105258. * @ignorenaming
  105259. */
  105260. DEBUGCANVASSIZE: {
  105261. width: number;
  105262. height: number;
  105263. };
  105264. private _byteFreqs;
  105265. private _byteTime;
  105266. private _floatFreqs;
  105267. private _webAudioAnalyser;
  105268. private _debugCanvas;
  105269. private _debugCanvasContext;
  105270. private _scene;
  105271. private _registerFunc;
  105272. private _audioEngine;
  105273. /**
  105274. * Creates a new analyser
  105275. * @param scene defines hosting scene
  105276. */
  105277. constructor(scene: Scene);
  105278. /**
  105279. * Get the number of data values you will have to play with for the visualization
  105280. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105281. * @returns a number
  105282. */
  105283. getFrequencyBinCount(): number;
  105284. /**
  105285. * Gets the current frequency data as a byte array
  105286. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105287. * @returns a Uint8Array
  105288. */
  105289. getByteFrequencyData(): Uint8Array;
  105290. /**
  105291. * Gets the current waveform as a byte array
  105292. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105293. * @returns a Uint8Array
  105294. */
  105295. getByteTimeDomainData(): Uint8Array;
  105296. /**
  105297. * Gets the current frequency data as a float array
  105298. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105299. * @returns a Float32Array
  105300. */
  105301. getFloatFrequencyData(): Float32Array;
  105302. /**
  105303. * Renders the debug canvas
  105304. */
  105305. drawDebugCanvas(): void;
  105306. /**
  105307. * Stops rendering the debug canvas and removes it
  105308. */
  105309. stopDebugCanvas(): void;
  105310. /**
  105311. * Connects two audio nodes
  105312. * @param inputAudioNode defines first node to connect
  105313. * @param outputAudioNode defines second node to connect
  105314. */
  105315. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105316. /**
  105317. * Releases all associated resources
  105318. */
  105319. dispose(): void;
  105320. }
  105321. }
  105322. declare module BABYLON {
  105323. /**
  105324. * This represents an audio engine and it is responsible
  105325. * to play, synchronize and analyse sounds throughout the application.
  105326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105327. */
  105328. export interface IAudioEngine extends IDisposable {
  105329. /**
  105330. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105331. */
  105332. readonly canUseWebAudio: boolean;
  105333. /**
  105334. * Gets the current AudioContext if available.
  105335. */
  105336. readonly audioContext: Nullable<AudioContext>;
  105337. /**
  105338. * The master gain node defines the global audio volume of your audio engine.
  105339. */
  105340. readonly masterGain: GainNode;
  105341. /**
  105342. * Gets whether or not mp3 are supported by your browser.
  105343. */
  105344. readonly isMP3supported: boolean;
  105345. /**
  105346. * Gets whether or not ogg are supported by your browser.
  105347. */
  105348. readonly isOGGsupported: boolean;
  105349. /**
  105350. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105351. * @ignoreNaming
  105352. */
  105353. WarnedWebAudioUnsupported: boolean;
  105354. /**
  105355. * Defines if the audio engine relies on a custom unlocked button.
  105356. * In this case, the embedded button will not be displayed.
  105357. */
  105358. useCustomUnlockedButton: boolean;
  105359. /**
  105360. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105361. */
  105362. readonly unlocked: boolean;
  105363. /**
  105364. * Event raised when audio has been unlocked on the browser.
  105365. */
  105366. onAudioUnlockedObservable: Observable<AudioEngine>;
  105367. /**
  105368. * Event raised when audio has been locked on the browser.
  105369. */
  105370. onAudioLockedObservable: Observable<AudioEngine>;
  105371. /**
  105372. * Flags the audio engine in Locked state.
  105373. * This happens due to new browser policies preventing audio to autoplay.
  105374. */
  105375. lock(): void;
  105376. /**
  105377. * Unlocks the audio engine once a user action has been done on the dom.
  105378. * This is helpful to resume play once browser policies have been satisfied.
  105379. */
  105380. unlock(): void;
  105381. }
  105382. /**
  105383. * This represents the default audio engine used in babylon.
  105384. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105386. */
  105387. export class AudioEngine implements IAudioEngine {
  105388. private _audioContext;
  105389. private _audioContextInitialized;
  105390. private _muteButton;
  105391. private _hostElement;
  105392. /**
  105393. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105394. */
  105395. canUseWebAudio: boolean;
  105396. /**
  105397. * The master gain node defines the global audio volume of your audio engine.
  105398. */
  105399. masterGain: GainNode;
  105400. /**
  105401. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105402. * @ignoreNaming
  105403. */
  105404. WarnedWebAudioUnsupported: boolean;
  105405. /**
  105406. * Gets whether or not mp3 are supported by your browser.
  105407. */
  105408. isMP3supported: boolean;
  105409. /**
  105410. * Gets whether or not ogg are supported by your browser.
  105411. */
  105412. isOGGsupported: boolean;
  105413. /**
  105414. * Gets whether audio has been unlocked on the device.
  105415. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105416. * a user interaction has happened.
  105417. */
  105418. unlocked: boolean;
  105419. /**
  105420. * Defines if the audio engine relies on a custom unlocked button.
  105421. * In this case, the embedded button will not be displayed.
  105422. */
  105423. useCustomUnlockedButton: boolean;
  105424. /**
  105425. * Event raised when audio has been unlocked on the browser.
  105426. */
  105427. onAudioUnlockedObservable: Observable<AudioEngine>;
  105428. /**
  105429. * Event raised when audio has been locked on the browser.
  105430. */
  105431. onAudioLockedObservable: Observable<AudioEngine>;
  105432. /**
  105433. * Gets the current AudioContext if available.
  105434. */
  105435. get audioContext(): Nullable<AudioContext>;
  105436. private _connectedAnalyser;
  105437. /**
  105438. * Instantiates a new audio engine.
  105439. *
  105440. * There should be only one per page as some browsers restrict the number
  105441. * of audio contexts you can create.
  105442. * @param hostElement defines the host element where to display the mute icon if necessary
  105443. */
  105444. constructor(hostElement?: Nullable<HTMLElement>);
  105445. /**
  105446. * Flags the audio engine in Locked state.
  105447. * This happens due to new browser policies preventing audio to autoplay.
  105448. */
  105449. lock(): void;
  105450. /**
  105451. * Unlocks the audio engine once a user action has been done on the dom.
  105452. * This is helpful to resume play once browser policies have been satisfied.
  105453. */
  105454. unlock(): void;
  105455. private _resumeAudioContext;
  105456. private _initializeAudioContext;
  105457. private _tryToRun;
  105458. private _triggerRunningState;
  105459. private _triggerSuspendedState;
  105460. private _displayMuteButton;
  105461. private _moveButtonToTopLeft;
  105462. private _onResize;
  105463. private _hideMuteButton;
  105464. /**
  105465. * Destroy and release the resources associated with the audio ccontext.
  105466. */
  105467. dispose(): void;
  105468. /**
  105469. * Gets the global volume sets on the master gain.
  105470. * @returns the global volume if set or -1 otherwise
  105471. */
  105472. getGlobalVolume(): number;
  105473. /**
  105474. * Sets the global volume of your experience (sets on the master gain).
  105475. * @param newVolume Defines the new global volume of the application
  105476. */
  105477. setGlobalVolume(newVolume: number): void;
  105478. /**
  105479. * Connect the audio engine to an audio analyser allowing some amazing
  105480. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105482. * @param analyser The analyser to connect to the engine
  105483. */
  105484. connectToAnalyser(analyser: Analyser): void;
  105485. }
  105486. }
  105487. declare module BABYLON {
  105488. /**
  105489. * Interface used to present a loading screen while loading a scene
  105490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105491. */
  105492. export interface ILoadingScreen {
  105493. /**
  105494. * Function called to display the loading screen
  105495. */
  105496. displayLoadingUI: () => void;
  105497. /**
  105498. * Function called to hide the loading screen
  105499. */
  105500. hideLoadingUI: () => void;
  105501. /**
  105502. * Gets or sets the color to use for the background
  105503. */
  105504. loadingUIBackgroundColor: string;
  105505. /**
  105506. * Gets or sets the text to display while loading
  105507. */
  105508. loadingUIText: string;
  105509. }
  105510. /**
  105511. * Class used for the default loading screen
  105512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105513. */
  105514. export class DefaultLoadingScreen implements ILoadingScreen {
  105515. private _renderingCanvas;
  105516. private _loadingText;
  105517. private _loadingDivBackgroundColor;
  105518. private _loadingDiv;
  105519. private _loadingTextDiv;
  105520. /** Gets or sets the logo url to use for the default loading screen */
  105521. static DefaultLogoUrl: string;
  105522. /** Gets or sets the spinner url to use for the default loading screen */
  105523. static DefaultSpinnerUrl: string;
  105524. /**
  105525. * Creates a new default loading screen
  105526. * @param _renderingCanvas defines the canvas used to render the scene
  105527. * @param _loadingText defines the default text to display
  105528. * @param _loadingDivBackgroundColor defines the default background color
  105529. */
  105530. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105531. /**
  105532. * Function called to display the loading screen
  105533. */
  105534. displayLoadingUI(): void;
  105535. /**
  105536. * Function called to hide the loading screen
  105537. */
  105538. hideLoadingUI(): void;
  105539. /**
  105540. * Gets or sets the text to display while loading
  105541. */
  105542. set loadingUIText(text: string);
  105543. get loadingUIText(): string;
  105544. /**
  105545. * Gets or sets the color to use for the background
  105546. */
  105547. get loadingUIBackgroundColor(): string;
  105548. set loadingUIBackgroundColor(color: string);
  105549. private _resizeLoadingUI;
  105550. }
  105551. }
  105552. declare module BABYLON {
  105553. /**
  105554. * Interface for any object that can request an animation frame
  105555. */
  105556. export interface ICustomAnimationFrameRequester {
  105557. /**
  105558. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105559. */
  105560. renderFunction?: Function;
  105561. /**
  105562. * Called to request the next frame to render to
  105563. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105564. */
  105565. requestAnimationFrame: Function;
  105566. /**
  105567. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  105568. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  105569. */
  105570. requestID?: number;
  105571. }
  105572. }
  105573. declare module BABYLON {
  105574. /**
  105575. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  105576. */
  105577. export class PerformanceMonitor {
  105578. private _enabled;
  105579. private _rollingFrameTime;
  105580. private _lastFrameTimeMs;
  105581. /**
  105582. * constructor
  105583. * @param frameSampleSize The number of samples required to saturate the sliding window
  105584. */
  105585. constructor(frameSampleSize?: number);
  105586. /**
  105587. * Samples current frame
  105588. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  105589. */
  105590. sampleFrame(timeMs?: number): void;
  105591. /**
  105592. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105593. */
  105594. get averageFrameTime(): number;
  105595. /**
  105596. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105597. */
  105598. get averageFrameTimeVariance(): number;
  105599. /**
  105600. * Returns the frame time of the most recent frame
  105601. */
  105602. get instantaneousFrameTime(): number;
  105603. /**
  105604. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  105605. */
  105606. get averageFPS(): number;
  105607. /**
  105608. * Returns the average framerate in frames per second using the most recent frame time
  105609. */
  105610. get instantaneousFPS(): number;
  105611. /**
  105612. * Returns true if enough samples have been taken to completely fill the sliding window
  105613. */
  105614. get isSaturated(): boolean;
  105615. /**
  105616. * Enables contributions to the sliding window sample set
  105617. */
  105618. enable(): void;
  105619. /**
  105620. * Disables contributions to the sliding window sample set
  105621. * Samples will not be interpolated over the disabled period
  105622. */
  105623. disable(): void;
  105624. /**
  105625. * Returns true if sampling is enabled
  105626. */
  105627. get isEnabled(): boolean;
  105628. /**
  105629. * Resets performance monitor
  105630. */
  105631. reset(): void;
  105632. }
  105633. /**
  105634. * RollingAverage
  105635. *
  105636. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  105637. */
  105638. export class RollingAverage {
  105639. /**
  105640. * Current average
  105641. */
  105642. average: number;
  105643. /**
  105644. * Current variance
  105645. */
  105646. variance: number;
  105647. protected _samples: Array<number>;
  105648. protected _sampleCount: number;
  105649. protected _pos: number;
  105650. protected _m2: number;
  105651. /**
  105652. * constructor
  105653. * @param length The number of samples required to saturate the sliding window
  105654. */
  105655. constructor(length: number);
  105656. /**
  105657. * Adds a sample to the sample set
  105658. * @param v The sample value
  105659. */
  105660. add(v: number): void;
  105661. /**
  105662. * Returns previously added values or null if outside of history or outside the sliding window domain
  105663. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  105664. * @return Value previously recorded with add() or null if outside of range
  105665. */
  105666. history(i: number): number;
  105667. /**
  105668. * Returns true if enough samples have been taken to completely fill the sliding window
  105669. * @return true if sample-set saturated
  105670. */
  105671. isSaturated(): boolean;
  105672. /**
  105673. * Resets the rolling average (equivalent to 0 samples taken so far)
  105674. */
  105675. reset(): void;
  105676. /**
  105677. * Wraps a value around the sample range boundaries
  105678. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  105679. * @return Wrapped position in sample range
  105680. */
  105681. protected _wrapPosition(i: number): number;
  105682. }
  105683. }
  105684. declare module BABYLON {
  105685. /**
  105686. * This class is used to track a performance counter which is number based.
  105687. * The user has access to many properties which give statistics of different nature.
  105688. *
  105689. * The implementer can track two kinds of Performance Counter: time and count.
  105690. * 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.
  105691. * 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.
  105692. */
  105693. export class PerfCounter {
  105694. /**
  105695. * Gets or sets a global boolean to turn on and off all the counters
  105696. */
  105697. static Enabled: boolean;
  105698. /**
  105699. * Returns the smallest value ever
  105700. */
  105701. get min(): number;
  105702. /**
  105703. * Returns the biggest value ever
  105704. */
  105705. get max(): number;
  105706. /**
  105707. * Returns the average value since the performance counter is running
  105708. */
  105709. get average(): number;
  105710. /**
  105711. * Returns the average value of the last second the counter was monitored
  105712. */
  105713. get lastSecAverage(): number;
  105714. /**
  105715. * Returns the current value
  105716. */
  105717. get current(): number;
  105718. /**
  105719. * Gets the accumulated total
  105720. */
  105721. get total(): number;
  105722. /**
  105723. * Gets the total value count
  105724. */
  105725. get count(): number;
  105726. /**
  105727. * Creates a new counter
  105728. */
  105729. constructor();
  105730. /**
  105731. * Call this method to start monitoring a new frame.
  105732. * 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.
  105733. */
  105734. fetchNewFrame(): void;
  105735. /**
  105736. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  105737. * @param newCount the count value to add to the monitored count
  105738. * @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.
  105739. */
  105740. addCount(newCount: number, fetchResult: boolean): void;
  105741. /**
  105742. * Start monitoring this performance counter
  105743. */
  105744. beginMonitoring(): void;
  105745. /**
  105746. * Compute the time lapsed since the previous beginMonitoring() call.
  105747. * @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
  105748. */
  105749. endMonitoring(newFrame?: boolean): void;
  105750. private _fetchResult;
  105751. private _startMonitoringTime;
  105752. private _min;
  105753. private _max;
  105754. private _average;
  105755. private _current;
  105756. private _totalValueCount;
  105757. private _totalAccumulated;
  105758. private _lastSecAverage;
  105759. private _lastSecAccumulated;
  105760. private _lastSecTime;
  105761. private _lastSecValueCount;
  105762. }
  105763. }
  105764. declare module BABYLON {
  105765. interface ThinEngine {
  105766. /**
  105767. * Sets alpha constants used by some alpha blending modes
  105768. * @param r defines the red component
  105769. * @param g defines the green component
  105770. * @param b defines the blue component
  105771. * @param a defines the alpha component
  105772. */
  105773. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  105774. /**
  105775. * Sets the current alpha mode
  105776. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  105777. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  105778. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105779. */
  105780. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105781. /**
  105782. * Gets the current alpha mode
  105783. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105784. * @returns the current alpha mode
  105785. */
  105786. getAlphaMode(): number;
  105787. /**
  105788. * Sets the current alpha equation
  105789. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  105790. */
  105791. setAlphaEquation(equation: number): void;
  105792. /**
  105793. * Gets the current alpha equation.
  105794. * @returns the current alpha equation
  105795. */
  105796. getAlphaEquation(): number;
  105797. }
  105798. }
  105799. declare module BABYLON {
  105800. /**
  105801. * Defines the interface used by display changed events
  105802. */
  105803. export interface IDisplayChangedEventArgs {
  105804. /** Gets the vrDisplay object (if any) */
  105805. vrDisplay: Nullable<any>;
  105806. /** Gets a boolean indicating if webVR is supported */
  105807. vrSupported: boolean;
  105808. }
  105809. /**
  105810. * Defines the interface used by objects containing a viewport (like a camera)
  105811. */
  105812. interface IViewportOwnerLike {
  105813. /**
  105814. * Gets or sets the viewport
  105815. */
  105816. viewport: IViewportLike;
  105817. }
  105818. /**
  105819. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  105820. */
  105821. export class Engine extends ThinEngine {
  105822. /** Defines that alpha blending is disabled */
  105823. static readonly ALPHA_DISABLE: number;
  105824. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  105825. static readonly ALPHA_ADD: number;
  105826. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  105827. static readonly ALPHA_COMBINE: number;
  105828. /** Defines that alpha blending to DEST - SRC * DEST */
  105829. static readonly ALPHA_SUBTRACT: number;
  105830. /** Defines that alpha blending to SRC * DEST */
  105831. static readonly ALPHA_MULTIPLY: number;
  105832. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  105833. static readonly ALPHA_MAXIMIZED: number;
  105834. /** Defines that alpha blending to SRC + DEST */
  105835. static readonly ALPHA_ONEONE: number;
  105836. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  105837. static readonly ALPHA_PREMULTIPLIED: number;
  105838. /**
  105839. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  105840. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  105841. */
  105842. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  105843. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  105844. static readonly ALPHA_INTERPOLATE: number;
  105845. /**
  105846. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  105847. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  105848. */
  105849. static readonly ALPHA_SCREENMODE: number;
  105850. /** Defines that the ressource is not delayed*/
  105851. static readonly DELAYLOADSTATE_NONE: number;
  105852. /** Defines that the ressource was successfully delay loaded */
  105853. static readonly DELAYLOADSTATE_LOADED: number;
  105854. /** Defines that the ressource is currently delay loading */
  105855. static readonly DELAYLOADSTATE_LOADING: number;
  105856. /** Defines that the ressource is delayed and has not started loading */
  105857. static readonly DELAYLOADSTATE_NOTLOADED: number;
  105858. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  105859. static readonly NEVER: number;
  105860. /** 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 */
  105861. static readonly ALWAYS: number;
  105862. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  105863. static readonly LESS: number;
  105864. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  105865. static readonly EQUAL: number;
  105866. /** 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 */
  105867. static readonly LEQUAL: number;
  105868. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  105869. static readonly GREATER: number;
  105870. /** 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 */
  105871. static readonly GEQUAL: number;
  105872. /** 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 */
  105873. static readonly NOTEQUAL: number;
  105874. /** Passed to stencilOperation to specify that stencil value must be kept */
  105875. static readonly KEEP: number;
  105876. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105877. static readonly REPLACE: number;
  105878. /** Passed to stencilOperation to specify that stencil value must be incremented */
  105879. static readonly INCR: number;
  105880. /** Passed to stencilOperation to specify that stencil value must be decremented */
  105881. static readonly DECR: number;
  105882. /** Passed to stencilOperation to specify that stencil value must be inverted */
  105883. static readonly INVERT: number;
  105884. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  105885. static readonly INCR_WRAP: number;
  105886. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  105887. static readonly DECR_WRAP: number;
  105888. /** Texture is not repeating outside of 0..1 UVs */
  105889. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  105890. /** Texture is repeating outside of 0..1 UVs */
  105891. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  105892. /** Texture is repeating and mirrored */
  105893. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  105894. /** ALPHA */
  105895. static readonly TEXTUREFORMAT_ALPHA: number;
  105896. /** LUMINANCE */
  105897. static readonly TEXTUREFORMAT_LUMINANCE: number;
  105898. /** LUMINANCE_ALPHA */
  105899. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  105900. /** RGB */
  105901. static readonly TEXTUREFORMAT_RGB: number;
  105902. /** RGBA */
  105903. static readonly TEXTUREFORMAT_RGBA: number;
  105904. /** RED */
  105905. static readonly TEXTUREFORMAT_RED: number;
  105906. /** RED (2nd reference) */
  105907. static readonly TEXTUREFORMAT_R: number;
  105908. /** RG */
  105909. static readonly TEXTUREFORMAT_RG: number;
  105910. /** RED_INTEGER */
  105911. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  105912. /** RED_INTEGER (2nd reference) */
  105913. static readonly TEXTUREFORMAT_R_INTEGER: number;
  105914. /** RG_INTEGER */
  105915. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  105916. /** RGB_INTEGER */
  105917. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  105918. /** RGBA_INTEGER */
  105919. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  105920. /** UNSIGNED_BYTE */
  105921. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  105922. /** UNSIGNED_BYTE (2nd reference) */
  105923. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  105924. /** FLOAT */
  105925. static readonly TEXTURETYPE_FLOAT: number;
  105926. /** HALF_FLOAT */
  105927. static readonly TEXTURETYPE_HALF_FLOAT: number;
  105928. /** BYTE */
  105929. static readonly TEXTURETYPE_BYTE: number;
  105930. /** SHORT */
  105931. static readonly TEXTURETYPE_SHORT: number;
  105932. /** UNSIGNED_SHORT */
  105933. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  105934. /** INT */
  105935. static readonly TEXTURETYPE_INT: number;
  105936. /** UNSIGNED_INT */
  105937. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  105938. /** UNSIGNED_SHORT_4_4_4_4 */
  105939. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  105940. /** UNSIGNED_SHORT_5_5_5_1 */
  105941. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  105942. /** UNSIGNED_SHORT_5_6_5 */
  105943. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  105944. /** UNSIGNED_INT_2_10_10_10_REV */
  105945. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  105946. /** UNSIGNED_INT_24_8 */
  105947. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  105948. /** UNSIGNED_INT_10F_11F_11F_REV */
  105949. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  105950. /** UNSIGNED_INT_5_9_9_9_REV */
  105951. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  105952. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  105953. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  105954. /** nearest is mag = nearest and min = nearest and mip = linear */
  105955. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  105956. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105957. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  105958. /** Trilinear is mag = linear and min = linear and mip = linear */
  105959. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  105960. /** nearest is mag = nearest and min = nearest and mip = linear */
  105961. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  105962. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105963. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  105964. /** Trilinear is mag = linear and min = linear and mip = linear */
  105965. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  105966. /** mag = nearest and min = nearest and mip = nearest */
  105967. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  105968. /** mag = nearest and min = linear and mip = nearest */
  105969. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  105970. /** mag = nearest and min = linear and mip = linear */
  105971. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  105972. /** mag = nearest and min = linear and mip = none */
  105973. static readonly TEXTURE_NEAREST_LINEAR: number;
  105974. /** mag = nearest and min = nearest and mip = none */
  105975. static readonly TEXTURE_NEAREST_NEAREST: number;
  105976. /** mag = linear and min = nearest and mip = nearest */
  105977. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  105978. /** mag = linear and min = nearest and mip = linear */
  105979. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  105980. /** mag = linear and min = linear and mip = none */
  105981. static readonly TEXTURE_LINEAR_LINEAR: number;
  105982. /** mag = linear and min = nearest and mip = none */
  105983. static readonly TEXTURE_LINEAR_NEAREST: number;
  105984. /** Explicit coordinates mode */
  105985. static readonly TEXTURE_EXPLICIT_MODE: number;
  105986. /** Spherical coordinates mode */
  105987. static readonly TEXTURE_SPHERICAL_MODE: number;
  105988. /** Planar coordinates mode */
  105989. static readonly TEXTURE_PLANAR_MODE: number;
  105990. /** Cubic coordinates mode */
  105991. static readonly TEXTURE_CUBIC_MODE: number;
  105992. /** Projection coordinates mode */
  105993. static readonly TEXTURE_PROJECTION_MODE: number;
  105994. /** Skybox coordinates mode */
  105995. static readonly TEXTURE_SKYBOX_MODE: number;
  105996. /** Inverse Cubic coordinates mode */
  105997. static readonly TEXTURE_INVCUBIC_MODE: number;
  105998. /** Equirectangular coordinates mode */
  105999. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106000. /** Equirectangular Fixed coordinates mode */
  106001. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106002. /** Equirectangular Fixed Mirrored coordinates mode */
  106003. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106004. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106005. static readonly SCALEMODE_FLOOR: number;
  106006. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106007. static readonly SCALEMODE_NEAREST: number;
  106008. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106009. static readonly SCALEMODE_CEILING: number;
  106010. /**
  106011. * Returns the current npm package of the sdk
  106012. */
  106013. static get NpmPackage(): string;
  106014. /**
  106015. * Returns the current version of the framework
  106016. */
  106017. static get Version(): string;
  106018. /** Gets the list of created engines */
  106019. static get Instances(): Engine[];
  106020. /**
  106021. * Gets the latest created engine
  106022. */
  106023. static get LastCreatedEngine(): Nullable<Engine>;
  106024. /**
  106025. * Gets the latest created scene
  106026. */
  106027. static get LastCreatedScene(): Nullable<Scene>;
  106028. /**
  106029. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106030. * @param flag defines which part of the materials must be marked as dirty
  106031. * @param predicate defines a predicate used to filter which materials should be affected
  106032. */
  106033. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106034. /**
  106035. * Method called to create the default loading screen.
  106036. * This can be overriden in your own app.
  106037. * @param canvas The rendering canvas element
  106038. * @returns The loading screen
  106039. */
  106040. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106041. /**
  106042. * Method called to create the default rescale post process on each engine.
  106043. */
  106044. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106045. /**
  106046. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106047. **/
  106048. enableOfflineSupport: boolean;
  106049. /**
  106050. * 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)
  106051. **/
  106052. disableManifestCheck: boolean;
  106053. /**
  106054. * Gets the list of created scenes
  106055. */
  106056. scenes: Scene[];
  106057. /**
  106058. * Event raised when a new scene is created
  106059. */
  106060. onNewSceneAddedObservable: Observable<Scene>;
  106061. /**
  106062. * Gets the list of created postprocesses
  106063. */
  106064. postProcesses: PostProcess[];
  106065. /**
  106066. * Gets a boolean indicating if the pointer is currently locked
  106067. */
  106068. isPointerLock: boolean;
  106069. /**
  106070. * Observable event triggered each time the rendering canvas is resized
  106071. */
  106072. onResizeObservable: Observable<Engine>;
  106073. /**
  106074. * Observable event triggered each time the canvas loses focus
  106075. */
  106076. onCanvasBlurObservable: Observable<Engine>;
  106077. /**
  106078. * Observable event triggered each time the canvas gains focus
  106079. */
  106080. onCanvasFocusObservable: Observable<Engine>;
  106081. /**
  106082. * Observable event triggered each time the canvas receives pointerout event
  106083. */
  106084. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106085. /**
  106086. * Observable raised when the engine begins a new frame
  106087. */
  106088. onBeginFrameObservable: Observable<Engine>;
  106089. /**
  106090. * If set, will be used to request the next animation frame for the render loop
  106091. */
  106092. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106093. /**
  106094. * Observable raised when the engine ends the current frame
  106095. */
  106096. onEndFrameObservable: Observable<Engine>;
  106097. /**
  106098. * Observable raised when the engine is about to compile a shader
  106099. */
  106100. onBeforeShaderCompilationObservable: Observable<Engine>;
  106101. /**
  106102. * Observable raised when the engine has jsut compiled a shader
  106103. */
  106104. onAfterShaderCompilationObservable: Observable<Engine>;
  106105. /**
  106106. * Gets the audio engine
  106107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106108. * @ignorenaming
  106109. */
  106110. static audioEngine: IAudioEngine;
  106111. /**
  106112. * Default AudioEngine factory responsible of creating the Audio Engine.
  106113. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106114. */
  106115. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106116. /**
  106117. * Default offline support factory responsible of creating a tool used to store data locally.
  106118. * By default, this will create a Database object if the workload has been embedded.
  106119. */
  106120. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106121. private _loadingScreen;
  106122. private _pointerLockRequested;
  106123. private _dummyFramebuffer;
  106124. private _rescalePostProcess;
  106125. private _deterministicLockstep;
  106126. private _lockstepMaxSteps;
  106127. private _timeStep;
  106128. protected get _supportsHardwareTextureRescaling(): boolean;
  106129. private _fps;
  106130. private _deltaTime;
  106131. /** @hidden */
  106132. _drawCalls: PerfCounter;
  106133. /** 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 */
  106134. canvasTabIndex: number;
  106135. /**
  106136. * Turn this value on if you want to pause FPS computation when in background
  106137. */
  106138. disablePerformanceMonitorInBackground: boolean;
  106139. private _performanceMonitor;
  106140. /**
  106141. * Gets the performance monitor attached to this engine
  106142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106143. */
  106144. get performanceMonitor(): PerformanceMonitor;
  106145. private _onFocus;
  106146. private _onBlur;
  106147. private _onCanvasPointerOut;
  106148. private _onCanvasBlur;
  106149. private _onCanvasFocus;
  106150. private _onFullscreenChange;
  106151. private _onPointerLockChange;
  106152. /**
  106153. * Gets the HTML element used to attach event listeners
  106154. * @returns a HTML element
  106155. */
  106156. getInputElement(): Nullable<HTMLElement>;
  106157. /**
  106158. * Creates a new engine
  106159. * @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
  106160. * @param antialias defines enable antialiasing (default: false)
  106161. * @param options defines further options to be sent to the getContext() function
  106162. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106163. */
  106164. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106165. /**
  106166. * Gets current aspect ratio
  106167. * @param viewportOwner defines the camera to use to get the aspect ratio
  106168. * @param useScreen defines if screen size must be used (or the current render target if any)
  106169. * @returns a number defining the aspect ratio
  106170. */
  106171. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106172. /**
  106173. * Gets current screen aspect ratio
  106174. * @returns a number defining the aspect ratio
  106175. */
  106176. getScreenAspectRatio(): number;
  106177. /**
  106178. * Gets the client rect of the HTML canvas attached with the current webGL context
  106179. * @returns a client rectanglee
  106180. */
  106181. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106182. /**
  106183. * Gets the client rect of the HTML element used for events
  106184. * @returns a client rectanglee
  106185. */
  106186. getInputElementClientRect(): Nullable<ClientRect>;
  106187. /**
  106188. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106189. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106190. * @returns true if engine is in deterministic lock step mode
  106191. */
  106192. isDeterministicLockStep(): boolean;
  106193. /**
  106194. * Gets the max steps when engine is running in deterministic lock step
  106195. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106196. * @returns the max steps
  106197. */
  106198. getLockstepMaxSteps(): number;
  106199. /**
  106200. * Returns the time in ms between steps when using deterministic lock step.
  106201. * @returns time step in (ms)
  106202. */
  106203. getTimeStep(): number;
  106204. /**
  106205. * Force the mipmap generation for the given render target texture
  106206. * @param texture defines the render target texture to use
  106207. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106208. */
  106209. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106210. /** States */
  106211. /**
  106212. * Set various states to the webGL context
  106213. * @param culling defines backface culling state
  106214. * @param zOffset defines the value to apply to zOffset (0 by default)
  106215. * @param force defines if states must be applied even if cache is up to date
  106216. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106217. */
  106218. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106219. /**
  106220. * Set the z offset to apply to current rendering
  106221. * @param value defines the offset to apply
  106222. */
  106223. setZOffset(value: number): void;
  106224. /**
  106225. * Gets the current value of the zOffset
  106226. * @returns the current zOffset state
  106227. */
  106228. getZOffset(): number;
  106229. /**
  106230. * Enable or disable depth buffering
  106231. * @param enable defines the state to set
  106232. */
  106233. setDepthBuffer(enable: boolean): void;
  106234. /**
  106235. * Gets a boolean indicating if depth writing is enabled
  106236. * @returns the current depth writing state
  106237. */
  106238. getDepthWrite(): boolean;
  106239. /**
  106240. * Enable or disable depth writing
  106241. * @param enable defines the state to set
  106242. */
  106243. setDepthWrite(enable: boolean): void;
  106244. /**
  106245. * Gets a boolean indicating if stencil buffer is enabled
  106246. * @returns the current stencil buffer state
  106247. */
  106248. getStencilBuffer(): boolean;
  106249. /**
  106250. * Enable or disable the stencil buffer
  106251. * @param enable defines if the stencil buffer must be enabled or disabled
  106252. */
  106253. setStencilBuffer(enable: boolean): void;
  106254. /**
  106255. * Gets the current stencil mask
  106256. * @returns a number defining the new stencil mask to use
  106257. */
  106258. getStencilMask(): number;
  106259. /**
  106260. * Sets the current stencil mask
  106261. * @param mask defines the new stencil mask to use
  106262. */
  106263. setStencilMask(mask: number): void;
  106264. /**
  106265. * Gets the current stencil function
  106266. * @returns a number defining the stencil function to use
  106267. */
  106268. getStencilFunction(): number;
  106269. /**
  106270. * Gets the current stencil reference value
  106271. * @returns a number defining the stencil reference value to use
  106272. */
  106273. getStencilFunctionReference(): number;
  106274. /**
  106275. * Gets the current stencil mask
  106276. * @returns a number defining the stencil mask to use
  106277. */
  106278. getStencilFunctionMask(): number;
  106279. /**
  106280. * Sets the current stencil function
  106281. * @param stencilFunc defines the new stencil function to use
  106282. */
  106283. setStencilFunction(stencilFunc: number): void;
  106284. /**
  106285. * Sets the current stencil reference
  106286. * @param reference defines the new stencil reference to use
  106287. */
  106288. setStencilFunctionReference(reference: number): void;
  106289. /**
  106290. * Sets the current stencil mask
  106291. * @param mask defines the new stencil mask to use
  106292. */
  106293. setStencilFunctionMask(mask: number): void;
  106294. /**
  106295. * Gets the current stencil operation when stencil fails
  106296. * @returns a number defining stencil operation to use when stencil fails
  106297. */
  106298. getStencilOperationFail(): number;
  106299. /**
  106300. * Gets the current stencil operation when depth fails
  106301. * @returns a number defining stencil operation to use when depth fails
  106302. */
  106303. getStencilOperationDepthFail(): number;
  106304. /**
  106305. * Gets the current stencil operation when stencil passes
  106306. * @returns a number defining stencil operation to use when stencil passes
  106307. */
  106308. getStencilOperationPass(): number;
  106309. /**
  106310. * Sets the stencil operation to use when stencil fails
  106311. * @param operation defines the stencil operation to use when stencil fails
  106312. */
  106313. setStencilOperationFail(operation: number): void;
  106314. /**
  106315. * Sets the stencil operation to use when depth fails
  106316. * @param operation defines the stencil operation to use when depth fails
  106317. */
  106318. setStencilOperationDepthFail(operation: number): void;
  106319. /**
  106320. * Sets the stencil operation to use when stencil passes
  106321. * @param operation defines the stencil operation to use when stencil passes
  106322. */
  106323. setStencilOperationPass(operation: number): void;
  106324. /**
  106325. * Sets a boolean indicating if the dithering state is enabled or disabled
  106326. * @param value defines the dithering state
  106327. */
  106328. setDitheringState(value: boolean): void;
  106329. /**
  106330. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106331. * @param value defines the rasterizer state
  106332. */
  106333. setRasterizerState(value: boolean): void;
  106334. /**
  106335. * Gets the current depth function
  106336. * @returns a number defining the depth function
  106337. */
  106338. getDepthFunction(): Nullable<number>;
  106339. /**
  106340. * Sets the current depth function
  106341. * @param depthFunc defines the function to use
  106342. */
  106343. setDepthFunction(depthFunc: number): void;
  106344. /**
  106345. * Sets the current depth function to GREATER
  106346. */
  106347. setDepthFunctionToGreater(): void;
  106348. /**
  106349. * Sets the current depth function to GEQUAL
  106350. */
  106351. setDepthFunctionToGreaterOrEqual(): void;
  106352. /**
  106353. * Sets the current depth function to LESS
  106354. */
  106355. setDepthFunctionToLess(): void;
  106356. /**
  106357. * Sets the current depth function to LEQUAL
  106358. */
  106359. setDepthFunctionToLessOrEqual(): void;
  106360. private _cachedStencilBuffer;
  106361. private _cachedStencilFunction;
  106362. private _cachedStencilMask;
  106363. private _cachedStencilOperationPass;
  106364. private _cachedStencilOperationFail;
  106365. private _cachedStencilOperationDepthFail;
  106366. private _cachedStencilReference;
  106367. /**
  106368. * Caches the the state of the stencil buffer
  106369. */
  106370. cacheStencilState(): void;
  106371. /**
  106372. * Restores the state of the stencil buffer
  106373. */
  106374. restoreStencilState(): void;
  106375. /**
  106376. * Directly set the WebGL Viewport
  106377. * @param x defines the x coordinate of the viewport (in screen space)
  106378. * @param y defines the y coordinate of the viewport (in screen space)
  106379. * @param width defines the width of the viewport (in screen space)
  106380. * @param height defines the height of the viewport (in screen space)
  106381. * @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
  106382. */
  106383. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106384. /**
  106385. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106386. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106387. * @param y defines the y-coordinate of the corner of the clear rectangle
  106388. * @param width defines the width of the clear rectangle
  106389. * @param height defines the height of the clear rectangle
  106390. * @param clearColor defines the clear color
  106391. */
  106392. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106393. /**
  106394. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106395. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106396. * @param y defines the y-coordinate of the corner of the clear rectangle
  106397. * @param width defines the width of the clear rectangle
  106398. * @param height defines the height of the clear rectangle
  106399. */
  106400. enableScissor(x: number, y: number, width: number, height: number): void;
  106401. /**
  106402. * Disable previously set scissor test rectangle
  106403. */
  106404. disableScissor(): void;
  106405. protected _reportDrawCall(): void;
  106406. /**
  106407. * Initializes a webVR display and starts listening to display change events
  106408. * The onVRDisplayChangedObservable will be notified upon these changes
  106409. * @returns The onVRDisplayChangedObservable
  106410. */
  106411. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106412. /** @hidden */
  106413. _prepareVRComponent(): void;
  106414. /** @hidden */
  106415. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106416. /** @hidden */
  106417. _submitVRFrame(): void;
  106418. /**
  106419. * Call this function to leave webVR mode
  106420. * Will do nothing if webVR is not supported or if there is no webVR device
  106421. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106422. */
  106423. disableVR(): void;
  106424. /**
  106425. * Gets a boolean indicating that the system is in VR mode and is presenting
  106426. * @returns true if VR mode is engaged
  106427. */
  106428. isVRPresenting(): boolean;
  106429. /** @hidden */
  106430. _requestVRFrame(): void;
  106431. /** @hidden */
  106432. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106433. /**
  106434. * Gets the source code of the vertex shader associated with a specific webGL program
  106435. * @param program defines the program to use
  106436. * @returns a string containing the source code of the vertex shader associated with the program
  106437. */
  106438. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106439. /**
  106440. * Gets the source code of the fragment shader associated with a specific webGL program
  106441. * @param program defines the program to use
  106442. * @returns a string containing the source code of the fragment shader associated with the program
  106443. */
  106444. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106445. /**
  106446. * Sets a depth stencil texture from a render target to the according uniform.
  106447. * @param channel The texture channel
  106448. * @param uniform The uniform to set
  106449. * @param texture The render target texture containing the depth stencil texture to apply
  106450. */
  106451. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106452. /**
  106453. * Sets a texture to the webGL context from a postprocess
  106454. * @param channel defines the channel to use
  106455. * @param postProcess defines the source postprocess
  106456. */
  106457. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106458. /**
  106459. * Binds the output of the passed in post process to the texture channel specified
  106460. * @param channel The channel the texture should be bound to
  106461. * @param postProcess The post process which's output should be bound
  106462. */
  106463. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106464. /** @hidden */
  106465. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106466. protected _rebuildBuffers(): void;
  106467. /** @hidden */
  106468. _renderFrame(): void;
  106469. _renderLoop(): void;
  106470. /** @hidden */
  106471. _renderViews(): boolean;
  106472. /**
  106473. * Toggle full screen mode
  106474. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106475. */
  106476. switchFullscreen(requestPointerLock: boolean): void;
  106477. /**
  106478. * Enters full screen mode
  106479. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106480. */
  106481. enterFullscreen(requestPointerLock: boolean): void;
  106482. /**
  106483. * Exits full screen mode
  106484. */
  106485. exitFullscreen(): void;
  106486. /**
  106487. * Enters Pointerlock mode
  106488. */
  106489. enterPointerlock(): void;
  106490. /**
  106491. * Exits Pointerlock mode
  106492. */
  106493. exitPointerlock(): void;
  106494. /**
  106495. * Begin a new frame
  106496. */
  106497. beginFrame(): void;
  106498. /**
  106499. * Enf the current frame
  106500. */
  106501. endFrame(): void;
  106502. resize(): void;
  106503. /**
  106504. * Set the compressed texture format to use, based on the formats you have, and the formats
  106505. * supported by the hardware / browser.
  106506. *
  106507. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  106508. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  106509. * to API arguments needed to compressed textures. This puts the burden on the container
  106510. * generator to house the arcane code for determining these for current & future formats.
  106511. *
  106512. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106513. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106514. *
  106515. * Note: The result of this call is not taken into account when a texture is base64.
  106516. *
  106517. * @param formatsAvailable defines the list of those format families you have created
  106518. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  106519. *
  106520. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  106521. * @returns The extension selected.
  106522. */
  106523. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  106524. /**
  106525. * Set the compressed texture extensions or file names to skip.
  106526. *
  106527. * @param skippedFiles defines the list of those texture files you want to skip
  106528. * Example: [".dds", ".env", "myfile.png"]
  106529. */
  106530. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  106531. /**
  106532. * Force a specific size of the canvas
  106533. * @param width defines the new canvas' width
  106534. * @param height defines the new canvas' height
  106535. */
  106536. setSize(width: number, height: number): void;
  106537. /**
  106538. * Updates a dynamic vertex buffer.
  106539. * @param vertexBuffer the vertex buffer to update
  106540. * @param data the data used to update the vertex buffer
  106541. * @param byteOffset the byte offset of the data
  106542. * @param byteLength the byte length of the data
  106543. */
  106544. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106545. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106546. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106547. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106548. _releaseTexture(texture: InternalTexture): void;
  106549. /**
  106550. * @hidden
  106551. * Rescales a texture
  106552. * @param source input texutre
  106553. * @param destination destination texture
  106554. * @param scene scene to use to render the resize
  106555. * @param internalFormat format to use when resizing
  106556. * @param onComplete callback to be called when resize has completed
  106557. */
  106558. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106559. /**
  106560. * Gets the current framerate
  106561. * @returns a number representing the framerate
  106562. */
  106563. getFps(): number;
  106564. /**
  106565. * Gets the time spent between current and previous frame
  106566. * @returns a number representing the delta time in ms
  106567. */
  106568. getDeltaTime(): number;
  106569. private _measureFps;
  106570. /** @hidden */
  106571. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106572. /**
  106573. * Update a dynamic index buffer
  106574. * @param indexBuffer defines the target index buffer
  106575. * @param indices defines the data to update
  106576. * @param offset defines the offset in the target index buffer where update should start
  106577. */
  106578. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106579. /**
  106580. * Updates the sample count of a render target texture
  106581. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106582. * @param texture defines the texture to update
  106583. * @param samples defines the sample count to set
  106584. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106585. */
  106586. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106587. /**
  106588. * Updates a depth texture Comparison Mode and Function.
  106589. * If the comparison Function is equal to 0, the mode will be set to none.
  106590. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106591. * @param texture The texture to set the comparison function for
  106592. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106593. */
  106594. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  106595. /**
  106596. * Creates a webGL buffer to use with instanciation
  106597. * @param capacity defines the size of the buffer
  106598. * @returns the webGL buffer
  106599. */
  106600. createInstancesBuffer(capacity: number): DataBuffer;
  106601. /**
  106602. * Delete a webGL buffer used with instanciation
  106603. * @param buffer defines the webGL buffer to delete
  106604. */
  106605. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  106606. /** @hidden */
  106607. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  106608. dispose(): void;
  106609. private _disableTouchAction;
  106610. /**
  106611. * Display the loading screen
  106612. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106613. */
  106614. displayLoadingUI(): void;
  106615. /**
  106616. * Hide the loading screen
  106617. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106618. */
  106619. hideLoadingUI(): void;
  106620. /**
  106621. * Gets the current loading screen object
  106622. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106623. */
  106624. get loadingScreen(): ILoadingScreen;
  106625. /**
  106626. * Sets the current loading screen object
  106627. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106628. */
  106629. set loadingScreen(loadingScreen: ILoadingScreen);
  106630. /**
  106631. * Sets the current loading screen text
  106632. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106633. */
  106634. set loadingUIText(text: string);
  106635. /**
  106636. * Sets the current loading screen background color
  106637. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106638. */
  106639. set loadingUIBackgroundColor(color: string);
  106640. /** Pointerlock and fullscreen */
  106641. /**
  106642. * Ask the browser to promote the current element to pointerlock mode
  106643. * @param element defines the DOM element to promote
  106644. */
  106645. static _RequestPointerlock(element: HTMLElement): void;
  106646. /**
  106647. * Asks the browser to exit pointerlock mode
  106648. */
  106649. static _ExitPointerlock(): void;
  106650. /**
  106651. * Ask the browser to promote the current element to fullscreen rendering mode
  106652. * @param element defines the DOM element to promote
  106653. */
  106654. static _RequestFullscreen(element: HTMLElement): void;
  106655. /**
  106656. * Asks the browser to exit fullscreen mode
  106657. */
  106658. static _ExitFullscreen(): void;
  106659. }
  106660. }
  106661. declare module BABYLON {
  106662. /**
  106663. * The engine store class is responsible to hold all the instances of Engine and Scene created
  106664. * during the life time of the application.
  106665. */
  106666. export class EngineStore {
  106667. /** Gets the list of created engines */
  106668. static Instances: Engine[];
  106669. /** @hidden */
  106670. static _LastCreatedScene: Nullable<Scene>;
  106671. /**
  106672. * Gets the latest created engine
  106673. */
  106674. static get LastCreatedEngine(): Nullable<Engine>;
  106675. /**
  106676. * Gets the latest created scene
  106677. */
  106678. static get LastCreatedScene(): Nullable<Scene>;
  106679. /**
  106680. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106681. * @ignorenaming
  106682. */
  106683. static UseFallbackTexture: boolean;
  106684. /**
  106685. * Texture content used if a texture cannot loaded
  106686. * @ignorenaming
  106687. */
  106688. static FallbackTexture: string;
  106689. }
  106690. }
  106691. declare module BABYLON {
  106692. /**
  106693. * Helper class that provides a small promise polyfill
  106694. */
  106695. export class PromisePolyfill {
  106696. /**
  106697. * Static function used to check if the polyfill is required
  106698. * If this is the case then the function will inject the polyfill to window.Promise
  106699. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  106700. */
  106701. static Apply(force?: boolean): void;
  106702. }
  106703. }
  106704. declare module BABYLON {
  106705. /**
  106706. * Interface for screenshot methods with describe argument called `size` as object with options
  106707. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  106708. */
  106709. export interface IScreenshotSize {
  106710. /**
  106711. * number in pixels for canvas height
  106712. */
  106713. height?: number;
  106714. /**
  106715. * multiplier allowing render at a higher or lower resolution
  106716. * If value is defined then height and width will be ignored and taken from camera
  106717. */
  106718. precision?: number;
  106719. /**
  106720. * number in pixels for canvas width
  106721. */
  106722. width?: number;
  106723. }
  106724. }
  106725. declare module BABYLON {
  106726. interface IColor4Like {
  106727. r: float;
  106728. g: float;
  106729. b: float;
  106730. a: float;
  106731. }
  106732. /**
  106733. * Class containing a set of static utilities functions
  106734. */
  106735. export class Tools {
  106736. /**
  106737. * Gets or sets the base URL to use to load assets
  106738. */
  106739. static get BaseUrl(): string;
  106740. static set BaseUrl(value: string);
  106741. /**
  106742. * Enable/Disable Custom HTTP Request Headers globally.
  106743. * default = false
  106744. * @see CustomRequestHeaders
  106745. */
  106746. static UseCustomRequestHeaders: boolean;
  106747. /**
  106748. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  106749. * i.e. when loading files, where the server/service expects an Authorization header
  106750. */
  106751. static CustomRequestHeaders: {
  106752. [key: string]: string;
  106753. };
  106754. /**
  106755. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  106756. */
  106757. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  106758. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  106759. /**
  106760. * Default behaviour for cors in the application.
  106761. * It can be a string if the expected behavior is identical in the entire app.
  106762. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  106763. */
  106764. static CorsBehavior: string | ((url: string | string[]) => string);
  106765. /**
  106766. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106767. * @ignorenaming
  106768. */
  106769. static get UseFallbackTexture(): boolean;
  106770. static set UseFallbackTexture(value: boolean);
  106771. /**
  106772. * Use this object to register external classes like custom textures or material
  106773. * to allow the laoders to instantiate them
  106774. */
  106775. static get RegisteredExternalClasses(): {
  106776. [key: string]: Object;
  106777. };
  106778. static set RegisteredExternalClasses(classes: {
  106779. [key: string]: Object;
  106780. });
  106781. /**
  106782. * Texture content used if a texture cannot loaded
  106783. * @ignorenaming
  106784. */
  106785. static get fallbackTexture(): string;
  106786. static set fallbackTexture(value: string);
  106787. /**
  106788. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  106789. * @param u defines the coordinate on X axis
  106790. * @param v defines the coordinate on Y axis
  106791. * @param width defines the width of the source data
  106792. * @param height defines the height of the source data
  106793. * @param pixels defines the source byte array
  106794. * @param color defines the output color
  106795. */
  106796. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  106797. /**
  106798. * Interpolates between a and b via alpha
  106799. * @param a The lower value (returned when alpha = 0)
  106800. * @param b The upper value (returned when alpha = 1)
  106801. * @param alpha The interpolation-factor
  106802. * @return The mixed value
  106803. */
  106804. static Mix(a: number, b: number, alpha: number): number;
  106805. /**
  106806. * Tries to instantiate a new object from a given class name
  106807. * @param className defines the class name to instantiate
  106808. * @returns the new object or null if the system was not able to do the instantiation
  106809. */
  106810. static Instantiate(className: string): any;
  106811. /**
  106812. * Provides a slice function that will work even on IE
  106813. * @param data defines the array to slice
  106814. * @param start defines the start of the data (optional)
  106815. * @param end defines the end of the data (optional)
  106816. * @returns the new sliced array
  106817. */
  106818. static Slice<T>(data: T, start?: number, end?: number): T;
  106819. /**
  106820. * Polyfill for setImmediate
  106821. * @param action defines the action to execute after the current execution block
  106822. */
  106823. static SetImmediate(action: () => void): void;
  106824. /**
  106825. * Function indicating if a number is an exponent of 2
  106826. * @param value defines the value to test
  106827. * @returns true if the value is an exponent of 2
  106828. */
  106829. static IsExponentOfTwo(value: number): boolean;
  106830. private static _tmpFloatArray;
  106831. /**
  106832. * Returns the nearest 32-bit single precision float representation of a Number
  106833. * @param value A Number. If the parameter is of a different type, it will get converted
  106834. * to a number or to NaN if it cannot be converted
  106835. * @returns number
  106836. */
  106837. static FloatRound(value: number): number;
  106838. /**
  106839. * Extracts the filename from a path
  106840. * @param path defines the path to use
  106841. * @returns the filename
  106842. */
  106843. static GetFilename(path: string): string;
  106844. /**
  106845. * Extracts the "folder" part of a path (everything before the filename).
  106846. * @param uri The URI to extract the info from
  106847. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  106848. * @returns The "folder" part of the path
  106849. */
  106850. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  106851. /**
  106852. * Extracts text content from a DOM element hierarchy
  106853. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  106854. */
  106855. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  106856. /**
  106857. * Convert an angle in radians to degrees
  106858. * @param angle defines the angle to convert
  106859. * @returns the angle in degrees
  106860. */
  106861. static ToDegrees(angle: number): number;
  106862. /**
  106863. * Convert an angle in degrees to radians
  106864. * @param angle defines the angle to convert
  106865. * @returns the angle in radians
  106866. */
  106867. static ToRadians(angle: number): number;
  106868. /**
  106869. * Returns an array if obj is not an array
  106870. * @param obj defines the object to evaluate as an array
  106871. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  106872. * @returns either obj directly if obj is an array or a new array containing obj
  106873. */
  106874. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  106875. /**
  106876. * Gets the pointer prefix to use
  106877. * @returns "pointer" if touch is enabled. Else returns "mouse"
  106878. */
  106879. static GetPointerPrefix(): string;
  106880. /**
  106881. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  106882. * @param url define the url we are trying
  106883. * @param element define the dom element where to configure the cors policy
  106884. */
  106885. static SetCorsBehavior(url: string | string[], element: {
  106886. crossOrigin: string | null;
  106887. }): void;
  106888. /**
  106889. * Removes unwanted characters from an url
  106890. * @param url defines the url to clean
  106891. * @returns the cleaned url
  106892. */
  106893. static CleanUrl(url: string): string;
  106894. /**
  106895. * Gets or sets a function used to pre-process url before using them to load assets
  106896. */
  106897. static get PreprocessUrl(): (url: string) => string;
  106898. static set PreprocessUrl(processor: (url: string) => string);
  106899. /**
  106900. * Loads an image as an HTMLImageElement.
  106901. * @param input url string, ArrayBuffer, or Blob to load
  106902. * @param onLoad callback called when the image successfully loads
  106903. * @param onError callback called when the image fails to load
  106904. * @param offlineProvider offline provider for caching
  106905. * @param mimeType optional mime type
  106906. * @returns the HTMLImageElement of the loaded image
  106907. */
  106908. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  106909. /**
  106910. * Loads a file from a url
  106911. * @param url url string, ArrayBuffer, or Blob to load
  106912. * @param onSuccess callback called when the file successfully loads
  106913. * @param onProgress callback called while file is loading (if the server supports this mode)
  106914. * @param offlineProvider defines the offline provider for caching
  106915. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106916. * @param onError callback called when the file fails to load
  106917. * @returns a file request object
  106918. */
  106919. 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;
  106920. /**
  106921. * Loads a file from a url
  106922. * @param url the file url to load
  106923. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106924. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  106925. */
  106926. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  106927. /**
  106928. * Load a script (identified by an url). When the url returns, the
  106929. * content of this file is added into a new script element, attached to the DOM (body element)
  106930. * @param scriptUrl defines the url of the script to laod
  106931. * @param onSuccess defines the callback called when the script is loaded
  106932. * @param onError defines the callback to call if an error occurs
  106933. * @param scriptId defines the id of the script element
  106934. */
  106935. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  106936. /**
  106937. * Load an asynchronous script (identified by an url). When the url returns, the
  106938. * content of this file is added into a new script element, attached to the DOM (body element)
  106939. * @param scriptUrl defines the url of the script to laod
  106940. * @param scriptId defines the id of the script element
  106941. * @returns a promise request object
  106942. */
  106943. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  106944. /**
  106945. * Loads a file from a blob
  106946. * @param fileToLoad defines the blob to use
  106947. * @param callback defines the callback to call when data is loaded
  106948. * @param progressCallback defines the callback to call during loading process
  106949. * @returns a file request object
  106950. */
  106951. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  106952. /**
  106953. * Reads a file from a File object
  106954. * @param file defines the file to load
  106955. * @param onSuccess defines the callback to call when data is loaded
  106956. * @param onProgress defines the callback to call during loading process
  106957. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  106958. * @param onError defines the callback to call when an error occurs
  106959. * @returns a file request object
  106960. */
  106961. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  106962. /**
  106963. * Creates a data url from a given string content
  106964. * @param content defines the content to convert
  106965. * @returns the new data url link
  106966. */
  106967. static FileAsURL(content: string): string;
  106968. /**
  106969. * Format the given number to a specific decimal format
  106970. * @param value defines the number to format
  106971. * @param decimals defines the number of decimals to use
  106972. * @returns the formatted string
  106973. */
  106974. static Format(value: number, decimals?: number): string;
  106975. /**
  106976. * Tries to copy an object by duplicating every property
  106977. * @param source defines the source object
  106978. * @param destination defines the target object
  106979. * @param doNotCopyList defines a list of properties to avoid
  106980. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  106981. */
  106982. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  106983. /**
  106984. * Gets a boolean indicating if the given object has no own property
  106985. * @param obj defines the object to test
  106986. * @returns true if object has no own property
  106987. */
  106988. static IsEmpty(obj: any): boolean;
  106989. /**
  106990. * Function used to register events at window level
  106991. * @param windowElement defines the Window object to use
  106992. * @param events defines the events to register
  106993. */
  106994. static RegisterTopRootEvents(windowElement: Window, events: {
  106995. name: string;
  106996. handler: Nullable<(e: FocusEvent) => any>;
  106997. }[]): void;
  106998. /**
  106999. * Function used to unregister events from window level
  107000. * @param windowElement defines the Window object to use
  107001. * @param events defines the events to unregister
  107002. */
  107003. static UnregisterTopRootEvents(windowElement: Window, events: {
  107004. name: string;
  107005. handler: Nullable<(e: FocusEvent) => any>;
  107006. }[]): void;
  107007. /**
  107008. * @ignore
  107009. */
  107010. static _ScreenshotCanvas: HTMLCanvasElement;
  107011. /**
  107012. * Dumps the current bound framebuffer
  107013. * @param width defines the rendering width
  107014. * @param height defines the rendering height
  107015. * @param engine defines the hosting engine
  107016. * @param successCallback defines the callback triggered once the data are available
  107017. * @param mimeType defines the mime type of the result
  107018. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107019. */
  107020. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107021. /**
  107022. * Converts the canvas data to blob.
  107023. * This acts as a polyfill for browsers not supporting the to blob function.
  107024. * @param canvas Defines the canvas to extract the data from
  107025. * @param successCallback Defines the callback triggered once the data are available
  107026. * @param mimeType Defines the mime type of the result
  107027. */
  107028. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107029. /**
  107030. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107031. * @param successCallback defines the callback triggered once the data are available
  107032. * @param mimeType defines the mime type of the result
  107033. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107034. */
  107035. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107036. /**
  107037. * Downloads a blob in the browser
  107038. * @param blob defines the blob to download
  107039. * @param fileName defines the name of the downloaded file
  107040. */
  107041. static Download(blob: Blob, fileName: string): void;
  107042. /**
  107043. * Captures a screenshot of the current rendering
  107044. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107045. * @param engine defines the rendering engine
  107046. * @param camera defines the source camera
  107047. * @param size This parameter can be set to a single number or to an object with the
  107048. * following (optional) properties: precision, width, height. If a single number is passed,
  107049. * it will be used for both width and height. If an object is passed, the screenshot size
  107050. * will be derived from the parameters. The precision property is a multiplier allowing
  107051. * rendering at a higher or lower resolution
  107052. * @param successCallback defines the callback receives a single parameter which contains the
  107053. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107054. * src parameter of an <img> to display it
  107055. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107056. * Check your browser for supported MIME types
  107057. */
  107058. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107059. /**
  107060. * Captures a screenshot of the current rendering
  107061. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107062. * @param engine defines the rendering engine
  107063. * @param camera defines the source camera
  107064. * @param size This parameter can be set to a single number or to an object with the
  107065. * following (optional) properties: precision, width, height. If a single number is passed,
  107066. * it will be used for both width and height. If an object is passed, the screenshot size
  107067. * will be derived from the parameters. The precision property is a multiplier allowing
  107068. * rendering at a higher or lower resolution
  107069. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107070. * Check your browser for supported MIME types
  107071. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107072. * to the src parameter of an <img> to display it
  107073. */
  107074. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107075. /**
  107076. * Generates an image screenshot from the specified camera.
  107077. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107078. * @param engine The engine to use for rendering
  107079. * @param camera The camera to use for rendering
  107080. * @param size This parameter can be set to a single number or to an object with the
  107081. * following (optional) properties: precision, width, height. If a single number is passed,
  107082. * it will be used for both width and height. If an object is passed, the screenshot size
  107083. * will be derived from the parameters. The precision property is a multiplier allowing
  107084. * rendering at a higher or lower resolution
  107085. * @param successCallback The callback receives a single parameter which contains the
  107086. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107087. * src parameter of an <img> to display it
  107088. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107089. * Check your browser for supported MIME types
  107090. * @param samples Texture samples (default: 1)
  107091. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107092. * @param fileName A name for for the downloaded file.
  107093. */
  107094. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107095. /**
  107096. * Generates an image screenshot from the specified camera.
  107097. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107098. * @param engine The engine to use for rendering
  107099. * @param camera The camera to use for rendering
  107100. * @param size This parameter can be set to a single number or to an object with the
  107101. * following (optional) properties: precision, width, height. If a single number is passed,
  107102. * it will be used for both width and height. If an object is passed, the screenshot size
  107103. * will be derived from the parameters. The precision property is a multiplier allowing
  107104. * rendering at a higher or lower resolution
  107105. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107106. * Check your browser for supported MIME types
  107107. * @param samples Texture samples (default: 1)
  107108. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107109. * @param fileName A name for for the downloaded file.
  107110. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107111. * to the src parameter of an <img> to display it
  107112. */
  107113. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107114. /**
  107115. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107116. * Be aware Math.random() could cause collisions, but:
  107117. * "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"
  107118. * @returns a pseudo random id
  107119. */
  107120. static RandomId(): string;
  107121. /**
  107122. * Test if the given uri is a base64 string
  107123. * @param uri The uri to test
  107124. * @return True if the uri is a base64 string or false otherwise
  107125. */
  107126. static IsBase64(uri: string): boolean;
  107127. /**
  107128. * Decode the given base64 uri.
  107129. * @param uri The uri to decode
  107130. * @return The decoded base64 data.
  107131. */
  107132. static DecodeBase64(uri: string): ArrayBuffer;
  107133. /**
  107134. * Gets the absolute url.
  107135. * @param url the input url
  107136. * @return the absolute url
  107137. */
  107138. static GetAbsoluteUrl(url: string): string;
  107139. /**
  107140. * No log
  107141. */
  107142. static readonly NoneLogLevel: number;
  107143. /**
  107144. * Only message logs
  107145. */
  107146. static readonly MessageLogLevel: number;
  107147. /**
  107148. * Only warning logs
  107149. */
  107150. static readonly WarningLogLevel: number;
  107151. /**
  107152. * Only error logs
  107153. */
  107154. static readonly ErrorLogLevel: number;
  107155. /**
  107156. * All logs
  107157. */
  107158. static readonly AllLogLevel: number;
  107159. /**
  107160. * Gets a value indicating the number of loading errors
  107161. * @ignorenaming
  107162. */
  107163. static get errorsCount(): number;
  107164. /**
  107165. * Callback called when a new log is added
  107166. */
  107167. static OnNewCacheEntry: (entry: string) => void;
  107168. /**
  107169. * Log a message to the console
  107170. * @param message defines the message to log
  107171. */
  107172. static Log(message: string): void;
  107173. /**
  107174. * Write a warning message to the console
  107175. * @param message defines the message to log
  107176. */
  107177. static Warn(message: string): void;
  107178. /**
  107179. * Write an error message to the console
  107180. * @param message defines the message to log
  107181. */
  107182. static Error(message: string): void;
  107183. /**
  107184. * Gets current log cache (list of logs)
  107185. */
  107186. static get LogCache(): string;
  107187. /**
  107188. * Clears the log cache
  107189. */
  107190. static ClearLogCache(): void;
  107191. /**
  107192. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107193. */
  107194. static set LogLevels(level: number);
  107195. /**
  107196. * Checks if the window object exists
  107197. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107198. */
  107199. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107200. /**
  107201. * No performance log
  107202. */
  107203. static readonly PerformanceNoneLogLevel: number;
  107204. /**
  107205. * Use user marks to log performance
  107206. */
  107207. static readonly PerformanceUserMarkLogLevel: number;
  107208. /**
  107209. * Log performance to the console
  107210. */
  107211. static readonly PerformanceConsoleLogLevel: number;
  107212. private static _performance;
  107213. /**
  107214. * Sets the current performance log level
  107215. */
  107216. static set PerformanceLogLevel(level: number);
  107217. private static _StartPerformanceCounterDisabled;
  107218. private static _EndPerformanceCounterDisabled;
  107219. private static _StartUserMark;
  107220. private static _EndUserMark;
  107221. private static _StartPerformanceConsole;
  107222. private static _EndPerformanceConsole;
  107223. /**
  107224. * Starts a performance counter
  107225. */
  107226. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107227. /**
  107228. * Ends a specific performance coutner
  107229. */
  107230. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107231. /**
  107232. * Gets either window.performance.now() if supported or Date.now() else
  107233. */
  107234. static get Now(): number;
  107235. /**
  107236. * This method will return the name of the class used to create the instance of the given object.
  107237. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107238. * @param object the object to get the class name from
  107239. * @param isType defines if the object is actually a type
  107240. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107241. */
  107242. static GetClassName(object: any, isType?: boolean): string;
  107243. /**
  107244. * Gets the first element of an array satisfying a given predicate
  107245. * @param array defines the array to browse
  107246. * @param predicate defines the predicate to use
  107247. * @returns null if not found or the element
  107248. */
  107249. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107250. /**
  107251. * This method will return the name of the full name of the class, including its owning module (if any).
  107252. * 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).
  107253. * @param object the object to get the class name from
  107254. * @param isType defines if the object is actually a type
  107255. * @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.
  107256. * @ignorenaming
  107257. */
  107258. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107259. /**
  107260. * Returns a promise that resolves after the given amount of time.
  107261. * @param delay Number of milliseconds to delay
  107262. * @returns Promise that resolves after the given amount of time
  107263. */
  107264. static DelayAsync(delay: number): Promise<void>;
  107265. /**
  107266. * Utility function to detect if the current user agent is Safari
  107267. * @returns whether or not the current user agent is safari
  107268. */
  107269. static IsSafari(): boolean;
  107270. }
  107271. /**
  107272. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107273. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107274. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107275. * @param name The name of the class, case should be preserved
  107276. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107277. */
  107278. export function className(name: string, module?: string): (target: Object) => void;
  107279. /**
  107280. * An implementation of a loop for asynchronous functions.
  107281. */
  107282. export class AsyncLoop {
  107283. /**
  107284. * Defines the number of iterations for the loop
  107285. */
  107286. iterations: number;
  107287. /**
  107288. * Defines the current index of the loop.
  107289. */
  107290. index: number;
  107291. private _done;
  107292. private _fn;
  107293. private _successCallback;
  107294. /**
  107295. * Constructor.
  107296. * @param iterations the number of iterations.
  107297. * @param func the function to run each iteration
  107298. * @param successCallback the callback that will be called upon succesful execution
  107299. * @param offset starting offset.
  107300. */
  107301. constructor(
  107302. /**
  107303. * Defines the number of iterations for the loop
  107304. */
  107305. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107306. /**
  107307. * Execute the next iteration. Must be called after the last iteration was finished.
  107308. */
  107309. executeNext(): void;
  107310. /**
  107311. * Break the loop and run the success callback.
  107312. */
  107313. breakLoop(): void;
  107314. /**
  107315. * Create and run an async loop.
  107316. * @param iterations the number of iterations.
  107317. * @param fn the function to run each iteration
  107318. * @param successCallback the callback that will be called upon succesful execution
  107319. * @param offset starting offset.
  107320. * @returns the created async loop object
  107321. */
  107322. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107323. /**
  107324. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107325. * @param iterations total number of iterations
  107326. * @param syncedIterations number of synchronous iterations in each async iteration.
  107327. * @param fn the function to call each iteration.
  107328. * @param callback a success call back that will be called when iterating stops.
  107329. * @param breakFunction a break condition (optional)
  107330. * @param timeout timeout settings for the setTimeout function. default - 0.
  107331. * @returns the created async loop object
  107332. */
  107333. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107334. }
  107335. }
  107336. declare module BABYLON {
  107337. /**
  107338. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107339. * The underlying implementation relies on an associative array to ensure the best performances.
  107340. * The value can be anything including 'null' but except 'undefined'
  107341. */
  107342. export class StringDictionary<T> {
  107343. /**
  107344. * This will clear this dictionary and copy the content from the 'source' one.
  107345. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107346. * @param source the dictionary to take the content from and copy to this dictionary
  107347. */
  107348. copyFrom(source: StringDictionary<T>): void;
  107349. /**
  107350. * Get a value based from its key
  107351. * @param key the given key to get the matching value from
  107352. * @return the value if found, otherwise undefined is returned
  107353. */
  107354. get(key: string): T | undefined;
  107355. /**
  107356. * Get a value from its key or add it if it doesn't exist.
  107357. * This method will ensure you that a given key/data will be present in the dictionary.
  107358. * @param key the given key to get the matching value from
  107359. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107360. * The factory will only be invoked if there's no data for the given key.
  107361. * @return the value corresponding to the key.
  107362. */
  107363. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107364. /**
  107365. * Get a value from its key if present in the dictionary otherwise add it
  107366. * @param key the key to get the value from
  107367. * @param val if there's no such key/value pair in the dictionary add it with this value
  107368. * @return the value corresponding to the key
  107369. */
  107370. getOrAdd(key: string, val: T): T;
  107371. /**
  107372. * Check if there's a given key in the dictionary
  107373. * @param key the key to check for
  107374. * @return true if the key is present, false otherwise
  107375. */
  107376. contains(key: string): boolean;
  107377. /**
  107378. * Add a new key and its corresponding value
  107379. * @param key the key to add
  107380. * @param value the value corresponding to the key
  107381. * @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
  107382. */
  107383. add(key: string, value: T): boolean;
  107384. /**
  107385. * Update a specific value associated to a key
  107386. * @param key defines the key to use
  107387. * @param value defines the value to store
  107388. * @returns true if the value was updated (or false if the key was not found)
  107389. */
  107390. set(key: string, value: T): boolean;
  107391. /**
  107392. * Get the element of the given key and remove it from the dictionary
  107393. * @param key defines the key to search
  107394. * @returns the value associated with the key or null if not found
  107395. */
  107396. getAndRemove(key: string): Nullable<T>;
  107397. /**
  107398. * Remove a key/value from the dictionary.
  107399. * @param key the key to remove
  107400. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107401. */
  107402. remove(key: string): boolean;
  107403. /**
  107404. * Clear the whole content of the dictionary
  107405. */
  107406. clear(): void;
  107407. /**
  107408. * Gets the current count
  107409. */
  107410. get count(): number;
  107411. /**
  107412. * Execute a callback on each key/val of the dictionary.
  107413. * Note that you can remove any element in this dictionary in the callback implementation
  107414. * @param callback the callback to execute on a given key/value pair
  107415. */
  107416. forEach(callback: (key: string, val: T) => void): void;
  107417. /**
  107418. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107419. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107420. * Note that you can remove any element in this dictionary in the callback implementation
  107421. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107422. * @returns the first item
  107423. */
  107424. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107425. private _count;
  107426. private _data;
  107427. }
  107428. }
  107429. declare module BABYLON {
  107430. /** @hidden */
  107431. export interface ICollisionCoordinator {
  107432. createCollider(): Collider;
  107433. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107434. init(scene: Scene): void;
  107435. }
  107436. /** @hidden */
  107437. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107438. private _scene;
  107439. private _scaledPosition;
  107440. private _scaledVelocity;
  107441. private _finalPosition;
  107442. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107443. createCollider(): Collider;
  107444. init(scene: Scene): void;
  107445. private _collideWithWorld;
  107446. }
  107447. }
  107448. declare module BABYLON {
  107449. /**
  107450. * Class used to manage all inputs for the scene.
  107451. */
  107452. export class InputManager {
  107453. /** The distance in pixel that you have to move to prevent some events */
  107454. static DragMovementThreshold: number;
  107455. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107456. static LongPressDelay: number;
  107457. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107458. static DoubleClickDelay: number;
  107459. /** If you need to check double click without raising a single click at first click, enable this flag */
  107460. static ExclusiveDoubleClickMode: boolean;
  107461. private _wheelEventName;
  107462. private _onPointerMove;
  107463. private _onPointerDown;
  107464. private _onPointerUp;
  107465. private _initClickEvent;
  107466. private _initActionManager;
  107467. private _delayedSimpleClick;
  107468. private _delayedSimpleClickTimeout;
  107469. private _previousDelayedSimpleClickTimeout;
  107470. private _meshPickProceed;
  107471. private _previousButtonPressed;
  107472. private _currentPickResult;
  107473. private _previousPickResult;
  107474. private _totalPointersPressed;
  107475. private _doubleClickOccured;
  107476. private _pointerOverMesh;
  107477. private _pickedDownMesh;
  107478. private _pickedUpMesh;
  107479. private _pointerX;
  107480. private _pointerY;
  107481. private _unTranslatedPointerX;
  107482. private _unTranslatedPointerY;
  107483. private _startingPointerPosition;
  107484. private _previousStartingPointerPosition;
  107485. private _startingPointerTime;
  107486. private _previousStartingPointerTime;
  107487. private _pointerCaptures;
  107488. private _onKeyDown;
  107489. private _onKeyUp;
  107490. private _onCanvasFocusObserver;
  107491. private _onCanvasBlurObserver;
  107492. private _scene;
  107493. /**
  107494. * Creates a new InputManager
  107495. * @param scene defines the hosting scene
  107496. */
  107497. constructor(scene: Scene);
  107498. /**
  107499. * Gets the mesh that is currently under the pointer
  107500. */
  107501. get meshUnderPointer(): Nullable<AbstractMesh>;
  107502. /**
  107503. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107504. */
  107505. get unTranslatedPointer(): Vector2;
  107506. /**
  107507. * Gets or sets the current on-screen X position of the pointer
  107508. */
  107509. get pointerX(): number;
  107510. set pointerX(value: number);
  107511. /**
  107512. * Gets or sets the current on-screen Y position of the pointer
  107513. */
  107514. get pointerY(): number;
  107515. set pointerY(value: number);
  107516. private _updatePointerPosition;
  107517. private _processPointerMove;
  107518. private _setRayOnPointerInfo;
  107519. private _checkPrePointerObservable;
  107520. /**
  107521. * Use this method to simulate a pointer move on a mesh
  107522. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107523. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107524. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107525. */
  107526. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107527. /**
  107528. * Use this method to simulate a pointer down on a mesh
  107529. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107530. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107531. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107532. */
  107533. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107534. private _processPointerDown;
  107535. /** @hidden */
  107536. _isPointerSwiping(): boolean;
  107537. /**
  107538. * Use this method to simulate a pointer up on a mesh
  107539. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107540. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107541. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107542. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107543. */
  107544. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107545. private _processPointerUp;
  107546. /**
  107547. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107548. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107549. * @returns true if the pointer was captured
  107550. */
  107551. isPointerCaptured(pointerId?: number): boolean;
  107552. /**
  107553. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107554. * @param attachUp defines if you want to attach events to pointerup
  107555. * @param attachDown defines if you want to attach events to pointerdown
  107556. * @param attachMove defines if you want to attach events to pointermove
  107557. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107558. */
  107559. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107560. /**
  107561. * Detaches all event handlers
  107562. */
  107563. detachControl(): void;
  107564. /**
  107565. * Force the value of meshUnderPointer
  107566. * @param mesh defines the mesh to use
  107567. */
  107568. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107569. /**
  107570. * Gets the mesh under the pointer
  107571. * @returns a Mesh or null if no mesh is under the pointer
  107572. */
  107573. getPointerOverMesh(): Nullable<AbstractMesh>;
  107574. }
  107575. }
  107576. declare module BABYLON {
  107577. /**
  107578. * Helper class used to generate session unique ID
  107579. */
  107580. export class UniqueIdGenerator {
  107581. private static _UniqueIdCounter;
  107582. /**
  107583. * Gets an unique (relatively to the current scene) Id
  107584. */
  107585. static get UniqueId(): number;
  107586. }
  107587. }
  107588. declare module BABYLON {
  107589. /**
  107590. * This class defines the direct association between an animation and a target
  107591. */
  107592. export class TargetedAnimation {
  107593. /**
  107594. * Animation to perform
  107595. */
  107596. animation: Animation;
  107597. /**
  107598. * Target to animate
  107599. */
  107600. target: any;
  107601. /**
  107602. * Serialize the object
  107603. * @returns the JSON object representing the current entity
  107604. */
  107605. serialize(): any;
  107606. }
  107607. /**
  107608. * Use this class to create coordinated animations on multiple targets
  107609. */
  107610. export class AnimationGroup implements IDisposable {
  107611. /** The name of the animation group */
  107612. name: string;
  107613. private _scene;
  107614. private _targetedAnimations;
  107615. private _animatables;
  107616. private _from;
  107617. private _to;
  107618. private _isStarted;
  107619. private _isPaused;
  107620. private _speedRatio;
  107621. private _loopAnimation;
  107622. /**
  107623. * Gets or sets the unique id of the node
  107624. */
  107625. uniqueId: number;
  107626. /**
  107627. * This observable will notify when one animation have ended
  107628. */
  107629. onAnimationEndObservable: Observable<TargetedAnimation>;
  107630. /**
  107631. * Observer raised when one animation loops
  107632. */
  107633. onAnimationLoopObservable: Observable<TargetedAnimation>;
  107634. /**
  107635. * Observer raised when all animations have looped
  107636. */
  107637. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  107638. /**
  107639. * This observable will notify when all animations have ended.
  107640. */
  107641. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  107642. /**
  107643. * This observable will notify when all animations have paused.
  107644. */
  107645. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  107646. /**
  107647. * This observable will notify when all animations are playing.
  107648. */
  107649. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  107650. /**
  107651. * Gets the first frame
  107652. */
  107653. get from(): number;
  107654. /**
  107655. * Gets the last frame
  107656. */
  107657. get to(): number;
  107658. /**
  107659. * Define if the animations are started
  107660. */
  107661. get isStarted(): boolean;
  107662. /**
  107663. * Gets a value indicating that the current group is playing
  107664. */
  107665. get isPlaying(): boolean;
  107666. /**
  107667. * Gets or sets the speed ratio to use for all animations
  107668. */
  107669. get speedRatio(): number;
  107670. /**
  107671. * Gets or sets the speed ratio to use for all animations
  107672. */
  107673. set speedRatio(value: number);
  107674. /**
  107675. * Gets or sets if all animations should loop or not
  107676. */
  107677. get loopAnimation(): boolean;
  107678. set loopAnimation(value: boolean);
  107679. /**
  107680. * Gets the targeted animations for this animation group
  107681. */
  107682. get targetedAnimations(): Array<TargetedAnimation>;
  107683. /**
  107684. * returning the list of animatables controlled by this animation group.
  107685. */
  107686. get animatables(): Array<Animatable>;
  107687. /**
  107688. * Instantiates a new Animation Group.
  107689. * This helps managing several animations at once.
  107690. * @see http://doc.babylonjs.com/how_to/group
  107691. * @param name Defines the name of the group
  107692. * @param scene Defines the scene the group belongs to
  107693. */
  107694. constructor(
  107695. /** The name of the animation group */
  107696. name: string, scene?: Nullable<Scene>);
  107697. /**
  107698. * Add an animation (with its target) in the group
  107699. * @param animation defines the animation we want to add
  107700. * @param target defines the target of the animation
  107701. * @returns the TargetedAnimation object
  107702. */
  107703. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  107704. /**
  107705. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  107706. * It can add constant keys at begin or end
  107707. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  107708. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  107709. * @returns the animation group
  107710. */
  107711. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  107712. private _animationLoopCount;
  107713. private _animationLoopFlags;
  107714. private _processLoop;
  107715. /**
  107716. * Start all animations on given targets
  107717. * @param loop defines if animations must loop
  107718. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  107719. * @param from defines the from key (optional)
  107720. * @param to defines the to key (optional)
  107721. * @returns the current animation group
  107722. */
  107723. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  107724. /**
  107725. * Pause all animations
  107726. * @returns the animation group
  107727. */
  107728. pause(): AnimationGroup;
  107729. /**
  107730. * Play all animations to initial state
  107731. * This function will start() the animations if they were not started or will restart() them if they were paused
  107732. * @param loop defines if animations must loop
  107733. * @returns the animation group
  107734. */
  107735. play(loop?: boolean): AnimationGroup;
  107736. /**
  107737. * Reset all animations to initial state
  107738. * @returns the animation group
  107739. */
  107740. reset(): AnimationGroup;
  107741. /**
  107742. * Restart animations from key 0
  107743. * @returns the animation group
  107744. */
  107745. restart(): AnimationGroup;
  107746. /**
  107747. * Stop all animations
  107748. * @returns the animation group
  107749. */
  107750. stop(): AnimationGroup;
  107751. /**
  107752. * Set animation weight for all animatables
  107753. * @param weight defines the weight to use
  107754. * @return the animationGroup
  107755. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107756. */
  107757. setWeightForAllAnimatables(weight: number): AnimationGroup;
  107758. /**
  107759. * Synchronize and normalize all animatables with a source animatable
  107760. * @param root defines the root animatable to synchronize with
  107761. * @return the animationGroup
  107762. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107763. */
  107764. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  107765. /**
  107766. * Goes to a specific frame in this animation group
  107767. * @param frame the frame number to go to
  107768. * @return the animationGroup
  107769. */
  107770. goToFrame(frame: number): AnimationGroup;
  107771. /**
  107772. * Dispose all associated resources
  107773. */
  107774. dispose(): void;
  107775. private _checkAnimationGroupEnded;
  107776. /**
  107777. * Clone the current animation group and returns a copy
  107778. * @param newName defines the name of the new group
  107779. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  107780. * @returns the new aniamtion group
  107781. */
  107782. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  107783. /**
  107784. * Serializes the animationGroup to an object
  107785. * @returns Serialized object
  107786. */
  107787. serialize(): any;
  107788. /**
  107789. * Returns a new AnimationGroup object parsed from the source provided.
  107790. * @param parsedAnimationGroup defines the source
  107791. * @param scene defines the scene that will receive the animationGroup
  107792. * @returns a new AnimationGroup
  107793. */
  107794. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  107795. /**
  107796. * Returns the string "AnimationGroup"
  107797. * @returns "AnimationGroup"
  107798. */
  107799. getClassName(): string;
  107800. /**
  107801. * Creates a detailled string about the object
  107802. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  107803. * @returns a string representing the object
  107804. */
  107805. toString(fullDetails?: boolean): string;
  107806. }
  107807. }
  107808. declare module BABYLON {
  107809. /**
  107810. * Define an interface for all classes that will hold resources
  107811. */
  107812. export interface IDisposable {
  107813. /**
  107814. * Releases all held resources
  107815. */
  107816. dispose(): void;
  107817. }
  107818. /** Interface defining initialization parameters for Scene class */
  107819. export interface SceneOptions {
  107820. /**
  107821. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  107822. * It will improve performance when the number of geometries becomes important.
  107823. */
  107824. useGeometryUniqueIdsMap?: boolean;
  107825. /**
  107826. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  107827. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107828. */
  107829. useMaterialMeshMap?: boolean;
  107830. /**
  107831. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  107832. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107833. */
  107834. useClonedMeshMap?: boolean;
  107835. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  107836. virtual?: boolean;
  107837. }
  107838. /**
  107839. * Represents a scene to be rendered by the engine.
  107840. * @see http://doc.babylonjs.com/features/scene
  107841. */
  107842. export class Scene extends AbstractScene implements IAnimatable {
  107843. /** The fog is deactivated */
  107844. static readonly FOGMODE_NONE: number;
  107845. /** The fog density is following an exponential function */
  107846. static readonly FOGMODE_EXP: number;
  107847. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  107848. static readonly FOGMODE_EXP2: number;
  107849. /** The fog density is following a linear function. */
  107850. static readonly FOGMODE_LINEAR: number;
  107851. /**
  107852. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  107853. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107854. */
  107855. static MinDeltaTime: number;
  107856. /**
  107857. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  107858. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107859. */
  107860. static MaxDeltaTime: number;
  107861. /**
  107862. * Factory used to create the default material.
  107863. * @param name The name of the material to create
  107864. * @param scene The scene to create the material for
  107865. * @returns The default material
  107866. */
  107867. static DefaultMaterialFactory(scene: Scene): Material;
  107868. /**
  107869. * Factory used to create the a collision coordinator.
  107870. * @returns The collision coordinator
  107871. */
  107872. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  107873. /** @hidden */
  107874. _inputManager: InputManager;
  107875. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  107876. cameraToUseForPointers: Nullable<Camera>;
  107877. /** @hidden */
  107878. readonly _isScene: boolean;
  107879. /**
  107880. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  107881. */
  107882. autoClear: boolean;
  107883. /**
  107884. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  107885. */
  107886. autoClearDepthAndStencil: boolean;
  107887. /**
  107888. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  107889. */
  107890. clearColor: Color4;
  107891. /**
  107892. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  107893. */
  107894. ambientColor: Color3;
  107895. /**
  107896. * This is use to store the default BRDF lookup for PBR materials in your scene.
  107897. * It should only be one of the following (if not the default embedded one):
  107898. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107899. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  107900. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107901. * The material properties need to be setup according to the type of texture in use.
  107902. */
  107903. environmentBRDFTexture: BaseTexture;
  107904. /** @hidden */
  107905. protected _environmentTexture: Nullable<BaseTexture>;
  107906. /**
  107907. * Texture used in all pbr material as the reflection texture.
  107908. * As in the majority of the scene they are the same (exception for multi room and so on),
  107909. * this is easier to reference from here than from all the materials.
  107910. */
  107911. get environmentTexture(): Nullable<BaseTexture>;
  107912. /**
  107913. * Texture used in all pbr material as the reflection texture.
  107914. * As in the majority of the scene they are the same (exception for multi room and so on),
  107915. * this is easier to set here than in all the materials.
  107916. */
  107917. set environmentTexture(value: Nullable<BaseTexture>);
  107918. /** @hidden */
  107919. protected _environmentIntensity: number;
  107920. /**
  107921. * Intensity of the environment in all pbr material.
  107922. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107923. * As in the majority of the scene they are the same (exception for multi room and so on),
  107924. * this is easier to reference from here than from all the materials.
  107925. */
  107926. get environmentIntensity(): number;
  107927. /**
  107928. * Intensity of the environment in all pbr material.
  107929. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107930. * As in the majority of the scene they are the same (exception for multi room and so on),
  107931. * this is easier to set here than in all the materials.
  107932. */
  107933. set environmentIntensity(value: number);
  107934. /** @hidden */
  107935. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107936. /**
  107937. * Default image processing configuration used either in the rendering
  107938. * Forward main pass or through the imageProcessingPostProcess if present.
  107939. * As in the majority of the scene they are the same (exception for multi camera),
  107940. * this is easier to reference from here than from all the materials and post process.
  107941. *
  107942. * No setter as we it is a shared configuration, you can set the values instead.
  107943. */
  107944. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107945. private _forceWireframe;
  107946. /**
  107947. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  107948. */
  107949. set forceWireframe(value: boolean);
  107950. get forceWireframe(): boolean;
  107951. private _skipFrustumClipping;
  107952. /**
  107953. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  107954. */
  107955. set skipFrustumClipping(value: boolean);
  107956. get skipFrustumClipping(): boolean;
  107957. private _forcePointsCloud;
  107958. /**
  107959. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  107960. */
  107961. set forcePointsCloud(value: boolean);
  107962. get forcePointsCloud(): boolean;
  107963. /**
  107964. * Gets or sets the active clipplane 1
  107965. */
  107966. clipPlane: Nullable<Plane>;
  107967. /**
  107968. * Gets or sets the active clipplane 2
  107969. */
  107970. clipPlane2: Nullable<Plane>;
  107971. /**
  107972. * Gets or sets the active clipplane 3
  107973. */
  107974. clipPlane3: Nullable<Plane>;
  107975. /**
  107976. * Gets or sets the active clipplane 4
  107977. */
  107978. clipPlane4: Nullable<Plane>;
  107979. /**
  107980. * Gets or sets the active clipplane 5
  107981. */
  107982. clipPlane5: Nullable<Plane>;
  107983. /**
  107984. * Gets or sets the active clipplane 6
  107985. */
  107986. clipPlane6: Nullable<Plane>;
  107987. /**
  107988. * Gets or sets a boolean indicating if animations are enabled
  107989. */
  107990. animationsEnabled: boolean;
  107991. private _animationPropertiesOverride;
  107992. /**
  107993. * Gets or sets the animation properties override
  107994. */
  107995. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107996. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107997. /**
  107998. * Gets or sets a boolean indicating if a constant deltatime has to be used
  107999. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108000. */
  108001. useConstantAnimationDeltaTime: boolean;
  108002. /**
  108003. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108004. * Please note that it requires to run a ray cast through the scene on every frame
  108005. */
  108006. constantlyUpdateMeshUnderPointer: boolean;
  108007. /**
  108008. * Defines the HTML cursor to use when hovering over interactive elements
  108009. */
  108010. hoverCursor: string;
  108011. /**
  108012. * Defines the HTML default cursor to use (empty by default)
  108013. */
  108014. defaultCursor: string;
  108015. /**
  108016. * Defines whether cursors are handled by the scene.
  108017. */
  108018. doNotHandleCursors: boolean;
  108019. /**
  108020. * This is used to call preventDefault() on pointer down
  108021. * in order to block unwanted artifacts like system double clicks
  108022. */
  108023. preventDefaultOnPointerDown: boolean;
  108024. /**
  108025. * This is used to call preventDefault() on pointer up
  108026. * in order to block unwanted artifacts like system double clicks
  108027. */
  108028. preventDefaultOnPointerUp: boolean;
  108029. /**
  108030. * Gets or sets user defined metadata
  108031. */
  108032. metadata: any;
  108033. /**
  108034. * For internal use only. Please do not use.
  108035. */
  108036. reservedDataStore: any;
  108037. /**
  108038. * Gets the name of the plugin used to load this scene (null by default)
  108039. */
  108040. loadingPluginName: string;
  108041. /**
  108042. * Use this array to add regular expressions used to disable offline support for specific urls
  108043. */
  108044. disableOfflineSupportExceptionRules: RegExp[];
  108045. /**
  108046. * An event triggered when the scene is disposed.
  108047. */
  108048. onDisposeObservable: Observable<Scene>;
  108049. private _onDisposeObserver;
  108050. /** Sets a function to be executed when this scene is disposed. */
  108051. set onDispose(callback: () => void);
  108052. /**
  108053. * An event triggered before rendering the scene (right after animations and physics)
  108054. */
  108055. onBeforeRenderObservable: Observable<Scene>;
  108056. private _onBeforeRenderObserver;
  108057. /** Sets a function to be executed before rendering this scene */
  108058. set beforeRender(callback: Nullable<() => void>);
  108059. /**
  108060. * An event triggered after rendering the scene
  108061. */
  108062. onAfterRenderObservable: Observable<Scene>;
  108063. /**
  108064. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108065. */
  108066. onAfterRenderCameraObservable: Observable<Camera>;
  108067. private _onAfterRenderObserver;
  108068. /** Sets a function to be executed after rendering this scene */
  108069. set afterRender(callback: Nullable<() => void>);
  108070. /**
  108071. * An event triggered before animating the scene
  108072. */
  108073. onBeforeAnimationsObservable: Observable<Scene>;
  108074. /**
  108075. * An event triggered after animations processing
  108076. */
  108077. onAfterAnimationsObservable: Observable<Scene>;
  108078. /**
  108079. * An event triggered before draw calls are ready to be sent
  108080. */
  108081. onBeforeDrawPhaseObservable: Observable<Scene>;
  108082. /**
  108083. * An event triggered after draw calls have been sent
  108084. */
  108085. onAfterDrawPhaseObservable: Observable<Scene>;
  108086. /**
  108087. * An event triggered when the scene is ready
  108088. */
  108089. onReadyObservable: Observable<Scene>;
  108090. /**
  108091. * An event triggered before rendering a camera
  108092. */
  108093. onBeforeCameraRenderObservable: Observable<Camera>;
  108094. private _onBeforeCameraRenderObserver;
  108095. /** Sets a function to be executed before rendering a camera*/
  108096. set beforeCameraRender(callback: () => void);
  108097. /**
  108098. * An event triggered after rendering a camera
  108099. */
  108100. onAfterCameraRenderObservable: Observable<Camera>;
  108101. private _onAfterCameraRenderObserver;
  108102. /** Sets a function to be executed after rendering a camera*/
  108103. set afterCameraRender(callback: () => void);
  108104. /**
  108105. * An event triggered when active meshes evaluation is about to start
  108106. */
  108107. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108108. /**
  108109. * An event triggered when active meshes evaluation is done
  108110. */
  108111. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108112. /**
  108113. * An event triggered when particles rendering is about to start
  108114. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108115. */
  108116. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108117. /**
  108118. * An event triggered when particles rendering is done
  108119. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108120. */
  108121. onAfterParticlesRenderingObservable: Observable<Scene>;
  108122. /**
  108123. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108124. */
  108125. onDataLoadedObservable: Observable<Scene>;
  108126. /**
  108127. * An event triggered when a camera is created
  108128. */
  108129. onNewCameraAddedObservable: Observable<Camera>;
  108130. /**
  108131. * An event triggered when a camera is removed
  108132. */
  108133. onCameraRemovedObservable: Observable<Camera>;
  108134. /**
  108135. * An event triggered when a light is created
  108136. */
  108137. onNewLightAddedObservable: Observable<Light>;
  108138. /**
  108139. * An event triggered when a light is removed
  108140. */
  108141. onLightRemovedObservable: Observable<Light>;
  108142. /**
  108143. * An event triggered when a geometry is created
  108144. */
  108145. onNewGeometryAddedObservable: Observable<Geometry>;
  108146. /**
  108147. * An event triggered when a geometry is removed
  108148. */
  108149. onGeometryRemovedObservable: Observable<Geometry>;
  108150. /**
  108151. * An event triggered when a transform node is created
  108152. */
  108153. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108154. /**
  108155. * An event triggered when a transform node is removed
  108156. */
  108157. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108158. /**
  108159. * An event triggered when a mesh is created
  108160. */
  108161. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108162. /**
  108163. * An event triggered when a mesh is removed
  108164. */
  108165. onMeshRemovedObservable: Observable<AbstractMesh>;
  108166. /**
  108167. * An event triggered when a skeleton is created
  108168. */
  108169. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108170. /**
  108171. * An event triggered when a skeleton is removed
  108172. */
  108173. onSkeletonRemovedObservable: Observable<Skeleton>;
  108174. /**
  108175. * An event triggered when a material is created
  108176. */
  108177. onNewMaterialAddedObservable: Observable<Material>;
  108178. /**
  108179. * An event triggered when a material is removed
  108180. */
  108181. onMaterialRemovedObservable: Observable<Material>;
  108182. /**
  108183. * An event triggered when a texture is created
  108184. */
  108185. onNewTextureAddedObservable: Observable<BaseTexture>;
  108186. /**
  108187. * An event triggered when a texture is removed
  108188. */
  108189. onTextureRemovedObservable: Observable<BaseTexture>;
  108190. /**
  108191. * An event triggered when render targets are about to be rendered
  108192. * Can happen multiple times per frame.
  108193. */
  108194. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108195. /**
  108196. * An event triggered when render targets were rendered.
  108197. * Can happen multiple times per frame.
  108198. */
  108199. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108200. /**
  108201. * An event triggered before calculating deterministic simulation step
  108202. */
  108203. onBeforeStepObservable: Observable<Scene>;
  108204. /**
  108205. * An event triggered after calculating deterministic simulation step
  108206. */
  108207. onAfterStepObservable: Observable<Scene>;
  108208. /**
  108209. * An event triggered when the activeCamera property is updated
  108210. */
  108211. onActiveCameraChanged: Observable<Scene>;
  108212. /**
  108213. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108214. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108215. * 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)
  108216. */
  108217. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108218. /**
  108219. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108220. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108221. * 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)
  108222. */
  108223. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108224. /**
  108225. * This Observable will when a mesh has been imported into the scene.
  108226. */
  108227. onMeshImportedObservable: Observable<AbstractMesh>;
  108228. /**
  108229. * This Observable will when an animation file has been imported into the scene.
  108230. */
  108231. onAnimationFileImportedObservable: Observable<Scene>;
  108232. /**
  108233. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108234. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108235. */
  108236. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108237. /** @hidden */
  108238. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108239. /**
  108240. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108241. */
  108242. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108243. /**
  108244. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108245. */
  108246. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108247. /**
  108248. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108249. */
  108250. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108251. /** Callback called when a pointer move is detected */
  108252. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108253. /** Callback called when a pointer down is detected */
  108254. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108255. /** Callback called when a pointer up is detected */
  108256. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108257. /** Callback called when a pointer pick is detected */
  108258. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108259. /**
  108260. * 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).
  108261. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108262. */
  108263. onPrePointerObservable: Observable<PointerInfoPre>;
  108264. /**
  108265. * Observable event triggered each time an input event is received from the rendering canvas
  108266. */
  108267. onPointerObservable: Observable<PointerInfo>;
  108268. /**
  108269. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108270. */
  108271. get unTranslatedPointer(): Vector2;
  108272. /**
  108273. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108274. */
  108275. static get DragMovementThreshold(): number;
  108276. static set DragMovementThreshold(value: number);
  108277. /**
  108278. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108279. */
  108280. static get LongPressDelay(): number;
  108281. static set LongPressDelay(value: number);
  108282. /**
  108283. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108284. */
  108285. static get DoubleClickDelay(): number;
  108286. static set DoubleClickDelay(value: number);
  108287. /** If you need to check double click without raising a single click at first click, enable this flag */
  108288. static get ExclusiveDoubleClickMode(): boolean;
  108289. static set ExclusiveDoubleClickMode(value: boolean);
  108290. /** @hidden */
  108291. _mirroredCameraPosition: Nullable<Vector3>;
  108292. /**
  108293. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108294. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108295. */
  108296. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108297. /**
  108298. * Observable event triggered each time an keyboard event is received from the hosting window
  108299. */
  108300. onKeyboardObservable: Observable<KeyboardInfo>;
  108301. private _useRightHandedSystem;
  108302. /**
  108303. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108304. */
  108305. set useRightHandedSystem(value: boolean);
  108306. get useRightHandedSystem(): boolean;
  108307. private _timeAccumulator;
  108308. private _currentStepId;
  108309. private _currentInternalStep;
  108310. /**
  108311. * Sets the step Id used by deterministic lock step
  108312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108313. * @param newStepId defines the step Id
  108314. */
  108315. setStepId(newStepId: number): void;
  108316. /**
  108317. * Gets the step Id used by deterministic lock step
  108318. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108319. * @returns the step Id
  108320. */
  108321. getStepId(): number;
  108322. /**
  108323. * Gets the internal step used by deterministic lock step
  108324. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108325. * @returns the internal step
  108326. */
  108327. getInternalStep(): number;
  108328. private _fogEnabled;
  108329. /**
  108330. * Gets or sets a boolean indicating if fog is enabled on this scene
  108331. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108332. * (Default is true)
  108333. */
  108334. set fogEnabled(value: boolean);
  108335. get fogEnabled(): boolean;
  108336. private _fogMode;
  108337. /**
  108338. * Gets or sets the fog mode to use
  108339. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108340. * | mode | value |
  108341. * | --- | --- |
  108342. * | FOGMODE_NONE | 0 |
  108343. * | FOGMODE_EXP | 1 |
  108344. * | FOGMODE_EXP2 | 2 |
  108345. * | FOGMODE_LINEAR | 3 |
  108346. */
  108347. set fogMode(value: number);
  108348. get fogMode(): number;
  108349. /**
  108350. * Gets or sets the fog color to use
  108351. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108352. * (Default is Color3(0.2, 0.2, 0.3))
  108353. */
  108354. fogColor: Color3;
  108355. /**
  108356. * Gets or sets the fog density to use
  108357. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108358. * (Default is 0.1)
  108359. */
  108360. fogDensity: number;
  108361. /**
  108362. * Gets or sets the fog start distance to use
  108363. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108364. * (Default is 0)
  108365. */
  108366. fogStart: number;
  108367. /**
  108368. * Gets or sets the fog end distance to use
  108369. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108370. * (Default is 1000)
  108371. */
  108372. fogEnd: number;
  108373. private _shadowsEnabled;
  108374. /**
  108375. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108376. */
  108377. set shadowsEnabled(value: boolean);
  108378. get shadowsEnabled(): boolean;
  108379. private _lightsEnabled;
  108380. /**
  108381. * Gets or sets a boolean indicating if lights are enabled on this scene
  108382. */
  108383. set lightsEnabled(value: boolean);
  108384. get lightsEnabled(): boolean;
  108385. /** All of the active cameras added to this scene. */
  108386. activeCameras: Camera[];
  108387. /** @hidden */
  108388. _activeCamera: Nullable<Camera>;
  108389. /** Gets or sets the current active camera */
  108390. get activeCamera(): Nullable<Camera>;
  108391. set activeCamera(value: Nullable<Camera>);
  108392. private _defaultMaterial;
  108393. /** The default material used on meshes when no material is affected */
  108394. get defaultMaterial(): Material;
  108395. /** The default material used on meshes when no material is affected */
  108396. set defaultMaterial(value: Material);
  108397. private _texturesEnabled;
  108398. /**
  108399. * Gets or sets a boolean indicating if textures are enabled on this scene
  108400. */
  108401. set texturesEnabled(value: boolean);
  108402. get texturesEnabled(): boolean;
  108403. /**
  108404. * Gets or sets a boolean indicating if particles are enabled on this scene
  108405. */
  108406. particlesEnabled: boolean;
  108407. /**
  108408. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108409. */
  108410. spritesEnabled: boolean;
  108411. private _skeletonsEnabled;
  108412. /**
  108413. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108414. */
  108415. set skeletonsEnabled(value: boolean);
  108416. get skeletonsEnabled(): boolean;
  108417. /**
  108418. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108419. */
  108420. lensFlaresEnabled: boolean;
  108421. /**
  108422. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108424. */
  108425. collisionsEnabled: boolean;
  108426. private _collisionCoordinator;
  108427. /** @hidden */
  108428. get collisionCoordinator(): ICollisionCoordinator;
  108429. /**
  108430. * Defines the gravity applied to this scene (used only for collisions)
  108431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108432. */
  108433. gravity: Vector3;
  108434. /**
  108435. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108436. */
  108437. postProcessesEnabled: boolean;
  108438. /**
  108439. * The list of postprocesses added to the scene
  108440. */
  108441. postProcesses: PostProcess[];
  108442. /**
  108443. * Gets the current postprocess manager
  108444. */
  108445. postProcessManager: PostProcessManager;
  108446. /**
  108447. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108448. */
  108449. renderTargetsEnabled: boolean;
  108450. /**
  108451. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108452. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108453. */
  108454. dumpNextRenderTargets: boolean;
  108455. /**
  108456. * The list of user defined render targets added to the scene
  108457. */
  108458. customRenderTargets: RenderTargetTexture[];
  108459. /**
  108460. * Defines if texture loading must be delayed
  108461. * If true, textures will only be loaded when they need to be rendered
  108462. */
  108463. useDelayedTextureLoading: boolean;
  108464. /**
  108465. * Gets the list of meshes imported to the scene through SceneLoader
  108466. */
  108467. importedMeshesFiles: String[];
  108468. /**
  108469. * Gets or sets a boolean indicating if probes are enabled on this scene
  108470. */
  108471. probesEnabled: boolean;
  108472. /**
  108473. * Gets or sets the current offline provider to use to store scene data
  108474. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108475. */
  108476. offlineProvider: IOfflineProvider;
  108477. /**
  108478. * Gets or sets the action manager associated with the scene
  108479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108480. */
  108481. actionManager: AbstractActionManager;
  108482. private _meshesForIntersections;
  108483. /**
  108484. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108485. */
  108486. proceduralTexturesEnabled: boolean;
  108487. private _engine;
  108488. private _totalVertices;
  108489. /** @hidden */
  108490. _activeIndices: PerfCounter;
  108491. /** @hidden */
  108492. _activeParticles: PerfCounter;
  108493. /** @hidden */
  108494. _activeBones: PerfCounter;
  108495. private _animationRatio;
  108496. /** @hidden */
  108497. _animationTimeLast: number;
  108498. /** @hidden */
  108499. _animationTime: number;
  108500. /**
  108501. * Gets or sets a general scale for animation speed
  108502. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108503. */
  108504. animationTimeScale: number;
  108505. /** @hidden */
  108506. _cachedMaterial: Nullable<Material>;
  108507. /** @hidden */
  108508. _cachedEffect: Nullable<Effect>;
  108509. /** @hidden */
  108510. _cachedVisibility: Nullable<number>;
  108511. private _renderId;
  108512. private _frameId;
  108513. private _executeWhenReadyTimeoutId;
  108514. private _intermediateRendering;
  108515. private _viewUpdateFlag;
  108516. private _projectionUpdateFlag;
  108517. /** @hidden */
  108518. _toBeDisposed: Nullable<IDisposable>[];
  108519. private _activeRequests;
  108520. /** @hidden */
  108521. _pendingData: any[];
  108522. private _isDisposed;
  108523. /**
  108524. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108525. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108526. */
  108527. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108528. private _activeMeshes;
  108529. private _processedMaterials;
  108530. private _renderTargets;
  108531. /** @hidden */
  108532. _activeParticleSystems: SmartArray<IParticleSystem>;
  108533. private _activeSkeletons;
  108534. private _softwareSkinnedMeshes;
  108535. private _renderingManager;
  108536. /** @hidden */
  108537. _activeAnimatables: Animatable[];
  108538. private _transformMatrix;
  108539. private _sceneUbo;
  108540. /** @hidden */
  108541. _viewMatrix: Matrix;
  108542. private _projectionMatrix;
  108543. /** @hidden */
  108544. _forcedViewPosition: Nullable<Vector3>;
  108545. /** @hidden */
  108546. _frustumPlanes: Plane[];
  108547. /**
  108548. * Gets the list of frustum planes (built from the active camera)
  108549. */
  108550. get frustumPlanes(): Plane[];
  108551. /**
  108552. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108553. * This is useful if there are more lights that the maximum simulteanous authorized
  108554. */
  108555. requireLightSorting: boolean;
  108556. /** @hidden */
  108557. readonly useMaterialMeshMap: boolean;
  108558. /** @hidden */
  108559. readonly useClonedMeshMap: boolean;
  108560. private _externalData;
  108561. private _uid;
  108562. /**
  108563. * @hidden
  108564. * Backing store of defined scene components.
  108565. */
  108566. _components: ISceneComponent[];
  108567. /**
  108568. * @hidden
  108569. * Backing store of defined scene components.
  108570. */
  108571. _serializableComponents: ISceneSerializableComponent[];
  108572. /**
  108573. * List of components to register on the next registration step.
  108574. */
  108575. private _transientComponents;
  108576. /**
  108577. * Registers the transient components if needed.
  108578. */
  108579. private _registerTransientComponents;
  108580. /**
  108581. * @hidden
  108582. * Add a component to the scene.
  108583. * Note that the ccomponent could be registered on th next frame if this is called after
  108584. * the register component stage.
  108585. * @param component Defines the component to add to the scene
  108586. */
  108587. _addComponent(component: ISceneComponent): void;
  108588. /**
  108589. * @hidden
  108590. * Gets a component from the scene.
  108591. * @param name defines the name of the component to retrieve
  108592. * @returns the component or null if not present
  108593. */
  108594. _getComponent(name: string): Nullable<ISceneComponent>;
  108595. /**
  108596. * @hidden
  108597. * Defines the actions happening before camera updates.
  108598. */
  108599. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  108600. /**
  108601. * @hidden
  108602. * Defines the actions happening before clear the canvas.
  108603. */
  108604. _beforeClearStage: Stage<SimpleStageAction>;
  108605. /**
  108606. * @hidden
  108607. * Defines the actions when collecting render targets for the frame.
  108608. */
  108609. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108610. /**
  108611. * @hidden
  108612. * Defines the actions happening for one camera in the frame.
  108613. */
  108614. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108615. /**
  108616. * @hidden
  108617. * Defines the actions happening during the per mesh ready checks.
  108618. */
  108619. _isReadyForMeshStage: Stage<MeshStageAction>;
  108620. /**
  108621. * @hidden
  108622. * Defines the actions happening before evaluate active mesh checks.
  108623. */
  108624. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  108625. /**
  108626. * @hidden
  108627. * Defines the actions happening during the evaluate sub mesh checks.
  108628. */
  108629. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  108630. /**
  108631. * @hidden
  108632. * Defines the actions happening during the active mesh stage.
  108633. */
  108634. _activeMeshStage: Stage<ActiveMeshStageAction>;
  108635. /**
  108636. * @hidden
  108637. * Defines the actions happening during the per camera render target step.
  108638. */
  108639. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  108640. /**
  108641. * @hidden
  108642. * Defines the actions happening just before the active camera is drawing.
  108643. */
  108644. _beforeCameraDrawStage: Stage<CameraStageAction>;
  108645. /**
  108646. * @hidden
  108647. * Defines the actions happening just before a render target is drawing.
  108648. */
  108649. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108650. /**
  108651. * @hidden
  108652. * Defines the actions happening just before a rendering group is drawing.
  108653. */
  108654. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108655. /**
  108656. * @hidden
  108657. * Defines the actions happening just before a mesh is drawing.
  108658. */
  108659. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108660. /**
  108661. * @hidden
  108662. * Defines the actions happening just after a mesh has been drawn.
  108663. */
  108664. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108665. /**
  108666. * @hidden
  108667. * Defines the actions happening just after a rendering group has been drawn.
  108668. */
  108669. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108670. /**
  108671. * @hidden
  108672. * Defines the actions happening just after the active camera has been drawn.
  108673. */
  108674. _afterCameraDrawStage: Stage<CameraStageAction>;
  108675. /**
  108676. * @hidden
  108677. * Defines the actions happening just after a render target has been drawn.
  108678. */
  108679. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108680. /**
  108681. * @hidden
  108682. * Defines the actions happening just after rendering all cameras and computing intersections.
  108683. */
  108684. _afterRenderStage: Stage<SimpleStageAction>;
  108685. /**
  108686. * @hidden
  108687. * Defines the actions happening when a pointer move event happens.
  108688. */
  108689. _pointerMoveStage: Stage<PointerMoveStageAction>;
  108690. /**
  108691. * @hidden
  108692. * Defines the actions happening when a pointer down event happens.
  108693. */
  108694. _pointerDownStage: Stage<PointerUpDownStageAction>;
  108695. /**
  108696. * @hidden
  108697. * Defines the actions happening when a pointer up event happens.
  108698. */
  108699. _pointerUpStage: Stage<PointerUpDownStageAction>;
  108700. /**
  108701. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  108702. */
  108703. private geometriesByUniqueId;
  108704. /**
  108705. * Creates a new Scene
  108706. * @param engine defines the engine to use to render this scene
  108707. * @param options defines the scene options
  108708. */
  108709. constructor(engine: Engine, options?: SceneOptions);
  108710. /**
  108711. * Gets a string idenfifying the name of the class
  108712. * @returns "Scene" string
  108713. */
  108714. getClassName(): string;
  108715. private _defaultMeshCandidates;
  108716. /**
  108717. * @hidden
  108718. */
  108719. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108720. private _defaultSubMeshCandidates;
  108721. /**
  108722. * @hidden
  108723. */
  108724. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108725. /**
  108726. * Sets the default candidate providers for the scene.
  108727. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  108728. * and getCollidingSubMeshCandidates to their default function
  108729. */
  108730. setDefaultCandidateProviders(): void;
  108731. /**
  108732. * Gets the mesh that is currently under the pointer
  108733. */
  108734. get meshUnderPointer(): Nullable<AbstractMesh>;
  108735. /**
  108736. * Gets or sets the current on-screen X position of the pointer
  108737. */
  108738. get pointerX(): number;
  108739. set pointerX(value: number);
  108740. /**
  108741. * Gets or sets the current on-screen Y position of the pointer
  108742. */
  108743. get pointerY(): number;
  108744. set pointerY(value: number);
  108745. /**
  108746. * Gets the cached material (ie. the latest rendered one)
  108747. * @returns the cached material
  108748. */
  108749. getCachedMaterial(): Nullable<Material>;
  108750. /**
  108751. * Gets the cached effect (ie. the latest rendered one)
  108752. * @returns the cached effect
  108753. */
  108754. getCachedEffect(): Nullable<Effect>;
  108755. /**
  108756. * Gets the cached visibility state (ie. the latest rendered one)
  108757. * @returns the cached visibility state
  108758. */
  108759. getCachedVisibility(): Nullable<number>;
  108760. /**
  108761. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  108762. * @param material defines the current material
  108763. * @param effect defines the current effect
  108764. * @param visibility defines the current visibility state
  108765. * @returns true if one parameter is not cached
  108766. */
  108767. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  108768. /**
  108769. * Gets the engine associated with the scene
  108770. * @returns an Engine
  108771. */
  108772. getEngine(): Engine;
  108773. /**
  108774. * Gets the total number of vertices rendered per frame
  108775. * @returns the total number of vertices rendered per frame
  108776. */
  108777. getTotalVertices(): number;
  108778. /**
  108779. * Gets the performance counter for total vertices
  108780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108781. */
  108782. get totalVerticesPerfCounter(): PerfCounter;
  108783. /**
  108784. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  108785. * @returns the total number of active indices rendered per frame
  108786. */
  108787. getActiveIndices(): number;
  108788. /**
  108789. * Gets the performance counter for active indices
  108790. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108791. */
  108792. get totalActiveIndicesPerfCounter(): PerfCounter;
  108793. /**
  108794. * Gets the total number of active particles rendered per frame
  108795. * @returns the total number of active particles rendered per frame
  108796. */
  108797. getActiveParticles(): number;
  108798. /**
  108799. * Gets the performance counter for active particles
  108800. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108801. */
  108802. get activeParticlesPerfCounter(): PerfCounter;
  108803. /**
  108804. * Gets the total number of active bones rendered per frame
  108805. * @returns the total number of active bones rendered per frame
  108806. */
  108807. getActiveBones(): number;
  108808. /**
  108809. * Gets the performance counter for active bones
  108810. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108811. */
  108812. get activeBonesPerfCounter(): PerfCounter;
  108813. /**
  108814. * Gets the array of active meshes
  108815. * @returns an array of AbstractMesh
  108816. */
  108817. getActiveMeshes(): SmartArray<AbstractMesh>;
  108818. /**
  108819. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  108820. * @returns a number
  108821. */
  108822. getAnimationRatio(): number;
  108823. /**
  108824. * Gets an unique Id for the current render phase
  108825. * @returns a number
  108826. */
  108827. getRenderId(): number;
  108828. /**
  108829. * Gets an unique Id for the current frame
  108830. * @returns a number
  108831. */
  108832. getFrameId(): number;
  108833. /** Call this function if you want to manually increment the render Id*/
  108834. incrementRenderId(): void;
  108835. private _createUbo;
  108836. /**
  108837. * Use this method to simulate a pointer move on a mesh
  108838. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108839. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108840. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108841. * @returns the current scene
  108842. */
  108843. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108844. /**
  108845. * Use this method to simulate a pointer down on a mesh
  108846. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108847. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108848. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108849. * @returns the current scene
  108850. */
  108851. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108852. /**
  108853. * Use this method to simulate a pointer up on a mesh
  108854. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108855. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108856. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108857. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108858. * @returns the current scene
  108859. */
  108860. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  108861. /**
  108862. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108863. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108864. * @returns true if the pointer was captured
  108865. */
  108866. isPointerCaptured(pointerId?: number): boolean;
  108867. /**
  108868. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108869. * @param attachUp defines if you want to attach events to pointerup
  108870. * @param attachDown defines if you want to attach events to pointerdown
  108871. * @param attachMove defines if you want to attach events to pointermove
  108872. */
  108873. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  108874. /** Detaches all event handlers*/
  108875. detachControl(): void;
  108876. /**
  108877. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  108878. * Delay loaded resources are not taking in account
  108879. * @return true if all required resources are ready
  108880. */
  108881. isReady(): boolean;
  108882. /** Resets all cached information relative to material (including effect and visibility) */
  108883. resetCachedMaterial(): void;
  108884. /**
  108885. * Registers a function to be called before every frame render
  108886. * @param func defines the function to register
  108887. */
  108888. registerBeforeRender(func: () => void): void;
  108889. /**
  108890. * Unregisters a function called before every frame render
  108891. * @param func defines the function to unregister
  108892. */
  108893. unregisterBeforeRender(func: () => void): void;
  108894. /**
  108895. * Registers a function to be called after every frame render
  108896. * @param func defines the function to register
  108897. */
  108898. registerAfterRender(func: () => void): void;
  108899. /**
  108900. * Unregisters a function called after every frame render
  108901. * @param func defines the function to unregister
  108902. */
  108903. unregisterAfterRender(func: () => void): void;
  108904. private _executeOnceBeforeRender;
  108905. /**
  108906. * The provided function will run before render once and will be disposed afterwards.
  108907. * A timeout delay can be provided so that the function will be executed in N ms.
  108908. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  108909. * @param func The function to be executed.
  108910. * @param timeout optional delay in ms
  108911. */
  108912. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  108913. /** @hidden */
  108914. _addPendingData(data: any): void;
  108915. /** @hidden */
  108916. _removePendingData(data: any): void;
  108917. /**
  108918. * Returns the number of items waiting to be loaded
  108919. * @returns the number of items waiting to be loaded
  108920. */
  108921. getWaitingItemsCount(): number;
  108922. /**
  108923. * Returns a boolean indicating if the scene is still loading data
  108924. */
  108925. get isLoading(): boolean;
  108926. /**
  108927. * Registers a function to be executed when the scene is ready
  108928. * @param {Function} func - the function to be executed
  108929. */
  108930. executeWhenReady(func: () => void): void;
  108931. /**
  108932. * Returns a promise that resolves when the scene is ready
  108933. * @returns A promise that resolves when the scene is ready
  108934. */
  108935. whenReadyAsync(): Promise<void>;
  108936. /** @hidden */
  108937. _checkIsReady(): void;
  108938. /**
  108939. * Gets all animatable attached to the scene
  108940. */
  108941. get animatables(): Animatable[];
  108942. /**
  108943. * Resets the last animation time frame.
  108944. * Useful to override when animations start running when loading a scene for the first time.
  108945. */
  108946. resetLastAnimationTimeFrame(): void;
  108947. /**
  108948. * Gets the current view matrix
  108949. * @returns a Matrix
  108950. */
  108951. getViewMatrix(): Matrix;
  108952. /**
  108953. * Gets the current projection matrix
  108954. * @returns a Matrix
  108955. */
  108956. getProjectionMatrix(): Matrix;
  108957. /**
  108958. * Gets the current transform matrix
  108959. * @returns a Matrix made of View * Projection
  108960. */
  108961. getTransformMatrix(): Matrix;
  108962. /**
  108963. * Sets the current transform matrix
  108964. * @param viewL defines the View matrix to use
  108965. * @param projectionL defines the Projection matrix to use
  108966. * @param viewR defines the right View matrix to use (if provided)
  108967. * @param projectionR defines the right Projection matrix to use (if provided)
  108968. */
  108969. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  108970. /**
  108971. * Gets the uniform buffer used to store scene data
  108972. * @returns a UniformBuffer
  108973. */
  108974. getSceneUniformBuffer(): UniformBuffer;
  108975. /**
  108976. * Gets an unique (relatively to the current scene) Id
  108977. * @returns an unique number for the scene
  108978. */
  108979. getUniqueId(): number;
  108980. /**
  108981. * Add a mesh to the list of scene's meshes
  108982. * @param newMesh defines the mesh to add
  108983. * @param recursive if all child meshes should also be added to the scene
  108984. */
  108985. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  108986. /**
  108987. * Remove a mesh for the list of scene's meshes
  108988. * @param toRemove defines the mesh to remove
  108989. * @param recursive if all child meshes should also be removed from the scene
  108990. * @returns the index where the mesh was in the mesh list
  108991. */
  108992. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  108993. /**
  108994. * Add a transform node to the list of scene's transform nodes
  108995. * @param newTransformNode defines the transform node to add
  108996. */
  108997. addTransformNode(newTransformNode: TransformNode): void;
  108998. /**
  108999. * Remove a transform node for the list of scene's transform nodes
  109000. * @param toRemove defines the transform node to remove
  109001. * @returns the index where the transform node was in the transform node list
  109002. */
  109003. removeTransformNode(toRemove: TransformNode): number;
  109004. /**
  109005. * Remove a skeleton for the list of scene's skeletons
  109006. * @param toRemove defines the skeleton to remove
  109007. * @returns the index where the skeleton was in the skeleton list
  109008. */
  109009. removeSkeleton(toRemove: Skeleton): number;
  109010. /**
  109011. * Remove a morph target for the list of scene's morph targets
  109012. * @param toRemove defines the morph target to remove
  109013. * @returns the index where the morph target was in the morph target list
  109014. */
  109015. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109016. /**
  109017. * Remove a light for the list of scene's lights
  109018. * @param toRemove defines the light to remove
  109019. * @returns the index where the light was in the light list
  109020. */
  109021. removeLight(toRemove: Light): number;
  109022. /**
  109023. * Remove a camera for the list of scene's cameras
  109024. * @param toRemove defines the camera to remove
  109025. * @returns the index where the camera was in the camera list
  109026. */
  109027. removeCamera(toRemove: Camera): number;
  109028. /**
  109029. * Remove a particle system for the list of scene's particle systems
  109030. * @param toRemove defines the particle system to remove
  109031. * @returns the index where the particle system was in the particle system list
  109032. */
  109033. removeParticleSystem(toRemove: IParticleSystem): number;
  109034. /**
  109035. * Remove a animation for the list of scene's animations
  109036. * @param toRemove defines the animation to remove
  109037. * @returns the index where the animation was in the animation list
  109038. */
  109039. removeAnimation(toRemove: Animation): number;
  109040. /**
  109041. * Will stop the animation of the given target
  109042. * @param target - the target
  109043. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109044. * @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)
  109045. */
  109046. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109047. /**
  109048. * Removes the given animation group from this scene.
  109049. * @param toRemove The animation group to remove
  109050. * @returns The index of the removed animation group
  109051. */
  109052. removeAnimationGroup(toRemove: AnimationGroup): number;
  109053. /**
  109054. * Removes the given multi-material from this scene.
  109055. * @param toRemove The multi-material to remove
  109056. * @returns The index of the removed multi-material
  109057. */
  109058. removeMultiMaterial(toRemove: MultiMaterial): number;
  109059. /**
  109060. * Removes the given material from this scene.
  109061. * @param toRemove The material to remove
  109062. * @returns The index of the removed material
  109063. */
  109064. removeMaterial(toRemove: Material): number;
  109065. /**
  109066. * Removes the given action manager from this scene.
  109067. * @param toRemove The action manager to remove
  109068. * @returns The index of the removed action manager
  109069. */
  109070. removeActionManager(toRemove: AbstractActionManager): number;
  109071. /**
  109072. * Removes the given texture from this scene.
  109073. * @param toRemove The texture to remove
  109074. * @returns The index of the removed texture
  109075. */
  109076. removeTexture(toRemove: BaseTexture): number;
  109077. /**
  109078. * Adds the given light to this scene
  109079. * @param newLight The light to add
  109080. */
  109081. addLight(newLight: Light): void;
  109082. /**
  109083. * Sorts the list list based on light priorities
  109084. */
  109085. sortLightsByPriority(): void;
  109086. /**
  109087. * Adds the given camera to this scene
  109088. * @param newCamera The camera to add
  109089. */
  109090. addCamera(newCamera: Camera): void;
  109091. /**
  109092. * Adds the given skeleton to this scene
  109093. * @param newSkeleton The skeleton to add
  109094. */
  109095. addSkeleton(newSkeleton: Skeleton): void;
  109096. /**
  109097. * Adds the given particle system to this scene
  109098. * @param newParticleSystem The particle system to add
  109099. */
  109100. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109101. /**
  109102. * Adds the given animation to this scene
  109103. * @param newAnimation The animation to add
  109104. */
  109105. addAnimation(newAnimation: Animation): void;
  109106. /**
  109107. * Adds the given animation group to this scene.
  109108. * @param newAnimationGroup The animation group to add
  109109. */
  109110. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109111. /**
  109112. * Adds the given multi-material to this scene
  109113. * @param newMultiMaterial The multi-material to add
  109114. */
  109115. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109116. /**
  109117. * Adds the given material to this scene
  109118. * @param newMaterial The material to add
  109119. */
  109120. addMaterial(newMaterial: Material): void;
  109121. /**
  109122. * Adds the given morph target to this scene
  109123. * @param newMorphTargetManager The morph target to add
  109124. */
  109125. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109126. /**
  109127. * Adds the given geometry to this scene
  109128. * @param newGeometry The geometry to add
  109129. */
  109130. addGeometry(newGeometry: Geometry): void;
  109131. /**
  109132. * Adds the given action manager to this scene
  109133. * @param newActionManager The action manager to add
  109134. */
  109135. addActionManager(newActionManager: AbstractActionManager): void;
  109136. /**
  109137. * Adds the given texture to this scene.
  109138. * @param newTexture The texture to add
  109139. */
  109140. addTexture(newTexture: BaseTexture): void;
  109141. /**
  109142. * Switch active camera
  109143. * @param newCamera defines the new active camera
  109144. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109145. */
  109146. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109147. /**
  109148. * sets the active camera of the scene using its ID
  109149. * @param id defines the camera's ID
  109150. * @return the new active camera or null if none found.
  109151. */
  109152. setActiveCameraByID(id: string): Nullable<Camera>;
  109153. /**
  109154. * sets the active camera of the scene using its name
  109155. * @param name defines the camera's name
  109156. * @returns the new active camera or null if none found.
  109157. */
  109158. setActiveCameraByName(name: string): Nullable<Camera>;
  109159. /**
  109160. * get an animation group using its name
  109161. * @param name defines the material's name
  109162. * @return the animation group or null if none found.
  109163. */
  109164. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109165. /**
  109166. * Get a material using its unique id
  109167. * @param uniqueId defines the material's unique id
  109168. * @return the material or null if none found.
  109169. */
  109170. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109171. /**
  109172. * get a material using its id
  109173. * @param id defines the material's ID
  109174. * @return the material or null if none found.
  109175. */
  109176. getMaterialByID(id: string): Nullable<Material>;
  109177. /**
  109178. * Gets a the last added material using a given id
  109179. * @param id defines the material's ID
  109180. * @return the last material with the given id or null if none found.
  109181. */
  109182. getLastMaterialByID(id: string): Nullable<Material>;
  109183. /**
  109184. * Gets a material using its name
  109185. * @param name defines the material's name
  109186. * @return the material or null if none found.
  109187. */
  109188. getMaterialByName(name: string): Nullable<Material>;
  109189. /**
  109190. * Get a texture using its unique id
  109191. * @param uniqueId defines the texture's unique id
  109192. * @return the texture or null if none found.
  109193. */
  109194. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109195. /**
  109196. * Gets a camera using its id
  109197. * @param id defines the id to look for
  109198. * @returns the camera or null if not found
  109199. */
  109200. getCameraByID(id: string): Nullable<Camera>;
  109201. /**
  109202. * Gets a camera using its unique id
  109203. * @param uniqueId defines the unique id to look for
  109204. * @returns the camera or null if not found
  109205. */
  109206. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109207. /**
  109208. * Gets a camera using its name
  109209. * @param name defines the camera's name
  109210. * @return the camera or null if none found.
  109211. */
  109212. getCameraByName(name: string): Nullable<Camera>;
  109213. /**
  109214. * Gets a bone using its id
  109215. * @param id defines the bone's id
  109216. * @return the bone or null if not found
  109217. */
  109218. getBoneByID(id: string): Nullable<Bone>;
  109219. /**
  109220. * Gets a bone using its id
  109221. * @param name defines the bone's name
  109222. * @return the bone or null if not found
  109223. */
  109224. getBoneByName(name: string): Nullable<Bone>;
  109225. /**
  109226. * Gets a light node using its name
  109227. * @param name defines the the light's name
  109228. * @return the light or null if none found.
  109229. */
  109230. getLightByName(name: string): Nullable<Light>;
  109231. /**
  109232. * Gets a light node using its id
  109233. * @param id defines the light's id
  109234. * @return the light or null if none found.
  109235. */
  109236. getLightByID(id: string): Nullable<Light>;
  109237. /**
  109238. * Gets a light node using its scene-generated unique ID
  109239. * @param uniqueId defines the light's unique id
  109240. * @return the light or null if none found.
  109241. */
  109242. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109243. /**
  109244. * Gets a particle system by id
  109245. * @param id defines the particle system id
  109246. * @return the corresponding system or null if none found
  109247. */
  109248. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109249. /**
  109250. * Gets a geometry using its ID
  109251. * @param id defines the geometry's id
  109252. * @return the geometry or null if none found.
  109253. */
  109254. getGeometryByID(id: string): Nullable<Geometry>;
  109255. private _getGeometryByUniqueID;
  109256. /**
  109257. * Add a new geometry to this scene
  109258. * @param geometry defines the geometry to be added to the scene.
  109259. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109260. * @return a boolean defining if the geometry was added or not
  109261. */
  109262. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109263. /**
  109264. * Removes an existing geometry
  109265. * @param geometry defines the geometry to be removed from the scene
  109266. * @return a boolean defining if the geometry was removed or not
  109267. */
  109268. removeGeometry(geometry: Geometry): boolean;
  109269. /**
  109270. * Gets the list of geometries attached to the scene
  109271. * @returns an array of Geometry
  109272. */
  109273. getGeometries(): Geometry[];
  109274. /**
  109275. * Gets the first added mesh found of a given ID
  109276. * @param id defines the id to search for
  109277. * @return the mesh found or null if not found at all
  109278. */
  109279. getMeshByID(id: string): Nullable<AbstractMesh>;
  109280. /**
  109281. * Gets a list of meshes using their id
  109282. * @param id defines the id to search for
  109283. * @returns a list of meshes
  109284. */
  109285. getMeshesByID(id: string): Array<AbstractMesh>;
  109286. /**
  109287. * Gets the first added transform node found of a given ID
  109288. * @param id defines the id to search for
  109289. * @return the found transform node or null if not found at all.
  109290. */
  109291. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109292. /**
  109293. * Gets a transform node with its auto-generated unique id
  109294. * @param uniqueId efines the unique id to search for
  109295. * @return the found transform node or null if not found at all.
  109296. */
  109297. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109298. /**
  109299. * Gets a list of transform nodes using their id
  109300. * @param id defines the id to search for
  109301. * @returns a list of transform nodes
  109302. */
  109303. getTransformNodesByID(id: string): Array<TransformNode>;
  109304. /**
  109305. * Gets a mesh with its auto-generated unique id
  109306. * @param uniqueId defines the unique id to search for
  109307. * @return the found mesh or null if not found at all.
  109308. */
  109309. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109310. /**
  109311. * Gets a the last added mesh using a given id
  109312. * @param id defines the id to search for
  109313. * @return the found mesh or null if not found at all.
  109314. */
  109315. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109316. /**
  109317. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109318. * @param id defines the id to search for
  109319. * @return the found node or null if not found at all
  109320. */
  109321. getLastEntryByID(id: string): Nullable<Node>;
  109322. /**
  109323. * Gets a node (Mesh, Camera, Light) using a given id
  109324. * @param id defines the id to search for
  109325. * @return the found node or null if not found at all
  109326. */
  109327. getNodeByID(id: string): Nullable<Node>;
  109328. /**
  109329. * Gets a node (Mesh, Camera, Light) using a given name
  109330. * @param name defines the name to search for
  109331. * @return the found node or null if not found at all.
  109332. */
  109333. getNodeByName(name: string): Nullable<Node>;
  109334. /**
  109335. * Gets a mesh using a given name
  109336. * @param name defines the name to search for
  109337. * @return the found mesh or null if not found at all.
  109338. */
  109339. getMeshByName(name: string): Nullable<AbstractMesh>;
  109340. /**
  109341. * Gets a transform node using a given name
  109342. * @param name defines the name to search for
  109343. * @return the found transform node or null if not found at all.
  109344. */
  109345. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109346. /**
  109347. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109348. * @param id defines the id to search for
  109349. * @return the found skeleton or null if not found at all.
  109350. */
  109351. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109352. /**
  109353. * Gets a skeleton using a given auto generated unique id
  109354. * @param uniqueId defines the unique id to search for
  109355. * @return the found skeleton or null if not found at all.
  109356. */
  109357. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109358. /**
  109359. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109360. * @param id defines the id to search for
  109361. * @return the found skeleton or null if not found at all.
  109362. */
  109363. getSkeletonById(id: string): Nullable<Skeleton>;
  109364. /**
  109365. * Gets a skeleton using a given name
  109366. * @param name defines the name to search for
  109367. * @return the found skeleton or null if not found at all.
  109368. */
  109369. getSkeletonByName(name: string): Nullable<Skeleton>;
  109370. /**
  109371. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109372. * @param id defines the id to search for
  109373. * @return the found morph target manager or null if not found at all.
  109374. */
  109375. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109376. /**
  109377. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109378. * @param id defines the id to search for
  109379. * @return the found morph target or null if not found at all.
  109380. */
  109381. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109382. /**
  109383. * Gets a boolean indicating if the given mesh is active
  109384. * @param mesh defines the mesh to look for
  109385. * @returns true if the mesh is in the active list
  109386. */
  109387. isActiveMesh(mesh: AbstractMesh): boolean;
  109388. /**
  109389. * Return a unique id as a string which can serve as an identifier for the scene
  109390. */
  109391. get uid(): string;
  109392. /**
  109393. * Add an externaly attached data from its key.
  109394. * This method call will fail and return false, if such key already exists.
  109395. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109396. * @param key the unique key that identifies the data
  109397. * @param data the data object to associate to the key for this Engine instance
  109398. * @return true if no such key were already present and the data was added successfully, false otherwise
  109399. */
  109400. addExternalData<T>(key: string, data: T): boolean;
  109401. /**
  109402. * Get an externaly attached data from its key
  109403. * @param key the unique key that identifies the data
  109404. * @return the associated data, if present (can be null), or undefined if not present
  109405. */
  109406. getExternalData<T>(key: string): Nullable<T>;
  109407. /**
  109408. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109409. * @param key the unique key that identifies the data
  109410. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109411. * @return the associated data, can be null if the factory returned null.
  109412. */
  109413. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109414. /**
  109415. * Remove an externaly attached data from the Engine instance
  109416. * @param key the unique key that identifies the data
  109417. * @return true if the data was successfully removed, false if it doesn't exist
  109418. */
  109419. removeExternalData(key: string): boolean;
  109420. private _evaluateSubMesh;
  109421. /**
  109422. * Clear the processed materials smart array preventing retention point in material dispose.
  109423. */
  109424. freeProcessedMaterials(): void;
  109425. private _preventFreeActiveMeshesAndRenderingGroups;
  109426. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109427. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109428. * when disposing several meshes in a row or a hierarchy of meshes.
  109429. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109430. */
  109431. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109432. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109433. /**
  109434. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109435. */
  109436. freeActiveMeshes(): void;
  109437. /**
  109438. * Clear the info related to rendering groups preventing retention points during dispose.
  109439. */
  109440. freeRenderingGroups(): void;
  109441. /** @hidden */
  109442. _isInIntermediateRendering(): boolean;
  109443. /**
  109444. * Lambda returning the list of potentially active meshes.
  109445. */
  109446. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109447. /**
  109448. * Lambda returning the list of potentially active sub meshes.
  109449. */
  109450. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109451. /**
  109452. * Lambda returning the list of potentially intersecting sub meshes.
  109453. */
  109454. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109455. /**
  109456. * Lambda returning the list of potentially colliding sub meshes.
  109457. */
  109458. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109459. private _activeMeshesFrozen;
  109460. private _skipEvaluateActiveMeshesCompletely;
  109461. /**
  109462. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109463. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109464. * @returns the current scene
  109465. */
  109466. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109467. /**
  109468. * Use this function to restart evaluating active meshes on every frame
  109469. * @returns the current scene
  109470. */
  109471. unfreezeActiveMeshes(): Scene;
  109472. private _evaluateActiveMeshes;
  109473. private _activeMesh;
  109474. /**
  109475. * Update the transform matrix to update from the current active camera
  109476. * @param force defines a boolean used to force the update even if cache is up to date
  109477. */
  109478. updateTransformMatrix(force?: boolean): void;
  109479. private _bindFrameBuffer;
  109480. /** @hidden */
  109481. _allowPostProcessClearColor: boolean;
  109482. /** @hidden */
  109483. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109484. private _processSubCameras;
  109485. private _checkIntersections;
  109486. /** @hidden */
  109487. _advancePhysicsEngineStep(step: number): void;
  109488. /**
  109489. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109490. */
  109491. getDeterministicFrameTime: () => number;
  109492. /** @hidden */
  109493. _animate(): void;
  109494. /** Execute all animations (for a frame) */
  109495. animate(): void;
  109496. /**
  109497. * Render the scene
  109498. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109499. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109500. */
  109501. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109502. /**
  109503. * Freeze all materials
  109504. * A frozen material will not be updatable but should be faster to render
  109505. */
  109506. freezeMaterials(): void;
  109507. /**
  109508. * Unfreeze all materials
  109509. * A frozen material will not be updatable but should be faster to render
  109510. */
  109511. unfreezeMaterials(): void;
  109512. /**
  109513. * Releases all held ressources
  109514. */
  109515. dispose(): void;
  109516. /**
  109517. * Gets if the scene is already disposed
  109518. */
  109519. get isDisposed(): boolean;
  109520. /**
  109521. * Call this function to reduce memory footprint of the scene.
  109522. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109523. */
  109524. clearCachedVertexData(): void;
  109525. /**
  109526. * This function will remove the local cached buffer data from texture.
  109527. * It will save memory but will prevent the texture from being rebuilt
  109528. */
  109529. cleanCachedTextureBuffer(): void;
  109530. /**
  109531. * Get the world extend vectors with an optional filter
  109532. *
  109533. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109534. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109535. */
  109536. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109537. min: Vector3;
  109538. max: Vector3;
  109539. };
  109540. /**
  109541. * Creates a ray that can be used to pick in the scene
  109542. * @param x defines the x coordinate of the origin (on-screen)
  109543. * @param y defines the y coordinate of the origin (on-screen)
  109544. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109545. * @param camera defines the camera to use for the picking
  109546. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109547. * @returns a Ray
  109548. */
  109549. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109550. /**
  109551. * Creates a ray that can be used to pick in the scene
  109552. * @param x defines the x coordinate of the origin (on-screen)
  109553. * @param y defines the y coordinate of the origin (on-screen)
  109554. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109555. * @param result defines the ray where to store the picking ray
  109556. * @param camera defines the camera to use for the picking
  109557. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109558. * @returns the current scene
  109559. */
  109560. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109561. /**
  109562. * Creates a ray that can be used to pick in the scene
  109563. * @param x defines the x coordinate of the origin (on-screen)
  109564. * @param y defines the y coordinate of the origin (on-screen)
  109565. * @param camera defines the camera to use for the picking
  109566. * @returns a Ray
  109567. */
  109568. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109569. /**
  109570. * Creates a ray that can be used to pick in the scene
  109571. * @param x defines the x coordinate of the origin (on-screen)
  109572. * @param y defines the y coordinate of the origin (on-screen)
  109573. * @param result defines the ray where to store the picking ray
  109574. * @param camera defines the camera to use for the picking
  109575. * @returns the current scene
  109576. */
  109577. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109578. /** Launch a ray to try to pick a mesh in the scene
  109579. * @param x position on screen
  109580. * @param y position on screen
  109581. * @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
  109582. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109583. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109585. * @returns a PickingInfo
  109586. */
  109587. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109588. /** Use the given ray to pick a mesh in the scene
  109589. * @param ray The ray to use to pick meshes
  109590. * @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
  109591. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  109592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109593. * @returns a PickingInfo
  109594. */
  109595. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109596. /**
  109597. * Launch a ray to try to pick a mesh in the scene
  109598. * @param x X position on screen
  109599. * @param y Y position on screen
  109600. * @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
  109601. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109602. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109603. * @returns an array of PickingInfo
  109604. */
  109605. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109606. /**
  109607. * Launch a ray to try to pick a mesh in the scene
  109608. * @param ray Ray to use
  109609. * @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
  109610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109611. * @returns an array of PickingInfo
  109612. */
  109613. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109614. /**
  109615. * Force the value of meshUnderPointer
  109616. * @param mesh defines the mesh to use
  109617. */
  109618. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109619. /**
  109620. * Gets the mesh under the pointer
  109621. * @returns a Mesh or null if no mesh is under the pointer
  109622. */
  109623. getPointerOverMesh(): Nullable<AbstractMesh>;
  109624. /** @hidden */
  109625. _rebuildGeometries(): void;
  109626. /** @hidden */
  109627. _rebuildTextures(): void;
  109628. private _getByTags;
  109629. /**
  109630. * Get a list of meshes by tags
  109631. * @param tagsQuery defines the tags query to use
  109632. * @param forEach defines a predicate used to filter results
  109633. * @returns an array of Mesh
  109634. */
  109635. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  109636. /**
  109637. * Get a list of cameras by tags
  109638. * @param tagsQuery defines the tags query to use
  109639. * @param forEach defines a predicate used to filter results
  109640. * @returns an array of Camera
  109641. */
  109642. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  109643. /**
  109644. * Get a list of lights by tags
  109645. * @param tagsQuery defines the tags query to use
  109646. * @param forEach defines a predicate used to filter results
  109647. * @returns an array of Light
  109648. */
  109649. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  109650. /**
  109651. * Get a list of materials by tags
  109652. * @param tagsQuery defines the tags query to use
  109653. * @param forEach defines a predicate used to filter results
  109654. * @returns an array of Material
  109655. */
  109656. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  109657. /**
  109658. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109659. * This allowed control for front to back rendering or reversly depending of the special needs.
  109660. *
  109661. * @param renderingGroupId The rendering group id corresponding to its index
  109662. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109663. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109664. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109665. */
  109666. 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;
  109667. /**
  109668. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109669. *
  109670. * @param renderingGroupId The rendering group id corresponding to its index
  109671. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109672. * @param depth Automatically clears depth between groups if true and autoClear is true.
  109673. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  109674. */
  109675. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  109676. /**
  109677. * Gets the current auto clear configuration for one rendering group of the rendering
  109678. * manager.
  109679. * @param index the rendering group index to get the information for
  109680. * @returns The auto clear setup for the requested rendering group
  109681. */
  109682. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  109683. private _blockMaterialDirtyMechanism;
  109684. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  109685. get blockMaterialDirtyMechanism(): boolean;
  109686. set blockMaterialDirtyMechanism(value: boolean);
  109687. /**
  109688. * Will flag all materials as dirty to trigger new shader compilation
  109689. * @param flag defines the flag used to specify which material part must be marked as dirty
  109690. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  109691. */
  109692. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109693. /** @hidden */
  109694. _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;
  109695. /** @hidden */
  109696. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109697. /** @hidden */
  109698. _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;
  109699. /** @hidden */
  109700. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  109701. /** @hidden */
  109702. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  109703. /** @hidden */
  109704. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109705. }
  109706. }
  109707. declare module BABYLON {
  109708. /**
  109709. * Set of assets to keep when moving a scene into an asset container.
  109710. */
  109711. export class KeepAssets extends AbstractScene {
  109712. }
  109713. /**
  109714. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  109715. */
  109716. export class InstantiatedEntries {
  109717. /**
  109718. * List of new root nodes (eg. nodes with no parent)
  109719. */
  109720. rootNodes: TransformNode[];
  109721. /**
  109722. * List of new skeletons
  109723. */
  109724. skeletons: Skeleton[];
  109725. /**
  109726. * List of new animation groups
  109727. */
  109728. animationGroups: AnimationGroup[];
  109729. }
  109730. /**
  109731. * Container with a set of assets that can be added or removed from a scene.
  109732. */
  109733. export class AssetContainer extends AbstractScene {
  109734. /**
  109735. * The scene the AssetContainer belongs to.
  109736. */
  109737. scene: Scene;
  109738. /**
  109739. * Instantiates an AssetContainer.
  109740. * @param scene The scene the AssetContainer belongs to.
  109741. */
  109742. constructor(scene: Scene);
  109743. /**
  109744. * Instantiate or clone all meshes and add the new ones to the scene.
  109745. * Skeletons and animation groups will all be cloned
  109746. * @param nameFunction defines an optional function used to get new names for clones
  109747. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  109748. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  109749. */
  109750. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  109751. /**
  109752. * Adds all the assets from the container to the scene.
  109753. */
  109754. addAllToScene(): void;
  109755. /**
  109756. * Removes all the assets in the container from the scene
  109757. */
  109758. removeAllFromScene(): void;
  109759. /**
  109760. * Disposes all the assets in the container
  109761. */
  109762. dispose(): void;
  109763. private _moveAssets;
  109764. /**
  109765. * Removes all the assets contained in the scene and adds them to the container.
  109766. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  109767. */
  109768. moveAllFromScene(keepAssets?: KeepAssets): void;
  109769. /**
  109770. * 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.
  109771. * @returns the root mesh
  109772. */
  109773. createRootMesh(): Mesh;
  109774. /**
  109775. * Merge animations from this asset container into a scene
  109776. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109777. * @param animatables set of animatables to retarget to a node from the scene
  109778. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  109779. */
  109780. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  109781. }
  109782. }
  109783. declare module BABYLON {
  109784. /**
  109785. * Defines how the parser contract is defined.
  109786. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  109787. */
  109788. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  109789. /**
  109790. * Defines how the individual parser contract is defined.
  109791. * These parser can parse an individual asset
  109792. */
  109793. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  109794. /**
  109795. * Base class of the scene acting as a container for the different elements composing a scene.
  109796. * This class is dynamically extended by the different components of the scene increasing
  109797. * flexibility and reducing coupling
  109798. */
  109799. export abstract class AbstractScene {
  109800. /**
  109801. * Stores the list of available parsers in the application.
  109802. */
  109803. private static _BabylonFileParsers;
  109804. /**
  109805. * Stores the list of available individual parsers in the application.
  109806. */
  109807. private static _IndividualBabylonFileParsers;
  109808. /**
  109809. * Adds a parser in the list of available ones
  109810. * @param name Defines the name of the parser
  109811. * @param parser Defines the parser to add
  109812. */
  109813. static AddParser(name: string, parser: BabylonFileParser): void;
  109814. /**
  109815. * Gets a general parser from the list of avaialble ones
  109816. * @param name Defines the name of the parser
  109817. * @returns the requested parser or null
  109818. */
  109819. static GetParser(name: string): Nullable<BabylonFileParser>;
  109820. /**
  109821. * Adds n individual parser in the list of available ones
  109822. * @param name Defines the name of the parser
  109823. * @param parser Defines the parser to add
  109824. */
  109825. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  109826. /**
  109827. * Gets an individual parser from the list of avaialble ones
  109828. * @param name Defines the name of the parser
  109829. * @returns the requested parser or null
  109830. */
  109831. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  109832. /**
  109833. * Parser json data and populate both a scene and its associated container object
  109834. * @param jsonData Defines the data to parse
  109835. * @param scene Defines the scene to parse the data for
  109836. * @param container Defines the container attached to the parsing sequence
  109837. * @param rootUrl Defines the root url of the data
  109838. */
  109839. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  109840. /**
  109841. * Gets the list of root nodes (ie. nodes with no parent)
  109842. */
  109843. rootNodes: Node[];
  109844. /** All of the cameras added to this scene
  109845. * @see http://doc.babylonjs.com/babylon101/cameras
  109846. */
  109847. cameras: Camera[];
  109848. /**
  109849. * All of the lights added to this scene
  109850. * @see http://doc.babylonjs.com/babylon101/lights
  109851. */
  109852. lights: Light[];
  109853. /**
  109854. * All of the (abstract) meshes added to this scene
  109855. */
  109856. meshes: AbstractMesh[];
  109857. /**
  109858. * The list of skeletons added to the scene
  109859. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109860. */
  109861. skeletons: Skeleton[];
  109862. /**
  109863. * All of the particle systems added to this scene
  109864. * @see http://doc.babylonjs.com/babylon101/particles
  109865. */
  109866. particleSystems: IParticleSystem[];
  109867. /**
  109868. * Gets a list of Animations associated with the scene
  109869. */
  109870. animations: Animation[];
  109871. /**
  109872. * All of the animation groups added to this scene
  109873. * @see http://doc.babylonjs.com/how_to/group
  109874. */
  109875. animationGroups: AnimationGroup[];
  109876. /**
  109877. * All of the multi-materials added to this scene
  109878. * @see http://doc.babylonjs.com/how_to/multi_materials
  109879. */
  109880. multiMaterials: MultiMaterial[];
  109881. /**
  109882. * All of the materials added to this scene
  109883. * In the context of a Scene, it is not supposed to be modified manually.
  109884. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  109885. * Note also that the order of the Material within the array is not significant and might change.
  109886. * @see http://doc.babylonjs.com/babylon101/materials
  109887. */
  109888. materials: Material[];
  109889. /**
  109890. * The list of morph target managers added to the scene
  109891. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  109892. */
  109893. morphTargetManagers: MorphTargetManager[];
  109894. /**
  109895. * The list of geometries used in the scene.
  109896. */
  109897. geometries: Geometry[];
  109898. /**
  109899. * All of the tranform nodes added to this scene
  109900. * In the context of a Scene, it is not supposed to be modified manually.
  109901. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  109902. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  109903. * @see http://doc.babylonjs.com/how_to/transformnode
  109904. */
  109905. transformNodes: TransformNode[];
  109906. /**
  109907. * ActionManagers available on the scene.
  109908. */
  109909. actionManagers: AbstractActionManager[];
  109910. /**
  109911. * Textures to keep.
  109912. */
  109913. textures: BaseTexture[];
  109914. /**
  109915. * Environment texture for the scene
  109916. */
  109917. environmentTexture: Nullable<BaseTexture>;
  109918. /**
  109919. * @returns all meshes, lights, cameras, transformNodes and bones
  109920. */
  109921. getNodes(): Array<Node>;
  109922. }
  109923. }
  109924. declare module BABYLON {
  109925. /**
  109926. * Interface used to define options for Sound class
  109927. */
  109928. export interface ISoundOptions {
  109929. /**
  109930. * Does the sound autoplay once loaded.
  109931. */
  109932. autoplay?: boolean;
  109933. /**
  109934. * Does the sound loop after it finishes playing once.
  109935. */
  109936. loop?: boolean;
  109937. /**
  109938. * Sound's volume
  109939. */
  109940. volume?: number;
  109941. /**
  109942. * Is it a spatial sound?
  109943. */
  109944. spatialSound?: boolean;
  109945. /**
  109946. * Maximum distance to hear that sound
  109947. */
  109948. maxDistance?: number;
  109949. /**
  109950. * Uses user defined attenuation function
  109951. */
  109952. useCustomAttenuation?: boolean;
  109953. /**
  109954. * Define the roll off factor of spatial sounds.
  109955. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109956. */
  109957. rolloffFactor?: number;
  109958. /**
  109959. * Define the reference distance the sound should be heard perfectly.
  109960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109961. */
  109962. refDistance?: number;
  109963. /**
  109964. * Define the distance attenuation model the sound will follow.
  109965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109966. */
  109967. distanceModel?: string;
  109968. /**
  109969. * Defines the playback speed (1 by default)
  109970. */
  109971. playbackRate?: number;
  109972. /**
  109973. * Defines if the sound is from a streaming source
  109974. */
  109975. streaming?: boolean;
  109976. /**
  109977. * Defines an optional length (in seconds) inside the sound file
  109978. */
  109979. length?: number;
  109980. /**
  109981. * Defines an optional offset (in seconds) inside the sound file
  109982. */
  109983. offset?: number;
  109984. /**
  109985. * If true, URLs will not be required to state the audio file codec to use.
  109986. */
  109987. skipCodecCheck?: boolean;
  109988. }
  109989. /**
  109990. * Defines a sound that can be played in the application.
  109991. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  109992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109993. */
  109994. export class Sound {
  109995. /**
  109996. * The name of the sound in the scene.
  109997. */
  109998. name: string;
  109999. /**
  110000. * Does the sound autoplay once loaded.
  110001. */
  110002. autoplay: boolean;
  110003. /**
  110004. * Does the sound loop after it finishes playing once.
  110005. */
  110006. loop: boolean;
  110007. /**
  110008. * Does the sound use a custom attenuation curve to simulate the falloff
  110009. * happening when the source gets further away from the camera.
  110010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110011. */
  110012. useCustomAttenuation: boolean;
  110013. /**
  110014. * The sound track id this sound belongs to.
  110015. */
  110016. soundTrackId: number;
  110017. /**
  110018. * Is this sound currently played.
  110019. */
  110020. isPlaying: boolean;
  110021. /**
  110022. * Is this sound currently paused.
  110023. */
  110024. isPaused: boolean;
  110025. /**
  110026. * Does this sound enables spatial sound.
  110027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110028. */
  110029. spatialSound: boolean;
  110030. /**
  110031. * Define the reference distance the sound should be heard perfectly.
  110032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110033. */
  110034. refDistance: number;
  110035. /**
  110036. * Define the roll off factor of spatial sounds.
  110037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110038. */
  110039. rolloffFactor: number;
  110040. /**
  110041. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110043. */
  110044. maxDistance: number;
  110045. /**
  110046. * Define the distance attenuation model the sound will follow.
  110047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110048. */
  110049. distanceModel: string;
  110050. /**
  110051. * @hidden
  110052. * Back Compat
  110053. **/
  110054. onended: () => any;
  110055. /**
  110056. * Observable event when the current playing sound finishes.
  110057. */
  110058. onEndedObservable: Observable<Sound>;
  110059. private _panningModel;
  110060. private _playbackRate;
  110061. private _streaming;
  110062. private _startTime;
  110063. private _startOffset;
  110064. private _position;
  110065. /** @hidden */
  110066. _positionInEmitterSpace: boolean;
  110067. private _localDirection;
  110068. private _volume;
  110069. private _isReadyToPlay;
  110070. private _isDirectional;
  110071. private _readyToPlayCallback;
  110072. private _audioBuffer;
  110073. private _soundSource;
  110074. private _streamingSource;
  110075. private _soundPanner;
  110076. private _soundGain;
  110077. private _inputAudioNode;
  110078. private _outputAudioNode;
  110079. private _coneInnerAngle;
  110080. private _coneOuterAngle;
  110081. private _coneOuterGain;
  110082. private _scene;
  110083. private _connectedTransformNode;
  110084. private _customAttenuationFunction;
  110085. private _registerFunc;
  110086. private _isOutputConnected;
  110087. private _htmlAudioElement;
  110088. private _urlType;
  110089. private _length?;
  110090. private _offset?;
  110091. /** @hidden */
  110092. static _SceneComponentInitialization: (scene: Scene) => void;
  110093. /**
  110094. * Create a sound and attach it to a scene
  110095. * @param name Name of your sound
  110096. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110097. * @param scene defines the scene the sound belongs to
  110098. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110099. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110100. */
  110101. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110102. /**
  110103. * Release the sound and its associated resources
  110104. */
  110105. dispose(): void;
  110106. /**
  110107. * Gets if the sounds is ready to be played or not.
  110108. * @returns true if ready, otherwise false
  110109. */
  110110. isReady(): boolean;
  110111. private _soundLoaded;
  110112. /**
  110113. * Sets the data of the sound from an audiobuffer
  110114. * @param audioBuffer The audioBuffer containing the data
  110115. */
  110116. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110117. /**
  110118. * Updates the current sounds options such as maxdistance, loop...
  110119. * @param options A JSON object containing values named as the object properties
  110120. */
  110121. updateOptions(options: ISoundOptions): void;
  110122. private _createSpatialParameters;
  110123. private _updateSpatialParameters;
  110124. /**
  110125. * Switch the panning model to HRTF:
  110126. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110128. */
  110129. switchPanningModelToHRTF(): void;
  110130. /**
  110131. * Switch the panning model to Equal Power:
  110132. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110134. */
  110135. switchPanningModelToEqualPower(): void;
  110136. private _switchPanningModel;
  110137. /**
  110138. * Connect this sound to a sound track audio node like gain...
  110139. * @param soundTrackAudioNode the sound track audio node to connect to
  110140. */
  110141. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110142. /**
  110143. * Transform this sound into a directional source
  110144. * @param coneInnerAngle Size of the inner cone in degree
  110145. * @param coneOuterAngle Size of the outer cone in degree
  110146. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110147. */
  110148. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110149. /**
  110150. * Gets or sets the inner angle for the directional cone.
  110151. */
  110152. get directionalConeInnerAngle(): number;
  110153. /**
  110154. * Gets or sets the inner angle for the directional cone.
  110155. */
  110156. set directionalConeInnerAngle(value: number);
  110157. /**
  110158. * Gets or sets the outer angle for the directional cone.
  110159. */
  110160. get directionalConeOuterAngle(): number;
  110161. /**
  110162. * Gets or sets the outer angle for the directional cone.
  110163. */
  110164. set directionalConeOuterAngle(value: number);
  110165. /**
  110166. * Sets the position of the emitter if spatial sound is enabled
  110167. * @param newPosition Defines the new posisiton
  110168. */
  110169. setPosition(newPosition: Vector3): void;
  110170. /**
  110171. * Sets the local direction of the emitter if spatial sound is enabled
  110172. * @param newLocalDirection Defines the new local direction
  110173. */
  110174. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110175. private _updateDirection;
  110176. /** @hidden */
  110177. updateDistanceFromListener(): void;
  110178. /**
  110179. * Sets a new custom attenuation function for the sound.
  110180. * @param callback Defines the function used for the attenuation
  110181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110182. */
  110183. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110184. /**
  110185. * Play the sound
  110186. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110187. * @param offset (optional) Start the sound at a specific time in seconds
  110188. * @param length (optional) Sound duration (in seconds)
  110189. */
  110190. play(time?: number, offset?: number, length?: number): void;
  110191. private _onended;
  110192. /**
  110193. * Stop the sound
  110194. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110195. */
  110196. stop(time?: number): void;
  110197. /**
  110198. * Put the sound in pause
  110199. */
  110200. pause(): void;
  110201. /**
  110202. * Sets a dedicated volume for this sounds
  110203. * @param newVolume Define the new volume of the sound
  110204. * @param time Define time for gradual change to new volume
  110205. */
  110206. setVolume(newVolume: number, time?: number): void;
  110207. /**
  110208. * Set the sound play back rate
  110209. * @param newPlaybackRate Define the playback rate the sound should be played at
  110210. */
  110211. setPlaybackRate(newPlaybackRate: number): void;
  110212. /**
  110213. * Gets the volume of the sound.
  110214. * @returns the volume of the sound
  110215. */
  110216. getVolume(): number;
  110217. /**
  110218. * Attach the sound to a dedicated mesh
  110219. * @param transformNode The transform node to connect the sound with
  110220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110221. */
  110222. attachToMesh(transformNode: TransformNode): void;
  110223. /**
  110224. * Detach the sound from the previously attached mesh
  110225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110226. */
  110227. detachFromMesh(): void;
  110228. private _onRegisterAfterWorldMatrixUpdate;
  110229. /**
  110230. * Clone the current sound in the scene.
  110231. * @returns the new sound clone
  110232. */
  110233. clone(): Nullable<Sound>;
  110234. /**
  110235. * Gets the current underlying audio buffer containing the data
  110236. * @returns the audio buffer
  110237. */
  110238. getAudioBuffer(): Nullable<AudioBuffer>;
  110239. /**
  110240. * Serializes the Sound in a JSON representation
  110241. * @returns the JSON representation of the sound
  110242. */
  110243. serialize(): any;
  110244. /**
  110245. * Parse a JSON representation of a sound to innstantiate in a given scene
  110246. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110247. * @param scene Define the scene the new parsed sound should be created in
  110248. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110249. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110250. * @returns the newly parsed sound
  110251. */
  110252. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110253. }
  110254. }
  110255. declare module BABYLON {
  110256. /**
  110257. * This defines an action helpful to play a defined sound on a triggered action.
  110258. */
  110259. export class PlaySoundAction extends Action {
  110260. private _sound;
  110261. /**
  110262. * Instantiate the action
  110263. * @param triggerOptions defines the trigger options
  110264. * @param sound defines the sound to play
  110265. * @param condition defines the trigger related conditions
  110266. */
  110267. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110268. /** @hidden */
  110269. _prepare(): void;
  110270. /**
  110271. * Execute the action and play the sound.
  110272. */
  110273. execute(): void;
  110274. /**
  110275. * Serializes the actions and its related information.
  110276. * @param parent defines the object to serialize in
  110277. * @returns the serialized object
  110278. */
  110279. serialize(parent: any): any;
  110280. }
  110281. /**
  110282. * This defines an action helpful to stop a defined sound on a triggered action.
  110283. */
  110284. export class StopSoundAction extends Action {
  110285. private _sound;
  110286. /**
  110287. * Instantiate the action
  110288. * @param triggerOptions defines the trigger options
  110289. * @param sound defines the sound to stop
  110290. * @param condition defines the trigger related conditions
  110291. */
  110292. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110293. /** @hidden */
  110294. _prepare(): void;
  110295. /**
  110296. * Execute the action and stop the sound.
  110297. */
  110298. execute(): void;
  110299. /**
  110300. * Serializes the actions and its related information.
  110301. * @param parent defines the object to serialize in
  110302. * @returns the serialized object
  110303. */
  110304. serialize(parent: any): any;
  110305. }
  110306. }
  110307. declare module BABYLON {
  110308. /**
  110309. * This defines an action responsible to change the value of a property
  110310. * by interpolating between its current value and the newly set one once triggered.
  110311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110312. */
  110313. export class InterpolateValueAction extends Action {
  110314. /**
  110315. * Defines the path of the property where the value should be interpolated
  110316. */
  110317. propertyPath: string;
  110318. /**
  110319. * Defines the target value at the end of the interpolation.
  110320. */
  110321. value: any;
  110322. /**
  110323. * Defines the time it will take for the property to interpolate to the value.
  110324. */
  110325. duration: number;
  110326. /**
  110327. * Defines if the other scene animations should be stopped when the action has been triggered
  110328. */
  110329. stopOtherAnimations?: boolean;
  110330. /**
  110331. * Defines a callback raised once the interpolation animation has been done.
  110332. */
  110333. onInterpolationDone?: () => void;
  110334. /**
  110335. * Observable triggered once the interpolation animation has been done.
  110336. */
  110337. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110338. private _target;
  110339. private _effectiveTarget;
  110340. private _property;
  110341. /**
  110342. * Instantiate the action
  110343. * @param triggerOptions defines the trigger options
  110344. * @param target defines the object containing the value to interpolate
  110345. * @param propertyPath defines the path to the property in the target object
  110346. * @param value defines the target value at the end of the interpolation
  110347. * @param duration deines the time it will take for the property to interpolate to the value.
  110348. * @param condition defines the trigger related conditions
  110349. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110350. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110351. */
  110352. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110353. /** @hidden */
  110354. _prepare(): void;
  110355. /**
  110356. * Execute the action starts the value interpolation.
  110357. */
  110358. execute(): void;
  110359. /**
  110360. * Serializes the actions and its related information.
  110361. * @param parent defines the object to serialize in
  110362. * @returns the serialized object
  110363. */
  110364. serialize(parent: any): any;
  110365. }
  110366. }
  110367. declare module BABYLON {
  110368. /**
  110369. * Options allowed during the creation of a sound track.
  110370. */
  110371. export interface ISoundTrackOptions {
  110372. /**
  110373. * The volume the sound track should take during creation
  110374. */
  110375. volume?: number;
  110376. /**
  110377. * Define if the sound track is the main sound track of the scene
  110378. */
  110379. mainTrack?: boolean;
  110380. }
  110381. /**
  110382. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110383. * It will be also used in a future release to apply effects on a specific track.
  110384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110385. */
  110386. export class SoundTrack {
  110387. /**
  110388. * The unique identifier of the sound track in the scene.
  110389. */
  110390. id: number;
  110391. /**
  110392. * The list of sounds included in the sound track.
  110393. */
  110394. soundCollection: Array<Sound>;
  110395. private _outputAudioNode;
  110396. private _scene;
  110397. private _connectedAnalyser;
  110398. private _options;
  110399. private _isInitialized;
  110400. /**
  110401. * Creates a new sound track.
  110402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110403. * @param scene Define the scene the sound track belongs to
  110404. * @param options
  110405. */
  110406. constructor(scene: Scene, options?: ISoundTrackOptions);
  110407. private _initializeSoundTrackAudioGraph;
  110408. /**
  110409. * Release the sound track and its associated resources
  110410. */
  110411. dispose(): void;
  110412. /**
  110413. * Adds a sound to this sound track
  110414. * @param sound define the cound to add
  110415. * @ignoreNaming
  110416. */
  110417. AddSound(sound: Sound): void;
  110418. /**
  110419. * Removes a sound to this sound track
  110420. * @param sound define the cound to remove
  110421. * @ignoreNaming
  110422. */
  110423. RemoveSound(sound: Sound): void;
  110424. /**
  110425. * Set a global volume for the full sound track.
  110426. * @param newVolume Define the new volume of the sound track
  110427. */
  110428. setVolume(newVolume: number): void;
  110429. /**
  110430. * Switch the panning model to HRTF:
  110431. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110433. */
  110434. switchPanningModelToHRTF(): void;
  110435. /**
  110436. * Switch the panning model to Equal Power:
  110437. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110439. */
  110440. switchPanningModelToEqualPower(): void;
  110441. /**
  110442. * Connect the sound track to an audio analyser allowing some amazing
  110443. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110445. * @param analyser The analyser to connect to the engine
  110446. */
  110447. connectToAnalyser(analyser: Analyser): void;
  110448. }
  110449. }
  110450. declare module BABYLON {
  110451. interface AbstractScene {
  110452. /**
  110453. * The list of sounds used in the scene.
  110454. */
  110455. sounds: Nullable<Array<Sound>>;
  110456. }
  110457. interface Scene {
  110458. /**
  110459. * @hidden
  110460. * Backing field
  110461. */
  110462. _mainSoundTrack: SoundTrack;
  110463. /**
  110464. * The main sound track played by the scene.
  110465. * It cotains your primary collection of sounds.
  110466. */
  110467. mainSoundTrack: SoundTrack;
  110468. /**
  110469. * The list of sound tracks added to the scene
  110470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110471. */
  110472. soundTracks: Nullable<Array<SoundTrack>>;
  110473. /**
  110474. * Gets a sound using a given name
  110475. * @param name defines the name to search for
  110476. * @return the found sound or null if not found at all.
  110477. */
  110478. getSoundByName(name: string): Nullable<Sound>;
  110479. /**
  110480. * Gets or sets if audio support is enabled
  110481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110482. */
  110483. audioEnabled: boolean;
  110484. /**
  110485. * Gets or sets if audio will be output to headphones
  110486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110487. */
  110488. headphone: boolean;
  110489. /**
  110490. * Gets or sets custom audio listener position provider
  110491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110492. */
  110493. audioListenerPositionProvider: Nullable<() => Vector3>;
  110494. /**
  110495. * Gets or sets a refresh rate when using 3D audio positioning
  110496. */
  110497. audioPositioningRefreshRate: number;
  110498. }
  110499. /**
  110500. * Defines the sound scene component responsible to manage any sounds
  110501. * in a given scene.
  110502. */
  110503. export class AudioSceneComponent implements ISceneSerializableComponent {
  110504. /**
  110505. * The component name helpfull to identify the component in the list of scene components.
  110506. */
  110507. readonly name: string;
  110508. /**
  110509. * The scene the component belongs to.
  110510. */
  110511. scene: Scene;
  110512. private _audioEnabled;
  110513. /**
  110514. * Gets whether audio is enabled or not.
  110515. * Please use related enable/disable method to switch state.
  110516. */
  110517. get audioEnabled(): boolean;
  110518. private _headphone;
  110519. /**
  110520. * Gets whether audio is outputing to headphone or not.
  110521. * Please use the according Switch methods to change output.
  110522. */
  110523. get headphone(): boolean;
  110524. /**
  110525. * Gets or sets a refresh rate when using 3D audio positioning
  110526. */
  110527. audioPositioningRefreshRate: number;
  110528. private _audioListenerPositionProvider;
  110529. /**
  110530. * Gets the current audio listener position provider
  110531. */
  110532. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110533. /**
  110534. * Sets a custom listener position for all sounds in the scene
  110535. * By default, this is the position of the first active camera
  110536. */
  110537. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110538. /**
  110539. * Creates a new instance of the component for the given scene
  110540. * @param scene Defines the scene to register the component in
  110541. */
  110542. constructor(scene: Scene);
  110543. /**
  110544. * Registers the component in a given scene
  110545. */
  110546. register(): void;
  110547. /**
  110548. * Rebuilds the elements related to this component in case of
  110549. * context lost for instance.
  110550. */
  110551. rebuild(): void;
  110552. /**
  110553. * Serializes the component data to the specified json object
  110554. * @param serializationObject The object to serialize to
  110555. */
  110556. serialize(serializationObject: any): void;
  110557. /**
  110558. * Adds all the elements from the container to the scene
  110559. * @param container the container holding the elements
  110560. */
  110561. addFromContainer(container: AbstractScene): void;
  110562. /**
  110563. * Removes all the elements in the container from the scene
  110564. * @param container contains the elements to remove
  110565. * @param dispose if the removed element should be disposed (default: false)
  110566. */
  110567. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110568. /**
  110569. * Disposes the component and the associated ressources.
  110570. */
  110571. dispose(): void;
  110572. /**
  110573. * Disables audio in the associated scene.
  110574. */
  110575. disableAudio(): void;
  110576. /**
  110577. * Enables audio in the associated scene.
  110578. */
  110579. enableAudio(): void;
  110580. /**
  110581. * Switch audio to headphone output.
  110582. */
  110583. switchAudioModeForHeadphones(): void;
  110584. /**
  110585. * Switch audio to normal speakers.
  110586. */
  110587. switchAudioModeForNormalSpeakers(): void;
  110588. private _cachedCameraDirection;
  110589. private _cachedCameraPosition;
  110590. private _lastCheck;
  110591. private _afterRender;
  110592. }
  110593. }
  110594. declare module BABYLON {
  110595. /**
  110596. * Wraps one or more Sound objects and selects one with random weight for playback.
  110597. */
  110598. export class WeightedSound {
  110599. /** When true a Sound will be selected and played when the current playing Sound completes. */
  110600. loop: boolean;
  110601. private _coneInnerAngle;
  110602. private _coneOuterAngle;
  110603. private _volume;
  110604. /** A Sound is currently playing. */
  110605. isPlaying: boolean;
  110606. /** A Sound is currently paused. */
  110607. isPaused: boolean;
  110608. private _sounds;
  110609. private _weights;
  110610. private _currentIndex?;
  110611. /**
  110612. * Creates a new WeightedSound from the list of sounds given.
  110613. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  110614. * @param sounds Array of Sounds that will be selected from.
  110615. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  110616. */
  110617. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  110618. /**
  110619. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  110620. */
  110621. get directionalConeInnerAngle(): number;
  110622. /**
  110623. * The size of cone in degress for a directional sound in which there will be no attenuation.
  110624. */
  110625. set directionalConeInnerAngle(value: number);
  110626. /**
  110627. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110628. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110629. */
  110630. get directionalConeOuterAngle(): number;
  110631. /**
  110632. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110633. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110634. */
  110635. set directionalConeOuterAngle(value: number);
  110636. /**
  110637. * Playback volume.
  110638. */
  110639. get volume(): number;
  110640. /**
  110641. * Playback volume.
  110642. */
  110643. set volume(value: number);
  110644. private _onended;
  110645. /**
  110646. * Suspend playback
  110647. */
  110648. pause(): void;
  110649. /**
  110650. * Stop playback
  110651. */
  110652. stop(): void;
  110653. /**
  110654. * Start playback.
  110655. * @param startOffset Position the clip head at a specific time in seconds.
  110656. */
  110657. play(startOffset?: number): void;
  110658. }
  110659. }
  110660. declare module BABYLON {
  110661. /**
  110662. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  110663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  110664. */
  110665. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  110666. /**
  110667. * Gets the name of the behavior.
  110668. */
  110669. get name(): string;
  110670. /**
  110671. * The easing function used by animations
  110672. */
  110673. static EasingFunction: BackEase;
  110674. /**
  110675. * The easing mode used by animations
  110676. */
  110677. static EasingMode: number;
  110678. /**
  110679. * The duration of the animation, in milliseconds
  110680. */
  110681. transitionDuration: number;
  110682. /**
  110683. * Length of the distance animated by the transition when lower radius is reached
  110684. */
  110685. lowerRadiusTransitionRange: number;
  110686. /**
  110687. * Length of the distance animated by the transition when upper radius is reached
  110688. */
  110689. upperRadiusTransitionRange: number;
  110690. private _autoTransitionRange;
  110691. /**
  110692. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110693. */
  110694. get autoTransitionRange(): boolean;
  110695. /**
  110696. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110697. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  110698. */
  110699. set autoTransitionRange(value: boolean);
  110700. private _attachedCamera;
  110701. private _onAfterCheckInputsObserver;
  110702. private _onMeshTargetChangedObserver;
  110703. /**
  110704. * Initializes the behavior.
  110705. */
  110706. init(): void;
  110707. /**
  110708. * Attaches the behavior to its arc rotate camera.
  110709. * @param camera Defines the camera to attach the behavior to
  110710. */
  110711. attach(camera: ArcRotateCamera): void;
  110712. /**
  110713. * Detaches the behavior from its current arc rotate camera.
  110714. */
  110715. detach(): void;
  110716. private _radiusIsAnimating;
  110717. private _radiusBounceTransition;
  110718. private _animatables;
  110719. private _cachedWheelPrecision;
  110720. /**
  110721. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  110722. * @param radiusLimit The limit to check against.
  110723. * @return Bool to indicate if at limit.
  110724. */
  110725. private _isRadiusAtLimit;
  110726. /**
  110727. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  110728. * @param radiusDelta The delta by which to animate to. Can be negative.
  110729. */
  110730. private _applyBoundRadiusAnimation;
  110731. /**
  110732. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  110733. */
  110734. protected _clearAnimationLocks(): void;
  110735. /**
  110736. * Stops and removes all animations that have been applied to the camera
  110737. */
  110738. stopAllAnimations(): void;
  110739. }
  110740. }
  110741. declare module BABYLON {
  110742. /**
  110743. * 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.
  110744. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  110745. */
  110746. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  110747. /**
  110748. * Gets the name of the behavior.
  110749. */
  110750. get name(): string;
  110751. private _mode;
  110752. private _radiusScale;
  110753. private _positionScale;
  110754. private _defaultElevation;
  110755. private _elevationReturnTime;
  110756. private _elevationReturnWaitTime;
  110757. private _zoomStopsAnimation;
  110758. private _framingTime;
  110759. /**
  110760. * The easing function used by animations
  110761. */
  110762. static EasingFunction: ExponentialEase;
  110763. /**
  110764. * The easing mode used by animations
  110765. */
  110766. static EasingMode: number;
  110767. /**
  110768. * Sets the current mode used by the behavior
  110769. */
  110770. set mode(mode: number);
  110771. /**
  110772. * Gets current mode used by the behavior.
  110773. */
  110774. get mode(): number;
  110775. /**
  110776. * Sets the scale applied to the radius (1 by default)
  110777. */
  110778. set radiusScale(radius: number);
  110779. /**
  110780. * Gets the scale applied to the radius
  110781. */
  110782. get radiusScale(): number;
  110783. /**
  110784. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110785. */
  110786. set positionScale(scale: number);
  110787. /**
  110788. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110789. */
  110790. get positionScale(): number;
  110791. /**
  110792. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110793. * behaviour is triggered, in radians.
  110794. */
  110795. set defaultElevation(elevation: number);
  110796. /**
  110797. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110798. * behaviour is triggered, in radians.
  110799. */
  110800. get defaultElevation(): number;
  110801. /**
  110802. * Sets the time (in milliseconds) taken to return to the default beta position.
  110803. * Negative value indicates camera should not return to default.
  110804. */
  110805. set elevationReturnTime(speed: number);
  110806. /**
  110807. * Gets the time (in milliseconds) taken to return to the default beta position.
  110808. * Negative value indicates camera should not return to default.
  110809. */
  110810. get elevationReturnTime(): number;
  110811. /**
  110812. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110813. */
  110814. set elevationReturnWaitTime(time: number);
  110815. /**
  110816. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110817. */
  110818. get elevationReturnWaitTime(): number;
  110819. /**
  110820. * Sets the flag that indicates if user zooming should stop animation.
  110821. */
  110822. set zoomStopsAnimation(flag: boolean);
  110823. /**
  110824. * Gets the flag that indicates if user zooming should stop animation.
  110825. */
  110826. get zoomStopsAnimation(): boolean;
  110827. /**
  110828. * Sets the transition time when framing the mesh, in milliseconds
  110829. */
  110830. set framingTime(time: number);
  110831. /**
  110832. * Gets the transition time when framing the mesh, in milliseconds
  110833. */
  110834. get framingTime(): number;
  110835. /**
  110836. * Define if the behavior should automatically change the configured
  110837. * camera limits and sensibilities.
  110838. */
  110839. autoCorrectCameraLimitsAndSensibility: boolean;
  110840. private _onPrePointerObservableObserver;
  110841. private _onAfterCheckInputsObserver;
  110842. private _onMeshTargetChangedObserver;
  110843. private _attachedCamera;
  110844. private _isPointerDown;
  110845. private _lastInteractionTime;
  110846. /**
  110847. * Initializes the behavior.
  110848. */
  110849. init(): void;
  110850. /**
  110851. * Attaches the behavior to its arc rotate camera.
  110852. * @param camera Defines the camera to attach the behavior to
  110853. */
  110854. attach(camera: ArcRotateCamera): void;
  110855. /**
  110856. * Detaches the behavior from its current arc rotate camera.
  110857. */
  110858. detach(): void;
  110859. private _animatables;
  110860. private _betaIsAnimating;
  110861. private _betaTransition;
  110862. private _radiusTransition;
  110863. private _vectorTransition;
  110864. /**
  110865. * Targets the given mesh and updates zoom level accordingly.
  110866. * @param mesh The mesh to target.
  110867. * @param radius Optional. If a cached radius position already exists, overrides default.
  110868. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110869. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110870. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110871. */
  110872. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110873. /**
  110874. * Targets the given mesh with its children and updates zoom level accordingly.
  110875. * @param mesh The mesh to target.
  110876. * @param radius Optional. If a cached radius position already exists, overrides default.
  110877. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110878. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110879. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110880. */
  110881. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110882. /**
  110883. * Targets the given meshes with their children and updates zoom level accordingly.
  110884. * @param meshes The mesh to target.
  110885. * @param radius Optional. If a cached radius position already exists, overrides default.
  110886. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110887. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110888. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110889. */
  110890. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110891. /**
  110892. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  110893. * @param minimumWorld Determines the smaller position of the bounding box extend
  110894. * @param maximumWorld Determines the bigger position of the bounding box extend
  110895. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110896. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110897. */
  110898. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110899. /**
  110900. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  110901. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  110902. * frustum width.
  110903. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  110904. * to fully enclose the mesh in the viewing frustum.
  110905. */
  110906. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  110907. /**
  110908. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  110909. * is automatically returned to its default position (expected to be above ground plane).
  110910. */
  110911. private _maintainCameraAboveGround;
  110912. /**
  110913. * Returns the frustum slope based on the canvas ratio and camera FOV
  110914. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  110915. */
  110916. private _getFrustumSlope;
  110917. /**
  110918. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  110919. */
  110920. private _clearAnimationLocks;
  110921. /**
  110922. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110923. */
  110924. private _applyUserInteraction;
  110925. /**
  110926. * Stops and removes all animations that have been applied to the camera
  110927. */
  110928. stopAllAnimations(): void;
  110929. /**
  110930. * Gets a value indicating if the user is moving the camera
  110931. */
  110932. get isUserIsMoving(): boolean;
  110933. /**
  110934. * The camera can move all the way towards the mesh.
  110935. */
  110936. static IgnoreBoundsSizeMode: number;
  110937. /**
  110938. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  110939. */
  110940. static FitFrustumSidesMode: number;
  110941. }
  110942. }
  110943. declare module BABYLON {
  110944. /**
  110945. * Base class for Camera Pointer Inputs.
  110946. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  110947. * for example usage.
  110948. */
  110949. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  110950. /**
  110951. * Defines the camera the input is attached to.
  110952. */
  110953. abstract camera: Camera;
  110954. /**
  110955. * Whether keyboard modifier keys are pressed at time of last mouse event.
  110956. */
  110957. protected _altKey: boolean;
  110958. protected _ctrlKey: boolean;
  110959. protected _metaKey: boolean;
  110960. protected _shiftKey: boolean;
  110961. /**
  110962. * Which mouse buttons were pressed at time of last mouse event.
  110963. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  110964. */
  110965. protected _buttonsPressed: number;
  110966. /**
  110967. * Defines the buttons associated with the input to handle camera move.
  110968. */
  110969. buttons: number[];
  110970. /**
  110971. * Attach the input controls to a specific dom element to get the input from.
  110972. * @param element Defines the element the controls should be listened from
  110973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110974. */
  110975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110976. /**
  110977. * Detach the current controls from the specified dom element.
  110978. * @param element Defines the element to stop listening the inputs from
  110979. */
  110980. detachControl(element: Nullable<HTMLElement>): void;
  110981. /**
  110982. * Gets the class name of the current input.
  110983. * @returns the class name
  110984. */
  110985. getClassName(): string;
  110986. /**
  110987. * Get the friendly name associated with the input class.
  110988. * @returns the input friendly name
  110989. */
  110990. getSimpleName(): string;
  110991. /**
  110992. * Called on pointer POINTERDOUBLETAP event.
  110993. * Override this method to provide functionality on POINTERDOUBLETAP event.
  110994. */
  110995. protected onDoubleTap(type: string): void;
  110996. /**
  110997. * Called on pointer POINTERMOVE event if only a single touch is active.
  110998. * Override this method to provide functionality.
  110999. */
  111000. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111001. /**
  111002. * Called on pointer POINTERMOVE event if multiple touches are active.
  111003. * Override this method to provide functionality.
  111004. */
  111005. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111006. /**
  111007. * Called on JS contextmenu event.
  111008. * Override this method to provide functionality.
  111009. */
  111010. protected onContextMenu(evt: PointerEvent): void;
  111011. /**
  111012. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111013. * press.
  111014. * Override this method to provide functionality.
  111015. */
  111016. protected onButtonDown(evt: PointerEvent): void;
  111017. /**
  111018. * Called each time a new POINTERUP event occurs. Ie, for each button
  111019. * release.
  111020. * Override this method to provide functionality.
  111021. */
  111022. protected onButtonUp(evt: PointerEvent): void;
  111023. /**
  111024. * Called when window becomes inactive.
  111025. * Override this method to provide functionality.
  111026. */
  111027. protected onLostFocus(): void;
  111028. private _pointerInput;
  111029. private _observer;
  111030. private _onLostFocus;
  111031. private pointA;
  111032. private pointB;
  111033. }
  111034. }
  111035. declare module BABYLON {
  111036. /**
  111037. * Manage the pointers inputs to control an arc rotate camera.
  111038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111039. */
  111040. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111041. /**
  111042. * Defines the camera the input is attached to.
  111043. */
  111044. camera: ArcRotateCamera;
  111045. /**
  111046. * Gets the class name of the current input.
  111047. * @returns the class name
  111048. */
  111049. getClassName(): string;
  111050. /**
  111051. * Defines the buttons associated with the input to handle camera move.
  111052. */
  111053. buttons: number[];
  111054. /**
  111055. * Defines the pointer angular sensibility along the X axis or how fast is
  111056. * the camera rotating.
  111057. */
  111058. angularSensibilityX: number;
  111059. /**
  111060. * Defines the pointer angular sensibility along the Y axis or how fast is
  111061. * the camera rotating.
  111062. */
  111063. angularSensibilityY: number;
  111064. /**
  111065. * Defines the pointer pinch precision or how fast is the camera zooming.
  111066. */
  111067. pinchPrecision: number;
  111068. /**
  111069. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111070. * from 0.
  111071. * It defines the percentage of current camera.radius to use as delta when
  111072. * pinch zoom is used.
  111073. */
  111074. pinchDeltaPercentage: number;
  111075. /**
  111076. * Defines the pointer panning sensibility or how fast is the camera moving.
  111077. */
  111078. panningSensibility: number;
  111079. /**
  111080. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111081. */
  111082. multiTouchPanning: boolean;
  111083. /**
  111084. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111085. * zoom (pinch) through multitouch.
  111086. */
  111087. multiTouchPanAndZoom: boolean;
  111088. /**
  111089. * Revers pinch action direction.
  111090. */
  111091. pinchInwards: boolean;
  111092. private _isPanClick;
  111093. private _twoFingerActivityCount;
  111094. private _isPinching;
  111095. /**
  111096. * Called on pointer POINTERMOVE event if only a single touch is active.
  111097. */
  111098. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111099. /**
  111100. * Called on pointer POINTERDOUBLETAP event.
  111101. */
  111102. protected onDoubleTap(type: string): void;
  111103. /**
  111104. * Called on pointer POINTERMOVE event if multiple touches are active.
  111105. */
  111106. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111107. /**
  111108. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111109. * press.
  111110. */
  111111. protected onButtonDown(evt: PointerEvent): void;
  111112. /**
  111113. * Called each time a new POINTERUP event occurs. Ie, for each button
  111114. * release.
  111115. */
  111116. protected onButtonUp(evt: PointerEvent): void;
  111117. /**
  111118. * Called when window becomes inactive.
  111119. */
  111120. protected onLostFocus(): void;
  111121. }
  111122. }
  111123. declare module BABYLON {
  111124. /**
  111125. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111127. */
  111128. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111129. /**
  111130. * Defines the camera the input is attached to.
  111131. */
  111132. camera: ArcRotateCamera;
  111133. /**
  111134. * Defines the list of key codes associated with the up action (increase alpha)
  111135. */
  111136. keysUp: number[];
  111137. /**
  111138. * Defines the list of key codes associated with the down action (decrease alpha)
  111139. */
  111140. keysDown: number[];
  111141. /**
  111142. * Defines the list of key codes associated with the left action (increase beta)
  111143. */
  111144. keysLeft: number[];
  111145. /**
  111146. * Defines the list of key codes associated with the right action (decrease beta)
  111147. */
  111148. keysRight: number[];
  111149. /**
  111150. * Defines the list of key codes associated with the reset action.
  111151. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111152. */
  111153. keysReset: number[];
  111154. /**
  111155. * Defines the panning sensibility of the inputs.
  111156. * (How fast is the camera panning)
  111157. */
  111158. panningSensibility: number;
  111159. /**
  111160. * Defines the zooming sensibility of the inputs.
  111161. * (How fast is the camera zooming)
  111162. */
  111163. zoomingSensibility: number;
  111164. /**
  111165. * Defines whether maintaining the alt key down switch the movement mode from
  111166. * orientation to zoom.
  111167. */
  111168. useAltToZoom: boolean;
  111169. /**
  111170. * Rotation speed of the camera
  111171. */
  111172. angularSpeed: number;
  111173. private _keys;
  111174. private _ctrlPressed;
  111175. private _altPressed;
  111176. private _onCanvasBlurObserver;
  111177. private _onKeyboardObserver;
  111178. private _engine;
  111179. private _scene;
  111180. /**
  111181. * Attach the input controls to a specific dom element to get the input from.
  111182. * @param element Defines the element the controls should be listened from
  111183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111184. */
  111185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111186. /**
  111187. * Detach the current controls from the specified dom element.
  111188. * @param element Defines the element to stop listening the inputs from
  111189. */
  111190. detachControl(element: Nullable<HTMLElement>): void;
  111191. /**
  111192. * Update the current camera state depending on the inputs that have been used this frame.
  111193. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111194. */
  111195. checkInputs(): void;
  111196. /**
  111197. * Gets the class name of the current intput.
  111198. * @returns the class name
  111199. */
  111200. getClassName(): string;
  111201. /**
  111202. * Get the friendly name associated with the input class.
  111203. * @returns the input friendly name
  111204. */
  111205. getSimpleName(): string;
  111206. }
  111207. }
  111208. declare module BABYLON {
  111209. /**
  111210. * Manage the mouse wheel inputs to control an arc rotate camera.
  111211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111212. */
  111213. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111214. /**
  111215. * Defines the camera the input is attached to.
  111216. */
  111217. camera: ArcRotateCamera;
  111218. /**
  111219. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111220. */
  111221. wheelPrecision: number;
  111222. /**
  111223. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111224. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111225. */
  111226. wheelDeltaPercentage: number;
  111227. private _wheel;
  111228. private _observer;
  111229. private computeDeltaFromMouseWheelLegacyEvent;
  111230. /**
  111231. * Attach the input controls to a specific dom element to get the input from.
  111232. * @param element Defines the element the controls should be listened from
  111233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111234. */
  111235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111236. /**
  111237. * Detach the current controls from the specified dom element.
  111238. * @param element Defines the element to stop listening the inputs from
  111239. */
  111240. detachControl(element: Nullable<HTMLElement>): void;
  111241. /**
  111242. * Gets the class name of the current intput.
  111243. * @returns the class name
  111244. */
  111245. getClassName(): string;
  111246. /**
  111247. * Get the friendly name associated with the input class.
  111248. * @returns the input friendly name
  111249. */
  111250. getSimpleName(): string;
  111251. }
  111252. }
  111253. declare module BABYLON {
  111254. /**
  111255. * Default Inputs manager for the ArcRotateCamera.
  111256. * It groups all the default supported inputs for ease of use.
  111257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111258. */
  111259. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111260. /**
  111261. * Instantiates a new ArcRotateCameraInputsManager.
  111262. * @param camera Defines the camera the inputs belong to
  111263. */
  111264. constructor(camera: ArcRotateCamera);
  111265. /**
  111266. * Add mouse wheel input support to the input manager.
  111267. * @returns the current input manager
  111268. */
  111269. addMouseWheel(): ArcRotateCameraInputsManager;
  111270. /**
  111271. * Add pointers input support to the input manager.
  111272. * @returns the current input manager
  111273. */
  111274. addPointers(): ArcRotateCameraInputsManager;
  111275. /**
  111276. * Add keyboard input support to the input manager.
  111277. * @returns the current input manager
  111278. */
  111279. addKeyboard(): ArcRotateCameraInputsManager;
  111280. }
  111281. }
  111282. declare module BABYLON {
  111283. /**
  111284. * This represents an orbital type of camera.
  111285. *
  111286. * 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.
  111287. * 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.
  111288. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111289. */
  111290. export class ArcRotateCamera extends TargetCamera {
  111291. /**
  111292. * Defines the rotation angle of the camera along the longitudinal axis.
  111293. */
  111294. alpha: number;
  111295. /**
  111296. * Defines the rotation angle of the camera along the latitudinal axis.
  111297. */
  111298. beta: number;
  111299. /**
  111300. * Defines the radius of the camera from it s target point.
  111301. */
  111302. radius: number;
  111303. protected _target: Vector3;
  111304. protected _targetHost: Nullable<AbstractMesh>;
  111305. /**
  111306. * Defines the target point of the camera.
  111307. * The camera looks towards it form the radius distance.
  111308. */
  111309. get target(): Vector3;
  111310. set target(value: Vector3);
  111311. /**
  111312. * Define the current local position of the camera in the scene
  111313. */
  111314. get position(): Vector3;
  111315. set position(newPosition: Vector3);
  111316. protected _upVector: Vector3;
  111317. protected _upToYMatrix: Matrix;
  111318. protected _YToUpMatrix: Matrix;
  111319. /**
  111320. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111321. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111322. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111323. */
  111324. set upVector(vec: Vector3);
  111325. get upVector(): Vector3;
  111326. /**
  111327. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111328. */
  111329. setMatUp(): void;
  111330. /**
  111331. * Current inertia value on the longitudinal axis.
  111332. * The bigger this number the longer it will take for the camera to stop.
  111333. */
  111334. inertialAlphaOffset: number;
  111335. /**
  111336. * Current inertia value on the latitudinal axis.
  111337. * The bigger this number the longer it will take for the camera to stop.
  111338. */
  111339. inertialBetaOffset: number;
  111340. /**
  111341. * Current inertia value on the radius axis.
  111342. * The bigger this number the longer it will take for the camera to stop.
  111343. */
  111344. inertialRadiusOffset: number;
  111345. /**
  111346. * Minimum allowed angle on the longitudinal axis.
  111347. * This can help limiting how the Camera is able to move in the scene.
  111348. */
  111349. lowerAlphaLimit: Nullable<number>;
  111350. /**
  111351. * Maximum allowed angle on the longitudinal axis.
  111352. * This can help limiting how the Camera is able to move in the scene.
  111353. */
  111354. upperAlphaLimit: Nullable<number>;
  111355. /**
  111356. * Minimum allowed angle on the latitudinal axis.
  111357. * This can help limiting how the Camera is able to move in the scene.
  111358. */
  111359. lowerBetaLimit: number;
  111360. /**
  111361. * Maximum allowed angle on the latitudinal axis.
  111362. * This can help limiting how the Camera is able to move in the scene.
  111363. */
  111364. upperBetaLimit: number;
  111365. /**
  111366. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111367. * This can help limiting how the Camera is able to move in the scene.
  111368. */
  111369. lowerRadiusLimit: Nullable<number>;
  111370. /**
  111371. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111372. * This can help limiting how the Camera is able to move in the scene.
  111373. */
  111374. upperRadiusLimit: Nullable<number>;
  111375. /**
  111376. * Defines the current inertia value used during panning of the camera along the X axis.
  111377. */
  111378. inertialPanningX: number;
  111379. /**
  111380. * Defines the current inertia value used during panning of the camera along the Y axis.
  111381. */
  111382. inertialPanningY: number;
  111383. /**
  111384. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111385. * Basically if your fingers moves away from more than this distance you will be considered
  111386. * in pinch mode.
  111387. */
  111388. pinchToPanMaxDistance: number;
  111389. /**
  111390. * Defines the maximum distance the camera can pan.
  111391. * This could help keeping the cammera always in your scene.
  111392. */
  111393. panningDistanceLimit: Nullable<number>;
  111394. /**
  111395. * Defines the target of the camera before paning.
  111396. */
  111397. panningOriginTarget: Vector3;
  111398. /**
  111399. * Defines the value of the inertia used during panning.
  111400. * 0 would mean stop inertia and one would mean no decelleration at all.
  111401. */
  111402. panningInertia: number;
  111403. /**
  111404. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111405. */
  111406. get angularSensibilityX(): number;
  111407. set angularSensibilityX(value: number);
  111408. /**
  111409. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111410. */
  111411. get angularSensibilityY(): number;
  111412. set angularSensibilityY(value: number);
  111413. /**
  111414. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111415. */
  111416. get pinchPrecision(): number;
  111417. set pinchPrecision(value: number);
  111418. /**
  111419. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111420. * It will be used instead of pinchDeltaPrecision if different from 0.
  111421. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111422. */
  111423. get pinchDeltaPercentage(): number;
  111424. set pinchDeltaPercentage(value: number);
  111425. /**
  111426. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111427. */
  111428. get panningSensibility(): number;
  111429. set panningSensibility(value: number);
  111430. /**
  111431. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111432. */
  111433. get keysUp(): number[];
  111434. set keysUp(value: number[]);
  111435. /**
  111436. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111437. */
  111438. get keysDown(): number[];
  111439. set keysDown(value: number[]);
  111440. /**
  111441. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111442. */
  111443. get keysLeft(): number[];
  111444. set keysLeft(value: number[]);
  111445. /**
  111446. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111447. */
  111448. get keysRight(): number[];
  111449. set keysRight(value: number[]);
  111450. /**
  111451. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111452. */
  111453. get wheelPrecision(): number;
  111454. set wheelPrecision(value: number);
  111455. /**
  111456. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111457. * It will be used instead of pinchDeltaPrecision if different from 0.
  111458. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111459. */
  111460. get wheelDeltaPercentage(): number;
  111461. set wheelDeltaPercentage(value: number);
  111462. /**
  111463. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111464. */
  111465. zoomOnFactor: number;
  111466. /**
  111467. * Defines a screen offset for the camera position.
  111468. */
  111469. targetScreenOffset: Vector2;
  111470. /**
  111471. * Allows the camera to be completely reversed.
  111472. * If false the camera can not arrive upside down.
  111473. */
  111474. allowUpsideDown: boolean;
  111475. /**
  111476. * Define if double tap/click is used to restore the previously saved state of the camera.
  111477. */
  111478. useInputToRestoreState: boolean;
  111479. /** @hidden */
  111480. _viewMatrix: Matrix;
  111481. /** @hidden */
  111482. _useCtrlForPanning: boolean;
  111483. /** @hidden */
  111484. _panningMouseButton: number;
  111485. /**
  111486. * Defines the input associated to the camera.
  111487. */
  111488. inputs: ArcRotateCameraInputsManager;
  111489. /** @hidden */
  111490. _reset: () => void;
  111491. /**
  111492. * Defines the allowed panning axis.
  111493. */
  111494. panningAxis: Vector3;
  111495. protected _localDirection: Vector3;
  111496. protected _transformedDirection: Vector3;
  111497. private _bouncingBehavior;
  111498. /**
  111499. * Gets the bouncing behavior of the camera if it has been enabled.
  111500. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111501. */
  111502. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111503. /**
  111504. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111505. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111506. */
  111507. get useBouncingBehavior(): boolean;
  111508. set useBouncingBehavior(value: boolean);
  111509. private _framingBehavior;
  111510. /**
  111511. * Gets the framing behavior of the camera if it has been enabled.
  111512. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111513. */
  111514. get framingBehavior(): Nullable<FramingBehavior>;
  111515. /**
  111516. * Defines if the framing behavior of the camera is enabled on the camera.
  111517. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111518. */
  111519. get useFramingBehavior(): boolean;
  111520. set useFramingBehavior(value: boolean);
  111521. private _autoRotationBehavior;
  111522. /**
  111523. * Gets the auto rotation behavior of the camera if it has been enabled.
  111524. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111525. */
  111526. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111527. /**
  111528. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111529. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111530. */
  111531. get useAutoRotationBehavior(): boolean;
  111532. set useAutoRotationBehavior(value: boolean);
  111533. /**
  111534. * Observable triggered when the mesh target has been changed on the camera.
  111535. */
  111536. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111537. /**
  111538. * Event raised when the camera is colliding with a mesh.
  111539. */
  111540. onCollide: (collidedMesh: AbstractMesh) => void;
  111541. /**
  111542. * Defines whether the camera should check collision with the objects oh the scene.
  111543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111544. */
  111545. checkCollisions: boolean;
  111546. /**
  111547. * Defines the collision radius of the camera.
  111548. * This simulates a sphere around the camera.
  111549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111550. */
  111551. collisionRadius: Vector3;
  111552. protected _collider: Collider;
  111553. protected _previousPosition: Vector3;
  111554. protected _collisionVelocity: Vector3;
  111555. protected _newPosition: Vector3;
  111556. protected _previousAlpha: number;
  111557. protected _previousBeta: number;
  111558. protected _previousRadius: number;
  111559. protected _collisionTriggered: boolean;
  111560. protected _targetBoundingCenter: Nullable<Vector3>;
  111561. private _computationVector;
  111562. /**
  111563. * Instantiates a new ArcRotateCamera in a given scene
  111564. * @param name Defines the name of the camera
  111565. * @param alpha Defines the camera rotation along the logitudinal axis
  111566. * @param beta Defines the camera rotation along the latitudinal axis
  111567. * @param radius Defines the camera distance from its target
  111568. * @param target Defines the camera target
  111569. * @param scene Defines the scene the camera belongs to
  111570. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111571. */
  111572. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111573. /** @hidden */
  111574. _initCache(): void;
  111575. /** @hidden */
  111576. _updateCache(ignoreParentClass?: boolean): void;
  111577. protected _getTargetPosition(): Vector3;
  111578. private _storedAlpha;
  111579. private _storedBeta;
  111580. private _storedRadius;
  111581. private _storedTarget;
  111582. private _storedTargetScreenOffset;
  111583. /**
  111584. * Stores the current state of the camera (alpha, beta, radius and target)
  111585. * @returns the camera itself
  111586. */
  111587. storeState(): Camera;
  111588. /**
  111589. * @hidden
  111590. * Restored camera state. You must call storeState() first
  111591. */
  111592. _restoreStateValues(): boolean;
  111593. /** @hidden */
  111594. _isSynchronizedViewMatrix(): boolean;
  111595. /**
  111596. * Attached controls to the current camera.
  111597. * @param element Defines the element the controls should be listened from
  111598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111599. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  111600. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  111601. */
  111602. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  111603. /**
  111604. * Detach the current controls from the camera.
  111605. * The camera will stop reacting to inputs.
  111606. * @param element Defines the element to stop listening the inputs from
  111607. */
  111608. detachControl(element: HTMLElement): void;
  111609. /** @hidden */
  111610. _checkInputs(): void;
  111611. protected _checkLimits(): void;
  111612. /**
  111613. * Rebuilds angles (alpha, beta) and radius from the give position and target
  111614. */
  111615. rebuildAnglesAndRadius(): void;
  111616. /**
  111617. * Use a position to define the current camera related information like alpha, beta and radius
  111618. * @param position Defines the position to set the camera at
  111619. */
  111620. setPosition(position: Vector3): void;
  111621. /**
  111622. * Defines the target the camera should look at.
  111623. * This will automatically adapt alpha beta and radius to fit within the new target.
  111624. * @param target Defines the new target as a Vector or a mesh
  111625. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  111626. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  111627. */
  111628. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  111629. /** @hidden */
  111630. _getViewMatrix(): Matrix;
  111631. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  111632. /**
  111633. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  111634. * @param meshes Defines the mesh to zoom on
  111635. * @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)
  111636. */
  111637. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  111638. /**
  111639. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  111640. * The target will be changed but the radius
  111641. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  111642. * @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)
  111643. */
  111644. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  111645. min: Vector3;
  111646. max: Vector3;
  111647. distance: number;
  111648. }, doNotUpdateMaxZ?: boolean): void;
  111649. /**
  111650. * @override
  111651. * Override Camera.createRigCamera
  111652. */
  111653. createRigCamera(name: string, cameraIndex: number): Camera;
  111654. /**
  111655. * @hidden
  111656. * @override
  111657. * Override Camera._updateRigCameras
  111658. */
  111659. _updateRigCameras(): void;
  111660. /**
  111661. * Destroy the camera and release the current resources hold by it.
  111662. */
  111663. dispose(): void;
  111664. /**
  111665. * Gets the current object class name.
  111666. * @return the class name
  111667. */
  111668. getClassName(): string;
  111669. }
  111670. }
  111671. declare module BABYLON {
  111672. /**
  111673. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  111674. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111675. */
  111676. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  111677. /**
  111678. * Gets the name of the behavior.
  111679. */
  111680. get name(): string;
  111681. private _zoomStopsAnimation;
  111682. private _idleRotationSpeed;
  111683. private _idleRotationWaitTime;
  111684. private _idleRotationSpinupTime;
  111685. /**
  111686. * Sets the flag that indicates if user zooming should stop animation.
  111687. */
  111688. set zoomStopsAnimation(flag: boolean);
  111689. /**
  111690. * Gets the flag that indicates if user zooming should stop animation.
  111691. */
  111692. get zoomStopsAnimation(): boolean;
  111693. /**
  111694. * Sets the default speed at which the camera rotates around the model.
  111695. */
  111696. set idleRotationSpeed(speed: number);
  111697. /**
  111698. * Gets the default speed at which the camera rotates around the model.
  111699. */
  111700. get idleRotationSpeed(): number;
  111701. /**
  111702. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  111703. */
  111704. set idleRotationWaitTime(time: number);
  111705. /**
  111706. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  111707. */
  111708. get idleRotationWaitTime(): number;
  111709. /**
  111710. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111711. */
  111712. set idleRotationSpinupTime(time: number);
  111713. /**
  111714. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111715. */
  111716. get idleRotationSpinupTime(): number;
  111717. /**
  111718. * Gets a value indicating if the camera is currently rotating because of this behavior
  111719. */
  111720. get rotationInProgress(): boolean;
  111721. private _onPrePointerObservableObserver;
  111722. private _onAfterCheckInputsObserver;
  111723. private _attachedCamera;
  111724. private _isPointerDown;
  111725. private _lastFrameTime;
  111726. private _lastInteractionTime;
  111727. private _cameraRotationSpeed;
  111728. /**
  111729. * Initializes the behavior.
  111730. */
  111731. init(): void;
  111732. /**
  111733. * Attaches the behavior to its arc rotate camera.
  111734. * @param camera Defines the camera to attach the behavior to
  111735. */
  111736. attach(camera: ArcRotateCamera): void;
  111737. /**
  111738. * Detaches the behavior from its current arc rotate camera.
  111739. */
  111740. detach(): void;
  111741. /**
  111742. * Returns true if user is scrolling.
  111743. * @return true if user is scrolling.
  111744. */
  111745. private _userIsZooming;
  111746. private _lastFrameRadius;
  111747. private _shouldAnimationStopForInteraction;
  111748. /**
  111749. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111750. */
  111751. private _applyUserInteraction;
  111752. private _userIsMoving;
  111753. }
  111754. }
  111755. declare module BABYLON {
  111756. /**
  111757. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  111758. */
  111759. export class AttachToBoxBehavior implements Behavior<Mesh> {
  111760. private ui;
  111761. /**
  111762. * The name of the behavior
  111763. */
  111764. name: string;
  111765. /**
  111766. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  111767. */
  111768. distanceAwayFromFace: number;
  111769. /**
  111770. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  111771. */
  111772. distanceAwayFromBottomOfFace: number;
  111773. private _faceVectors;
  111774. private _target;
  111775. private _scene;
  111776. private _onRenderObserver;
  111777. private _tmpMatrix;
  111778. private _tmpVector;
  111779. /**
  111780. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  111781. * @param ui The transform node that should be attched to the mesh
  111782. */
  111783. constructor(ui: TransformNode);
  111784. /**
  111785. * Initializes the behavior
  111786. */
  111787. init(): void;
  111788. private _closestFace;
  111789. private _zeroVector;
  111790. private _lookAtTmpMatrix;
  111791. private _lookAtToRef;
  111792. /**
  111793. * Attaches the AttachToBoxBehavior to the passed in mesh
  111794. * @param target The mesh that the specified node will be attached to
  111795. */
  111796. attach(target: Mesh): void;
  111797. /**
  111798. * Detaches the behavior from the mesh
  111799. */
  111800. detach(): void;
  111801. }
  111802. }
  111803. declare module BABYLON {
  111804. /**
  111805. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  111806. */
  111807. export class FadeInOutBehavior implements Behavior<Mesh> {
  111808. /**
  111809. * Time in milliseconds to delay before fading in (Default: 0)
  111810. */
  111811. delay: number;
  111812. /**
  111813. * Time in milliseconds for the mesh to fade in (Default: 300)
  111814. */
  111815. fadeInTime: number;
  111816. private _millisecondsPerFrame;
  111817. private _hovered;
  111818. private _hoverValue;
  111819. private _ownerNode;
  111820. /**
  111821. * Instatiates the FadeInOutBehavior
  111822. */
  111823. constructor();
  111824. /**
  111825. * The name of the behavior
  111826. */
  111827. get name(): string;
  111828. /**
  111829. * Initializes the behavior
  111830. */
  111831. init(): void;
  111832. /**
  111833. * Attaches the fade behavior on the passed in mesh
  111834. * @param ownerNode The mesh that will be faded in/out once attached
  111835. */
  111836. attach(ownerNode: Mesh): void;
  111837. /**
  111838. * Detaches the behavior from the mesh
  111839. */
  111840. detach(): void;
  111841. /**
  111842. * Triggers the mesh to begin fading in or out
  111843. * @param value if the object should fade in or out (true to fade in)
  111844. */
  111845. fadeIn(value: boolean): void;
  111846. private _update;
  111847. private _setAllVisibility;
  111848. }
  111849. }
  111850. declare module BABYLON {
  111851. /**
  111852. * Class containing a set of static utilities functions for managing Pivots
  111853. * @hidden
  111854. */
  111855. export class PivotTools {
  111856. private static _PivotCached;
  111857. private static _OldPivotPoint;
  111858. private static _PivotTranslation;
  111859. private static _PivotTmpVector;
  111860. /** @hidden */
  111861. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  111862. /** @hidden */
  111863. static _RestorePivotPoint(mesh: AbstractMesh): void;
  111864. }
  111865. }
  111866. declare module BABYLON {
  111867. /**
  111868. * Class containing static functions to help procedurally build meshes
  111869. */
  111870. export class PlaneBuilder {
  111871. /**
  111872. * Creates a plane mesh
  111873. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  111874. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  111875. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  111876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111879. * @param name defines the name of the mesh
  111880. * @param options defines the options used to create the mesh
  111881. * @param scene defines the hosting scene
  111882. * @returns the plane mesh
  111883. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  111884. */
  111885. static CreatePlane(name: string, options: {
  111886. size?: number;
  111887. width?: number;
  111888. height?: number;
  111889. sideOrientation?: number;
  111890. frontUVs?: Vector4;
  111891. backUVs?: Vector4;
  111892. updatable?: boolean;
  111893. sourcePlane?: Plane;
  111894. }, scene?: Nullable<Scene>): Mesh;
  111895. }
  111896. }
  111897. declare module BABYLON {
  111898. /**
  111899. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  111900. */
  111901. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  111902. private static _AnyMouseID;
  111903. /**
  111904. * Abstract mesh the behavior is set on
  111905. */
  111906. attachedNode: AbstractMesh;
  111907. private _dragPlane;
  111908. private _scene;
  111909. private _pointerObserver;
  111910. private _beforeRenderObserver;
  111911. private static _planeScene;
  111912. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  111913. /**
  111914. * 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)
  111915. */
  111916. maxDragAngle: number;
  111917. /**
  111918. * @hidden
  111919. */
  111920. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  111921. /**
  111922. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111923. */
  111924. currentDraggingPointerID: number;
  111925. /**
  111926. * The last position where the pointer hit the drag plane in world space
  111927. */
  111928. lastDragPosition: Vector3;
  111929. /**
  111930. * If the behavior is currently in a dragging state
  111931. */
  111932. dragging: boolean;
  111933. /**
  111934. * 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)
  111935. */
  111936. dragDeltaRatio: number;
  111937. /**
  111938. * If the drag plane orientation should be updated during the dragging (Default: true)
  111939. */
  111940. updateDragPlane: boolean;
  111941. private _debugMode;
  111942. private _moving;
  111943. /**
  111944. * Fires each time the attached mesh is dragged with the pointer
  111945. * * delta between last drag position and current drag position in world space
  111946. * * dragDistance along the drag axis
  111947. * * dragPlaneNormal normal of the current drag plane used during the drag
  111948. * * dragPlanePoint in world space where the drag intersects the drag plane
  111949. */
  111950. onDragObservable: Observable<{
  111951. delta: Vector3;
  111952. dragPlanePoint: Vector3;
  111953. dragPlaneNormal: Vector3;
  111954. dragDistance: number;
  111955. pointerId: number;
  111956. }>;
  111957. /**
  111958. * Fires each time a drag begins (eg. mouse down on mesh)
  111959. */
  111960. onDragStartObservable: Observable<{
  111961. dragPlanePoint: Vector3;
  111962. pointerId: number;
  111963. }>;
  111964. /**
  111965. * Fires each time a drag ends (eg. mouse release after drag)
  111966. */
  111967. onDragEndObservable: Observable<{
  111968. dragPlanePoint: Vector3;
  111969. pointerId: number;
  111970. }>;
  111971. /**
  111972. * If the attached mesh should be moved when dragged
  111973. */
  111974. moveAttached: boolean;
  111975. /**
  111976. * If the drag behavior will react to drag events (Default: true)
  111977. */
  111978. enabled: boolean;
  111979. /**
  111980. * If pointer events should start and release the drag (Default: true)
  111981. */
  111982. startAndReleaseDragOnPointerEvents: boolean;
  111983. /**
  111984. * If camera controls should be detached during the drag
  111985. */
  111986. detachCameraControls: boolean;
  111987. /**
  111988. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  111989. */
  111990. useObjectOrientationForDragging: boolean;
  111991. private _options;
  111992. /**
  111993. * Gets the options used by the behavior
  111994. */
  111995. get options(): {
  111996. dragAxis?: Vector3;
  111997. dragPlaneNormal?: Vector3;
  111998. };
  111999. /**
  112000. * Sets the options used by the behavior
  112001. */
  112002. set options(options: {
  112003. dragAxis?: Vector3;
  112004. dragPlaneNormal?: Vector3;
  112005. });
  112006. /**
  112007. * Creates a pointer drag behavior that can be attached to a mesh
  112008. * @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)
  112009. */
  112010. constructor(options?: {
  112011. dragAxis?: Vector3;
  112012. dragPlaneNormal?: Vector3;
  112013. });
  112014. /**
  112015. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112016. */
  112017. validateDrag: (targetPosition: Vector3) => boolean;
  112018. /**
  112019. * The name of the behavior
  112020. */
  112021. get name(): string;
  112022. /**
  112023. * Initializes the behavior
  112024. */
  112025. init(): void;
  112026. private _tmpVector;
  112027. private _alternatePickedPoint;
  112028. private _worldDragAxis;
  112029. private _targetPosition;
  112030. private _attachedElement;
  112031. /**
  112032. * Attaches the drag behavior the passed in mesh
  112033. * @param ownerNode The mesh that will be dragged around once attached
  112034. * @param predicate Predicate to use for pick filtering
  112035. */
  112036. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112037. /**
  112038. * Force relase the drag action by code.
  112039. */
  112040. releaseDrag(): void;
  112041. private _startDragRay;
  112042. private _lastPointerRay;
  112043. /**
  112044. * Simulates the start of a pointer drag event on the behavior
  112045. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112046. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112047. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112048. */
  112049. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112050. private _startDrag;
  112051. private _dragDelta;
  112052. private _moveDrag;
  112053. private _pickWithRayOnDragPlane;
  112054. private _pointA;
  112055. private _pointB;
  112056. private _pointC;
  112057. private _lineA;
  112058. private _lineB;
  112059. private _localAxis;
  112060. private _lookAt;
  112061. private _updateDragPlanePosition;
  112062. /**
  112063. * Detaches the behavior from the mesh
  112064. */
  112065. detach(): void;
  112066. }
  112067. }
  112068. declare module BABYLON {
  112069. /**
  112070. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112071. */
  112072. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112073. private _dragBehaviorA;
  112074. private _dragBehaviorB;
  112075. private _startDistance;
  112076. private _initialScale;
  112077. private _targetScale;
  112078. private _ownerNode;
  112079. private _sceneRenderObserver;
  112080. /**
  112081. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112082. */
  112083. constructor();
  112084. /**
  112085. * The name of the behavior
  112086. */
  112087. get name(): string;
  112088. /**
  112089. * Initializes the behavior
  112090. */
  112091. init(): void;
  112092. private _getCurrentDistance;
  112093. /**
  112094. * Attaches the scale behavior the passed in mesh
  112095. * @param ownerNode The mesh that will be scaled around once attached
  112096. */
  112097. attach(ownerNode: Mesh): void;
  112098. /**
  112099. * Detaches the behavior from the mesh
  112100. */
  112101. detach(): void;
  112102. }
  112103. }
  112104. declare module BABYLON {
  112105. /**
  112106. * 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
  112107. */
  112108. export class SixDofDragBehavior implements Behavior<Mesh> {
  112109. private static _virtualScene;
  112110. private _ownerNode;
  112111. private _sceneRenderObserver;
  112112. private _scene;
  112113. private _targetPosition;
  112114. private _virtualOriginMesh;
  112115. private _virtualDragMesh;
  112116. private _pointerObserver;
  112117. private _moving;
  112118. private _startingOrientation;
  112119. /**
  112120. * 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)
  112121. */
  112122. private zDragFactor;
  112123. /**
  112124. * If the object should rotate to face the drag origin
  112125. */
  112126. rotateDraggedObject: boolean;
  112127. /**
  112128. * If the behavior is currently in a dragging state
  112129. */
  112130. dragging: boolean;
  112131. /**
  112132. * 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)
  112133. */
  112134. dragDeltaRatio: number;
  112135. /**
  112136. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112137. */
  112138. currentDraggingPointerID: number;
  112139. /**
  112140. * If camera controls should be detached during the drag
  112141. */
  112142. detachCameraControls: boolean;
  112143. /**
  112144. * Fires each time a drag starts
  112145. */
  112146. onDragStartObservable: Observable<{}>;
  112147. /**
  112148. * Fires each time a drag ends (eg. mouse release after drag)
  112149. */
  112150. onDragEndObservable: Observable<{}>;
  112151. /**
  112152. * 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
  112153. */
  112154. constructor();
  112155. /**
  112156. * The name of the behavior
  112157. */
  112158. get name(): string;
  112159. /**
  112160. * Initializes the behavior
  112161. */
  112162. init(): void;
  112163. /**
  112164. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112165. */
  112166. private get _pointerCamera();
  112167. /**
  112168. * Attaches the scale behavior the passed in mesh
  112169. * @param ownerNode The mesh that will be scaled around once attached
  112170. */
  112171. attach(ownerNode: Mesh): void;
  112172. /**
  112173. * Detaches the behavior from the mesh
  112174. */
  112175. detach(): void;
  112176. }
  112177. }
  112178. declare module BABYLON {
  112179. /**
  112180. * Class used to apply inverse kinematics to bones
  112181. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112182. */
  112183. export class BoneIKController {
  112184. private static _tmpVecs;
  112185. private static _tmpQuat;
  112186. private static _tmpMats;
  112187. /**
  112188. * Gets or sets the target mesh
  112189. */
  112190. targetMesh: AbstractMesh;
  112191. /** Gets or sets the mesh used as pole */
  112192. poleTargetMesh: AbstractMesh;
  112193. /**
  112194. * Gets or sets the bone used as pole
  112195. */
  112196. poleTargetBone: Nullable<Bone>;
  112197. /**
  112198. * Gets or sets the target position
  112199. */
  112200. targetPosition: Vector3;
  112201. /**
  112202. * Gets or sets the pole target position
  112203. */
  112204. poleTargetPosition: Vector3;
  112205. /**
  112206. * Gets or sets the pole target local offset
  112207. */
  112208. poleTargetLocalOffset: Vector3;
  112209. /**
  112210. * Gets or sets the pole angle
  112211. */
  112212. poleAngle: number;
  112213. /**
  112214. * Gets or sets the mesh associated with the controller
  112215. */
  112216. mesh: AbstractMesh;
  112217. /**
  112218. * 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)
  112219. */
  112220. slerpAmount: number;
  112221. private _bone1Quat;
  112222. private _bone1Mat;
  112223. private _bone2Ang;
  112224. private _bone1;
  112225. private _bone2;
  112226. private _bone1Length;
  112227. private _bone2Length;
  112228. private _maxAngle;
  112229. private _maxReach;
  112230. private _rightHandedSystem;
  112231. private _bendAxis;
  112232. private _slerping;
  112233. private _adjustRoll;
  112234. /**
  112235. * Gets or sets maximum allowed angle
  112236. */
  112237. get maxAngle(): number;
  112238. set maxAngle(value: number);
  112239. /**
  112240. * Creates a new BoneIKController
  112241. * @param mesh defines the mesh to control
  112242. * @param bone defines the bone to control
  112243. * @param options defines options to set up the controller
  112244. */
  112245. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112246. targetMesh?: AbstractMesh;
  112247. poleTargetMesh?: AbstractMesh;
  112248. poleTargetBone?: Bone;
  112249. poleTargetLocalOffset?: Vector3;
  112250. poleAngle?: number;
  112251. bendAxis?: Vector3;
  112252. maxAngle?: number;
  112253. slerpAmount?: number;
  112254. });
  112255. private _setMaxAngle;
  112256. /**
  112257. * Force the controller to update the bones
  112258. */
  112259. update(): void;
  112260. }
  112261. }
  112262. declare module BABYLON {
  112263. /**
  112264. * Class used to make a bone look toward a point in space
  112265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112266. */
  112267. export class BoneLookController {
  112268. private static _tmpVecs;
  112269. private static _tmpQuat;
  112270. private static _tmpMats;
  112271. /**
  112272. * The target Vector3 that the bone will look at
  112273. */
  112274. target: Vector3;
  112275. /**
  112276. * The mesh that the bone is attached to
  112277. */
  112278. mesh: AbstractMesh;
  112279. /**
  112280. * The bone that will be looking to the target
  112281. */
  112282. bone: Bone;
  112283. /**
  112284. * The up axis of the coordinate system that is used when the bone is rotated
  112285. */
  112286. upAxis: Vector3;
  112287. /**
  112288. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112289. */
  112290. upAxisSpace: Space;
  112291. /**
  112292. * Used to make an adjustment to the yaw of the bone
  112293. */
  112294. adjustYaw: number;
  112295. /**
  112296. * Used to make an adjustment to the pitch of the bone
  112297. */
  112298. adjustPitch: number;
  112299. /**
  112300. * Used to make an adjustment to the roll of the bone
  112301. */
  112302. adjustRoll: number;
  112303. /**
  112304. * 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)
  112305. */
  112306. slerpAmount: number;
  112307. private _minYaw;
  112308. private _maxYaw;
  112309. private _minPitch;
  112310. private _maxPitch;
  112311. private _minYawSin;
  112312. private _minYawCos;
  112313. private _maxYawSin;
  112314. private _maxYawCos;
  112315. private _midYawConstraint;
  112316. private _minPitchTan;
  112317. private _maxPitchTan;
  112318. private _boneQuat;
  112319. private _slerping;
  112320. private _transformYawPitch;
  112321. private _transformYawPitchInv;
  112322. private _firstFrameSkipped;
  112323. private _yawRange;
  112324. private _fowardAxis;
  112325. /**
  112326. * Gets or sets the minimum yaw angle that the bone can look to
  112327. */
  112328. get minYaw(): number;
  112329. set minYaw(value: number);
  112330. /**
  112331. * Gets or sets the maximum yaw angle that the bone can look to
  112332. */
  112333. get maxYaw(): number;
  112334. set maxYaw(value: number);
  112335. /**
  112336. * Gets or sets the minimum pitch angle that the bone can look to
  112337. */
  112338. get minPitch(): number;
  112339. set minPitch(value: number);
  112340. /**
  112341. * Gets or sets the maximum pitch angle that the bone can look to
  112342. */
  112343. get maxPitch(): number;
  112344. set maxPitch(value: number);
  112345. /**
  112346. * Create a BoneLookController
  112347. * @param mesh the mesh that the bone belongs to
  112348. * @param bone the bone that will be looking to the target
  112349. * @param target the target Vector3 to look at
  112350. * @param options optional settings:
  112351. * * maxYaw: the maximum angle the bone will yaw to
  112352. * * minYaw: the minimum angle the bone will yaw to
  112353. * * maxPitch: the maximum angle the bone will pitch to
  112354. * * minPitch: the minimum angle the bone will yaw to
  112355. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112356. * * upAxis: the up axis of the coordinate system
  112357. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112358. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112359. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112360. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112361. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112362. * * adjustRoll: used to make an adjustment to the roll of the bone
  112363. **/
  112364. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112365. maxYaw?: number;
  112366. minYaw?: number;
  112367. maxPitch?: number;
  112368. minPitch?: number;
  112369. slerpAmount?: number;
  112370. upAxis?: Vector3;
  112371. upAxisSpace?: Space;
  112372. yawAxis?: Vector3;
  112373. pitchAxis?: Vector3;
  112374. adjustYaw?: number;
  112375. adjustPitch?: number;
  112376. adjustRoll?: number;
  112377. });
  112378. /**
  112379. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112380. */
  112381. update(): void;
  112382. private _getAngleDiff;
  112383. private _getAngleBetween;
  112384. private _isAngleBetween;
  112385. }
  112386. }
  112387. declare module BABYLON {
  112388. /**
  112389. * Manage the gamepad inputs to control an arc rotate camera.
  112390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112391. */
  112392. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112393. /**
  112394. * Defines the camera the input is attached to.
  112395. */
  112396. camera: ArcRotateCamera;
  112397. /**
  112398. * Defines the gamepad the input is gathering event from.
  112399. */
  112400. gamepad: Nullable<Gamepad>;
  112401. /**
  112402. * Defines the gamepad rotation sensiblity.
  112403. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112404. */
  112405. gamepadRotationSensibility: number;
  112406. /**
  112407. * Defines the gamepad move sensiblity.
  112408. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112409. */
  112410. gamepadMoveSensibility: number;
  112411. private _yAxisScale;
  112412. /**
  112413. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112414. */
  112415. get invertYAxis(): boolean;
  112416. set invertYAxis(value: boolean);
  112417. private _onGamepadConnectedObserver;
  112418. private _onGamepadDisconnectedObserver;
  112419. /**
  112420. * Attach the input controls to a specific dom element to get the input from.
  112421. * @param element Defines the element the controls should be listened from
  112422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112423. */
  112424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112425. /**
  112426. * Detach the current controls from the specified dom element.
  112427. * @param element Defines the element to stop listening the inputs from
  112428. */
  112429. detachControl(element: Nullable<HTMLElement>): void;
  112430. /**
  112431. * Update the current camera state depending on the inputs that have been used this frame.
  112432. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112433. */
  112434. checkInputs(): void;
  112435. /**
  112436. * Gets the class name of the current intput.
  112437. * @returns the class name
  112438. */
  112439. getClassName(): string;
  112440. /**
  112441. * Get the friendly name associated with the input class.
  112442. * @returns the input friendly name
  112443. */
  112444. getSimpleName(): string;
  112445. }
  112446. }
  112447. declare module BABYLON {
  112448. interface ArcRotateCameraInputsManager {
  112449. /**
  112450. * Add orientation input support to the input manager.
  112451. * @returns the current input manager
  112452. */
  112453. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112454. }
  112455. /**
  112456. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112458. */
  112459. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112460. /**
  112461. * Defines the camera the input is attached to.
  112462. */
  112463. camera: ArcRotateCamera;
  112464. /**
  112465. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112466. */
  112467. alphaCorrection: number;
  112468. /**
  112469. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112470. */
  112471. gammaCorrection: number;
  112472. private _alpha;
  112473. private _gamma;
  112474. private _dirty;
  112475. private _deviceOrientationHandler;
  112476. /**
  112477. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112478. */
  112479. constructor();
  112480. /**
  112481. * Attach the input controls to a specific dom element to get the input from.
  112482. * @param element Defines the element the controls should be listened from
  112483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112484. */
  112485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112486. /** @hidden */
  112487. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112488. /**
  112489. * Update the current camera state depending on the inputs that have been used this frame.
  112490. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112491. */
  112492. checkInputs(): void;
  112493. /**
  112494. * Detach the current controls from the specified dom element.
  112495. * @param element Defines the element to stop listening the inputs from
  112496. */
  112497. detachControl(element: Nullable<HTMLElement>): void;
  112498. /**
  112499. * Gets the class name of the current intput.
  112500. * @returns the class name
  112501. */
  112502. getClassName(): string;
  112503. /**
  112504. * Get the friendly name associated with the input class.
  112505. * @returns the input friendly name
  112506. */
  112507. getSimpleName(): string;
  112508. }
  112509. }
  112510. declare module BABYLON {
  112511. /**
  112512. * Listen to mouse events to control the camera.
  112513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112514. */
  112515. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112516. /**
  112517. * Defines the camera the input is attached to.
  112518. */
  112519. camera: FlyCamera;
  112520. /**
  112521. * Defines if touch is enabled. (Default is true.)
  112522. */
  112523. touchEnabled: boolean;
  112524. /**
  112525. * Defines the buttons associated with the input to handle camera rotation.
  112526. */
  112527. buttons: number[];
  112528. /**
  112529. * Assign buttons for Yaw control.
  112530. */
  112531. buttonsYaw: number[];
  112532. /**
  112533. * Assign buttons for Pitch control.
  112534. */
  112535. buttonsPitch: number[];
  112536. /**
  112537. * Assign buttons for Roll control.
  112538. */
  112539. buttonsRoll: number[];
  112540. /**
  112541. * Detect if any button is being pressed while mouse is moved.
  112542. * -1 = Mouse locked.
  112543. * 0 = Left button.
  112544. * 1 = Middle Button.
  112545. * 2 = Right Button.
  112546. */
  112547. activeButton: number;
  112548. /**
  112549. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112550. * Higher values reduce its sensitivity.
  112551. */
  112552. angularSensibility: number;
  112553. private _mousemoveCallback;
  112554. private _observer;
  112555. private _rollObserver;
  112556. private previousPosition;
  112557. private noPreventDefault;
  112558. private element;
  112559. /**
  112560. * Listen to mouse events to control the camera.
  112561. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112563. */
  112564. constructor(touchEnabled?: boolean);
  112565. /**
  112566. * Attach the mouse control to the HTML DOM element.
  112567. * @param element Defines the element that listens to the input events.
  112568. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112569. */
  112570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112571. /**
  112572. * Detach the current controls from the specified dom element.
  112573. * @param element Defines the element to stop listening the inputs from
  112574. */
  112575. detachControl(element: Nullable<HTMLElement>): void;
  112576. /**
  112577. * Gets the class name of the current input.
  112578. * @returns the class name.
  112579. */
  112580. getClassName(): string;
  112581. /**
  112582. * Get the friendly name associated with the input class.
  112583. * @returns the input's friendly name.
  112584. */
  112585. getSimpleName(): string;
  112586. private _pointerInput;
  112587. private _onMouseMove;
  112588. /**
  112589. * Rotate camera by mouse offset.
  112590. */
  112591. private rotateCamera;
  112592. }
  112593. }
  112594. declare module BABYLON {
  112595. /**
  112596. * Default Inputs manager for the FlyCamera.
  112597. * It groups all the default supported inputs for ease of use.
  112598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112599. */
  112600. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  112601. /**
  112602. * Instantiates a new FlyCameraInputsManager.
  112603. * @param camera Defines the camera the inputs belong to.
  112604. */
  112605. constructor(camera: FlyCamera);
  112606. /**
  112607. * Add keyboard input support to the input manager.
  112608. * @returns the new FlyCameraKeyboardMoveInput().
  112609. */
  112610. addKeyboard(): FlyCameraInputsManager;
  112611. /**
  112612. * Add mouse input support to the input manager.
  112613. * @param touchEnabled Enable touch screen support.
  112614. * @returns the new FlyCameraMouseInput().
  112615. */
  112616. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  112617. }
  112618. }
  112619. declare module BABYLON {
  112620. /**
  112621. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112622. * such as in a 3D Space Shooter or a Flight Simulator.
  112623. */
  112624. export class FlyCamera extends TargetCamera {
  112625. /**
  112626. * Define the collision ellipsoid of the camera.
  112627. * This is helpful for simulating a camera body, like a player's body.
  112628. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112629. */
  112630. ellipsoid: Vector3;
  112631. /**
  112632. * Define an offset for the position of the ellipsoid around the camera.
  112633. * This can be helpful if the camera is attached away from the player's body center,
  112634. * such as at its head.
  112635. */
  112636. ellipsoidOffset: Vector3;
  112637. /**
  112638. * Enable or disable collisions of the camera with the rest of the scene objects.
  112639. */
  112640. checkCollisions: boolean;
  112641. /**
  112642. * Enable or disable gravity on the camera.
  112643. */
  112644. applyGravity: boolean;
  112645. /**
  112646. * Define the current direction the camera is moving to.
  112647. */
  112648. cameraDirection: Vector3;
  112649. /**
  112650. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  112651. * This overrides and empties cameraRotation.
  112652. */
  112653. rotationQuaternion: Quaternion;
  112654. /**
  112655. * Track Roll to maintain the wanted Rolling when looking around.
  112656. */
  112657. _trackRoll: number;
  112658. /**
  112659. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  112660. */
  112661. rollCorrect: number;
  112662. /**
  112663. * Mimic a banked turn, Rolling the camera when Yawing.
  112664. * It's recommended to use rollCorrect = 10 for faster banking correction.
  112665. */
  112666. bankedTurn: boolean;
  112667. /**
  112668. * Limit in radians for how much Roll banking will add. (Default: 90°)
  112669. */
  112670. bankedTurnLimit: number;
  112671. /**
  112672. * Value of 0 disables the banked Roll.
  112673. * Value of 1 is equal to the Yaw angle in radians.
  112674. */
  112675. bankedTurnMultiplier: number;
  112676. /**
  112677. * The inputs manager loads all the input sources, such as keyboard and mouse.
  112678. */
  112679. inputs: FlyCameraInputsManager;
  112680. /**
  112681. * Gets the input sensibility for mouse input.
  112682. * Higher values reduce sensitivity.
  112683. */
  112684. get angularSensibility(): number;
  112685. /**
  112686. * Sets the input sensibility for a mouse input.
  112687. * Higher values reduce sensitivity.
  112688. */
  112689. set angularSensibility(value: number);
  112690. /**
  112691. * Get the keys for camera movement forward.
  112692. */
  112693. get keysForward(): number[];
  112694. /**
  112695. * Set the keys for camera movement forward.
  112696. */
  112697. set keysForward(value: number[]);
  112698. /**
  112699. * Get the keys for camera movement backward.
  112700. */
  112701. get keysBackward(): number[];
  112702. set keysBackward(value: number[]);
  112703. /**
  112704. * Get the keys for camera movement up.
  112705. */
  112706. get keysUp(): number[];
  112707. /**
  112708. * Set the keys for camera movement up.
  112709. */
  112710. set keysUp(value: number[]);
  112711. /**
  112712. * Get the keys for camera movement down.
  112713. */
  112714. get keysDown(): number[];
  112715. /**
  112716. * Set the keys for camera movement down.
  112717. */
  112718. set keysDown(value: number[]);
  112719. /**
  112720. * Get the keys for camera movement left.
  112721. */
  112722. get keysLeft(): number[];
  112723. /**
  112724. * Set the keys for camera movement left.
  112725. */
  112726. set keysLeft(value: number[]);
  112727. /**
  112728. * Set the keys for camera movement right.
  112729. */
  112730. get keysRight(): number[];
  112731. /**
  112732. * Set the keys for camera movement right.
  112733. */
  112734. set keysRight(value: number[]);
  112735. /**
  112736. * Event raised when the camera collides with a mesh in the scene.
  112737. */
  112738. onCollide: (collidedMesh: AbstractMesh) => void;
  112739. private _collider;
  112740. private _needMoveForGravity;
  112741. private _oldPosition;
  112742. private _diffPosition;
  112743. private _newPosition;
  112744. /** @hidden */
  112745. _localDirection: Vector3;
  112746. /** @hidden */
  112747. _transformedDirection: Vector3;
  112748. /**
  112749. * Instantiates a FlyCamera.
  112750. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112751. * such as in a 3D Space Shooter or a Flight Simulator.
  112752. * @param name Define the name of the camera in the scene.
  112753. * @param position Define the starting position of the camera in the scene.
  112754. * @param scene Define the scene the camera belongs to.
  112755. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  112756. */
  112757. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112758. /**
  112759. * Attach a control to the HTML DOM element.
  112760. * @param element Defines the element that listens to the input events.
  112761. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  112762. */
  112763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112764. /**
  112765. * Detach a control from the HTML DOM element.
  112766. * The camera will stop reacting to that input.
  112767. * @param element Defines the element that listens to the input events.
  112768. */
  112769. detachControl(element: HTMLElement): void;
  112770. private _collisionMask;
  112771. /**
  112772. * Get the mask that the camera ignores in collision events.
  112773. */
  112774. get collisionMask(): number;
  112775. /**
  112776. * Set the mask that the camera ignores in collision events.
  112777. */
  112778. set collisionMask(mask: number);
  112779. /** @hidden */
  112780. _collideWithWorld(displacement: Vector3): void;
  112781. /** @hidden */
  112782. private _onCollisionPositionChange;
  112783. /** @hidden */
  112784. _checkInputs(): void;
  112785. /** @hidden */
  112786. _decideIfNeedsToMove(): boolean;
  112787. /** @hidden */
  112788. _updatePosition(): void;
  112789. /**
  112790. * Restore the Roll to its target value at the rate specified.
  112791. * @param rate - Higher means slower restoring.
  112792. * @hidden
  112793. */
  112794. restoreRoll(rate: number): void;
  112795. /**
  112796. * Destroy the camera and release the current resources held by it.
  112797. */
  112798. dispose(): void;
  112799. /**
  112800. * Get the current object class name.
  112801. * @returns the class name.
  112802. */
  112803. getClassName(): string;
  112804. }
  112805. }
  112806. declare module BABYLON {
  112807. /**
  112808. * Listen to keyboard events to control the camera.
  112809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112810. */
  112811. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  112812. /**
  112813. * Defines the camera the input is attached to.
  112814. */
  112815. camera: FlyCamera;
  112816. /**
  112817. * The list of keyboard keys used to control the forward move of the camera.
  112818. */
  112819. keysForward: number[];
  112820. /**
  112821. * The list of keyboard keys used to control the backward move of the camera.
  112822. */
  112823. keysBackward: number[];
  112824. /**
  112825. * The list of keyboard keys used to control the forward move of the camera.
  112826. */
  112827. keysUp: number[];
  112828. /**
  112829. * The list of keyboard keys used to control the backward move of the camera.
  112830. */
  112831. keysDown: number[];
  112832. /**
  112833. * The list of keyboard keys used to control the right strafe move of the camera.
  112834. */
  112835. keysRight: number[];
  112836. /**
  112837. * The list of keyboard keys used to control the left strafe move of the camera.
  112838. */
  112839. keysLeft: number[];
  112840. private _keys;
  112841. private _onCanvasBlurObserver;
  112842. private _onKeyboardObserver;
  112843. private _engine;
  112844. private _scene;
  112845. /**
  112846. * Attach the input controls to a specific dom element to get the input from.
  112847. * @param element Defines the element the controls should be listened from
  112848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112849. */
  112850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112851. /**
  112852. * Detach the current controls from the specified dom element.
  112853. * @param element Defines the element to stop listening the inputs from
  112854. */
  112855. detachControl(element: Nullable<HTMLElement>): void;
  112856. /**
  112857. * Gets the class name of the current intput.
  112858. * @returns the class name
  112859. */
  112860. getClassName(): string;
  112861. /** @hidden */
  112862. _onLostFocus(e: FocusEvent): void;
  112863. /**
  112864. * Get the friendly name associated with the input class.
  112865. * @returns the input friendly name
  112866. */
  112867. getSimpleName(): string;
  112868. /**
  112869. * Update the current camera state depending on the inputs that have been used this frame.
  112870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112871. */
  112872. checkInputs(): void;
  112873. }
  112874. }
  112875. declare module BABYLON {
  112876. /**
  112877. * Manage the mouse wheel inputs to control a follow camera.
  112878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112879. */
  112880. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  112881. /**
  112882. * Defines the camera the input is attached to.
  112883. */
  112884. camera: FollowCamera;
  112885. /**
  112886. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  112887. */
  112888. axisControlRadius: boolean;
  112889. /**
  112890. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  112891. */
  112892. axisControlHeight: boolean;
  112893. /**
  112894. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  112895. */
  112896. axisControlRotation: boolean;
  112897. /**
  112898. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  112899. * relation to mouseWheel events.
  112900. */
  112901. wheelPrecision: number;
  112902. /**
  112903. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112904. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112905. */
  112906. wheelDeltaPercentage: number;
  112907. private _wheel;
  112908. private _observer;
  112909. /**
  112910. * Attach the input controls to a specific dom element to get the input from.
  112911. * @param element Defines the element the controls should be listened from
  112912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112913. */
  112914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112915. /**
  112916. * Detach the current controls from the specified dom element.
  112917. * @param element Defines the element to stop listening the inputs from
  112918. */
  112919. detachControl(element: Nullable<HTMLElement>): void;
  112920. /**
  112921. * Gets the class name of the current intput.
  112922. * @returns the class name
  112923. */
  112924. getClassName(): string;
  112925. /**
  112926. * Get the friendly name associated with the input class.
  112927. * @returns the input friendly name
  112928. */
  112929. getSimpleName(): string;
  112930. }
  112931. }
  112932. declare module BABYLON {
  112933. /**
  112934. * Manage the pointers inputs to control an follow camera.
  112935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112936. */
  112937. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  112938. /**
  112939. * Defines the camera the input is attached to.
  112940. */
  112941. camera: FollowCamera;
  112942. /**
  112943. * Gets the class name of the current input.
  112944. * @returns the class name
  112945. */
  112946. getClassName(): string;
  112947. /**
  112948. * Defines the pointer angular sensibility along the X axis or how fast is
  112949. * the camera rotating.
  112950. * A negative number will reverse the axis direction.
  112951. */
  112952. angularSensibilityX: number;
  112953. /**
  112954. * Defines the pointer angular sensibility along the Y axis or how fast is
  112955. * the camera rotating.
  112956. * A negative number will reverse the axis direction.
  112957. */
  112958. angularSensibilityY: number;
  112959. /**
  112960. * Defines the pointer pinch precision or how fast is the camera zooming.
  112961. * A negative number will reverse the axis direction.
  112962. */
  112963. pinchPrecision: number;
  112964. /**
  112965. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112966. * from 0.
  112967. * It defines the percentage of current camera.radius to use as delta when
  112968. * pinch zoom is used.
  112969. */
  112970. pinchDeltaPercentage: number;
  112971. /**
  112972. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  112973. */
  112974. axisXControlRadius: boolean;
  112975. /**
  112976. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  112977. */
  112978. axisXControlHeight: boolean;
  112979. /**
  112980. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  112981. */
  112982. axisXControlRotation: boolean;
  112983. /**
  112984. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  112985. */
  112986. axisYControlRadius: boolean;
  112987. /**
  112988. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  112989. */
  112990. axisYControlHeight: boolean;
  112991. /**
  112992. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  112993. */
  112994. axisYControlRotation: boolean;
  112995. /**
  112996. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  112997. */
  112998. axisPinchControlRadius: boolean;
  112999. /**
  113000. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113001. */
  113002. axisPinchControlHeight: boolean;
  113003. /**
  113004. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113005. */
  113006. axisPinchControlRotation: boolean;
  113007. /**
  113008. * Log error messages if basic misconfiguration has occurred.
  113009. */
  113010. warningEnable: boolean;
  113011. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113012. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113013. private _warningCounter;
  113014. private _warning;
  113015. }
  113016. }
  113017. declare module BABYLON {
  113018. /**
  113019. * Default Inputs manager for the FollowCamera.
  113020. * It groups all the default supported inputs for ease of use.
  113021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113022. */
  113023. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113024. /**
  113025. * Instantiates a new FollowCameraInputsManager.
  113026. * @param camera Defines the camera the inputs belong to
  113027. */
  113028. constructor(camera: FollowCamera);
  113029. /**
  113030. * Add keyboard input support to the input manager.
  113031. * @returns the current input manager
  113032. */
  113033. addKeyboard(): FollowCameraInputsManager;
  113034. /**
  113035. * Add mouse wheel input support to the input manager.
  113036. * @returns the current input manager
  113037. */
  113038. addMouseWheel(): FollowCameraInputsManager;
  113039. /**
  113040. * Add pointers input support to the input manager.
  113041. * @returns the current input manager
  113042. */
  113043. addPointers(): FollowCameraInputsManager;
  113044. /**
  113045. * Add orientation input support to the input manager.
  113046. * @returns the current input manager
  113047. */
  113048. addVRDeviceOrientation(): FollowCameraInputsManager;
  113049. }
  113050. }
  113051. declare module BABYLON {
  113052. /**
  113053. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113054. * an arc rotate version arcFollowCamera are available.
  113055. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113056. */
  113057. export class FollowCamera extends TargetCamera {
  113058. /**
  113059. * Distance the follow camera should follow an object at
  113060. */
  113061. radius: number;
  113062. /**
  113063. * Minimum allowed distance of the camera to the axis of rotation
  113064. * (The camera can not get closer).
  113065. * This can help limiting how the Camera is able to move in the scene.
  113066. */
  113067. lowerRadiusLimit: Nullable<number>;
  113068. /**
  113069. * Maximum allowed distance of the camera to the axis of rotation
  113070. * (The camera can not get further).
  113071. * This can help limiting how the Camera is able to move in the scene.
  113072. */
  113073. upperRadiusLimit: Nullable<number>;
  113074. /**
  113075. * Define a rotation offset between the camera and the object it follows
  113076. */
  113077. rotationOffset: number;
  113078. /**
  113079. * Minimum allowed angle to camera position relative to target object.
  113080. * This can help limiting how the Camera is able to move in the scene.
  113081. */
  113082. lowerRotationOffsetLimit: Nullable<number>;
  113083. /**
  113084. * Maximum allowed angle to camera position relative to target object.
  113085. * This can help limiting how the Camera is able to move in the scene.
  113086. */
  113087. upperRotationOffsetLimit: Nullable<number>;
  113088. /**
  113089. * Define a height offset between the camera and the object it follows.
  113090. * It can help following an object from the top (like a car chaing a plane)
  113091. */
  113092. heightOffset: number;
  113093. /**
  113094. * Minimum allowed height of camera position relative to target object.
  113095. * This can help limiting how the Camera is able to move in the scene.
  113096. */
  113097. lowerHeightOffsetLimit: Nullable<number>;
  113098. /**
  113099. * Maximum allowed height of camera position relative to target object.
  113100. * This can help limiting how the Camera is able to move in the scene.
  113101. */
  113102. upperHeightOffsetLimit: Nullable<number>;
  113103. /**
  113104. * Define how fast the camera can accelerate to follow it s target.
  113105. */
  113106. cameraAcceleration: number;
  113107. /**
  113108. * Define the speed limit of the camera following an object.
  113109. */
  113110. maxCameraSpeed: number;
  113111. /**
  113112. * Define the target of the camera.
  113113. */
  113114. lockedTarget: Nullable<AbstractMesh>;
  113115. /**
  113116. * Defines the input associated with the camera.
  113117. */
  113118. inputs: FollowCameraInputsManager;
  113119. /**
  113120. * Instantiates the follow camera.
  113121. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113122. * @param name Define the name of the camera in the scene
  113123. * @param position Define the position of the camera
  113124. * @param scene Define the scene the camera belong to
  113125. * @param lockedTarget Define the target of the camera
  113126. */
  113127. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113128. private _follow;
  113129. /**
  113130. * Attached controls to the current camera.
  113131. * @param element Defines the element the controls should be listened from
  113132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113133. */
  113134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113135. /**
  113136. * Detach the current controls from the camera.
  113137. * The camera will stop reacting to inputs.
  113138. * @param element Defines the element to stop listening the inputs from
  113139. */
  113140. detachControl(element: HTMLElement): void;
  113141. /** @hidden */
  113142. _checkInputs(): void;
  113143. private _checkLimits;
  113144. /**
  113145. * Gets the camera class name.
  113146. * @returns the class name
  113147. */
  113148. getClassName(): string;
  113149. }
  113150. /**
  113151. * Arc Rotate version of the follow camera.
  113152. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113153. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113154. */
  113155. export class ArcFollowCamera extends TargetCamera {
  113156. /** The longitudinal angle of the camera */
  113157. alpha: number;
  113158. /** The latitudinal angle of the camera */
  113159. beta: number;
  113160. /** The radius of the camera from its target */
  113161. radius: number;
  113162. /** Define the camera target (the messh it should follow) */
  113163. target: Nullable<AbstractMesh>;
  113164. private _cartesianCoordinates;
  113165. /**
  113166. * Instantiates a new ArcFollowCamera
  113167. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113168. * @param name Define the name of the camera
  113169. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113170. * @param beta Define the rotation angle of the camera around the elevation axis
  113171. * @param radius Define the radius of the camera from its target point
  113172. * @param target Define the target of the camera
  113173. * @param scene Define the scene the camera belongs to
  113174. */
  113175. constructor(name: string,
  113176. /** The longitudinal angle of the camera */
  113177. alpha: number,
  113178. /** The latitudinal angle of the camera */
  113179. beta: number,
  113180. /** The radius of the camera from its target */
  113181. radius: number,
  113182. /** Define the camera target (the messh it should follow) */
  113183. target: Nullable<AbstractMesh>, scene: Scene);
  113184. private _follow;
  113185. /** @hidden */
  113186. _checkInputs(): void;
  113187. /**
  113188. * Returns the class name of the object.
  113189. * It is mostly used internally for serialization purposes.
  113190. */
  113191. getClassName(): string;
  113192. }
  113193. }
  113194. declare module BABYLON {
  113195. /**
  113196. * Manage the keyboard inputs to control the movement of a follow camera.
  113197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113198. */
  113199. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113200. /**
  113201. * Defines the camera the input is attached to.
  113202. */
  113203. camera: FollowCamera;
  113204. /**
  113205. * Defines the list of key codes associated with the up action (increase heightOffset)
  113206. */
  113207. keysHeightOffsetIncr: number[];
  113208. /**
  113209. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113210. */
  113211. keysHeightOffsetDecr: number[];
  113212. /**
  113213. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113214. */
  113215. keysHeightOffsetModifierAlt: boolean;
  113216. /**
  113217. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113218. */
  113219. keysHeightOffsetModifierCtrl: boolean;
  113220. /**
  113221. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113222. */
  113223. keysHeightOffsetModifierShift: boolean;
  113224. /**
  113225. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113226. */
  113227. keysRotationOffsetIncr: number[];
  113228. /**
  113229. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113230. */
  113231. keysRotationOffsetDecr: number[];
  113232. /**
  113233. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113234. */
  113235. keysRotationOffsetModifierAlt: boolean;
  113236. /**
  113237. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113238. */
  113239. keysRotationOffsetModifierCtrl: boolean;
  113240. /**
  113241. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113242. */
  113243. keysRotationOffsetModifierShift: boolean;
  113244. /**
  113245. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113246. */
  113247. keysRadiusIncr: number[];
  113248. /**
  113249. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113250. */
  113251. keysRadiusDecr: number[];
  113252. /**
  113253. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113254. */
  113255. keysRadiusModifierAlt: boolean;
  113256. /**
  113257. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113258. */
  113259. keysRadiusModifierCtrl: boolean;
  113260. /**
  113261. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113262. */
  113263. keysRadiusModifierShift: boolean;
  113264. /**
  113265. * Defines the rate of change of heightOffset.
  113266. */
  113267. heightSensibility: number;
  113268. /**
  113269. * Defines the rate of change of rotationOffset.
  113270. */
  113271. rotationSensibility: number;
  113272. /**
  113273. * Defines the rate of change of radius.
  113274. */
  113275. radiusSensibility: number;
  113276. private _keys;
  113277. private _ctrlPressed;
  113278. private _altPressed;
  113279. private _shiftPressed;
  113280. private _onCanvasBlurObserver;
  113281. private _onKeyboardObserver;
  113282. private _engine;
  113283. private _scene;
  113284. /**
  113285. * Attach the input controls to a specific dom element to get the input from.
  113286. * @param element Defines the element the controls should be listened from
  113287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113288. */
  113289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113290. /**
  113291. * Detach the current controls from the specified dom element.
  113292. * @param element Defines the element to stop listening the inputs from
  113293. */
  113294. detachControl(element: Nullable<HTMLElement>): void;
  113295. /**
  113296. * Update the current camera state depending on the inputs that have been used this frame.
  113297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113298. */
  113299. checkInputs(): void;
  113300. /**
  113301. * Gets the class name of the current input.
  113302. * @returns the class name
  113303. */
  113304. getClassName(): string;
  113305. /**
  113306. * Get the friendly name associated with the input class.
  113307. * @returns the input friendly name
  113308. */
  113309. getSimpleName(): string;
  113310. /**
  113311. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113312. * allow modification of the heightOffset value.
  113313. */
  113314. private _modifierHeightOffset;
  113315. /**
  113316. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113317. * allow modification of the rotationOffset value.
  113318. */
  113319. private _modifierRotationOffset;
  113320. /**
  113321. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113322. * allow modification of the radius value.
  113323. */
  113324. private _modifierRadius;
  113325. }
  113326. }
  113327. declare module BABYLON {
  113328. interface FreeCameraInputsManager {
  113329. /**
  113330. * @hidden
  113331. */
  113332. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113333. /**
  113334. * Add orientation input support to the input manager.
  113335. * @returns the current input manager
  113336. */
  113337. addDeviceOrientation(): FreeCameraInputsManager;
  113338. }
  113339. /**
  113340. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113341. * Screen rotation is taken into account.
  113342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113343. */
  113344. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113345. private _camera;
  113346. private _screenOrientationAngle;
  113347. private _constantTranform;
  113348. private _screenQuaternion;
  113349. private _alpha;
  113350. private _beta;
  113351. private _gamma;
  113352. /**
  113353. * Can be used to detect if a device orientation sensor is available on a device
  113354. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113355. * @returns a promise that will resolve on orientation change
  113356. */
  113357. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113358. /**
  113359. * @hidden
  113360. */
  113361. _onDeviceOrientationChangedObservable: Observable<void>;
  113362. /**
  113363. * Instantiates a new input
  113364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113365. */
  113366. constructor();
  113367. /**
  113368. * Define the camera controlled by the input.
  113369. */
  113370. get camera(): FreeCamera;
  113371. set camera(camera: FreeCamera);
  113372. /**
  113373. * Attach the input controls to a specific dom element to get the input from.
  113374. * @param element Defines the element the controls should be listened from
  113375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113376. */
  113377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113378. private _orientationChanged;
  113379. private _deviceOrientation;
  113380. /**
  113381. * Detach the current controls from the specified dom element.
  113382. * @param element Defines the element to stop listening the inputs from
  113383. */
  113384. detachControl(element: Nullable<HTMLElement>): void;
  113385. /**
  113386. * Update the current camera state depending on the inputs that have been used this frame.
  113387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113388. */
  113389. checkInputs(): void;
  113390. /**
  113391. * Gets the class name of the current intput.
  113392. * @returns the class name
  113393. */
  113394. getClassName(): string;
  113395. /**
  113396. * Get the friendly name associated with the input class.
  113397. * @returns the input friendly name
  113398. */
  113399. getSimpleName(): string;
  113400. }
  113401. }
  113402. declare module BABYLON {
  113403. /**
  113404. * Manage the gamepad inputs to control a free camera.
  113405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113406. */
  113407. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113408. /**
  113409. * Define the camera the input is attached to.
  113410. */
  113411. camera: FreeCamera;
  113412. /**
  113413. * Define the Gamepad controlling the input
  113414. */
  113415. gamepad: Nullable<Gamepad>;
  113416. /**
  113417. * Defines the gamepad rotation sensiblity.
  113418. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113419. */
  113420. gamepadAngularSensibility: number;
  113421. /**
  113422. * Defines the gamepad move sensiblity.
  113423. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113424. */
  113425. gamepadMoveSensibility: number;
  113426. private _yAxisScale;
  113427. /**
  113428. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113429. */
  113430. get invertYAxis(): boolean;
  113431. set invertYAxis(value: boolean);
  113432. private _onGamepadConnectedObserver;
  113433. private _onGamepadDisconnectedObserver;
  113434. private _cameraTransform;
  113435. private _deltaTransform;
  113436. private _vector3;
  113437. private _vector2;
  113438. /**
  113439. * Attach the input controls to a specific dom element to get the input from.
  113440. * @param element Defines the element the controls should be listened from
  113441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113442. */
  113443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113444. /**
  113445. * Detach the current controls from the specified dom element.
  113446. * @param element Defines the element to stop listening the inputs from
  113447. */
  113448. detachControl(element: Nullable<HTMLElement>): void;
  113449. /**
  113450. * Update the current camera state depending on the inputs that have been used this frame.
  113451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113452. */
  113453. checkInputs(): void;
  113454. /**
  113455. * Gets the class name of the current intput.
  113456. * @returns the class name
  113457. */
  113458. getClassName(): string;
  113459. /**
  113460. * Get the friendly name associated with the input class.
  113461. * @returns the input friendly name
  113462. */
  113463. getSimpleName(): string;
  113464. }
  113465. }
  113466. declare module BABYLON {
  113467. /**
  113468. * Defines the potential axis of a Joystick
  113469. */
  113470. export enum JoystickAxis {
  113471. /** X axis */
  113472. X = 0,
  113473. /** Y axis */
  113474. Y = 1,
  113475. /** Z axis */
  113476. Z = 2
  113477. }
  113478. /**
  113479. * Class used to define virtual joystick (used in touch mode)
  113480. */
  113481. export class VirtualJoystick {
  113482. /**
  113483. * Gets or sets a boolean indicating that left and right values must be inverted
  113484. */
  113485. reverseLeftRight: boolean;
  113486. /**
  113487. * Gets or sets a boolean indicating that up and down values must be inverted
  113488. */
  113489. reverseUpDown: boolean;
  113490. /**
  113491. * Gets the offset value for the position (ie. the change of the position value)
  113492. */
  113493. deltaPosition: Vector3;
  113494. /**
  113495. * Gets a boolean indicating if the virtual joystick was pressed
  113496. */
  113497. pressed: boolean;
  113498. /**
  113499. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113500. */
  113501. static Canvas: Nullable<HTMLCanvasElement>;
  113502. private static _globalJoystickIndex;
  113503. private static vjCanvasContext;
  113504. private static vjCanvasWidth;
  113505. private static vjCanvasHeight;
  113506. private static halfWidth;
  113507. private _action;
  113508. private _axisTargetedByLeftAndRight;
  113509. private _axisTargetedByUpAndDown;
  113510. private _joystickSensibility;
  113511. private _inversedSensibility;
  113512. private _joystickPointerID;
  113513. private _joystickColor;
  113514. private _joystickPointerPos;
  113515. private _joystickPreviousPointerPos;
  113516. private _joystickPointerStartPos;
  113517. private _deltaJoystickVector;
  113518. private _leftJoystick;
  113519. private _touches;
  113520. private _onPointerDownHandlerRef;
  113521. private _onPointerMoveHandlerRef;
  113522. private _onPointerUpHandlerRef;
  113523. private _onResize;
  113524. /**
  113525. * Creates a new virtual joystick
  113526. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113527. */
  113528. constructor(leftJoystick?: boolean);
  113529. /**
  113530. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113531. * @param newJoystickSensibility defines the new sensibility
  113532. */
  113533. setJoystickSensibility(newJoystickSensibility: number): void;
  113534. private _onPointerDown;
  113535. private _onPointerMove;
  113536. private _onPointerUp;
  113537. /**
  113538. * Change the color of the virtual joystick
  113539. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113540. */
  113541. setJoystickColor(newColor: string): void;
  113542. /**
  113543. * Defines a callback to call when the joystick is touched
  113544. * @param action defines the callback
  113545. */
  113546. setActionOnTouch(action: () => any): void;
  113547. /**
  113548. * Defines which axis you'd like to control for left & right
  113549. * @param axis defines the axis to use
  113550. */
  113551. setAxisForLeftRight(axis: JoystickAxis): void;
  113552. /**
  113553. * Defines which axis you'd like to control for up & down
  113554. * @param axis defines the axis to use
  113555. */
  113556. setAxisForUpDown(axis: JoystickAxis): void;
  113557. private _drawVirtualJoystick;
  113558. /**
  113559. * Release internal HTML canvas
  113560. */
  113561. releaseCanvas(): void;
  113562. }
  113563. }
  113564. declare module BABYLON {
  113565. interface FreeCameraInputsManager {
  113566. /**
  113567. * Add virtual joystick input support to the input manager.
  113568. * @returns the current input manager
  113569. */
  113570. addVirtualJoystick(): FreeCameraInputsManager;
  113571. }
  113572. /**
  113573. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113575. */
  113576. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113577. /**
  113578. * Defines the camera the input is attached to.
  113579. */
  113580. camera: FreeCamera;
  113581. private _leftjoystick;
  113582. private _rightjoystick;
  113583. /**
  113584. * Gets the left stick of the virtual joystick.
  113585. * @returns The virtual Joystick
  113586. */
  113587. getLeftJoystick(): VirtualJoystick;
  113588. /**
  113589. * Gets the right stick of the virtual joystick.
  113590. * @returns The virtual Joystick
  113591. */
  113592. getRightJoystick(): VirtualJoystick;
  113593. /**
  113594. * Update the current camera state depending on the inputs that have been used this frame.
  113595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113596. */
  113597. checkInputs(): void;
  113598. /**
  113599. * Attach the input controls to a specific dom element to get the input from.
  113600. * @param element Defines the element the controls should be listened from
  113601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113602. */
  113603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113604. /**
  113605. * Detach the current controls from the specified dom element.
  113606. * @param element Defines the element to stop listening the inputs from
  113607. */
  113608. detachControl(element: Nullable<HTMLElement>): void;
  113609. /**
  113610. * Gets the class name of the current intput.
  113611. * @returns the class name
  113612. */
  113613. getClassName(): string;
  113614. /**
  113615. * Get the friendly name associated with the input class.
  113616. * @returns the input friendly name
  113617. */
  113618. getSimpleName(): string;
  113619. }
  113620. }
  113621. declare module BABYLON {
  113622. /**
  113623. * This represents a FPS type of camera controlled by touch.
  113624. * This is like a universal camera minus the Gamepad controls.
  113625. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113626. */
  113627. export class TouchCamera extends FreeCamera {
  113628. /**
  113629. * Defines the touch sensibility for rotation.
  113630. * The higher the faster.
  113631. */
  113632. get touchAngularSensibility(): number;
  113633. set touchAngularSensibility(value: number);
  113634. /**
  113635. * Defines the touch sensibility for move.
  113636. * The higher the faster.
  113637. */
  113638. get touchMoveSensibility(): number;
  113639. set touchMoveSensibility(value: number);
  113640. /**
  113641. * Instantiates a new touch camera.
  113642. * This represents a FPS type of camera controlled by touch.
  113643. * This is like a universal camera minus the Gamepad controls.
  113644. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113645. * @param name Define the name of the camera in the scene
  113646. * @param position Define the start position of the camera in the scene
  113647. * @param scene Define the scene the camera belongs to
  113648. */
  113649. constructor(name: string, position: Vector3, scene: Scene);
  113650. /**
  113651. * Gets the current object class name.
  113652. * @return the class name
  113653. */
  113654. getClassName(): string;
  113655. /** @hidden */
  113656. _setupInputs(): void;
  113657. }
  113658. }
  113659. declare module BABYLON {
  113660. /**
  113661. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  113662. * being tilted forward or back and left or right.
  113663. */
  113664. export class DeviceOrientationCamera extends FreeCamera {
  113665. private _initialQuaternion;
  113666. private _quaternionCache;
  113667. private _tmpDragQuaternion;
  113668. private _disablePointerInputWhenUsingDeviceOrientation;
  113669. /**
  113670. * Creates a new device orientation camera
  113671. * @param name The name of the camera
  113672. * @param position The start position camera
  113673. * @param scene The scene the camera belongs to
  113674. */
  113675. constructor(name: string, position: Vector3, scene: Scene);
  113676. /**
  113677. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  113678. */
  113679. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  113680. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  113681. private _dragFactor;
  113682. /**
  113683. * Enabled turning on the y axis when the orientation sensor is active
  113684. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  113685. */
  113686. enableHorizontalDragging(dragFactor?: number): void;
  113687. /**
  113688. * Gets the current instance class name ("DeviceOrientationCamera").
  113689. * This helps avoiding instanceof at run time.
  113690. * @returns the class name
  113691. */
  113692. getClassName(): string;
  113693. /**
  113694. * @hidden
  113695. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  113696. */
  113697. _checkInputs(): void;
  113698. /**
  113699. * Reset the camera to its default orientation on the specified axis only.
  113700. * @param axis The axis to reset
  113701. */
  113702. resetToCurrentRotation(axis?: Axis): void;
  113703. }
  113704. }
  113705. declare module BABYLON {
  113706. /**
  113707. * Defines supported buttons for XBox360 compatible gamepads
  113708. */
  113709. export enum Xbox360Button {
  113710. /** A */
  113711. A = 0,
  113712. /** B */
  113713. B = 1,
  113714. /** X */
  113715. X = 2,
  113716. /** Y */
  113717. Y = 3,
  113718. /** Start */
  113719. Start = 4,
  113720. /** Back */
  113721. Back = 5,
  113722. /** Left button */
  113723. LB = 6,
  113724. /** Right button */
  113725. RB = 7,
  113726. /** Left stick */
  113727. LeftStick = 8,
  113728. /** Right stick */
  113729. RightStick = 9
  113730. }
  113731. /** Defines values for XBox360 DPad */
  113732. export enum Xbox360Dpad {
  113733. /** Up */
  113734. Up = 0,
  113735. /** Down */
  113736. Down = 1,
  113737. /** Left */
  113738. Left = 2,
  113739. /** Right */
  113740. Right = 3
  113741. }
  113742. /**
  113743. * Defines a XBox360 gamepad
  113744. */
  113745. export class Xbox360Pad extends Gamepad {
  113746. private _leftTrigger;
  113747. private _rightTrigger;
  113748. private _onlefttriggerchanged;
  113749. private _onrighttriggerchanged;
  113750. private _onbuttondown;
  113751. private _onbuttonup;
  113752. private _ondpaddown;
  113753. private _ondpadup;
  113754. /** Observable raised when a button is pressed */
  113755. onButtonDownObservable: Observable<Xbox360Button>;
  113756. /** Observable raised when a button is released */
  113757. onButtonUpObservable: Observable<Xbox360Button>;
  113758. /** Observable raised when a pad is pressed */
  113759. onPadDownObservable: Observable<Xbox360Dpad>;
  113760. /** Observable raised when a pad is released */
  113761. onPadUpObservable: Observable<Xbox360Dpad>;
  113762. private _buttonA;
  113763. private _buttonB;
  113764. private _buttonX;
  113765. private _buttonY;
  113766. private _buttonBack;
  113767. private _buttonStart;
  113768. private _buttonLB;
  113769. private _buttonRB;
  113770. private _buttonLeftStick;
  113771. private _buttonRightStick;
  113772. private _dPadUp;
  113773. private _dPadDown;
  113774. private _dPadLeft;
  113775. private _dPadRight;
  113776. private _isXboxOnePad;
  113777. /**
  113778. * Creates a new XBox360 gamepad object
  113779. * @param id defines the id of this gamepad
  113780. * @param index defines its index
  113781. * @param gamepad defines the internal HTML gamepad object
  113782. * @param xboxOne defines if it is a XBox One gamepad
  113783. */
  113784. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  113785. /**
  113786. * Defines the callback to call when left trigger is pressed
  113787. * @param callback defines the callback to use
  113788. */
  113789. onlefttriggerchanged(callback: (value: number) => void): void;
  113790. /**
  113791. * Defines the callback to call when right trigger is pressed
  113792. * @param callback defines the callback to use
  113793. */
  113794. onrighttriggerchanged(callback: (value: number) => void): void;
  113795. /**
  113796. * Gets the left trigger value
  113797. */
  113798. get leftTrigger(): number;
  113799. /**
  113800. * Sets the left trigger value
  113801. */
  113802. set leftTrigger(newValue: number);
  113803. /**
  113804. * Gets the right trigger value
  113805. */
  113806. get rightTrigger(): number;
  113807. /**
  113808. * Sets the right trigger value
  113809. */
  113810. set rightTrigger(newValue: number);
  113811. /**
  113812. * Defines the callback to call when a button is pressed
  113813. * @param callback defines the callback to use
  113814. */
  113815. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  113816. /**
  113817. * Defines the callback to call when a button is released
  113818. * @param callback defines the callback to use
  113819. */
  113820. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  113821. /**
  113822. * Defines the callback to call when a pad is pressed
  113823. * @param callback defines the callback to use
  113824. */
  113825. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  113826. /**
  113827. * Defines the callback to call when a pad is released
  113828. * @param callback defines the callback to use
  113829. */
  113830. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  113831. private _setButtonValue;
  113832. private _setDPadValue;
  113833. /**
  113834. * Gets the value of the `A` button
  113835. */
  113836. get buttonA(): number;
  113837. /**
  113838. * Sets the value of the `A` button
  113839. */
  113840. set buttonA(value: number);
  113841. /**
  113842. * Gets the value of the `B` button
  113843. */
  113844. get buttonB(): number;
  113845. /**
  113846. * Sets the value of the `B` button
  113847. */
  113848. set buttonB(value: number);
  113849. /**
  113850. * Gets the value of the `X` button
  113851. */
  113852. get buttonX(): number;
  113853. /**
  113854. * Sets the value of the `X` button
  113855. */
  113856. set buttonX(value: number);
  113857. /**
  113858. * Gets the value of the `Y` button
  113859. */
  113860. get buttonY(): number;
  113861. /**
  113862. * Sets the value of the `Y` button
  113863. */
  113864. set buttonY(value: number);
  113865. /**
  113866. * Gets the value of the `Start` button
  113867. */
  113868. get buttonStart(): number;
  113869. /**
  113870. * Sets the value of the `Start` button
  113871. */
  113872. set buttonStart(value: number);
  113873. /**
  113874. * Gets the value of the `Back` button
  113875. */
  113876. get buttonBack(): number;
  113877. /**
  113878. * Sets the value of the `Back` button
  113879. */
  113880. set buttonBack(value: number);
  113881. /**
  113882. * Gets the value of the `Left` button
  113883. */
  113884. get buttonLB(): number;
  113885. /**
  113886. * Sets the value of the `Left` button
  113887. */
  113888. set buttonLB(value: number);
  113889. /**
  113890. * Gets the value of the `Right` button
  113891. */
  113892. get buttonRB(): number;
  113893. /**
  113894. * Sets the value of the `Right` button
  113895. */
  113896. set buttonRB(value: number);
  113897. /**
  113898. * Gets the value of the Left joystick
  113899. */
  113900. get buttonLeftStick(): number;
  113901. /**
  113902. * Sets the value of the Left joystick
  113903. */
  113904. set buttonLeftStick(value: number);
  113905. /**
  113906. * Gets the value of the Right joystick
  113907. */
  113908. get buttonRightStick(): number;
  113909. /**
  113910. * Sets the value of the Right joystick
  113911. */
  113912. set buttonRightStick(value: number);
  113913. /**
  113914. * Gets the value of D-pad up
  113915. */
  113916. get dPadUp(): number;
  113917. /**
  113918. * Sets the value of D-pad up
  113919. */
  113920. set dPadUp(value: number);
  113921. /**
  113922. * Gets the value of D-pad down
  113923. */
  113924. get dPadDown(): number;
  113925. /**
  113926. * Sets the value of D-pad down
  113927. */
  113928. set dPadDown(value: number);
  113929. /**
  113930. * Gets the value of D-pad left
  113931. */
  113932. get dPadLeft(): number;
  113933. /**
  113934. * Sets the value of D-pad left
  113935. */
  113936. set dPadLeft(value: number);
  113937. /**
  113938. * Gets the value of D-pad right
  113939. */
  113940. get dPadRight(): number;
  113941. /**
  113942. * Sets the value of D-pad right
  113943. */
  113944. set dPadRight(value: number);
  113945. /**
  113946. * Force the gamepad to synchronize with device values
  113947. */
  113948. update(): void;
  113949. /**
  113950. * Disposes the gamepad
  113951. */
  113952. dispose(): void;
  113953. }
  113954. }
  113955. declare module BABYLON {
  113956. /**
  113957. * Defines supported buttons for DualShock compatible gamepads
  113958. */
  113959. export enum DualShockButton {
  113960. /** Cross */
  113961. Cross = 0,
  113962. /** Circle */
  113963. Circle = 1,
  113964. /** Square */
  113965. Square = 2,
  113966. /** Triangle */
  113967. Triangle = 3,
  113968. /** Options */
  113969. Options = 4,
  113970. /** Share */
  113971. Share = 5,
  113972. /** L1 */
  113973. L1 = 6,
  113974. /** R1 */
  113975. R1 = 7,
  113976. /** Left stick */
  113977. LeftStick = 8,
  113978. /** Right stick */
  113979. RightStick = 9
  113980. }
  113981. /** Defines values for DualShock DPad */
  113982. export enum DualShockDpad {
  113983. /** Up */
  113984. Up = 0,
  113985. /** Down */
  113986. Down = 1,
  113987. /** Left */
  113988. Left = 2,
  113989. /** Right */
  113990. Right = 3
  113991. }
  113992. /**
  113993. * Defines a DualShock gamepad
  113994. */
  113995. export class DualShockPad extends Gamepad {
  113996. private _leftTrigger;
  113997. private _rightTrigger;
  113998. private _onlefttriggerchanged;
  113999. private _onrighttriggerchanged;
  114000. private _onbuttondown;
  114001. private _onbuttonup;
  114002. private _ondpaddown;
  114003. private _ondpadup;
  114004. /** Observable raised when a button is pressed */
  114005. onButtonDownObservable: Observable<DualShockButton>;
  114006. /** Observable raised when a button is released */
  114007. onButtonUpObservable: Observable<DualShockButton>;
  114008. /** Observable raised when a pad is pressed */
  114009. onPadDownObservable: Observable<DualShockDpad>;
  114010. /** Observable raised when a pad is released */
  114011. onPadUpObservable: Observable<DualShockDpad>;
  114012. private _buttonCross;
  114013. private _buttonCircle;
  114014. private _buttonSquare;
  114015. private _buttonTriangle;
  114016. private _buttonShare;
  114017. private _buttonOptions;
  114018. private _buttonL1;
  114019. private _buttonR1;
  114020. private _buttonLeftStick;
  114021. private _buttonRightStick;
  114022. private _dPadUp;
  114023. private _dPadDown;
  114024. private _dPadLeft;
  114025. private _dPadRight;
  114026. /**
  114027. * Creates a new DualShock gamepad object
  114028. * @param id defines the id of this gamepad
  114029. * @param index defines its index
  114030. * @param gamepad defines the internal HTML gamepad object
  114031. */
  114032. constructor(id: string, index: number, gamepad: any);
  114033. /**
  114034. * Defines the callback to call when left trigger is pressed
  114035. * @param callback defines the callback to use
  114036. */
  114037. onlefttriggerchanged(callback: (value: number) => void): void;
  114038. /**
  114039. * Defines the callback to call when right trigger is pressed
  114040. * @param callback defines the callback to use
  114041. */
  114042. onrighttriggerchanged(callback: (value: number) => void): void;
  114043. /**
  114044. * Gets the left trigger value
  114045. */
  114046. get leftTrigger(): number;
  114047. /**
  114048. * Sets the left trigger value
  114049. */
  114050. set leftTrigger(newValue: number);
  114051. /**
  114052. * Gets the right trigger value
  114053. */
  114054. get rightTrigger(): number;
  114055. /**
  114056. * Sets the right trigger value
  114057. */
  114058. set rightTrigger(newValue: number);
  114059. /**
  114060. * Defines the callback to call when a button is pressed
  114061. * @param callback defines the callback to use
  114062. */
  114063. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114064. /**
  114065. * Defines the callback to call when a button is released
  114066. * @param callback defines the callback to use
  114067. */
  114068. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114069. /**
  114070. * Defines the callback to call when a pad is pressed
  114071. * @param callback defines the callback to use
  114072. */
  114073. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114074. /**
  114075. * Defines the callback to call when a pad is released
  114076. * @param callback defines the callback to use
  114077. */
  114078. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114079. private _setButtonValue;
  114080. private _setDPadValue;
  114081. /**
  114082. * Gets the value of the `Cross` button
  114083. */
  114084. get buttonCross(): number;
  114085. /**
  114086. * Sets the value of the `Cross` button
  114087. */
  114088. set buttonCross(value: number);
  114089. /**
  114090. * Gets the value of the `Circle` button
  114091. */
  114092. get buttonCircle(): number;
  114093. /**
  114094. * Sets the value of the `Circle` button
  114095. */
  114096. set buttonCircle(value: number);
  114097. /**
  114098. * Gets the value of the `Square` button
  114099. */
  114100. get buttonSquare(): number;
  114101. /**
  114102. * Sets the value of the `Square` button
  114103. */
  114104. set buttonSquare(value: number);
  114105. /**
  114106. * Gets the value of the `Triangle` button
  114107. */
  114108. get buttonTriangle(): number;
  114109. /**
  114110. * Sets the value of the `Triangle` button
  114111. */
  114112. set buttonTriangle(value: number);
  114113. /**
  114114. * Gets the value of the `Options` button
  114115. */
  114116. get buttonOptions(): number;
  114117. /**
  114118. * Sets the value of the `Options` button
  114119. */
  114120. set buttonOptions(value: number);
  114121. /**
  114122. * Gets the value of the `Share` button
  114123. */
  114124. get buttonShare(): number;
  114125. /**
  114126. * Sets the value of the `Share` button
  114127. */
  114128. set buttonShare(value: number);
  114129. /**
  114130. * Gets the value of the `L1` button
  114131. */
  114132. get buttonL1(): number;
  114133. /**
  114134. * Sets the value of the `L1` button
  114135. */
  114136. set buttonL1(value: number);
  114137. /**
  114138. * Gets the value of the `R1` button
  114139. */
  114140. get buttonR1(): number;
  114141. /**
  114142. * Sets the value of the `R1` button
  114143. */
  114144. set buttonR1(value: number);
  114145. /**
  114146. * Gets the value of the Left joystick
  114147. */
  114148. get buttonLeftStick(): number;
  114149. /**
  114150. * Sets the value of the Left joystick
  114151. */
  114152. set buttonLeftStick(value: number);
  114153. /**
  114154. * Gets the value of the Right joystick
  114155. */
  114156. get buttonRightStick(): number;
  114157. /**
  114158. * Sets the value of the Right joystick
  114159. */
  114160. set buttonRightStick(value: number);
  114161. /**
  114162. * Gets the value of D-pad up
  114163. */
  114164. get dPadUp(): number;
  114165. /**
  114166. * Sets the value of D-pad up
  114167. */
  114168. set dPadUp(value: number);
  114169. /**
  114170. * Gets the value of D-pad down
  114171. */
  114172. get dPadDown(): number;
  114173. /**
  114174. * Sets the value of D-pad down
  114175. */
  114176. set dPadDown(value: number);
  114177. /**
  114178. * Gets the value of D-pad left
  114179. */
  114180. get dPadLeft(): number;
  114181. /**
  114182. * Sets the value of D-pad left
  114183. */
  114184. set dPadLeft(value: number);
  114185. /**
  114186. * Gets the value of D-pad right
  114187. */
  114188. get dPadRight(): number;
  114189. /**
  114190. * Sets the value of D-pad right
  114191. */
  114192. set dPadRight(value: number);
  114193. /**
  114194. * Force the gamepad to synchronize with device values
  114195. */
  114196. update(): void;
  114197. /**
  114198. * Disposes the gamepad
  114199. */
  114200. dispose(): void;
  114201. }
  114202. }
  114203. declare module BABYLON {
  114204. /**
  114205. * Manager for handling gamepads
  114206. */
  114207. export class GamepadManager {
  114208. private _scene?;
  114209. private _babylonGamepads;
  114210. private _oneGamepadConnected;
  114211. /** @hidden */
  114212. _isMonitoring: boolean;
  114213. private _gamepadEventSupported;
  114214. private _gamepadSupport?;
  114215. /**
  114216. * observable to be triggered when the gamepad controller has been connected
  114217. */
  114218. onGamepadConnectedObservable: Observable<Gamepad>;
  114219. /**
  114220. * observable to be triggered when the gamepad controller has been disconnected
  114221. */
  114222. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114223. private _onGamepadConnectedEvent;
  114224. private _onGamepadDisconnectedEvent;
  114225. /**
  114226. * Initializes the gamepad manager
  114227. * @param _scene BabylonJS scene
  114228. */
  114229. constructor(_scene?: Scene | undefined);
  114230. /**
  114231. * The gamepads in the game pad manager
  114232. */
  114233. get gamepads(): Gamepad[];
  114234. /**
  114235. * Get the gamepad controllers based on type
  114236. * @param type The type of gamepad controller
  114237. * @returns Nullable gamepad
  114238. */
  114239. getGamepadByType(type?: number): Nullable<Gamepad>;
  114240. /**
  114241. * Disposes the gamepad manager
  114242. */
  114243. dispose(): void;
  114244. private _addNewGamepad;
  114245. private _startMonitoringGamepads;
  114246. private _stopMonitoringGamepads;
  114247. /** @hidden */
  114248. _checkGamepadsStatus(): void;
  114249. private _updateGamepadObjects;
  114250. }
  114251. }
  114252. declare module BABYLON {
  114253. interface Scene {
  114254. /** @hidden */
  114255. _gamepadManager: Nullable<GamepadManager>;
  114256. /**
  114257. * Gets the gamepad manager associated with the scene
  114258. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114259. */
  114260. gamepadManager: GamepadManager;
  114261. }
  114262. /**
  114263. * Interface representing a free camera inputs manager
  114264. */
  114265. interface FreeCameraInputsManager {
  114266. /**
  114267. * Adds gamepad input support to the FreeCameraInputsManager.
  114268. * @returns the FreeCameraInputsManager
  114269. */
  114270. addGamepad(): FreeCameraInputsManager;
  114271. }
  114272. /**
  114273. * Interface representing an arc rotate camera inputs manager
  114274. */
  114275. interface ArcRotateCameraInputsManager {
  114276. /**
  114277. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114278. * @returns the camera inputs manager
  114279. */
  114280. addGamepad(): ArcRotateCameraInputsManager;
  114281. }
  114282. /**
  114283. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114284. */
  114285. export class GamepadSystemSceneComponent implements ISceneComponent {
  114286. /**
  114287. * The component name helpfull to identify the component in the list of scene components.
  114288. */
  114289. readonly name: string;
  114290. /**
  114291. * The scene the component belongs to.
  114292. */
  114293. scene: Scene;
  114294. /**
  114295. * Creates a new instance of the component for the given scene
  114296. * @param scene Defines the scene to register the component in
  114297. */
  114298. constructor(scene: Scene);
  114299. /**
  114300. * Registers the component in a given scene
  114301. */
  114302. register(): void;
  114303. /**
  114304. * Rebuilds the elements related to this component in case of
  114305. * context lost for instance.
  114306. */
  114307. rebuild(): void;
  114308. /**
  114309. * Disposes the component and the associated ressources
  114310. */
  114311. dispose(): void;
  114312. private _beforeCameraUpdate;
  114313. }
  114314. }
  114315. declare module BABYLON {
  114316. /**
  114317. * 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,
  114318. * which still works and will still be found in many Playgrounds.
  114319. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114320. */
  114321. export class UniversalCamera extends TouchCamera {
  114322. /**
  114323. * Defines the gamepad rotation sensiblity.
  114324. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114325. */
  114326. get gamepadAngularSensibility(): number;
  114327. set gamepadAngularSensibility(value: number);
  114328. /**
  114329. * Defines the gamepad move sensiblity.
  114330. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114331. */
  114332. get gamepadMoveSensibility(): number;
  114333. set gamepadMoveSensibility(value: number);
  114334. /**
  114335. * 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,
  114336. * which still works and will still be found in many Playgrounds.
  114337. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114338. * @param name Define the name of the camera in the scene
  114339. * @param position Define the start position of the camera in the scene
  114340. * @param scene Define the scene the camera belongs to
  114341. */
  114342. constructor(name: string, position: Vector3, scene: Scene);
  114343. /**
  114344. * Gets the current object class name.
  114345. * @return the class name
  114346. */
  114347. getClassName(): string;
  114348. }
  114349. }
  114350. declare module BABYLON {
  114351. /**
  114352. * This represents a FPS type of camera. This is only here for back compat purpose.
  114353. * Please use the UniversalCamera instead as both are identical.
  114354. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114355. */
  114356. export class GamepadCamera extends UniversalCamera {
  114357. /**
  114358. * Instantiates a new Gamepad Camera
  114359. * This represents a FPS type of camera. This is only here for back compat purpose.
  114360. * Please use the UniversalCamera instead as both are identical.
  114361. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114362. * @param name Define the name of the camera in the scene
  114363. * @param position Define the start position of the camera in the scene
  114364. * @param scene Define the scene the camera belongs to
  114365. */
  114366. constructor(name: string, position: Vector3, scene: Scene);
  114367. /**
  114368. * Gets the current object class name.
  114369. * @return the class name
  114370. */
  114371. getClassName(): string;
  114372. }
  114373. }
  114374. declare module BABYLON {
  114375. /** @hidden */
  114376. export var passPixelShader: {
  114377. name: string;
  114378. shader: string;
  114379. };
  114380. }
  114381. declare module BABYLON {
  114382. /** @hidden */
  114383. export var passCubePixelShader: {
  114384. name: string;
  114385. shader: string;
  114386. };
  114387. }
  114388. declare module BABYLON {
  114389. /**
  114390. * PassPostProcess which produces an output the same as it's input
  114391. */
  114392. export class PassPostProcess extends PostProcess {
  114393. /**
  114394. * Creates the PassPostProcess
  114395. * @param name The name of the effect.
  114396. * @param options The required width/height ratio to downsize to before computing the render pass.
  114397. * @param camera The camera to apply the render pass to.
  114398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114399. * @param engine The engine which the post process will be applied. (default: current engine)
  114400. * @param reusable If the post process can be reused on the same frame. (default: false)
  114401. * @param textureType The type of texture to be used when performing the post processing.
  114402. * @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)
  114403. */
  114404. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114405. }
  114406. /**
  114407. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114408. */
  114409. export class PassCubePostProcess extends PostProcess {
  114410. private _face;
  114411. /**
  114412. * Gets or sets the cube face to display.
  114413. * * 0 is +X
  114414. * * 1 is -X
  114415. * * 2 is +Y
  114416. * * 3 is -Y
  114417. * * 4 is +Z
  114418. * * 5 is -Z
  114419. */
  114420. get face(): number;
  114421. set face(value: number);
  114422. /**
  114423. * Creates the PassCubePostProcess
  114424. * @param name The name of the effect.
  114425. * @param options The required width/height ratio to downsize to before computing the render pass.
  114426. * @param camera The camera to apply the render pass to.
  114427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114428. * @param engine The engine which the post process will be applied. (default: current engine)
  114429. * @param reusable If the post process can be reused on the same frame. (default: false)
  114430. * @param textureType The type of texture to be used when performing the post processing.
  114431. * @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)
  114432. */
  114433. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114434. }
  114435. }
  114436. declare module BABYLON {
  114437. /** @hidden */
  114438. export var anaglyphPixelShader: {
  114439. name: string;
  114440. shader: string;
  114441. };
  114442. }
  114443. declare module BABYLON {
  114444. /**
  114445. * Postprocess used to generate anaglyphic rendering
  114446. */
  114447. export class AnaglyphPostProcess extends PostProcess {
  114448. private _passedProcess;
  114449. /**
  114450. * Creates a new AnaglyphPostProcess
  114451. * @param name defines postprocess name
  114452. * @param options defines creation options or target ratio scale
  114453. * @param rigCameras defines cameras using this postprocess
  114454. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114455. * @param engine defines hosting engine
  114456. * @param reusable defines if the postprocess will be reused multiple times per frame
  114457. */
  114458. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114459. }
  114460. }
  114461. declare module BABYLON {
  114462. /**
  114463. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114464. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114465. */
  114466. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114467. /**
  114468. * Creates a new AnaglyphArcRotateCamera
  114469. * @param name defines camera name
  114470. * @param alpha defines alpha angle (in radians)
  114471. * @param beta defines beta angle (in radians)
  114472. * @param radius defines radius
  114473. * @param target defines camera target
  114474. * @param interaxialDistance defines distance between each color axis
  114475. * @param scene defines the hosting scene
  114476. */
  114477. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114478. /**
  114479. * Gets camera class name
  114480. * @returns AnaglyphArcRotateCamera
  114481. */
  114482. getClassName(): string;
  114483. }
  114484. }
  114485. declare module BABYLON {
  114486. /**
  114487. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114488. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114489. */
  114490. export class AnaglyphFreeCamera extends FreeCamera {
  114491. /**
  114492. * Creates a new AnaglyphFreeCamera
  114493. * @param name defines camera name
  114494. * @param position defines initial position
  114495. * @param interaxialDistance defines distance between each color axis
  114496. * @param scene defines the hosting scene
  114497. */
  114498. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114499. /**
  114500. * Gets camera class name
  114501. * @returns AnaglyphFreeCamera
  114502. */
  114503. getClassName(): string;
  114504. }
  114505. }
  114506. declare module BABYLON {
  114507. /**
  114508. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114509. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114510. */
  114511. export class AnaglyphGamepadCamera extends GamepadCamera {
  114512. /**
  114513. * Creates a new AnaglyphGamepadCamera
  114514. * @param name defines camera name
  114515. * @param position defines initial position
  114516. * @param interaxialDistance defines distance between each color axis
  114517. * @param scene defines the hosting scene
  114518. */
  114519. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114520. /**
  114521. * Gets camera class name
  114522. * @returns AnaglyphGamepadCamera
  114523. */
  114524. getClassName(): string;
  114525. }
  114526. }
  114527. declare module BABYLON {
  114528. /**
  114529. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114530. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114531. */
  114532. export class AnaglyphUniversalCamera extends UniversalCamera {
  114533. /**
  114534. * Creates a new AnaglyphUniversalCamera
  114535. * @param name defines camera name
  114536. * @param position defines initial position
  114537. * @param interaxialDistance defines distance between each color axis
  114538. * @param scene defines the hosting scene
  114539. */
  114540. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114541. /**
  114542. * Gets camera class name
  114543. * @returns AnaglyphUniversalCamera
  114544. */
  114545. getClassName(): string;
  114546. }
  114547. }
  114548. declare module BABYLON {
  114549. /** @hidden */
  114550. export var stereoscopicInterlacePixelShader: {
  114551. name: string;
  114552. shader: string;
  114553. };
  114554. }
  114555. declare module BABYLON {
  114556. /**
  114557. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  114558. */
  114559. export class StereoscopicInterlacePostProcessI extends PostProcess {
  114560. private _stepSize;
  114561. private _passedProcess;
  114562. /**
  114563. * Initializes a StereoscopicInterlacePostProcessI
  114564. * @param name The name of the effect.
  114565. * @param rigCameras The rig cameras to be appled to the post process
  114566. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  114567. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  114568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114569. * @param engine The engine which the post process will be applied. (default: current engine)
  114570. * @param reusable If the post process can be reused on the same frame. (default: false)
  114571. */
  114572. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114573. }
  114574. /**
  114575. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114576. */
  114577. export class StereoscopicInterlacePostProcess extends PostProcess {
  114578. private _stepSize;
  114579. private _passedProcess;
  114580. /**
  114581. * Initializes a StereoscopicInterlacePostProcess
  114582. * @param name The name of the effect.
  114583. * @param rigCameras The rig cameras to be appled to the post process
  114584. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  114585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114586. * @param engine The engine which the post process will be applied. (default: current engine)
  114587. * @param reusable If the post process can be reused on the same frame. (default: false)
  114588. */
  114589. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114590. }
  114591. }
  114592. declare module BABYLON {
  114593. /**
  114594. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  114595. * @see http://doc.babylonjs.com/features/cameras
  114596. */
  114597. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  114598. /**
  114599. * Creates a new StereoscopicArcRotateCamera
  114600. * @param name defines camera name
  114601. * @param alpha defines alpha angle (in radians)
  114602. * @param beta defines beta angle (in radians)
  114603. * @param radius defines radius
  114604. * @param target defines camera target
  114605. * @param interaxialDistance defines distance between each color axis
  114606. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114607. * @param scene defines the hosting scene
  114608. */
  114609. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114610. /**
  114611. * Gets camera class name
  114612. * @returns StereoscopicArcRotateCamera
  114613. */
  114614. getClassName(): string;
  114615. }
  114616. }
  114617. declare module BABYLON {
  114618. /**
  114619. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  114620. * @see http://doc.babylonjs.com/features/cameras
  114621. */
  114622. export class StereoscopicFreeCamera extends FreeCamera {
  114623. /**
  114624. * Creates a new StereoscopicFreeCamera
  114625. * @param name defines camera name
  114626. * @param position defines initial position
  114627. * @param interaxialDistance defines distance between each color axis
  114628. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114629. * @param scene defines the hosting scene
  114630. */
  114631. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114632. /**
  114633. * Gets camera class name
  114634. * @returns StereoscopicFreeCamera
  114635. */
  114636. getClassName(): string;
  114637. }
  114638. }
  114639. declare module BABYLON {
  114640. /**
  114641. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  114642. * @see http://doc.babylonjs.com/features/cameras
  114643. */
  114644. export class StereoscopicGamepadCamera extends GamepadCamera {
  114645. /**
  114646. * Creates a new StereoscopicGamepadCamera
  114647. * @param name defines camera name
  114648. * @param position defines initial position
  114649. * @param interaxialDistance defines distance between each color axis
  114650. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114651. * @param scene defines the hosting scene
  114652. */
  114653. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114654. /**
  114655. * Gets camera class name
  114656. * @returns StereoscopicGamepadCamera
  114657. */
  114658. getClassName(): string;
  114659. }
  114660. }
  114661. declare module BABYLON {
  114662. /**
  114663. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  114664. * @see http://doc.babylonjs.com/features/cameras
  114665. */
  114666. export class StereoscopicUniversalCamera extends UniversalCamera {
  114667. /**
  114668. * Creates a new StereoscopicUniversalCamera
  114669. * @param name defines camera name
  114670. * @param position defines initial position
  114671. * @param interaxialDistance defines distance between each color axis
  114672. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114673. * @param scene defines the hosting scene
  114674. */
  114675. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114676. /**
  114677. * Gets camera class name
  114678. * @returns StereoscopicUniversalCamera
  114679. */
  114680. getClassName(): string;
  114681. }
  114682. }
  114683. declare module BABYLON {
  114684. /**
  114685. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  114686. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114687. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114688. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114689. */
  114690. export class VirtualJoysticksCamera extends FreeCamera {
  114691. /**
  114692. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  114693. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114694. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114695. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114696. * @param name Define the name of the camera in the scene
  114697. * @param position Define the start position of the camera in the scene
  114698. * @param scene Define the scene the camera belongs to
  114699. */
  114700. constructor(name: string, position: Vector3, scene: Scene);
  114701. /**
  114702. * Gets the current object class name.
  114703. * @return the class name
  114704. */
  114705. getClassName(): string;
  114706. }
  114707. }
  114708. declare module BABYLON {
  114709. /**
  114710. * This represents all the required metrics to create a VR camera.
  114711. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  114712. */
  114713. export class VRCameraMetrics {
  114714. /**
  114715. * Define the horizontal resolution off the screen.
  114716. */
  114717. hResolution: number;
  114718. /**
  114719. * Define the vertical resolution off the screen.
  114720. */
  114721. vResolution: number;
  114722. /**
  114723. * Define the horizontal screen size.
  114724. */
  114725. hScreenSize: number;
  114726. /**
  114727. * Define the vertical screen size.
  114728. */
  114729. vScreenSize: number;
  114730. /**
  114731. * Define the vertical screen center position.
  114732. */
  114733. vScreenCenter: number;
  114734. /**
  114735. * Define the distance of the eyes to the screen.
  114736. */
  114737. eyeToScreenDistance: number;
  114738. /**
  114739. * Define the distance between both lenses
  114740. */
  114741. lensSeparationDistance: number;
  114742. /**
  114743. * Define the distance between both viewer's eyes.
  114744. */
  114745. interpupillaryDistance: number;
  114746. /**
  114747. * Define the distortion factor of the VR postprocess.
  114748. * Please, touch with care.
  114749. */
  114750. distortionK: number[];
  114751. /**
  114752. * Define the chromatic aberration correction factors for the VR post process.
  114753. */
  114754. chromaAbCorrection: number[];
  114755. /**
  114756. * Define the scale factor of the post process.
  114757. * The smaller the better but the slower.
  114758. */
  114759. postProcessScaleFactor: number;
  114760. /**
  114761. * Define an offset for the lens center.
  114762. */
  114763. lensCenterOffset: number;
  114764. /**
  114765. * Define if the current vr camera should compensate the distortion of the lense or not.
  114766. */
  114767. compensateDistortion: boolean;
  114768. /**
  114769. * Defines if multiview should be enabled when rendering (Default: false)
  114770. */
  114771. multiviewEnabled: boolean;
  114772. /**
  114773. * Gets the rendering aspect ratio based on the provided resolutions.
  114774. */
  114775. get aspectRatio(): number;
  114776. /**
  114777. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  114778. */
  114779. get aspectRatioFov(): number;
  114780. /**
  114781. * @hidden
  114782. */
  114783. get leftHMatrix(): Matrix;
  114784. /**
  114785. * @hidden
  114786. */
  114787. get rightHMatrix(): Matrix;
  114788. /**
  114789. * @hidden
  114790. */
  114791. get leftPreViewMatrix(): Matrix;
  114792. /**
  114793. * @hidden
  114794. */
  114795. get rightPreViewMatrix(): Matrix;
  114796. /**
  114797. * Get the default VRMetrics based on the most generic setup.
  114798. * @returns the default vr metrics
  114799. */
  114800. static GetDefault(): VRCameraMetrics;
  114801. }
  114802. }
  114803. declare module BABYLON {
  114804. /** @hidden */
  114805. export var vrDistortionCorrectionPixelShader: {
  114806. name: string;
  114807. shader: string;
  114808. };
  114809. }
  114810. declare module BABYLON {
  114811. /**
  114812. * VRDistortionCorrectionPostProcess used for mobile VR
  114813. */
  114814. export class VRDistortionCorrectionPostProcess extends PostProcess {
  114815. private _isRightEye;
  114816. private _distortionFactors;
  114817. private _postProcessScaleFactor;
  114818. private _lensCenterOffset;
  114819. private _scaleIn;
  114820. private _scaleFactor;
  114821. private _lensCenter;
  114822. /**
  114823. * Initializes the VRDistortionCorrectionPostProcess
  114824. * @param name The name of the effect.
  114825. * @param camera The camera to apply the render pass to.
  114826. * @param isRightEye If this is for the right eye distortion
  114827. * @param vrMetrics All the required metrics for the VR camera
  114828. */
  114829. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  114830. }
  114831. }
  114832. declare module BABYLON {
  114833. /**
  114834. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  114835. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114836. */
  114837. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  114838. /**
  114839. * Creates a new VRDeviceOrientationArcRotateCamera
  114840. * @param name defines camera name
  114841. * @param alpha defines the camera rotation along the logitudinal axis
  114842. * @param beta defines the camera rotation along the latitudinal axis
  114843. * @param radius defines the camera distance from its target
  114844. * @param target defines the camera target
  114845. * @param scene defines the scene the camera belongs to
  114846. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114847. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114848. */
  114849. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114850. /**
  114851. * Gets camera class name
  114852. * @returns VRDeviceOrientationArcRotateCamera
  114853. */
  114854. getClassName(): string;
  114855. }
  114856. }
  114857. declare module BABYLON {
  114858. /**
  114859. * Camera used to simulate VR rendering (based on FreeCamera)
  114860. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114861. */
  114862. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  114863. /**
  114864. * Creates a new VRDeviceOrientationFreeCamera
  114865. * @param name defines camera name
  114866. * @param position defines the start position of the camera
  114867. * @param scene defines the scene the camera belongs to
  114868. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114869. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114870. */
  114871. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114872. /**
  114873. * Gets camera class name
  114874. * @returns VRDeviceOrientationFreeCamera
  114875. */
  114876. getClassName(): string;
  114877. }
  114878. }
  114879. declare module BABYLON {
  114880. /**
  114881. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  114882. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114883. */
  114884. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  114885. /**
  114886. * Creates a new VRDeviceOrientationGamepadCamera
  114887. * @param name defines camera name
  114888. * @param position defines the start position of the camera
  114889. * @param scene defines the scene the camera belongs to
  114890. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114891. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114892. */
  114893. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114894. /**
  114895. * Gets camera class name
  114896. * @returns VRDeviceOrientationGamepadCamera
  114897. */
  114898. getClassName(): string;
  114899. }
  114900. }
  114901. declare module BABYLON {
  114902. /** @hidden */
  114903. export var imageProcessingPixelShader: {
  114904. name: string;
  114905. shader: string;
  114906. };
  114907. }
  114908. declare module BABYLON {
  114909. /**
  114910. * ImageProcessingPostProcess
  114911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  114912. */
  114913. export class ImageProcessingPostProcess extends PostProcess {
  114914. /**
  114915. * Default configuration related to image processing available in the PBR Material.
  114916. */
  114917. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114918. /**
  114919. * Gets the image processing configuration used either in this material.
  114920. */
  114921. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  114922. /**
  114923. * Sets the Default image processing configuration used either in the this material.
  114924. *
  114925. * If sets to null, the scene one is in use.
  114926. */
  114927. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  114928. /**
  114929. * Keep track of the image processing observer to allow dispose and replace.
  114930. */
  114931. private _imageProcessingObserver;
  114932. /**
  114933. * Attaches a new image processing configuration to the PBR Material.
  114934. * @param configuration
  114935. */
  114936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  114937. /**
  114938. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114939. */
  114940. get colorCurves(): Nullable<ColorCurves>;
  114941. /**
  114942. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114943. */
  114944. set colorCurves(value: Nullable<ColorCurves>);
  114945. /**
  114946. * Gets wether the color curves effect is enabled.
  114947. */
  114948. get colorCurvesEnabled(): boolean;
  114949. /**
  114950. * Sets wether the color curves effect is enabled.
  114951. */
  114952. set colorCurvesEnabled(value: boolean);
  114953. /**
  114954. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114955. */
  114956. get colorGradingTexture(): Nullable<BaseTexture>;
  114957. /**
  114958. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114959. */
  114960. set colorGradingTexture(value: Nullable<BaseTexture>);
  114961. /**
  114962. * Gets wether the color grading effect is enabled.
  114963. */
  114964. get colorGradingEnabled(): boolean;
  114965. /**
  114966. * Gets wether the color grading effect is enabled.
  114967. */
  114968. set colorGradingEnabled(value: boolean);
  114969. /**
  114970. * Gets exposure used in the effect.
  114971. */
  114972. get exposure(): number;
  114973. /**
  114974. * Sets exposure used in the effect.
  114975. */
  114976. set exposure(value: number);
  114977. /**
  114978. * Gets wether tonemapping is enabled or not.
  114979. */
  114980. get toneMappingEnabled(): boolean;
  114981. /**
  114982. * Sets wether tonemapping is enabled or not
  114983. */
  114984. set toneMappingEnabled(value: boolean);
  114985. /**
  114986. * Gets the type of tone mapping effect.
  114987. */
  114988. get toneMappingType(): number;
  114989. /**
  114990. * Sets the type of tone mapping effect.
  114991. */
  114992. set toneMappingType(value: number);
  114993. /**
  114994. * Gets contrast used in the effect.
  114995. */
  114996. get contrast(): number;
  114997. /**
  114998. * Sets contrast used in the effect.
  114999. */
  115000. set contrast(value: number);
  115001. /**
  115002. * Gets Vignette stretch size.
  115003. */
  115004. get vignetteStretch(): number;
  115005. /**
  115006. * Sets Vignette stretch size.
  115007. */
  115008. set vignetteStretch(value: number);
  115009. /**
  115010. * Gets Vignette centre X Offset.
  115011. */
  115012. get vignetteCentreX(): number;
  115013. /**
  115014. * Sets Vignette centre X Offset.
  115015. */
  115016. set vignetteCentreX(value: number);
  115017. /**
  115018. * Gets Vignette centre Y Offset.
  115019. */
  115020. get vignetteCentreY(): number;
  115021. /**
  115022. * Sets Vignette centre Y Offset.
  115023. */
  115024. set vignetteCentreY(value: number);
  115025. /**
  115026. * Gets Vignette weight or intensity of the vignette effect.
  115027. */
  115028. get vignetteWeight(): number;
  115029. /**
  115030. * Sets Vignette weight or intensity of the vignette effect.
  115031. */
  115032. set vignetteWeight(value: number);
  115033. /**
  115034. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115035. * if vignetteEnabled is set to true.
  115036. */
  115037. get vignetteColor(): Color4;
  115038. /**
  115039. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115040. * if vignetteEnabled is set to true.
  115041. */
  115042. set vignetteColor(value: Color4);
  115043. /**
  115044. * Gets Camera field of view used by the Vignette effect.
  115045. */
  115046. get vignetteCameraFov(): number;
  115047. /**
  115048. * Sets Camera field of view used by the Vignette effect.
  115049. */
  115050. set vignetteCameraFov(value: number);
  115051. /**
  115052. * Gets the vignette blend mode allowing different kind of effect.
  115053. */
  115054. get vignetteBlendMode(): number;
  115055. /**
  115056. * Sets the vignette blend mode allowing different kind of effect.
  115057. */
  115058. set vignetteBlendMode(value: number);
  115059. /**
  115060. * Gets wether the vignette effect is enabled.
  115061. */
  115062. get vignetteEnabled(): boolean;
  115063. /**
  115064. * Sets wether the vignette effect is enabled.
  115065. */
  115066. set vignetteEnabled(value: boolean);
  115067. private _fromLinearSpace;
  115068. /**
  115069. * Gets wether the input of the processing is in Gamma or Linear Space.
  115070. */
  115071. get fromLinearSpace(): boolean;
  115072. /**
  115073. * Sets wether the input of the processing is in Gamma or Linear Space.
  115074. */
  115075. set fromLinearSpace(value: boolean);
  115076. /**
  115077. * Defines cache preventing GC.
  115078. */
  115079. private _defines;
  115080. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115081. /**
  115082. * "ImageProcessingPostProcess"
  115083. * @returns "ImageProcessingPostProcess"
  115084. */
  115085. getClassName(): string;
  115086. protected _updateParameters(): void;
  115087. dispose(camera?: Camera): void;
  115088. }
  115089. }
  115090. declare module BABYLON {
  115091. /**
  115092. * Class containing static functions to help procedurally build meshes
  115093. */
  115094. export class GroundBuilder {
  115095. /**
  115096. * Creates a ground mesh
  115097. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115098. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115100. * @param name defines the name of the mesh
  115101. * @param options defines the options used to create the mesh
  115102. * @param scene defines the hosting scene
  115103. * @returns the ground mesh
  115104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115105. */
  115106. static CreateGround(name: string, options: {
  115107. width?: number;
  115108. height?: number;
  115109. subdivisions?: number;
  115110. subdivisionsX?: number;
  115111. subdivisionsY?: number;
  115112. updatable?: boolean;
  115113. }, scene: any): Mesh;
  115114. /**
  115115. * Creates a tiled ground mesh
  115116. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115117. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115118. * * 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
  115119. * * 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
  115120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115121. * @param name defines the name of the mesh
  115122. * @param options defines the options used to create the mesh
  115123. * @param scene defines the hosting scene
  115124. * @returns the tiled ground mesh
  115125. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115126. */
  115127. static CreateTiledGround(name: string, options: {
  115128. xmin: number;
  115129. zmin: number;
  115130. xmax: number;
  115131. zmax: number;
  115132. subdivisions?: {
  115133. w: number;
  115134. h: number;
  115135. };
  115136. precision?: {
  115137. w: number;
  115138. h: number;
  115139. };
  115140. updatable?: boolean;
  115141. }, scene?: Nullable<Scene>): Mesh;
  115142. /**
  115143. * Creates a ground mesh from a height map
  115144. * * The parameter `url` sets the URL of the height map image resource.
  115145. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115146. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115147. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115148. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115149. * * 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.
  115150. * * 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).
  115151. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115153. * @param name defines the name of the mesh
  115154. * @param url defines the url to the height map
  115155. * @param options defines the options used to create the mesh
  115156. * @param scene defines the hosting scene
  115157. * @returns the ground mesh
  115158. * @see https://doc.babylonjs.com/babylon101/height_map
  115159. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115160. */
  115161. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115162. width?: number;
  115163. height?: number;
  115164. subdivisions?: number;
  115165. minHeight?: number;
  115166. maxHeight?: number;
  115167. colorFilter?: Color3;
  115168. alphaFilter?: number;
  115169. updatable?: boolean;
  115170. onReady?: (mesh: GroundMesh) => void;
  115171. }, scene?: Nullable<Scene>): GroundMesh;
  115172. }
  115173. }
  115174. declare module BABYLON {
  115175. /**
  115176. * Class containing static functions to help procedurally build meshes
  115177. */
  115178. export class TorusBuilder {
  115179. /**
  115180. * Creates a torus mesh
  115181. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115182. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115183. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115187. * @param name defines the name of the mesh
  115188. * @param options defines the options used to create the mesh
  115189. * @param scene defines the hosting scene
  115190. * @returns the torus mesh
  115191. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115192. */
  115193. static CreateTorus(name: string, options: {
  115194. diameter?: number;
  115195. thickness?: number;
  115196. tessellation?: number;
  115197. updatable?: boolean;
  115198. sideOrientation?: number;
  115199. frontUVs?: Vector4;
  115200. backUVs?: Vector4;
  115201. }, scene: any): Mesh;
  115202. }
  115203. }
  115204. declare module BABYLON {
  115205. /**
  115206. * Class containing static functions to help procedurally build meshes
  115207. */
  115208. export class CylinderBuilder {
  115209. /**
  115210. * Creates a cylinder or a cone mesh
  115211. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115212. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115213. * * 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.
  115214. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115215. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115216. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115217. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115218. * * 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).
  115219. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115220. * * 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).
  115221. * * 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
  115222. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115223. * * 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
  115224. * * 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.
  115225. * * If `enclose` is false, a ring surface is one element.
  115226. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115227. * * 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
  115228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115231. * @param name defines the name of the mesh
  115232. * @param options defines the options used to create the mesh
  115233. * @param scene defines the hosting scene
  115234. * @returns the cylinder mesh
  115235. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115236. */
  115237. static CreateCylinder(name: string, options: {
  115238. height?: number;
  115239. diameterTop?: number;
  115240. diameterBottom?: number;
  115241. diameter?: number;
  115242. tessellation?: number;
  115243. subdivisions?: number;
  115244. arc?: number;
  115245. faceColors?: Color4[];
  115246. faceUV?: Vector4[];
  115247. updatable?: boolean;
  115248. hasRings?: boolean;
  115249. enclose?: boolean;
  115250. cap?: number;
  115251. sideOrientation?: number;
  115252. frontUVs?: Vector4;
  115253. backUVs?: Vector4;
  115254. }, scene: any): Mesh;
  115255. }
  115256. }
  115257. declare module BABYLON {
  115258. /**
  115259. * States of the webXR experience
  115260. */
  115261. export enum WebXRState {
  115262. /**
  115263. * Transitioning to being in XR mode
  115264. */
  115265. ENTERING_XR = 0,
  115266. /**
  115267. * Transitioning to non XR mode
  115268. */
  115269. EXITING_XR = 1,
  115270. /**
  115271. * In XR mode and presenting
  115272. */
  115273. IN_XR = 2,
  115274. /**
  115275. * Not entered XR mode
  115276. */
  115277. NOT_IN_XR = 3
  115278. }
  115279. /**
  115280. * Abstraction of the XR render target
  115281. */
  115282. export interface WebXRRenderTarget extends IDisposable {
  115283. /**
  115284. * xrpresent context of the canvas which can be used to display/mirror xr content
  115285. */
  115286. canvasContext: WebGLRenderingContext;
  115287. /**
  115288. * xr layer for the canvas
  115289. */
  115290. xrLayer: Nullable<XRWebGLLayer>;
  115291. /**
  115292. * Initializes the xr layer for the session
  115293. * @param xrSession xr session
  115294. * @returns a promise that will resolve once the XR Layer has been created
  115295. */
  115296. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115297. }
  115298. }
  115299. declare module BABYLON {
  115300. /**
  115301. * COnfiguration object for WebXR output canvas
  115302. */
  115303. export class WebXRManagedOutputCanvasOptions {
  115304. /**
  115305. * Options for this XR Layer output
  115306. */
  115307. canvasOptions?: XRWebGLLayerOptions;
  115308. /**
  115309. * CSS styling for a newly created canvas (if not provided)
  115310. */
  115311. newCanvasCssStyle?: string;
  115312. /**
  115313. * An optional canvas in case you wish to create it yourself and provide it here.
  115314. * If not provided, a new canvas will be created
  115315. */
  115316. canvasElement?: HTMLCanvasElement;
  115317. /**
  115318. * Get the default values of the configuration object
  115319. * @returns default values of this configuration object
  115320. */
  115321. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115322. }
  115323. /**
  115324. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115325. */
  115326. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115327. private _options;
  115328. private _engine;
  115329. private _canvas;
  115330. /**
  115331. * Rendering context of the canvas which can be used to display/mirror xr content
  115332. */
  115333. canvasContext: WebGLRenderingContext;
  115334. /**
  115335. * xr layer for the canvas
  115336. */
  115337. xrLayer: Nullable<XRWebGLLayer>;
  115338. /**
  115339. * Initializes the xr layer for the session
  115340. * @param xrSession xr session
  115341. * @returns a promise that will resolve once the XR Layer has been created
  115342. */
  115343. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115344. /**
  115345. * Initializes the canvas to be added/removed upon entering/exiting xr
  115346. * @param _xrSessionManager The XR Session manager
  115347. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115348. */
  115349. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115350. /**
  115351. * Disposes of the object
  115352. */
  115353. dispose(): void;
  115354. private _setManagedOutputCanvas;
  115355. private _addCanvas;
  115356. private _removeCanvas;
  115357. }
  115358. }
  115359. declare module BABYLON {
  115360. /**
  115361. * Manages an XRSession to work with Babylon's engine
  115362. * @see https://doc.babylonjs.com/how_to/webxr
  115363. */
  115364. export class WebXRSessionManager implements IDisposable {
  115365. /** The scene which the session should be created for */
  115366. scene: Scene;
  115367. /**
  115368. * Fires every time a new xrFrame arrives which can be used to update the camera
  115369. */
  115370. onXRFrameObservable: Observable<XRFrame>;
  115371. /**
  115372. * Fires when the xr session is ended either by the device or manually done
  115373. */
  115374. onXRSessionEnded: Observable<any>;
  115375. /**
  115376. * Fires when the xr session is ended either by the device or manually done
  115377. */
  115378. onXRSessionInit: Observable<XRSession>;
  115379. /**
  115380. * Fires when the reference space changed
  115381. */
  115382. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115383. /**
  115384. * Underlying xr session
  115385. */
  115386. session: XRSession;
  115387. /**
  115388. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115389. * or get the offset the player is currently at.
  115390. */
  115391. viewerReferenceSpace: XRReferenceSpace;
  115392. private _referenceSpace;
  115393. /**
  115394. * The current reference space used in this session. This reference space can constantly change!
  115395. * It is mainly used to offset the camera's position.
  115396. */
  115397. get referenceSpace(): XRReferenceSpace;
  115398. /**
  115399. * Set a new reference space and triggers the observable
  115400. */
  115401. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115402. /**
  115403. * The base reference space from which the session started. good if you want to reset your
  115404. * reference space
  115405. */
  115406. baseReferenceSpace: XRReferenceSpace;
  115407. /**
  115408. * Used just in case of a failure to initialize an immersive session.
  115409. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115410. */
  115411. defaultHeightCompensation: number;
  115412. /**
  115413. * Current XR frame
  115414. */
  115415. currentFrame: Nullable<XRFrame>;
  115416. /** WebXR timestamp updated every frame */
  115417. currentTimestamp: number;
  115418. private _xrNavigator;
  115419. private baseLayer;
  115420. private _rttProvider;
  115421. private _sessionEnded;
  115422. /**
  115423. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115424. * @param scene The scene which the session should be created for
  115425. */
  115426. constructor(
  115427. /** The scene which the session should be created for */
  115428. scene: Scene);
  115429. /**
  115430. * Initializes the manager
  115431. * After initialization enterXR can be called to start an XR session
  115432. * @returns Promise which resolves after it is initialized
  115433. */
  115434. initializeAsync(): Promise<void>;
  115435. /**
  115436. * Initializes an xr session
  115437. * @param xrSessionMode mode to initialize
  115438. * @param xrSessionInit defines optional and required values to pass to the session builder
  115439. * @returns a promise which will resolve once the session has been initialized
  115440. */
  115441. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115442. /**
  115443. * Sets the reference space on the xr session
  115444. * @param referenceSpaceType space to set
  115445. * @returns a promise that will resolve once the reference space has been set
  115446. */
  115447. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115448. /**
  115449. * Resets the reference space to the one started the session
  115450. */
  115451. resetReferenceSpace(): void;
  115452. /**
  115453. * Updates the render state of the session
  115454. * @param state state to set
  115455. * @returns a promise that resolves once the render state has been updated
  115456. */
  115457. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115458. /**
  115459. * Starts rendering to the xr layer
  115460. */
  115461. runXRRenderLoop(): void;
  115462. /**
  115463. * Gets the correct render target texture to be rendered this frame for this eye
  115464. * @param eye the eye for which to get the render target
  115465. * @returns the render target for the specified eye
  115466. */
  115467. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115468. /**
  115469. * Stops the xrSession and restores the renderloop
  115470. * @returns Promise which resolves after it exits XR
  115471. */
  115472. exitXRAsync(): Promise<void>;
  115473. /**
  115474. * Checks if a session would be supported for the creation options specified
  115475. * @param sessionMode session mode to check if supported eg. immersive-vr
  115476. * @returns A Promise that resolves to true if supported and false if not
  115477. */
  115478. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115479. /**
  115480. * Creates a WebXRRenderTarget object for the XR session
  115481. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115482. * @param options optional options to provide when creating a new render target
  115483. * @returns a WebXR render target to which the session can render
  115484. */
  115485. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115486. /**
  115487. * @hidden
  115488. * Converts the render layer of xrSession to a render target
  115489. * @param session session to create render target for
  115490. * @param scene scene the new render target should be created for
  115491. * @param baseLayer the webgl layer to create the render target for
  115492. */
  115493. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  115494. /**
  115495. * Disposes of the session manager
  115496. */
  115497. dispose(): void;
  115498. /**
  115499. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115500. * @param sessionMode defines the session to test
  115501. * @returns a promise with boolean as final value
  115502. */
  115503. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115504. }
  115505. }
  115506. declare module BABYLON {
  115507. /**
  115508. * WebXR Camera which holds the views for the xrSession
  115509. * @see https://doc.babylonjs.com/how_to/webxr
  115510. */
  115511. export class WebXRCamera extends FreeCamera {
  115512. private _xrSessionManager;
  115513. /**
  115514. * Should position compensation execute on first frame.
  115515. * This is used when copying the position from a native (non XR) camera
  115516. */
  115517. compensateOnFirstFrame: boolean;
  115518. private _firstFrame;
  115519. private _referencedPosition;
  115520. private _referenceQuaternion;
  115521. private _xrInvPositionCache;
  115522. private _xrInvQuaternionCache;
  115523. private _realWorldHeight;
  115524. /**
  115525. * Prevent the camera from calculating the real-world height
  115526. * If you are not using the user's height disable this for better performance
  115527. */
  115528. disableRealWorldHeightCalculation: boolean;
  115529. /**
  115530. * Return the user's height, unrelated to the current ground.
  115531. */
  115532. get realWorldHeight(): number;
  115533. /**
  115534. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115535. * @param name the name of the camera
  115536. * @param scene the scene to add the camera to
  115537. */
  115538. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115539. private _updateNumberOfRigCameras;
  115540. /**
  115541. * Sets this camera's transformation based on a non-vr camera
  115542. * @param otherCamera the non-vr camera to copy the transformation from
  115543. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115544. */
  115545. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  115546. /** @hidden */
  115547. _updateForDualEyeDebugging(): void;
  115548. private _updateReferenceSpace;
  115549. private _updateReferenceSpaceOffset;
  115550. private _updateFromXRSession;
  115551. }
  115552. }
  115553. declare module BABYLON {
  115554. /**
  115555. * Defining the interface required for a (webxr) feature
  115556. */
  115557. export interface IWebXRFeature extends IDisposable {
  115558. /**
  115559. * Is this feature attached
  115560. */
  115561. attached: boolean;
  115562. /**
  115563. * Should auto-attach be disabled?
  115564. */
  115565. disableAutoAttach: boolean;
  115566. /**
  115567. * Attach the feature to the session
  115568. * Will usually be called by the features manager
  115569. *
  115570. * @param force should attachment be forced (even when already attached)
  115571. * @returns true if successful.
  115572. */
  115573. attach(force?: boolean): boolean;
  115574. /**
  115575. * Detach the feature from the session
  115576. * Will usually be called by the features manager
  115577. *
  115578. * @returns true if successful.
  115579. */
  115580. detach(): boolean;
  115581. }
  115582. /**
  115583. * A list of the currently available features without referencing them
  115584. */
  115585. export class WebXRFeatureName {
  115586. /**
  115587. * The name of the hit test feature
  115588. */
  115589. static HIT_TEST: string;
  115590. /**
  115591. * The name of the anchor system feature
  115592. */
  115593. static ANCHOR_SYSTEM: string;
  115594. /**
  115595. * The name of the background remover feature
  115596. */
  115597. static BACKGROUND_REMOVER: string;
  115598. /**
  115599. * The name of the pointer selection feature
  115600. */
  115601. static POINTER_SELECTION: string;
  115602. /**
  115603. * The name of the teleportation feature
  115604. */
  115605. static TELEPORTATION: string;
  115606. /**
  115607. * The name of the plane detection feature
  115608. */
  115609. static PLANE_DETECTION: string;
  115610. /**
  115611. * physics impostors for xr controllers feature
  115612. */
  115613. static PHYSICS_CONTROLLERS: string;
  115614. }
  115615. /**
  115616. * Defining the constructor of a feature. Used to register the modules.
  115617. */
  115618. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  115619. /**
  115620. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  115621. * It is mainly used in AR sessions.
  115622. *
  115623. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  115624. */
  115625. export class WebXRFeaturesManager implements IDisposable {
  115626. private _xrSessionManager;
  115627. private static readonly _AvailableFeatures;
  115628. /**
  115629. * Used to register a module. After calling this function a developer can use this feature in the scene.
  115630. * Mainly used internally.
  115631. *
  115632. * @param featureName the name of the feature to register
  115633. * @param constructorFunction the function used to construct the module
  115634. * @param version the (babylon) version of the module
  115635. * @param stable is that a stable version of this module
  115636. */
  115637. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  115638. /**
  115639. * Returns a constructor of a specific feature.
  115640. *
  115641. * @param featureName the name of the feature to construct
  115642. * @param version the version of the feature to load
  115643. * @param xrSessionManager the xrSessionManager. Used to construct the module
  115644. * @param options optional options provided to the module.
  115645. * @returns a function that, when called, will return a new instance of this feature
  115646. */
  115647. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  115648. /**
  115649. * Return the latest unstable version of this feature
  115650. * @param featureName the name of the feature to search
  115651. * @returns the version number. if not found will return -1
  115652. */
  115653. static GetLatestVersionOfFeature(featureName: string): number;
  115654. /**
  115655. * Return the latest stable version of this feature
  115656. * @param featureName the name of the feature to search
  115657. * @returns the version number. if not found will return -1
  115658. */
  115659. static GetStableVersionOfFeature(featureName: string): number;
  115660. /**
  115661. * Can be used to return the list of features currently registered
  115662. *
  115663. * @returns an Array of available features
  115664. */
  115665. static GetAvailableFeatures(): string[];
  115666. /**
  115667. * Gets the versions available for a specific feature
  115668. * @param featureName the name of the feature
  115669. * @returns an array with the available versions
  115670. */
  115671. static GetAvailableVersions(featureName: string): string[];
  115672. private _features;
  115673. /**
  115674. * constructs a new features manages.
  115675. *
  115676. * @param _xrSessionManager an instance of WebXRSessionManager
  115677. */
  115678. constructor(_xrSessionManager: WebXRSessionManager);
  115679. /**
  115680. * 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.
  115681. * 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.
  115682. *
  115683. * @param featureName the name of the feature to load or the class of the feature
  115684. * @param version optional version to load. if not provided the latest version will be enabled
  115685. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  115686. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  115687. * @returns a new constructed feature or throws an error if feature not found.
  115688. */
  115689. enableFeature(featureName: string | {
  115690. Name: string;
  115691. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  115692. /**
  115693. * Used to disable an already-enabled feature
  115694. * The feature will be disposed and will be recreated once enabled.
  115695. * @param featureName the feature to disable
  115696. * @returns true if disable was successful
  115697. */
  115698. disableFeature(featureName: string | {
  115699. Name: string;
  115700. }): boolean;
  115701. /**
  115702. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  115703. * Can be used during a session to start a feature
  115704. * @param featureName the name of feature to attach
  115705. */
  115706. attachFeature(featureName: string): void;
  115707. /**
  115708. * Can be used inside a session or when the session ends to detach a specific feature
  115709. * @param featureName the name of the feature to detach
  115710. */
  115711. detachFeature(featureName: string): void;
  115712. /**
  115713. * Get the list of enabled features
  115714. * @returns an array of enabled features
  115715. */
  115716. getEnabledFeatures(): string[];
  115717. /**
  115718. * get the implementation of an enabled feature.
  115719. * @param featureName the name of the feature to load
  115720. * @returns the feature class, if found
  115721. */
  115722. getEnabledFeature(featureName: string): IWebXRFeature;
  115723. /**
  115724. * dispose this features manager
  115725. */
  115726. dispose(): void;
  115727. }
  115728. }
  115729. declare module BABYLON {
  115730. /**
  115731. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  115732. * @see https://doc.babylonjs.com/how_to/webxr
  115733. */
  115734. export class WebXRExperienceHelper implements IDisposable {
  115735. private scene;
  115736. /**
  115737. * Camera used to render xr content
  115738. */
  115739. camera: WebXRCamera;
  115740. /**
  115741. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  115742. */
  115743. state: WebXRState;
  115744. private _setState;
  115745. /**
  115746. * Fires when the state of the experience helper has changed
  115747. */
  115748. onStateChangedObservable: Observable<WebXRState>;
  115749. /**
  115750. * Observers registered here will be triggered after the camera's initial transformation is set
  115751. * This can be used to set a different ground level or an extra rotation.
  115752. *
  115753. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  115754. * to the position set after this observable is done executing.
  115755. */
  115756. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  115757. /** Session manager used to keep track of xr session */
  115758. sessionManager: WebXRSessionManager;
  115759. /** A features manager for this xr session */
  115760. featuresManager: WebXRFeaturesManager;
  115761. private _nonVRCamera;
  115762. private _originalSceneAutoClear;
  115763. private _supported;
  115764. /**
  115765. * Creates the experience helper
  115766. * @param scene the scene to attach the experience helper to
  115767. * @returns a promise for the experience helper
  115768. */
  115769. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  115770. /**
  115771. * Creates a WebXRExperienceHelper
  115772. * @param scene The scene the helper should be created in
  115773. */
  115774. private constructor();
  115775. /**
  115776. * Exits XR mode and returns the scene to its original state
  115777. * @returns promise that resolves after xr mode has exited
  115778. */
  115779. exitXRAsync(): Promise<void>;
  115780. /**
  115781. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  115782. * @param sessionMode options for the XR session
  115783. * @param referenceSpaceType frame of reference of the XR session
  115784. * @param renderTarget the output canvas that will be used to enter XR mode
  115785. * @returns promise that resolves after xr mode has entered
  115786. */
  115787. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  115788. /**
  115789. * Disposes of the experience helper
  115790. */
  115791. dispose(): void;
  115792. private _nonXRToXRCamera;
  115793. }
  115794. }
  115795. declare module BABYLON {
  115796. /**
  115797. * X-Y values for axes in WebXR
  115798. */
  115799. export interface IWebXRMotionControllerAxesValue {
  115800. /**
  115801. * The value of the x axis
  115802. */
  115803. x: number;
  115804. /**
  115805. * The value of the y-axis
  115806. */
  115807. y: number;
  115808. }
  115809. /**
  115810. * changed / previous values for the values of this component
  115811. */
  115812. export interface IWebXRMotionControllerComponentChangesValues<T> {
  115813. /**
  115814. * current (this frame) value
  115815. */
  115816. current: T;
  115817. /**
  115818. * previous (last change) value
  115819. */
  115820. previous: T;
  115821. }
  115822. /**
  115823. * Represents changes in the component between current frame and last values recorded
  115824. */
  115825. export interface IWebXRMotionControllerComponentChanges {
  115826. /**
  115827. * will be populated with previous and current values if touched changed
  115828. */
  115829. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115830. /**
  115831. * will be populated with previous and current values if pressed changed
  115832. */
  115833. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115834. /**
  115835. * will be populated with previous and current values if value changed
  115836. */
  115837. value?: IWebXRMotionControllerComponentChangesValues<number>;
  115838. /**
  115839. * will be populated with previous and current values if axes changed
  115840. */
  115841. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  115842. }
  115843. /**
  115844. * This class represents a single component (for example button or thumbstick) of a motion controller
  115845. */
  115846. export class WebXRControllerComponent implements IDisposable {
  115847. /**
  115848. * the id of this component
  115849. */
  115850. id: string;
  115851. /**
  115852. * the type of the component
  115853. */
  115854. type: MotionControllerComponentType;
  115855. private _buttonIndex;
  115856. private _axesIndices;
  115857. /**
  115858. * Thumbstick component type
  115859. */
  115860. static THUMBSTICK: MotionControllerComponentType;
  115861. /**
  115862. * Touchpad component type
  115863. */
  115864. static TOUCHPAD: MotionControllerComponentType;
  115865. /**
  115866. * trigger component type
  115867. */
  115868. static TRIGGER: MotionControllerComponentType;
  115869. /**
  115870. * squeeze component type
  115871. */
  115872. static SQUEEZE: MotionControllerComponentType;
  115873. /**
  115874. * button component type
  115875. */
  115876. static BUTTON: MotionControllerComponentType;
  115877. /**
  115878. * Observers registered here will be triggered when the state of a button changes
  115879. * State change is either pressed / touched / value
  115880. */
  115881. onButtonStateChanged: Observable<WebXRControllerComponent>;
  115882. /**
  115883. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  115884. * the axes data changes
  115885. */
  115886. onAxisValueChanged: Observable<{
  115887. x: number;
  115888. y: number;
  115889. }>;
  115890. private _currentValue;
  115891. private _touched;
  115892. private _pressed;
  115893. private _axes;
  115894. private _changes;
  115895. private _hasChanges;
  115896. /**
  115897. * Return whether or not the component changed the last frame
  115898. */
  115899. get hasChanges(): boolean;
  115900. /**
  115901. * Creates a new component for a motion controller.
  115902. * It is created by the motion controller itself
  115903. *
  115904. * @param id the id of this component
  115905. * @param type the type of the component
  115906. * @param _buttonIndex index in the buttons array of the gamepad
  115907. * @param _axesIndices indices of the values in the axes array of the gamepad
  115908. */
  115909. constructor(
  115910. /**
  115911. * the id of this component
  115912. */
  115913. id: string,
  115914. /**
  115915. * the type of the component
  115916. */
  115917. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  115918. /**
  115919. * Get the current value of this component
  115920. */
  115921. get value(): number;
  115922. /**
  115923. * is the button currently pressed
  115924. */
  115925. get pressed(): boolean;
  115926. /**
  115927. * is the button currently touched
  115928. */
  115929. get touched(): boolean;
  115930. /**
  115931. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  115932. */
  115933. get axes(): IWebXRMotionControllerAxesValue;
  115934. /**
  115935. * Get the changes. Elements will be populated only if they changed with their previous and current value
  115936. */
  115937. get changes(): IWebXRMotionControllerComponentChanges;
  115938. /**
  115939. * Is this component a button (hence - pressable)
  115940. * @returns true if can be pressed
  115941. */
  115942. isButton(): boolean;
  115943. /**
  115944. * Are there axes correlating to this component
  115945. * @return true is axes data is available
  115946. */
  115947. isAxes(): boolean;
  115948. /**
  115949. * update this component using the gamepad object it is in. Called on every frame
  115950. * @param nativeController the native gamepad controller object
  115951. */
  115952. update(nativeController: IMinimalMotionControllerObject): void;
  115953. /**
  115954. * Dispose this component
  115955. */
  115956. dispose(): void;
  115957. }
  115958. }
  115959. declare module BABYLON {
  115960. /**
  115961. * Class used to represent data loading progression
  115962. */
  115963. export class SceneLoaderProgressEvent {
  115964. /** defines if data length to load can be evaluated */
  115965. readonly lengthComputable: boolean;
  115966. /** defines the loaded data length */
  115967. readonly loaded: number;
  115968. /** defines the data length to load */
  115969. readonly total: number;
  115970. /**
  115971. * Create a new progress event
  115972. * @param lengthComputable defines if data length to load can be evaluated
  115973. * @param loaded defines the loaded data length
  115974. * @param total defines the data length to load
  115975. */
  115976. constructor(
  115977. /** defines if data length to load can be evaluated */
  115978. lengthComputable: boolean,
  115979. /** defines the loaded data length */
  115980. loaded: number,
  115981. /** defines the data length to load */
  115982. total: number);
  115983. /**
  115984. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  115985. * @param event defines the source event
  115986. * @returns a new SceneLoaderProgressEvent
  115987. */
  115988. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  115989. }
  115990. /**
  115991. * Interface used by SceneLoader plugins to define supported file extensions
  115992. */
  115993. export interface ISceneLoaderPluginExtensions {
  115994. /**
  115995. * Defines the list of supported extensions
  115996. */
  115997. [extension: string]: {
  115998. isBinary: boolean;
  115999. };
  116000. }
  116001. /**
  116002. * Interface used by SceneLoader plugin factory
  116003. */
  116004. export interface ISceneLoaderPluginFactory {
  116005. /**
  116006. * Defines the name of the factory
  116007. */
  116008. name: string;
  116009. /**
  116010. * Function called to create a new plugin
  116011. * @return the new plugin
  116012. */
  116013. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116014. /**
  116015. * The callback that returns true if the data can be directly loaded.
  116016. * @param data string containing the file data
  116017. * @returns if the data can be loaded directly
  116018. */
  116019. canDirectLoad?(data: string): boolean;
  116020. }
  116021. /**
  116022. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116023. */
  116024. export interface ISceneLoaderPluginBase {
  116025. /**
  116026. * The friendly name of this plugin.
  116027. */
  116028. name: string;
  116029. /**
  116030. * The file extensions supported by this plugin.
  116031. */
  116032. extensions: string | ISceneLoaderPluginExtensions;
  116033. /**
  116034. * The callback called when loading from a url.
  116035. * @param scene scene loading this url
  116036. * @param url url to load
  116037. * @param onSuccess callback called when the file successfully loads
  116038. * @param onProgress callback called while file is loading (if the server supports this mode)
  116039. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116040. * @param onError callback called when the file fails to load
  116041. * @returns a file request object
  116042. */
  116043. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116044. /**
  116045. * The callback called when loading from a file object.
  116046. * @param scene scene loading this file
  116047. * @param file defines the file to load
  116048. * @param onSuccess defines the callback to call when data is loaded
  116049. * @param onProgress defines the callback to call during loading process
  116050. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116051. * @param onError defines the callback to call when an error occurs
  116052. * @returns a file request object
  116053. */
  116054. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116055. /**
  116056. * The callback that returns true if the data can be directly loaded.
  116057. * @param data string containing the file data
  116058. * @returns if the data can be loaded directly
  116059. */
  116060. canDirectLoad?(data: string): boolean;
  116061. /**
  116062. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116063. * @param scene scene loading this data
  116064. * @param data string containing the data
  116065. * @returns data to pass to the plugin
  116066. */
  116067. directLoad?(scene: Scene, data: string): any;
  116068. /**
  116069. * The callback that allows custom handling of the root url based on the response url.
  116070. * @param rootUrl the original root url
  116071. * @param responseURL the response url if available
  116072. * @returns the new root url
  116073. */
  116074. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116075. }
  116076. /**
  116077. * Interface used to define a SceneLoader plugin
  116078. */
  116079. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116080. /**
  116081. * Import meshes into a scene.
  116082. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116083. * @param scene The scene to import into
  116084. * @param data The data to import
  116085. * @param rootUrl The root url for scene and resources
  116086. * @param meshes The meshes array to import into
  116087. * @param particleSystems The particle systems array to import into
  116088. * @param skeletons The skeletons array to import into
  116089. * @param onError The callback when import fails
  116090. * @returns True if successful or false otherwise
  116091. */
  116092. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116093. /**
  116094. * Load into a scene.
  116095. * @param scene The scene to load into
  116096. * @param data The data to import
  116097. * @param rootUrl The root url for scene and resources
  116098. * @param onError The callback when import fails
  116099. * @returns True if successful or false otherwise
  116100. */
  116101. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116102. /**
  116103. * Load into an asset container.
  116104. * @param scene The scene to load into
  116105. * @param data The data to import
  116106. * @param rootUrl The root url for scene and resources
  116107. * @param onError The callback when import fails
  116108. * @returns The loaded asset container
  116109. */
  116110. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116111. }
  116112. /**
  116113. * Interface used to define an async SceneLoader plugin
  116114. */
  116115. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116116. /**
  116117. * Import meshes into a scene.
  116118. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116119. * @param scene The scene to import into
  116120. * @param data The data to import
  116121. * @param rootUrl The root url for scene and resources
  116122. * @param onProgress The callback when the load progresses
  116123. * @param fileName Defines the name of the file to load
  116124. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116125. */
  116126. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116127. meshes: AbstractMesh[];
  116128. particleSystems: IParticleSystem[];
  116129. skeletons: Skeleton[];
  116130. animationGroups: AnimationGroup[];
  116131. }>;
  116132. /**
  116133. * Load into a scene.
  116134. * @param scene The scene to load into
  116135. * @param data The data to import
  116136. * @param rootUrl The root url for scene and resources
  116137. * @param onProgress The callback when the load progresses
  116138. * @param fileName Defines the name of the file to load
  116139. * @returns Nothing
  116140. */
  116141. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116142. /**
  116143. * Load into an asset container.
  116144. * @param scene The scene to load into
  116145. * @param data The data to import
  116146. * @param rootUrl The root url for scene and resources
  116147. * @param onProgress The callback when the load progresses
  116148. * @param fileName Defines the name of the file to load
  116149. * @returns The loaded asset container
  116150. */
  116151. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116152. }
  116153. /**
  116154. * Mode that determines how to handle old animation groups before loading new ones.
  116155. */
  116156. export enum SceneLoaderAnimationGroupLoadingMode {
  116157. /**
  116158. * Reset all old animations to initial state then dispose them.
  116159. */
  116160. Clean = 0,
  116161. /**
  116162. * Stop all old animations.
  116163. */
  116164. Stop = 1,
  116165. /**
  116166. * Restart old animations from first frame.
  116167. */
  116168. Sync = 2,
  116169. /**
  116170. * Old animations remains untouched.
  116171. */
  116172. NoSync = 3
  116173. }
  116174. /**
  116175. * Class used to load scene from various file formats using registered plugins
  116176. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116177. */
  116178. export class SceneLoader {
  116179. /**
  116180. * No logging while loading
  116181. */
  116182. static readonly NO_LOGGING: number;
  116183. /**
  116184. * Minimal logging while loading
  116185. */
  116186. static readonly MINIMAL_LOGGING: number;
  116187. /**
  116188. * Summary logging while loading
  116189. */
  116190. static readonly SUMMARY_LOGGING: number;
  116191. /**
  116192. * Detailled logging while loading
  116193. */
  116194. static readonly DETAILED_LOGGING: number;
  116195. /**
  116196. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116197. */
  116198. static get ForceFullSceneLoadingForIncremental(): boolean;
  116199. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116200. /**
  116201. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116202. */
  116203. static get ShowLoadingScreen(): boolean;
  116204. static set ShowLoadingScreen(value: boolean);
  116205. /**
  116206. * Defines the current logging level (while loading the scene)
  116207. * @ignorenaming
  116208. */
  116209. static get loggingLevel(): number;
  116210. static set loggingLevel(value: number);
  116211. /**
  116212. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116213. */
  116214. static get CleanBoneMatrixWeights(): boolean;
  116215. static set CleanBoneMatrixWeights(value: boolean);
  116216. /**
  116217. * Event raised when a plugin is used to load a scene
  116218. */
  116219. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116220. private static _registeredPlugins;
  116221. private static _getDefaultPlugin;
  116222. private static _getPluginForExtension;
  116223. private static _getPluginForDirectLoad;
  116224. private static _getPluginForFilename;
  116225. private static _getDirectLoad;
  116226. private static _loadData;
  116227. private static _getFileInfo;
  116228. /**
  116229. * Gets a plugin that can load the given extension
  116230. * @param extension defines the extension to load
  116231. * @returns a plugin or null if none works
  116232. */
  116233. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116234. /**
  116235. * Gets a boolean indicating that the given extension can be loaded
  116236. * @param extension defines the extension to load
  116237. * @returns true if the extension is supported
  116238. */
  116239. static IsPluginForExtensionAvailable(extension: string): boolean;
  116240. /**
  116241. * Adds a new plugin to the list of registered plugins
  116242. * @param plugin defines the plugin to add
  116243. */
  116244. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116245. /**
  116246. * Import meshes into a scene
  116247. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116248. * @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)
  116249. * @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)
  116250. * @param scene the instance of BABYLON.Scene to append to
  116251. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116252. * @param onProgress a callback with a progress event for each file being loaded
  116253. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116254. * @param pluginExtension the extension used to determine the plugin
  116255. * @returns The loaded plugin
  116256. */
  116257. 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>;
  116258. /**
  116259. * Import meshes into a scene
  116260. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116261. * @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)
  116262. * @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)
  116263. * @param scene the instance of BABYLON.Scene to append to
  116264. * @param onProgress a callback with a progress event for each file being loaded
  116265. * @param pluginExtension the extension used to determine the plugin
  116266. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116267. */
  116268. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116269. meshes: AbstractMesh[];
  116270. particleSystems: IParticleSystem[];
  116271. skeletons: Skeleton[];
  116272. animationGroups: AnimationGroup[];
  116273. }>;
  116274. /**
  116275. * Load a scene
  116276. * @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)
  116277. * @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)
  116278. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116279. * @param onSuccess a callback with the scene when import succeeds
  116280. * @param onProgress a callback with a progress event for each file being loaded
  116281. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116282. * @param pluginExtension the extension used to determine the plugin
  116283. * @returns The loaded plugin
  116284. */
  116285. 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>;
  116286. /**
  116287. * Load a scene
  116288. * @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)
  116289. * @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)
  116290. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116291. * @param onProgress a callback with a progress event for each file being loaded
  116292. * @param pluginExtension the extension used to determine the plugin
  116293. * @returns The loaded scene
  116294. */
  116295. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116296. /**
  116297. * Append a scene
  116298. * @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)
  116299. * @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)
  116300. * @param scene is the instance of BABYLON.Scene to append to
  116301. * @param onSuccess a callback with the scene when import succeeds
  116302. * @param onProgress a callback with a progress event for each file being loaded
  116303. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116304. * @param pluginExtension the extension used to determine the plugin
  116305. * @returns The loaded plugin
  116306. */
  116307. 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>;
  116308. /**
  116309. * Append a scene
  116310. * @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)
  116311. * @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)
  116312. * @param scene is the instance of BABYLON.Scene to append to
  116313. * @param onProgress a callback with a progress event for each file being loaded
  116314. * @param pluginExtension the extension used to determine the plugin
  116315. * @returns The given scene
  116316. */
  116317. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116318. /**
  116319. * Load a scene into an asset container
  116320. * @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)
  116321. * @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)
  116322. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116323. * @param onSuccess a callback with the scene when import succeeds
  116324. * @param onProgress a callback with a progress event for each file being loaded
  116325. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116326. * @param pluginExtension the extension used to determine the plugin
  116327. * @returns The loaded plugin
  116328. */
  116329. 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>;
  116330. /**
  116331. * Load a scene into an asset container
  116332. * @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)
  116333. * @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)
  116334. * @param scene is the instance of Scene to append to
  116335. * @param onProgress a callback with a progress event for each file being loaded
  116336. * @param pluginExtension the extension used to determine the plugin
  116337. * @returns The loaded asset container
  116338. */
  116339. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116340. /**
  116341. * Import animations from a file into a scene
  116342. * @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)
  116343. * @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)
  116344. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116345. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116346. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116347. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116348. * @param onSuccess a callback with the scene when import succeeds
  116349. * @param onProgress a callback with a progress event for each file being loaded
  116350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116351. */
  116352. 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;
  116353. /**
  116354. * Import animations from a file into a scene
  116355. * @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)
  116356. * @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)
  116357. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116358. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116359. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116360. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116361. * @param onSuccess a callback with the scene when import succeeds
  116362. * @param onProgress a callback with a progress event for each file being loaded
  116363. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116364. * @returns the updated scene with imported animations
  116365. */
  116366. 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>;
  116367. }
  116368. }
  116369. declare module BABYLON {
  116370. /**
  116371. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116372. */
  116373. export type MotionControllerHandness = "none" | "left" | "right";
  116374. /**
  116375. * The type of components available in motion controllers.
  116376. * This is not the name of the component.
  116377. */
  116378. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116379. /**
  116380. * The state of a controller component
  116381. */
  116382. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116383. /**
  116384. * The schema of motion controller layout.
  116385. * No object will be initialized using this interface
  116386. * This is used just to define the profile.
  116387. */
  116388. export interface IMotionControllerLayout {
  116389. /**
  116390. * Defines the main button component id
  116391. */
  116392. selectComponentId: string;
  116393. /**
  116394. * Available components (unsorted)
  116395. */
  116396. components: {
  116397. /**
  116398. * A map of component Ids
  116399. */
  116400. [componentId: string]: {
  116401. /**
  116402. * The type of input the component outputs
  116403. */
  116404. type: MotionControllerComponentType;
  116405. /**
  116406. * The indices of this component in the gamepad object
  116407. */
  116408. gamepadIndices: {
  116409. /**
  116410. * Index of button
  116411. */
  116412. button?: number;
  116413. /**
  116414. * If available, index of x-axis
  116415. */
  116416. xAxis?: number;
  116417. /**
  116418. * If available, index of y-axis
  116419. */
  116420. yAxis?: number;
  116421. };
  116422. /**
  116423. * The mesh's root node name
  116424. */
  116425. rootNodeName: string;
  116426. /**
  116427. * Animation definitions for this model
  116428. */
  116429. visualResponses: {
  116430. [stateKey: string]: {
  116431. /**
  116432. * What property will be animated
  116433. */
  116434. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116435. /**
  116436. * What states influence this visual reponse
  116437. */
  116438. states: MotionControllerComponentStateType[];
  116439. /**
  116440. * Type of animation - movement or visibility
  116441. */
  116442. valueNodeProperty: "transform" | "visibility";
  116443. /**
  116444. * Base node name to move. Its position will be calculated according to the min and max nodes
  116445. */
  116446. valueNodeName?: string;
  116447. /**
  116448. * Minimum movement node
  116449. */
  116450. minNodeName?: string;
  116451. /**
  116452. * Max movement node
  116453. */
  116454. maxNodeName?: string;
  116455. };
  116456. };
  116457. /**
  116458. * If touch enabled, what is the name of node to display user feedback
  116459. */
  116460. touchPointNodeName?: string;
  116461. };
  116462. };
  116463. /**
  116464. * Is it xr standard mapping or not
  116465. */
  116466. gamepadMapping: "" | "xr-standard";
  116467. /**
  116468. * Base root node of this entire model
  116469. */
  116470. rootNodeName: string;
  116471. /**
  116472. * Path to load the assets. Usually relative to the base path
  116473. */
  116474. assetPath: string;
  116475. }
  116476. /**
  116477. * A definition for the layout map in the input profile
  116478. */
  116479. export interface IMotionControllerLayoutMap {
  116480. /**
  116481. * Layouts with handness type as a key
  116482. */
  116483. [handness: string]: IMotionControllerLayout;
  116484. }
  116485. /**
  116486. * The XR Input profile schema
  116487. * Profiles can be found here:
  116488. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116489. */
  116490. export interface IMotionControllerProfile {
  116491. /**
  116492. * The id of this profile
  116493. * correlates to the profile(s) in the xrInput.profiles array
  116494. */
  116495. profileId: string;
  116496. /**
  116497. * fallback profiles for this profileId
  116498. */
  116499. fallbackProfileIds: string[];
  116500. /**
  116501. * The layout map, with handness as key
  116502. */
  116503. layouts: IMotionControllerLayoutMap;
  116504. }
  116505. /**
  116506. * A helper-interface for the 3 meshes needed for controller button animation
  116507. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116508. */
  116509. export interface IMotionControllerButtonMeshMap {
  116510. /**
  116511. * The mesh that will be changed when value changes
  116512. */
  116513. valueMesh: AbstractMesh;
  116514. /**
  116515. * the mesh that defines the pressed value mesh position.
  116516. * This is used to find the max-position of this button
  116517. */
  116518. pressedMesh: AbstractMesh;
  116519. /**
  116520. * the mesh that defines the unpressed value mesh position.
  116521. * This is used to find the min (or initial) position of this button
  116522. */
  116523. unpressedMesh: AbstractMesh;
  116524. }
  116525. /**
  116526. * A helper-interface for the 3 meshes needed for controller axis animation.
  116527. * This will be expanded when touchpad animations are fully supported
  116528. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116529. */
  116530. export interface IMotionControllerMeshMap {
  116531. /**
  116532. * The mesh that will be changed when axis value changes
  116533. */
  116534. valueMesh: AbstractMesh;
  116535. /**
  116536. * the mesh that defines the minimum value mesh position.
  116537. */
  116538. minMesh?: AbstractMesh;
  116539. /**
  116540. * the mesh that defines the maximum value mesh position.
  116541. */
  116542. maxMesh?: AbstractMesh;
  116543. }
  116544. /**
  116545. * The elements needed for change-detection of the gamepad objects in motion controllers
  116546. */
  116547. export interface IMinimalMotionControllerObject {
  116548. /**
  116549. * An array of available buttons
  116550. */
  116551. buttons: Array<{
  116552. /**
  116553. * Value of the button/trigger
  116554. */
  116555. value: number;
  116556. /**
  116557. * If the button/trigger is currently touched
  116558. */
  116559. touched: boolean;
  116560. /**
  116561. * If the button/trigger is currently pressed
  116562. */
  116563. pressed: boolean;
  116564. }>;
  116565. /**
  116566. * Available axes of this controller
  116567. */
  116568. axes: number[];
  116569. }
  116570. /**
  116571. * An Abstract Motion controller
  116572. * This class receives an xrInput and a profile layout and uses those to initialize the components
  116573. * Each component has an observable to check for changes in value and state
  116574. */
  116575. export abstract class WebXRAbstractMotionController implements IDisposable {
  116576. protected scene: Scene;
  116577. protected layout: IMotionControllerLayout;
  116578. /**
  116579. * The gamepad object correlating to this controller
  116580. */
  116581. gamepadObject: IMinimalMotionControllerObject;
  116582. /**
  116583. * handness (left/right/none) of this controller
  116584. */
  116585. handness: MotionControllerHandness;
  116586. /**
  116587. * The profile id of this motion controller
  116588. */
  116589. abstract profileId: string;
  116590. /**
  116591. * A map of components (WebXRControllerComponent) in this motion controller
  116592. * Components have a ComponentType and can also have both button and axis definitions
  116593. */
  116594. readonly components: {
  116595. [id: string]: WebXRControllerComponent;
  116596. };
  116597. /**
  116598. * Observers registered here will be triggered when the model of this controller is done loading
  116599. */
  116600. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  116601. /**
  116602. * The root mesh of the model. It is null if the model was not yet initialized
  116603. */
  116604. rootMesh: Nullable<AbstractMesh>;
  116605. /**
  116606. * Disable the model's animation. Can be set at any time.
  116607. */
  116608. disableAnimation: boolean;
  116609. private _modelReady;
  116610. /**
  116611. * constructs a new abstract motion controller
  116612. * @param scene the scene to which the model of the controller will be added
  116613. * @param layout The profile layout to load
  116614. * @param gamepadObject The gamepad object correlating to this controller
  116615. * @param handness handness (left/right/none) of this controller
  116616. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  116617. */
  116618. constructor(scene: Scene, layout: IMotionControllerLayout,
  116619. /**
  116620. * The gamepad object correlating to this controller
  116621. */
  116622. gamepadObject: IMinimalMotionControllerObject,
  116623. /**
  116624. * handness (left/right/none) of this controller
  116625. */
  116626. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  116627. private _initComponent;
  116628. /**
  116629. * Update this model using the current XRFrame
  116630. * @param xrFrame the current xr frame to use and update the model
  116631. */
  116632. updateFromXRFrame(xrFrame: XRFrame): void;
  116633. /**
  116634. * Get the list of components available in this motion controller
  116635. * @returns an array of strings correlating to available components
  116636. */
  116637. getComponentIds(): string[];
  116638. /**
  116639. * Get the main (Select) component of this controller as defined in the layout
  116640. * @returns the main component of this controller
  116641. */
  116642. getMainComponent(): WebXRControllerComponent;
  116643. /**
  116644. * get a component based an its component id as defined in layout.components
  116645. * @param id the id of the component
  116646. * @returns the component correlates to the id or undefined if not found
  116647. */
  116648. getComponent(id: string): WebXRControllerComponent;
  116649. /**
  116650. * Get the first component of specific type
  116651. * @param type type of component to find
  116652. * @return a controller component or null if not found
  116653. */
  116654. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  116655. /**
  116656. * Returns all components of specific type
  116657. * @param type the type to search for
  116658. * @return an array of components with this type
  116659. */
  116660. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  116661. /**
  116662. * Loads the model correlating to this controller
  116663. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  116664. * @returns A promise fulfilled with the result of the model loading
  116665. */
  116666. loadModel(): Promise<boolean>;
  116667. /**
  116668. * Update the model itself with the current frame data
  116669. * @param xrFrame the frame to use for updating the model mesh
  116670. */
  116671. protected updateModel(xrFrame: XRFrame): void;
  116672. /**
  116673. * Moves the axis on the controller mesh based on its current state
  116674. * @param axis the index of the axis
  116675. * @param axisValue the value of the axis which determines the meshes new position
  116676. * @hidden
  116677. */
  116678. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  116679. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  116680. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  116681. private _getGenericFilenameAndPath;
  116682. private _getGenericParentMesh;
  116683. /**
  116684. * Get the filename and path for this controller's model
  116685. * @returns a map of filename and path
  116686. */
  116687. protected abstract _getFilenameAndPath(): {
  116688. filename: string;
  116689. path: string;
  116690. };
  116691. /**
  116692. * This function will be called after the model was successfully loaded and can be used
  116693. * for mesh transformations before it is available for the user
  116694. * @param meshes the loaded meshes
  116695. */
  116696. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  116697. /**
  116698. * Set the root mesh for this controller. Important for the WebXR controller class
  116699. * @param meshes the loaded meshes
  116700. */
  116701. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  116702. /**
  116703. * A function executed each frame that updates the mesh (if needed)
  116704. * @param xrFrame the current xrFrame
  116705. */
  116706. protected abstract _updateModel(xrFrame: XRFrame): void;
  116707. /**
  116708. * This function is called before the mesh is loaded. It checks for loading constraints.
  116709. * For example, this function can check if the GLB loader is available
  116710. * If this function returns false, the generic controller will be loaded instead
  116711. * @returns Is the client ready to load the mesh
  116712. */
  116713. protected abstract _getModelLoadingConstraints(): boolean;
  116714. /**
  116715. * Dispose this controller, the model mesh and all its components
  116716. */
  116717. dispose(): void;
  116718. }
  116719. }
  116720. declare module BABYLON {
  116721. /**
  116722. * A generic trigger-only motion controller for WebXR
  116723. */
  116724. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  116725. /**
  116726. * Static version of the profile id of this controller
  116727. */
  116728. static ProfileId: string;
  116729. profileId: string;
  116730. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116731. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  116732. protected _updateModel(): void;
  116733. protected _getFilenameAndPath(): {
  116734. filename: string;
  116735. path: string;
  116736. };
  116737. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116738. protected _getModelLoadingConstraints(): boolean;
  116739. }
  116740. }
  116741. declare module BABYLON {
  116742. /**
  116743. * Class containing static functions to help procedurally build meshes
  116744. */
  116745. export class SphereBuilder {
  116746. /**
  116747. * Creates a sphere mesh
  116748. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116749. * * 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`)
  116750. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116751. * * 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
  116752. * * 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)
  116753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116756. * @param name defines the name of the mesh
  116757. * @param options defines the options used to create the mesh
  116758. * @param scene defines the hosting scene
  116759. * @returns the sphere mesh
  116760. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116761. */
  116762. static CreateSphere(name: string, options: {
  116763. segments?: number;
  116764. diameter?: number;
  116765. diameterX?: number;
  116766. diameterY?: number;
  116767. diameterZ?: number;
  116768. arc?: number;
  116769. slice?: number;
  116770. sideOrientation?: number;
  116771. frontUVs?: Vector4;
  116772. backUVs?: Vector4;
  116773. updatable?: boolean;
  116774. }, scene?: Nullable<Scene>): Mesh;
  116775. }
  116776. }
  116777. declare module BABYLON {
  116778. /**
  116779. * A profiled motion controller has its profile loaded from an online repository.
  116780. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  116781. */
  116782. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  116783. private _repositoryUrl;
  116784. /**
  116785. * The profile ID of this controller. Will be populated when the controller initializes.
  116786. */
  116787. profileId: string;
  116788. private _buttonMeshMapping;
  116789. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  116790. protected _getFilenameAndPath(): {
  116791. filename: string;
  116792. path: string;
  116793. };
  116794. private _touchDots;
  116795. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116796. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116797. protected _updateModel(_xrFrame: XRFrame): void;
  116798. protected _getModelLoadingConstraints(): boolean;
  116799. dispose(): void;
  116800. }
  116801. }
  116802. declare module BABYLON {
  116803. /**
  116804. * A construction function type to create a new controller based on an xrInput object
  116805. */
  116806. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  116807. /**
  116808. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  116809. *
  116810. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  116811. * it should be replaced with auto-loaded controllers.
  116812. *
  116813. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  116814. */
  116815. export class WebXRMotionControllerManager {
  116816. /**
  116817. * The base URL of the online controller repository. Can be changed at any time.
  116818. */
  116819. static BaseRepositoryUrl: string;
  116820. /**
  116821. * Use the online repository, or use only locally-defined controllers
  116822. */
  116823. static UseOnlineRepository: boolean;
  116824. /**
  116825. * Which repository gets priority - local or online
  116826. */
  116827. static PrioritizeOnlineRepository: boolean;
  116828. private static _AvailableControllers;
  116829. private static _Fallbacks;
  116830. /**
  116831. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  116832. *
  116833. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  116834. *
  116835. * @param type the profile type to register
  116836. * @param constructFunction the function to be called when loading this profile
  116837. */
  116838. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  116839. /**
  116840. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  116841. * The order of search:
  116842. *
  116843. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  116844. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  116845. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  116846. * 4) return the generic trigger controller if none were found
  116847. *
  116848. * @param xrInput the xrInput to which a new controller is initialized
  116849. * @param scene the scene to which the model will be added
  116850. * @param forceProfile force a certain profile for this controller
  116851. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  116852. */
  116853. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  116854. private static _LoadProfilesFromAvailableControllers;
  116855. private static _ProfilesList;
  116856. private static _ProfileLoadingPromises;
  116857. private static _LoadProfileFromRepository;
  116858. /**
  116859. * Clear the cache used for profile loading and reload when requested again
  116860. */
  116861. static ClearProfilesCache(): void;
  116862. /**
  116863. * Will update the list of profiles available in the repository
  116864. * @return a promise that resolves to a map of profiles available online
  116865. */
  116866. static UpdateProfilesList(): Promise<{
  116867. [profile: string]: string;
  116868. }>;
  116869. /**
  116870. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  116871. * @param profileId the profile to which a fallback needs to be found
  116872. * @return an array with corresponding fallback profiles
  116873. */
  116874. static FindFallbackWithProfileId(profileId: string): string[];
  116875. /**
  116876. * Register a fallback to a specific profile.
  116877. * @param profileId the profileId that will receive the fallbacks
  116878. * @param fallbacks A list of fallback profiles
  116879. */
  116880. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  116881. /**
  116882. * Register the default fallbacks.
  116883. * This function is called automatically when this file is imported.
  116884. */
  116885. static DefaultFallbacks(): void;
  116886. }
  116887. }
  116888. declare module BABYLON {
  116889. /**
  116890. * Configuration options for the WebXR controller creation
  116891. */
  116892. export interface IWebXRControllerOptions {
  116893. /**
  116894. * Force a specific controller type for this controller.
  116895. * This can be used when creating your own profile or when testing different controllers
  116896. */
  116897. forceControllerProfile?: string;
  116898. /**
  116899. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  116900. */
  116901. doNotLoadControllerMesh?: boolean;
  116902. /**
  116903. * Should the controller mesh be animated when a user interacts with it
  116904. * The pressed buttons / thumbstick and touchpad animations will be disabled
  116905. */
  116906. disableMotionControllerAnimation?: boolean;
  116907. }
  116908. /**
  116909. * Represents an XR controller
  116910. */
  116911. export class WebXRController {
  116912. private _scene;
  116913. /** The underlying input source for the controller */
  116914. inputSource: XRInputSource;
  116915. private _options;
  116916. /**
  116917. * 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
  116918. */
  116919. grip?: AbstractMesh;
  116920. /**
  116921. * Pointer which can be used to select objects or attach a visible laser to
  116922. */
  116923. pointer: AbstractMesh;
  116924. /**
  116925. * If available, this is the gamepad object related to this controller.
  116926. * Using this object it is possible to get click events and trackpad changes of the
  116927. * webxr controller that is currently being used.
  116928. */
  116929. motionController?: WebXRAbstractMotionController;
  116930. /**
  116931. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  116932. */
  116933. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  116934. /**
  116935. * Will be triggered when the mesh associated with the motion controller is done loading.
  116936. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  116937. * A shortened version of controller -> motion controller -> on mesh loaded.
  116938. */
  116939. onMeshLoadedObservable: Observable<AbstractMesh>;
  116940. /**
  116941. * Event that fires when the controller is removed/disposed.
  116942. * The object provided as event data is this controller, after associated assets were disposed.
  116943. * uniqueId is still available.
  116944. */
  116945. onDisposeObservable: Observable<WebXRController>;
  116946. private _tmpQuaternion;
  116947. private _tmpVector;
  116948. private _uniqueId;
  116949. /**
  116950. * Creates the controller
  116951. * @see https://doc.babylonjs.com/how_to/webxr
  116952. * @param _scene the scene which the controller should be associated to
  116953. * @param inputSource the underlying input source for the controller
  116954. * @param _options options for this controller creation
  116955. */
  116956. constructor(_scene: Scene,
  116957. /** The underlying input source for the controller */
  116958. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  116959. /**
  116960. * Get this controllers unique id
  116961. */
  116962. get uniqueId(): string;
  116963. /**
  116964. * Updates the controller pose based on the given XRFrame
  116965. * @param xrFrame xr frame to update the pose with
  116966. * @param referenceSpace reference space to use
  116967. */
  116968. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  116969. /**
  116970. * Gets a world space ray coming from the controller
  116971. * @param result the resulting ray
  116972. */
  116973. getWorldPointerRayToRef(result: Ray): void;
  116974. /**
  116975. * Disposes of the object
  116976. */
  116977. dispose(): void;
  116978. }
  116979. }
  116980. declare module BABYLON {
  116981. /**
  116982. * The schema for initialization options of the XR Input class
  116983. */
  116984. export interface IWebXRInputOptions {
  116985. /**
  116986. * If set to true no model will be automatically loaded
  116987. */
  116988. doNotLoadControllerMeshes?: boolean;
  116989. /**
  116990. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  116991. * If not found, the xr input profile data will be used.
  116992. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  116993. */
  116994. forceInputProfile?: string;
  116995. /**
  116996. * Do not send a request to the controlle repository to load the profile.
  116997. *
  116998. * Instead, use the controllers available in babylon itself.
  116999. */
  117000. disableOnlineControllerRepository?: boolean;
  117001. /**
  117002. * A custom URL for the controllers repository
  117003. */
  117004. customControllersRepositoryURL?: string;
  117005. /**
  117006. * Should the controller model's components not move according to the user input
  117007. */
  117008. disableControllerAnimation?: boolean;
  117009. }
  117010. /**
  117011. * XR input used to track XR inputs such as controllers/rays
  117012. */
  117013. export class WebXRInput implements IDisposable {
  117014. /**
  117015. * the xr session manager for this session
  117016. */
  117017. xrSessionManager: WebXRSessionManager;
  117018. /**
  117019. * the WebXR camera for this session. Mainly used for teleportation
  117020. */
  117021. xrCamera: WebXRCamera;
  117022. private readonly options;
  117023. /**
  117024. * XR controllers being tracked
  117025. */
  117026. controllers: Array<WebXRController>;
  117027. private _frameObserver;
  117028. private _sessionEndedObserver;
  117029. private _sessionInitObserver;
  117030. /**
  117031. * Event when a controller has been connected/added
  117032. */
  117033. onControllerAddedObservable: Observable<WebXRController>;
  117034. /**
  117035. * Event when a controller has been removed/disconnected
  117036. */
  117037. onControllerRemovedObservable: Observable<WebXRController>;
  117038. /**
  117039. * Initializes the WebXRInput
  117040. * @param xrSessionManager the xr session manager for this session
  117041. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117042. * @param options = initialization options for this xr input
  117043. */
  117044. constructor(
  117045. /**
  117046. * the xr session manager for this session
  117047. */
  117048. xrSessionManager: WebXRSessionManager,
  117049. /**
  117050. * the WebXR camera for this session. Mainly used for teleportation
  117051. */
  117052. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117053. private _onInputSourcesChange;
  117054. private _addAndRemoveControllers;
  117055. /**
  117056. * Disposes of the object
  117057. */
  117058. dispose(): void;
  117059. }
  117060. }
  117061. declare module BABYLON {
  117062. /**
  117063. * This is the base class for all WebXR features.
  117064. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117065. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117066. */
  117067. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117068. protected _xrSessionManager: WebXRSessionManager;
  117069. /**
  117070. * Construct a new (abstract) webxr feature
  117071. * @param _xrSessionManager the xr session manager for this feature
  117072. */
  117073. constructor(_xrSessionManager: WebXRSessionManager);
  117074. private _attached;
  117075. private _removeOnDetach;
  117076. /**
  117077. * Is this feature attached
  117078. */
  117079. get attached(): boolean;
  117080. /**
  117081. * Should auto-attach be disabled?
  117082. */
  117083. disableAutoAttach: boolean;
  117084. /**
  117085. * attach this feature
  117086. *
  117087. * @param force should attachment be forced (even when already attached)
  117088. * @returns true if successful, false is failed or already attached
  117089. */
  117090. attach(force?: boolean): boolean;
  117091. /**
  117092. * detach this feature.
  117093. *
  117094. * @returns true if successful, false if failed or already detached
  117095. */
  117096. detach(): boolean;
  117097. /**
  117098. * Dispose this feature and all of the resources attached
  117099. */
  117100. dispose(): void;
  117101. /**
  117102. * Code in this function will be executed on each xrFrame received from the browser.
  117103. * This function will not execute after the feature is detached.
  117104. * @param _xrFrame the current frame
  117105. */
  117106. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117107. /**
  117108. * This is used to register callbacks that will automatically be removed when detach is called.
  117109. * @param observable the observable to which the observer will be attached
  117110. * @param callback the callback to register
  117111. */
  117112. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117113. }
  117114. }
  117115. declare module BABYLON {
  117116. /**
  117117. * Options interface for the pointer selection module
  117118. */
  117119. export interface IWebXRControllerPointerSelectionOptions {
  117120. /**
  117121. * the xr input to use with this pointer selection
  117122. */
  117123. xrInput: WebXRInput;
  117124. /**
  117125. * Different button type to use instead of the main component
  117126. */
  117127. overrideButtonId?: string;
  117128. /**
  117129. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117130. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117131. * 3000 means 3 seconds between pointing at something and selecting it
  117132. */
  117133. timeToSelect?: number;
  117134. /**
  117135. * 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)
  117136. * If not disabled, the last picked point will be used to execute a pointer up event
  117137. * If disabled, pointer up event will be triggered right after the pointer down event.
  117138. * Used in screen and gaze target ray mode only
  117139. */
  117140. disablePointerUpOnTouchOut: boolean;
  117141. /**
  117142. * For gaze mode (time to select instead of press)
  117143. */
  117144. forceGazeMode: boolean;
  117145. /**
  117146. * 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
  117147. * to start a new countdown to the pointer down event.
  117148. * Defaults to 1.
  117149. */
  117150. gazeModePointerMovedFactor?: number;
  117151. }
  117152. /**
  117153. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117154. */
  117155. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117156. private readonly _options;
  117157. /**
  117158. * The module's name
  117159. */
  117160. static readonly Name: string;
  117161. /**
  117162. * The (Babylon) version of this module.
  117163. * This is an integer representing the implementation version.
  117164. * This number does not correspond to the webxr specs version
  117165. */
  117166. static readonly Version: number;
  117167. /**
  117168. * This color will be set to the laser pointer when selection is triggered
  117169. */
  117170. laserPointerPickedColor: Color3;
  117171. /**
  117172. * This color will be applied to the selection ring when selection is triggered
  117173. */
  117174. selectionMeshPickedColor: Color3;
  117175. /**
  117176. * default color of the selection ring
  117177. */
  117178. selectionMeshDefaultColor: Color3;
  117179. /**
  117180. * Default color of the laser pointer
  117181. */
  117182. lasterPointerDefaultColor: Color3;
  117183. /**
  117184. * Should the laser pointer be displayed
  117185. */
  117186. displayLaserPointer: boolean;
  117187. /**
  117188. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117189. */
  117190. displaySelectionMesh: boolean;
  117191. /**
  117192. * Disable lighting on the laser pointer (so it will always be visible)
  117193. */
  117194. disablePointerLighting: boolean;
  117195. /**
  117196. * Disable lighting on the selection mesh (so it will always be visible)
  117197. */
  117198. disableSelectionMeshLighting: boolean;
  117199. private static _idCounter;
  117200. private _tmpRay;
  117201. private _controllers;
  117202. private _scene;
  117203. /**
  117204. * constructs a new background remover module
  117205. * @param _xrSessionManager the session manager for this module
  117206. * @param _options read-only options to be used in this module
  117207. */
  117208. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117209. /**
  117210. * attach this feature
  117211. * Will usually be called by the features manager
  117212. *
  117213. * @returns true if successful.
  117214. */
  117215. attach(): boolean;
  117216. /**
  117217. * detach this feature.
  117218. * Will usually be called by the features manager
  117219. *
  117220. * @returns true if successful.
  117221. */
  117222. detach(): boolean;
  117223. /**
  117224. * Get the xr controller that correlates to the pointer id in the pointer event
  117225. *
  117226. * @param id the pointer id to search for
  117227. * @returns the controller that correlates to this id or null if not found
  117228. */
  117229. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  117230. protected _onXRFrame(_xrFrame: XRFrame): void;
  117231. private _attachController;
  117232. private _attachScreenRayMode;
  117233. private _attachGazeMode;
  117234. private _tmpVectorForPickCompare;
  117235. private _pickingMoved;
  117236. private _attachTrackedPointerRayMode;
  117237. private _detachController;
  117238. private _generateNewMeshPair;
  117239. private _convertNormalToDirectionOfRay;
  117240. private _updatePointerDistance;
  117241. }
  117242. }
  117243. declare module BABYLON {
  117244. /**
  117245. * Button which can be used to enter a different mode of XR
  117246. */
  117247. export class WebXREnterExitUIButton {
  117248. /** button element */
  117249. element: HTMLElement;
  117250. /** XR initialization options for the button */
  117251. sessionMode: XRSessionMode;
  117252. /** Reference space type */
  117253. referenceSpaceType: XRReferenceSpaceType;
  117254. /**
  117255. * Creates a WebXREnterExitUIButton
  117256. * @param element button element
  117257. * @param sessionMode XR initialization session mode
  117258. * @param referenceSpaceType the type of reference space to be used
  117259. */
  117260. constructor(
  117261. /** button element */
  117262. element: HTMLElement,
  117263. /** XR initialization options for the button */
  117264. sessionMode: XRSessionMode,
  117265. /** Reference space type */
  117266. referenceSpaceType: XRReferenceSpaceType);
  117267. /**
  117268. * Overwritable function which can be used to update the button's visuals when the state changes
  117269. * @param activeButton the current active button in the UI
  117270. */
  117271. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117272. }
  117273. /**
  117274. * Options to create the webXR UI
  117275. */
  117276. export class WebXREnterExitUIOptions {
  117277. /**
  117278. * Context to enter xr with
  117279. */
  117280. renderTarget?: Nullable<WebXRRenderTarget>;
  117281. /**
  117282. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117283. */
  117284. customButtons?: Array<WebXREnterExitUIButton>;
  117285. /**
  117286. * A session mode to use when creating the default button.
  117287. * Default is immersive-vr
  117288. */
  117289. sessionMode?: XRSessionMode;
  117290. /**
  117291. * A reference space type to use when creating the default button.
  117292. * Default is local-floor
  117293. */
  117294. referenceSpaceType?: XRReferenceSpaceType;
  117295. }
  117296. /**
  117297. * UI to allow the user to enter/exit XR mode
  117298. */
  117299. export class WebXREnterExitUI implements IDisposable {
  117300. private scene;
  117301. /** version of the options passed to this UI */
  117302. options: WebXREnterExitUIOptions;
  117303. private _overlay;
  117304. private _buttons;
  117305. private _activeButton;
  117306. /**
  117307. * Fired every time the active button is changed.
  117308. *
  117309. * When xr is entered via a button that launches xr that button will be the callback parameter
  117310. *
  117311. * When exiting xr the callback parameter will be null)
  117312. */
  117313. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117314. /**
  117315. * Creates UI to allow the user to enter/exit XR mode
  117316. * @param scene the scene to add the ui to
  117317. * @param helper the xr experience helper to enter/exit xr with
  117318. * @param options options to configure the UI
  117319. * @returns the created ui
  117320. */
  117321. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117322. /**
  117323. *
  117324. * @param scene babylon scene object to use
  117325. * @param options (read-only) version of the options passed to this UI
  117326. */
  117327. private constructor();
  117328. private _updateButtons;
  117329. /**
  117330. * Disposes of the object
  117331. */
  117332. dispose(): void;
  117333. }
  117334. }
  117335. declare module BABYLON {
  117336. /**
  117337. * Class containing static functions to help procedurally build meshes
  117338. */
  117339. export class LinesBuilder {
  117340. /**
  117341. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117342. * * 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
  117343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117344. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117345. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117346. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117347. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117348. * * 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
  117349. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117352. * @param name defines the name of the new line system
  117353. * @param options defines the options used to create the line system
  117354. * @param scene defines the hosting scene
  117355. * @returns a new line system mesh
  117356. */
  117357. static CreateLineSystem(name: string, options: {
  117358. lines: Vector3[][];
  117359. updatable?: boolean;
  117360. instance?: Nullable<LinesMesh>;
  117361. colors?: Nullable<Color4[][]>;
  117362. useVertexAlpha?: boolean;
  117363. }, scene: Nullable<Scene>): LinesMesh;
  117364. /**
  117365. * Creates a line mesh
  117366. * 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
  117367. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117368. * * The parameter `points` is an array successive Vector3
  117369. * * 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
  117370. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117371. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117372. * * When updating an instance, remember that only point positions can change, not the number of points
  117373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117375. * @param name defines the name of the new line system
  117376. * @param options defines the options used to create the line system
  117377. * @param scene defines the hosting scene
  117378. * @returns a new line mesh
  117379. */
  117380. static CreateLines(name: string, options: {
  117381. points: Vector3[];
  117382. updatable?: boolean;
  117383. instance?: Nullable<LinesMesh>;
  117384. colors?: Color4[];
  117385. useVertexAlpha?: boolean;
  117386. }, scene?: Nullable<Scene>): LinesMesh;
  117387. /**
  117388. * Creates a dashed line mesh
  117389. * * 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
  117390. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117391. * * The parameter `points` is an array successive Vector3
  117392. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117393. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117394. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117395. * * 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
  117396. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117397. * * When updating an instance, remember that only point positions can change, not the number of points
  117398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117399. * @param name defines the name of the mesh
  117400. * @param options defines the options used to create the mesh
  117401. * @param scene defines the hosting scene
  117402. * @returns the dashed line mesh
  117403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117404. */
  117405. static CreateDashedLines(name: string, options: {
  117406. points: Vector3[];
  117407. dashSize?: number;
  117408. gapSize?: number;
  117409. dashNb?: number;
  117410. updatable?: boolean;
  117411. instance?: LinesMesh;
  117412. useVertexAlpha?: boolean;
  117413. }, scene?: Nullable<Scene>): LinesMesh;
  117414. }
  117415. }
  117416. declare module BABYLON {
  117417. /**
  117418. * The options container for the teleportation module
  117419. */
  117420. export interface IWebXRTeleportationOptions {
  117421. /**
  117422. * Babylon XR Input class for controller
  117423. */
  117424. xrInput: WebXRInput;
  117425. /**
  117426. * A list of meshes to use as floor meshes.
  117427. * Meshes can be added and removed after initializing the feature using the
  117428. * addFloorMesh and removeFloorMesh functions
  117429. * If empty, rotation will still work
  117430. */
  117431. floorMeshes?: AbstractMesh[];
  117432. /**
  117433. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  117434. * If you want to support rotation, make sure your mesh has a direction indicator.
  117435. *
  117436. * When left untouched, the default mesh will be initialized.
  117437. */
  117438. teleportationTargetMesh?: AbstractMesh;
  117439. /**
  117440. * Values to configure the default target mesh
  117441. */
  117442. defaultTargetMeshOptions?: {
  117443. /**
  117444. * Fill color of the teleportation area
  117445. */
  117446. teleportationFillColor?: string;
  117447. /**
  117448. * Border color for the teleportation area
  117449. */
  117450. teleportationBorderColor?: string;
  117451. /**
  117452. * Disable the mesh's animation sequence
  117453. */
  117454. disableAnimation?: boolean;
  117455. /**
  117456. * Disable lighting on the material or the ring and arrow
  117457. */
  117458. disableLighting?: boolean;
  117459. /**
  117460. * Override the default material of the torus and arrow
  117461. */
  117462. torusArrowMaterial?: Material;
  117463. };
  117464. /**
  117465. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  117466. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  117467. */
  117468. useMainComponentOnly?: boolean;
  117469. /**
  117470. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  117471. */
  117472. timeToTeleport?: number;
  117473. }
  117474. /**
  117475. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  117476. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  117477. * the input of the attached controllers.
  117478. */
  117479. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  117480. private _options;
  117481. /**
  117482. * The module's name
  117483. */
  117484. static readonly Name: string;
  117485. /**
  117486. * The (Babylon) version of this module.
  117487. * This is an integer representing the implementation version.
  117488. * This number does not correspond to the webxr specs version
  117489. */
  117490. static readonly Version: number;
  117491. /**
  117492. * Is rotation enabled when moving forward?
  117493. * Disabling this feature will prevent the user from deciding the direction when teleporting
  117494. */
  117495. rotationEnabled: boolean;
  117496. /**
  117497. * Should the module support parabolic ray on top of direct ray
  117498. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  117499. * Very helpful when moving between floors / different heights
  117500. */
  117501. parabolicRayEnabled: boolean;
  117502. /**
  117503. * The distance from the user to the inspection point in the direction of the controller
  117504. * A higher number will allow the user to move further
  117505. * defaults to 5 (meters, in xr units)
  117506. */
  117507. parabolicCheckRadius: number;
  117508. /**
  117509. * How much rotation should be applied when rotating right and left
  117510. */
  117511. rotationAngle: number;
  117512. /**
  117513. * Is movement backwards enabled
  117514. */
  117515. backwardsMovementEnabled: boolean;
  117516. /**
  117517. * Distance to travel when moving backwards
  117518. */
  117519. backwardsTeleportationDistance: number;
  117520. /**
  117521. * Add a new mesh to the floor meshes array
  117522. * @param mesh the mesh to use as floor mesh
  117523. */
  117524. addFloorMesh(mesh: AbstractMesh): void;
  117525. /**
  117526. * Remove a mesh from the floor meshes array
  117527. * @param mesh the mesh to remove
  117528. */
  117529. removeFloorMesh(mesh: AbstractMesh): void;
  117530. /**
  117531. * Remove a mesh from the floor meshes array using its name
  117532. * @param name the mesh name to remove
  117533. */
  117534. removeFloorMeshByName(name: string): void;
  117535. private _tmpRay;
  117536. private _tmpVector;
  117537. private _floorMeshes;
  117538. private _controllers;
  117539. /**
  117540. * constructs a new anchor system
  117541. * @param _xrSessionManager an instance of WebXRSessionManager
  117542. * @param _options configuration object for this feature
  117543. */
  117544. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  117545. private _selectionFeature;
  117546. /**
  117547. * This function sets a selection feature that will be disabled when
  117548. * the forward ray is shown and will be reattached when hidden.
  117549. * This is used to remove the selection rays when moving.
  117550. * @param selectionFeature the feature to disable when forward movement is enabled
  117551. */
  117552. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  117553. attach(): boolean;
  117554. detach(): boolean;
  117555. dispose(): void;
  117556. protected _onXRFrame(_xrFrame: XRFrame): void;
  117557. private _currentTeleportationControllerId;
  117558. private _attachController;
  117559. private _teleportForward;
  117560. private _detachController;
  117561. private createDefaultTargetMesh;
  117562. private setTargetMeshVisibility;
  117563. private setTargetMeshPosition;
  117564. private _quadraticBezierCurve;
  117565. private _showParabolicPath;
  117566. }
  117567. }
  117568. declare module BABYLON {
  117569. /**
  117570. * Options for the default xr helper
  117571. */
  117572. export class WebXRDefaultExperienceOptions {
  117573. /**
  117574. * Floor meshes that will be used for teleporting
  117575. */
  117576. floorMeshes?: Array<AbstractMesh>;
  117577. /**
  117578. * Enable or disable default UI to enter XR
  117579. */
  117580. disableDefaultUI?: boolean;
  117581. /**
  117582. * optional configuration for the output canvas
  117583. */
  117584. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  117585. /**
  117586. * optional UI options. This can be used among other to change session mode and reference space type
  117587. */
  117588. uiOptions?: WebXREnterExitUIOptions;
  117589. /**
  117590. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  117591. */
  117592. inputOptions?: IWebXRInputOptions;
  117593. /**
  117594. * Should teleportation not initialize. defaults to false.
  117595. */
  117596. disableTeleportation?: boolean;
  117597. /**
  117598. * If set to true, the first frame will not be used to reset position
  117599. * The first frame is mainly used when copying transformation from the old camera
  117600. * Mainly used in AR
  117601. */
  117602. ignoreNativeCameraTransformation?: boolean;
  117603. /**
  117604. * When loading teleportation and pointer select, use stable versions instead of latest.
  117605. */
  117606. useStablePlugins?: boolean;
  117607. }
  117608. /**
  117609. * Default experience which provides a similar setup to the previous webVRExperience
  117610. */
  117611. export class WebXRDefaultExperience {
  117612. /**
  117613. * Base experience
  117614. */
  117615. baseExperience: WebXRExperienceHelper;
  117616. /**
  117617. * Input experience extension
  117618. */
  117619. input: WebXRInput;
  117620. /**
  117621. * Enables laser pointer and selection
  117622. */
  117623. pointerSelection: WebXRControllerPointerSelection;
  117624. /**
  117625. * Enables teleportation
  117626. */
  117627. teleportation: WebXRMotionControllerTeleportation;
  117628. /**
  117629. * Enables ui for entering/exiting xr
  117630. */
  117631. enterExitUI: WebXREnterExitUI;
  117632. /**
  117633. * Default target xr should render to
  117634. */
  117635. renderTarget: WebXRRenderTarget;
  117636. /**
  117637. * Creates the default xr experience
  117638. * @param scene scene
  117639. * @param options options for basic configuration
  117640. * @returns resulting WebXRDefaultExperience
  117641. */
  117642. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117643. private constructor();
  117644. /**
  117645. * DIsposes of the experience helper
  117646. */
  117647. dispose(): void;
  117648. }
  117649. }
  117650. declare module BABYLON {
  117651. /**
  117652. * Options to modify the vr teleportation behavior.
  117653. */
  117654. export interface VRTeleportationOptions {
  117655. /**
  117656. * The name of the mesh which should be used as the teleportation floor. (default: null)
  117657. */
  117658. floorMeshName?: string;
  117659. /**
  117660. * A list of meshes to be used as the teleportation floor. (default: empty)
  117661. */
  117662. floorMeshes?: Mesh[];
  117663. /**
  117664. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  117665. */
  117666. teleportationMode?: number;
  117667. /**
  117668. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  117669. */
  117670. teleportationTime?: number;
  117671. /**
  117672. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  117673. */
  117674. teleportationSpeed?: number;
  117675. /**
  117676. * The easing function used in the animation or null for Linear. (default CircleEase)
  117677. */
  117678. easingFunction?: EasingFunction;
  117679. }
  117680. /**
  117681. * Options to modify the vr experience helper's behavior.
  117682. */
  117683. export interface VRExperienceHelperOptions extends WebVROptions {
  117684. /**
  117685. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  117686. */
  117687. createDeviceOrientationCamera?: boolean;
  117688. /**
  117689. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  117690. */
  117691. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  117692. /**
  117693. * Uses the main button on the controller to toggle the laser casted. (default: true)
  117694. */
  117695. laserToggle?: boolean;
  117696. /**
  117697. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  117698. */
  117699. floorMeshes?: Mesh[];
  117700. /**
  117701. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  117702. */
  117703. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  117704. /**
  117705. * Defines if WebXR should be used instead of WebVR (if available)
  117706. */
  117707. useXR?: boolean;
  117708. }
  117709. /**
  117710. * Event containing information after VR has been entered
  117711. */
  117712. export class OnAfterEnteringVRObservableEvent {
  117713. /**
  117714. * If entering vr was successful
  117715. */
  117716. success: boolean;
  117717. }
  117718. /**
  117719. * Helps to quickly add VR support to an existing scene.
  117720. * See http://doc.babylonjs.com/how_to/webvr_helper
  117721. */
  117722. export class VRExperienceHelper {
  117723. /** Options to modify the vr experience helper's behavior. */
  117724. webVROptions: VRExperienceHelperOptions;
  117725. private _scene;
  117726. private _position;
  117727. private _btnVR;
  117728. private _btnVRDisplayed;
  117729. private _webVRsupported;
  117730. private _webVRready;
  117731. private _webVRrequesting;
  117732. private _webVRpresenting;
  117733. private _hasEnteredVR;
  117734. private _fullscreenVRpresenting;
  117735. private _inputElement;
  117736. private _webVRCamera;
  117737. private _vrDeviceOrientationCamera;
  117738. private _deviceOrientationCamera;
  117739. private _existingCamera;
  117740. private _onKeyDown;
  117741. private _onVrDisplayPresentChange;
  117742. private _onVRDisplayChanged;
  117743. private _onVRRequestPresentStart;
  117744. private _onVRRequestPresentComplete;
  117745. /**
  117746. * 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)
  117747. */
  117748. enableGazeEvenWhenNoPointerLock: boolean;
  117749. /**
  117750. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  117751. */
  117752. exitVROnDoubleTap: boolean;
  117753. /**
  117754. * Observable raised right before entering VR.
  117755. */
  117756. onEnteringVRObservable: Observable<VRExperienceHelper>;
  117757. /**
  117758. * Observable raised when entering VR has completed.
  117759. */
  117760. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  117761. /**
  117762. * Observable raised when exiting VR.
  117763. */
  117764. onExitingVRObservable: Observable<VRExperienceHelper>;
  117765. /**
  117766. * Observable raised when controller mesh is loaded.
  117767. */
  117768. onControllerMeshLoadedObservable: Observable<WebVRController>;
  117769. /** Return this.onEnteringVRObservable
  117770. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  117771. */
  117772. get onEnteringVR(): Observable<VRExperienceHelper>;
  117773. /** Return this.onExitingVRObservable
  117774. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  117775. */
  117776. get onExitingVR(): Observable<VRExperienceHelper>;
  117777. /** Return this.onControllerMeshLoadedObservable
  117778. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  117779. */
  117780. get onControllerMeshLoaded(): Observable<WebVRController>;
  117781. private _rayLength;
  117782. private _useCustomVRButton;
  117783. private _teleportationRequested;
  117784. private _teleportActive;
  117785. private _floorMeshName;
  117786. private _floorMeshesCollection;
  117787. private _teleportationMode;
  117788. private _teleportationTime;
  117789. private _teleportationSpeed;
  117790. private _teleportationEasing;
  117791. private _rotationAllowed;
  117792. private _teleportBackwardsVector;
  117793. private _teleportationTarget;
  117794. private _isDefaultTeleportationTarget;
  117795. private _postProcessMove;
  117796. private _teleportationFillColor;
  117797. private _teleportationBorderColor;
  117798. private _rotationAngle;
  117799. private _haloCenter;
  117800. private _cameraGazer;
  117801. private _padSensibilityUp;
  117802. private _padSensibilityDown;
  117803. private _leftController;
  117804. private _rightController;
  117805. private _gazeColor;
  117806. private _laserColor;
  117807. private _pickedLaserColor;
  117808. private _pickedGazeColor;
  117809. /**
  117810. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  117811. */
  117812. onNewMeshSelected: Observable<AbstractMesh>;
  117813. /**
  117814. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  117815. * This observable will provide the mesh and the controller used to select the mesh
  117816. */
  117817. onMeshSelectedWithController: Observable<{
  117818. mesh: AbstractMesh;
  117819. controller: WebVRController;
  117820. }>;
  117821. /**
  117822. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  117823. */
  117824. onNewMeshPicked: Observable<PickingInfo>;
  117825. private _circleEase;
  117826. /**
  117827. * Observable raised before camera teleportation
  117828. */
  117829. onBeforeCameraTeleport: Observable<Vector3>;
  117830. /**
  117831. * Observable raised after camera teleportation
  117832. */
  117833. onAfterCameraTeleport: Observable<Vector3>;
  117834. /**
  117835. * Observable raised when current selected mesh gets unselected
  117836. */
  117837. onSelectedMeshUnselected: Observable<AbstractMesh>;
  117838. private _raySelectionPredicate;
  117839. /**
  117840. * To be optionaly changed by user to define custom ray selection
  117841. */
  117842. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  117843. /**
  117844. * To be optionaly changed by user to define custom selection logic (after ray selection)
  117845. */
  117846. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117847. /**
  117848. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  117849. */
  117850. teleportationEnabled: boolean;
  117851. private _defaultHeight;
  117852. private _teleportationInitialized;
  117853. private _interactionsEnabled;
  117854. private _interactionsRequested;
  117855. private _displayGaze;
  117856. private _displayLaserPointer;
  117857. /**
  117858. * The mesh used to display where the user is going to teleport.
  117859. */
  117860. get teleportationTarget(): Mesh;
  117861. /**
  117862. * Sets the mesh to be used to display where the user is going to teleport.
  117863. */
  117864. set teleportationTarget(value: Mesh);
  117865. /**
  117866. * 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
  117867. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  117868. * See http://doc.babylonjs.com/resources/baking_transformations
  117869. */
  117870. get gazeTrackerMesh(): Mesh;
  117871. set gazeTrackerMesh(value: Mesh);
  117872. /**
  117873. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  117874. */
  117875. updateGazeTrackerScale: boolean;
  117876. /**
  117877. * If the gaze trackers color should be updated when selecting meshes
  117878. */
  117879. updateGazeTrackerColor: boolean;
  117880. /**
  117881. * If the controller laser color should be updated when selecting meshes
  117882. */
  117883. updateControllerLaserColor: boolean;
  117884. /**
  117885. * The gaze tracking mesh corresponding to the left controller
  117886. */
  117887. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  117888. /**
  117889. * The gaze tracking mesh corresponding to the right controller
  117890. */
  117891. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  117892. /**
  117893. * If the ray of the gaze should be displayed.
  117894. */
  117895. get displayGaze(): boolean;
  117896. /**
  117897. * Sets if the ray of the gaze should be displayed.
  117898. */
  117899. set displayGaze(value: boolean);
  117900. /**
  117901. * If the ray of the LaserPointer should be displayed.
  117902. */
  117903. get displayLaserPointer(): boolean;
  117904. /**
  117905. * Sets if the ray of the LaserPointer should be displayed.
  117906. */
  117907. set displayLaserPointer(value: boolean);
  117908. /**
  117909. * The deviceOrientationCamera used as the camera when not in VR.
  117910. */
  117911. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  117912. /**
  117913. * Based on the current WebVR support, returns the current VR camera used.
  117914. */
  117915. get currentVRCamera(): Nullable<Camera>;
  117916. /**
  117917. * The webVRCamera which is used when in VR.
  117918. */
  117919. get webVRCamera(): WebVRFreeCamera;
  117920. /**
  117921. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  117922. */
  117923. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  117924. /**
  117925. * The html button that is used to trigger entering into VR.
  117926. */
  117927. get vrButton(): Nullable<HTMLButtonElement>;
  117928. private get _teleportationRequestInitiated();
  117929. /**
  117930. * Defines whether or not Pointer lock should be requested when switching to
  117931. * full screen.
  117932. */
  117933. requestPointerLockOnFullScreen: boolean;
  117934. /**
  117935. * If asking to force XR, this will be populated with the default xr experience
  117936. */
  117937. xr: WebXRDefaultExperience;
  117938. /**
  117939. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  117940. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  117941. */
  117942. xrTestDone: boolean;
  117943. /**
  117944. * Instantiates a VRExperienceHelper.
  117945. * Helps to quickly add VR support to an existing scene.
  117946. * @param scene The scene the VRExperienceHelper belongs to.
  117947. * @param webVROptions Options to modify the vr experience helper's behavior.
  117948. */
  117949. constructor(scene: Scene,
  117950. /** Options to modify the vr experience helper's behavior. */
  117951. webVROptions?: VRExperienceHelperOptions);
  117952. private completeVRInit;
  117953. private _onDefaultMeshLoaded;
  117954. private _onResize;
  117955. private _onFullscreenChange;
  117956. /**
  117957. * Gets a value indicating if we are currently in VR mode.
  117958. */
  117959. get isInVRMode(): boolean;
  117960. private onVrDisplayPresentChange;
  117961. private onVRDisplayChanged;
  117962. private moveButtonToBottomRight;
  117963. private displayVRButton;
  117964. private updateButtonVisibility;
  117965. private _cachedAngularSensibility;
  117966. /**
  117967. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  117968. * Otherwise, will use the fullscreen API.
  117969. */
  117970. enterVR(): void;
  117971. /**
  117972. * Attempt to exit VR, or fullscreen.
  117973. */
  117974. exitVR(): void;
  117975. /**
  117976. * The position of the vr experience helper.
  117977. */
  117978. get position(): Vector3;
  117979. /**
  117980. * Sets the position of the vr experience helper.
  117981. */
  117982. set position(value: Vector3);
  117983. /**
  117984. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  117985. */
  117986. enableInteractions(): void;
  117987. private get _noControllerIsActive();
  117988. private beforeRender;
  117989. private _isTeleportationFloor;
  117990. /**
  117991. * Adds a floor mesh to be used for teleportation.
  117992. * @param floorMesh the mesh to be used for teleportation.
  117993. */
  117994. addFloorMesh(floorMesh: Mesh): void;
  117995. /**
  117996. * Removes a floor mesh from being used for teleportation.
  117997. * @param floorMesh the mesh to be removed.
  117998. */
  117999. removeFloorMesh(floorMesh: Mesh): void;
  118000. /**
  118001. * Enables interactions and teleportation using the VR controllers and gaze.
  118002. * @param vrTeleportationOptions options to modify teleportation behavior.
  118003. */
  118004. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118005. private _onNewGamepadConnected;
  118006. private _tryEnableInteractionOnController;
  118007. private _onNewGamepadDisconnected;
  118008. private _enableInteractionOnController;
  118009. private _checkTeleportWithRay;
  118010. private _checkRotate;
  118011. private _checkTeleportBackwards;
  118012. private _enableTeleportationOnController;
  118013. private _createTeleportationCircles;
  118014. private _displayTeleportationTarget;
  118015. private _hideTeleportationTarget;
  118016. private _rotateCamera;
  118017. private _moveTeleportationSelectorTo;
  118018. private _workingVector;
  118019. private _workingQuaternion;
  118020. private _workingMatrix;
  118021. /**
  118022. * Time Constant Teleportation Mode
  118023. */
  118024. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118025. /**
  118026. * Speed Constant Teleportation Mode
  118027. */
  118028. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118029. /**
  118030. * Teleports the users feet to the desired location
  118031. * @param location The location where the user's feet should be placed
  118032. */
  118033. teleportCamera(location: Vector3): void;
  118034. private _convertNormalToDirectionOfRay;
  118035. private _castRayAndSelectObject;
  118036. private _notifySelectedMeshUnselected;
  118037. /**
  118038. * Permanently set new colors for the laser pointer
  118039. * @param color the new laser color
  118040. * @param pickedColor the new laser color when picked mesh detected
  118041. */
  118042. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118043. /**
  118044. * Set lighting enabled / disabled on the laser pointer of both controllers
  118045. * @param enabled should the lighting be enabled on the laser pointer
  118046. */
  118047. setLaserLightingState(enabled?: boolean): void;
  118048. /**
  118049. * Permanently set new colors for the gaze pointer
  118050. * @param color the new gaze color
  118051. * @param pickedColor the new gaze color when picked mesh detected
  118052. */
  118053. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118054. /**
  118055. * Sets the color of the laser ray from the vr controllers.
  118056. * @param color new color for the ray.
  118057. */
  118058. changeLaserColor(color: Color3): void;
  118059. /**
  118060. * Sets the color of the ray from the vr headsets gaze.
  118061. * @param color new color for the ray.
  118062. */
  118063. changeGazeColor(color: Color3): void;
  118064. /**
  118065. * Exits VR and disposes of the vr experience helper
  118066. */
  118067. dispose(): void;
  118068. /**
  118069. * Gets the name of the VRExperienceHelper class
  118070. * @returns "VRExperienceHelper"
  118071. */
  118072. getClassName(): string;
  118073. }
  118074. }
  118075. declare module BABYLON {
  118076. /**
  118077. * Contains an array of blocks representing the octree
  118078. */
  118079. export interface IOctreeContainer<T> {
  118080. /**
  118081. * Blocks within the octree
  118082. */
  118083. blocks: Array<OctreeBlock<T>>;
  118084. }
  118085. /**
  118086. * Class used to store a cell in an octree
  118087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118088. */
  118089. export class OctreeBlock<T> {
  118090. /**
  118091. * Gets the content of the current block
  118092. */
  118093. entries: T[];
  118094. /**
  118095. * Gets the list of block children
  118096. */
  118097. blocks: Array<OctreeBlock<T>>;
  118098. private _depth;
  118099. private _maxDepth;
  118100. private _capacity;
  118101. private _minPoint;
  118102. private _maxPoint;
  118103. private _boundingVectors;
  118104. private _creationFunc;
  118105. /**
  118106. * Creates a new block
  118107. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118108. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118109. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118110. * @param depth defines the current depth of this block in the octree
  118111. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118112. * @param creationFunc defines a callback to call when an element is added to the block
  118113. */
  118114. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118115. /**
  118116. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118117. */
  118118. get capacity(): number;
  118119. /**
  118120. * Gets the minimum vector (in world space) of the block's bounding box
  118121. */
  118122. get minPoint(): Vector3;
  118123. /**
  118124. * Gets the maximum vector (in world space) of the block's bounding box
  118125. */
  118126. get maxPoint(): Vector3;
  118127. /**
  118128. * Add a new element to this block
  118129. * @param entry defines the element to add
  118130. */
  118131. addEntry(entry: T): void;
  118132. /**
  118133. * Remove an element from this block
  118134. * @param entry defines the element to remove
  118135. */
  118136. removeEntry(entry: T): void;
  118137. /**
  118138. * Add an array of elements to this block
  118139. * @param entries defines the array of elements to add
  118140. */
  118141. addEntries(entries: T[]): void;
  118142. /**
  118143. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118144. * @param frustumPlanes defines the frustum planes to test
  118145. * @param selection defines the array to store current content if selection is positive
  118146. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118147. */
  118148. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118149. /**
  118150. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118151. * @param sphereCenter defines the bounding sphere center
  118152. * @param sphereRadius defines the bounding sphere radius
  118153. * @param selection defines the array to store current content if selection is positive
  118154. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118155. */
  118156. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118157. /**
  118158. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118159. * @param ray defines the ray to test with
  118160. * @param selection defines the array to store current content if selection is positive
  118161. */
  118162. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118163. /**
  118164. * Subdivide the content into child blocks (this block will then be empty)
  118165. */
  118166. createInnerBlocks(): void;
  118167. /**
  118168. * @hidden
  118169. */
  118170. 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;
  118171. }
  118172. }
  118173. declare module BABYLON {
  118174. /**
  118175. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118177. */
  118178. export class Octree<T> {
  118179. /** 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.) */
  118180. maxDepth: number;
  118181. /**
  118182. * Blocks within the octree containing objects
  118183. */
  118184. blocks: Array<OctreeBlock<T>>;
  118185. /**
  118186. * Content stored in the octree
  118187. */
  118188. dynamicContent: T[];
  118189. private _maxBlockCapacity;
  118190. private _selectionContent;
  118191. private _creationFunc;
  118192. /**
  118193. * Creates a octree
  118194. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118195. * @param creationFunc function to be used to instatiate the octree
  118196. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118197. * @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.)
  118198. */
  118199. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118200. /** 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.) */
  118201. maxDepth?: number);
  118202. /**
  118203. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118204. * @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);
  118205. * @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);
  118206. * @param entries meshes to be added to the octree blocks
  118207. */
  118208. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118209. /**
  118210. * Adds a mesh to the octree
  118211. * @param entry Mesh to add to the octree
  118212. */
  118213. addMesh(entry: T): void;
  118214. /**
  118215. * Remove an element from the octree
  118216. * @param entry defines the element to remove
  118217. */
  118218. removeMesh(entry: T): void;
  118219. /**
  118220. * Selects an array of meshes within the frustum
  118221. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118222. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118223. * @returns array of meshes within the frustum
  118224. */
  118225. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118226. /**
  118227. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118228. * @param sphereCenter defines the bounding sphere center
  118229. * @param sphereRadius defines the bounding sphere radius
  118230. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118231. * @returns an array of objects that intersect the sphere
  118232. */
  118233. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118234. /**
  118235. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118236. * @param ray defines the ray to test with
  118237. * @returns array of intersected objects
  118238. */
  118239. intersectsRay(ray: Ray): SmartArray<T>;
  118240. /**
  118241. * Adds a mesh into the octree block if it intersects the block
  118242. */
  118243. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118244. /**
  118245. * Adds a submesh into the octree block if it intersects the block
  118246. */
  118247. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118248. }
  118249. }
  118250. declare module BABYLON {
  118251. interface Scene {
  118252. /**
  118253. * @hidden
  118254. * Backing Filed
  118255. */
  118256. _selectionOctree: Octree<AbstractMesh>;
  118257. /**
  118258. * Gets the octree used to boost mesh selection (picking)
  118259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118260. */
  118261. selectionOctree: Octree<AbstractMesh>;
  118262. /**
  118263. * Creates or updates the octree used to boost selection (picking)
  118264. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118265. * @param maxCapacity defines the maximum capacity per leaf
  118266. * @param maxDepth defines the maximum depth of the octree
  118267. * @returns an octree of AbstractMesh
  118268. */
  118269. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118270. }
  118271. interface AbstractMesh {
  118272. /**
  118273. * @hidden
  118274. * Backing Field
  118275. */
  118276. _submeshesOctree: Octree<SubMesh>;
  118277. /**
  118278. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118279. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118280. * @param maxCapacity defines the maximum size of each block (64 by default)
  118281. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118282. * @returns the new octree
  118283. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118284. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118285. */
  118286. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118287. }
  118288. /**
  118289. * Defines the octree scene component responsible to manage any octrees
  118290. * in a given scene.
  118291. */
  118292. export class OctreeSceneComponent {
  118293. /**
  118294. * The component name help to identify the component in the list of scene components.
  118295. */
  118296. readonly name: string;
  118297. /**
  118298. * The scene the component belongs to.
  118299. */
  118300. scene: Scene;
  118301. /**
  118302. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118303. */
  118304. readonly checksIsEnabled: boolean;
  118305. /**
  118306. * Creates a new instance of the component for the given scene
  118307. * @param scene Defines the scene to register the component in
  118308. */
  118309. constructor(scene: Scene);
  118310. /**
  118311. * Registers the component in a given scene
  118312. */
  118313. register(): void;
  118314. /**
  118315. * Return the list of active meshes
  118316. * @returns the list of active meshes
  118317. */
  118318. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118319. /**
  118320. * Return the list of active sub meshes
  118321. * @param mesh The mesh to get the candidates sub meshes from
  118322. * @returns the list of active sub meshes
  118323. */
  118324. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118325. private _tempRay;
  118326. /**
  118327. * Return the list of sub meshes intersecting with a given local ray
  118328. * @param mesh defines the mesh to find the submesh for
  118329. * @param localRay defines the ray in local space
  118330. * @returns the list of intersecting sub meshes
  118331. */
  118332. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118333. /**
  118334. * Return the list of sub meshes colliding with a collider
  118335. * @param mesh defines the mesh to find the submesh for
  118336. * @param collider defines the collider to evaluate the collision against
  118337. * @returns the list of colliding sub meshes
  118338. */
  118339. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118340. /**
  118341. * Rebuilds the elements related to this component in case of
  118342. * context lost for instance.
  118343. */
  118344. rebuild(): void;
  118345. /**
  118346. * Disposes the component and the associated ressources.
  118347. */
  118348. dispose(): void;
  118349. }
  118350. }
  118351. declare module BABYLON {
  118352. /**
  118353. * Renders a layer on top of an existing scene
  118354. */
  118355. export class UtilityLayerRenderer implements IDisposable {
  118356. /** the original scene that will be rendered on top of */
  118357. originalScene: Scene;
  118358. private _pointerCaptures;
  118359. private _lastPointerEvents;
  118360. private static _DefaultUtilityLayer;
  118361. private static _DefaultKeepDepthUtilityLayer;
  118362. private _sharedGizmoLight;
  118363. private _renderCamera;
  118364. /**
  118365. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118366. * @returns the camera that is used when rendering the utility layer
  118367. */
  118368. getRenderCamera(): Camera;
  118369. /**
  118370. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118371. * @param cam the camera that should be used when rendering the utility layer
  118372. */
  118373. setRenderCamera(cam: Nullable<Camera>): void;
  118374. /**
  118375. * @hidden
  118376. * Light which used by gizmos to get light shading
  118377. */
  118378. _getSharedGizmoLight(): HemisphericLight;
  118379. /**
  118380. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118381. */
  118382. pickUtilitySceneFirst: boolean;
  118383. /**
  118384. * 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)
  118385. */
  118386. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118387. /**
  118388. * 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)
  118389. */
  118390. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118391. /**
  118392. * The scene that is rendered on top of the original scene
  118393. */
  118394. utilityLayerScene: Scene;
  118395. /**
  118396. * If the utility layer should automatically be rendered on top of existing scene
  118397. */
  118398. shouldRender: boolean;
  118399. /**
  118400. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118401. */
  118402. onlyCheckPointerDownEvents: boolean;
  118403. /**
  118404. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118405. */
  118406. processAllEvents: boolean;
  118407. /**
  118408. * Observable raised when the pointer move from the utility layer scene to the main scene
  118409. */
  118410. onPointerOutObservable: Observable<number>;
  118411. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118412. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118413. private _afterRenderObserver;
  118414. private _sceneDisposeObserver;
  118415. private _originalPointerObserver;
  118416. /**
  118417. * Instantiates a UtilityLayerRenderer
  118418. * @param originalScene the original scene that will be rendered on top of
  118419. * @param handleEvents boolean indicating if the utility layer should handle events
  118420. */
  118421. constructor(
  118422. /** the original scene that will be rendered on top of */
  118423. originalScene: Scene, handleEvents?: boolean);
  118424. private _notifyObservers;
  118425. /**
  118426. * Renders the utility layers scene on top of the original scene
  118427. */
  118428. render(): void;
  118429. /**
  118430. * Disposes of the renderer
  118431. */
  118432. dispose(): void;
  118433. private _updateCamera;
  118434. }
  118435. }
  118436. declare module BABYLON {
  118437. /**
  118438. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118439. */
  118440. export class Gizmo implements IDisposable {
  118441. /** The utility layer the gizmo will be added to */
  118442. gizmoLayer: UtilityLayerRenderer;
  118443. /**
  118444. * The root mesh of the gizmo
  118445. */
  118446. _rootMesh: Mesh;
  118447. private _attachedMesh;
  118448. /**
  118449. * Ratio for the scale of the gizmo (Default: 1)
  118450. */
  118451. scaleRatio: number;
  118452. /**
  118453. * If a custom mesh has been set (Default: false)
  118454. */
  118455. protected _customMeshSet: boolean;
  118456. /**
  118457. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118458. * * When set, interactions will be enabled
  118459. */
  118460. get attachedMesh(): Nullable<AbstractMesh>;
  118461. set attachedMesh(value: Nullable<AbstractMesh>);
  118462. /**
  118463. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118464. * @param mesh The mesh to replace the default mesh of the gizmo
  118465. */
  118466. setCustomMesh(mesh: Mesh): void;
  118467. /**
  118468. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118469. */
  118470. updateGizmoRotationToMatchAttachedMesh: boolean;
  118471. /**
  118472. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118473. */
  118474. updateGizmoPositionToMatchAttachedMesh: boolean;
  118475. /**
  118476. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118477. */
  118478. updateScale: boolean;
  118479. protected _interactionsEnabled: boolean;
  118480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118481. private _beforeRenderObserver;
  118482. private _tempVector;
  118483. /**
  118484. * Creates a gizmo
  118485. * @param gizmoLayer The utility layer the gizmo will be added to
  118486. */
  118487. constructor(
  118488. /** The utility layer the gizmo will be added to */
  118489. gizmoLayer?: UtilityLayerRenderer);
  118490. /**
  118491. * Updates the gizmo to match the attached mesh's position/rotation
  118492. */
  118493. protected _update(): void;
  118494. /**
  118495. * Disposes of the gizmo
  118496. */
  118497. dispose(): void;
  118498. }
  118499. }
  118500. declare module BABYLON {
  118501. /**
  118502. * Single plane drag gizmo
  118503. */
  118504. export class PlaneDragGizmo extends Gizmo {
  118505. /**
  118506. * Drag behavior responsible for the gizmos dragging interactions
  118507. */
  118508. dragBehavior: PointerDragBehavior;
  118509. private _pointerObserver;
  118510. /**
  118511. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118512. */
  118513. snapDistance: number;
  118514. /**
  118515. * Event that fires each time the gizmo snaps to a new location.
  118516. * * snapDistance is the the change in distance
  118517. */
  118518. onSnapObservable: Observable<{
  118519. snapDistance: number;
  118520. }>;
  118521. private _plane;
  118522. private _coloredMaterial;
  118523. private _hoverMaterial;
  118524. private _isEnabled;
  118525. private _parent;
  118526. /** @hidden */
  118527. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  118528. /** @hidden */
  118529. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118530. /**
  118531. * Creates a PlaneDragGizmo
  118532. * @param gizmoLayer The utility layer the gizmo will be added to
  118533. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  118534. * @param color The color of the gizmo
  118535. */
  118536. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118537. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118538. /**
  118539. * If the gizmo is enabled
  118540. */
  118541. set isEnabled(value: boolean);
  118542. get isEnabled(): boolean;
  118543. /**
  118544. * Disposes of the gizmo
  118545. */
  118546. dispose(): void;
  118547. }
  118548. }
  118549. declare module BABYLON {
  118550. /**
  118551. * Gizmo that enables dragging a mesh along 3 axis
  118552. */
  118553. export class PositionGizmo extends Gizmo {
  118554. /**
  118555. * Internal gizmo used for interactions on the x axis
  118556. */
  118557. xGizmo: AxisDragGizmo;
  118558. /**
  118559. * Internal gizmo used for interactions on the y axis
  118560. */
  118561. yGizmo: AxisDragGizmo;
  118562. /**
  118563. * Internal gizmo used for interactions on the z axis
  118564. */
  118565. zGizmo: AxisDragGizmo;
  118566. /**
  118567. * Internal gizmo used for interactions on the yz plane
  118568. */
  118569. xPlaneGizmo: PlaneDragGizmo;
  118570. /**
  118571. * Internal gizmo used for interactions on the xz plane
  118572. */
  118573. yPlaneGizmo: PlaneDragGizmo;
  118574. /**
  118575. * Internal gizmo used for interactions on the xy plane
  118576. */
  118577. zPlaneGizmo: PlaneDragGizmo;
  118578. /**
  118579. * private variables
  118580. */
  118581. private _meshAttached;
  118582. private _updateGizmoRotationToMatchAttachedMesh;
  118583. private _snapDistance;
  118584. private _scaleRatio;
  118585. /** Fires an event when any of it's sub gizmos are dragged */
  118586. onDragStartObservable: Observable<unknown>;
  118587. /** Fires an event when any of it's sub gizmos are released from dragging */
  118588. onDragEndObservable: Observable<unknown>;
  118589. /**
  118590. * If set to true, planar drag is enabled
  118591. */
  118592. private _planarGizmoEnabled;
  118593. get attachedMesh(): Nullable<AbstractMesh>;
  118594. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118595. /**
  118596. * Creates a PositionGizmo
  118597. * @param gizmoLayer The utility layer the gizmo will be added to
  118598. */
  118599. constructor(gizmoLayer?: UtilityLayerRenderer);
  118600. /**
  118601. * If the planar drag gizmo is enabled
  118602. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  118603. */
  118604. set planarGizmoEnabled(value: boolean);
  118605. get planarGizmoEnabled(): boolean;
  118606. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118607. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118608. /**
  118609. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118610. */
  118611. set snapDistance(value: number);
  118612. get snapDistance(): number;
  118613. /**
  118614. * Ratio for the scale of the gizmo (Default: 1)
  118615. */
  118616. set scaleRatio(value: number);
  118617. get scaleRatio(): number;
  118618. /**
  118619. * Disposes of the gizmo
  118620. */
  118621. dispose(): void;
  118622. /**
  118623. * CustomMeshes are not supported by this gizmo
  118624. * @param mesh The mesh to replace the default mesh of the gizmo
  118625. */
  118626. setCustomMesh(mesh: Mesh): void;
  118627. }
  118628. }
  118629. declare module BABYLON {
  118630. /**
  118631. * Single axis drag gizmo
  118632. */
  118633. export class AxisDragGizmo extends Gizmo {
  118634. /**
  118635. * Drag behavior responsible for the gizmos dragging interactions
  118636. */
  118637. dragBehavior: PointerDragBehavior;
  118638. private _pointerObserver;
  118639. /**
  118640. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118641. */
  118642. snapDistance: number;
  118643. /**
  118644. * Event that fires each time the gizmo snaps to a new location.
  118645. * * snapDistance is the the change in distance
  118646. */
  118647. onSnapObservable: Observable<{
  118648. snapDistance: number;
  118649. }>;
  118650. private _isEnabled;
  118651. private _parent;
  118652. private _arrow;
  118653. private _coloredMaterial;
  118654. private _hoverMaterial;
  118655. /** @hidden */
  118656. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  118657. /** @hidden */
  118658. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118659. /**
  118660. * Creates an AxisDragGizmo
  118661. * @param gizmoLayer The utility layer the gizmo will be added to
  118662. * @param dragAxis The axis which the gizmo will be able to drag on
  118663. * @param color The color of the gizmo
  118664. */
  118665. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118666. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118667. /**
  118668. * If the gizmo is enabled
  118669. */
  118670. set isEnabled(value: boolean);
  118671. get isEnabled(): boolean;
  118672. /**
  118673. * Disposes of the gizmo
  118674. */
  118675. dispose(): void;
  118676. }
  118677. }
  118678. declare module BABYLON.Debug {
  118679. /**
  118680. * The Axes viewer will show 3 axes in a specific point in space
  118681. */
  118682. export class AxesViewer {
  118683. private _xAxis;
  118684. private _yAxis;
  118685. private _zAxis;
  118686. private _scaleLinesFactor;
  118687. private _instanced;
  118688. /**
  118689. * Gets the hosting scene
  118690. */
  118691. scene: Scene;
  118692. /**
  118693. * Gets or sets a number used to scale line length
  118694. */
  118695. scaleLines: number;
  118696. /** Gets the node hierarchy used to render x-axis */
  118697. get xAxis(): TransformNode;
  118698. /** Gets the node hierarchy used to render y-axis */
  118699. get yAxis(): TransformNode;
  118700. /** Gets the node hierarchy used to render z-axis */
  118701. get zAxis(): TransformNode;
  118702. /**
  118703. * Creates a new AxesViewer
  118704. * @param scene defines the hosting scene
  118705. * @param scaleLines defines a number used to scale line length (1 by default)
  118706. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  118707. * @param xAxis defines the node hierarchy used to render the x-axis
  118708. * @param yAxis defines the node hierarchy used to render the y-axis
  118709. * @param zAxis defines the node hierarchy used to render the z-axis
  118710. */
  118711. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  118712. /**
  118713. * Force the viewer to update
  118714. * @param position defines the position of the viewer
  118715. * @param xaxis defines the x axis of the viewer
  118716. * @param yaxis defines the y axis of the viewer
  118717. * @param zaxis defines the z axis of the viewer
  118718. */
  118719. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  118720. /**
  118721. * Creates an instance of this axes viewer.
  118722. * @returns a new axes viewer with instanced meshes
  118723. */
  118724. createInstance(): AxesViewer;
  118725. /** Releases resources */
  118726. dispose(): void;
  118727. private static _SetRenderingGroupId;
  118728. }
  118729. }
  118730. declare module BABYLON.Debug {
  118731. /**
  118732. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  118733. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  118734. */
  118735. export class BoneAxesViewer extends AxesViewer {
  118736. /**
  118737. * Gets or sets the target mesh where to display the axes viewer
  118738. */
  118739. mesh: Nullable<Mesh>;
  118740. /**
  118741. * Gets or sets the target bone where to display the axes viewer
  118742. */
  118743. bone: Nullable<Bone>;
  118744. /** Gets current position */
  118745. pos: Vector3;
  118746. /** Gets direction of X axis */
  118747. xaxis: Vector3;
  118748. /** Gets direction of Y axis */
  118749. yaxis: Vector3;
  118750. /** Gets direction of Z axis */
  118751. zaxis: Vector3;
  118752. /**
  118753. * Creates a new BoneAxesViewer
  118754. * @param scene defines the hosting scene
  118755. * @param bone defines the target bone
  118756. * @param mesh defines the target mesh
  118757. * @param scaleLines defines a scaling factor for line length (1 by default)
  118758. */
  118759. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  118760. /**
  118761. * Force the viewer to update
  118762. */
  118763. update(): void;
  118764. /** Releases resources */
  118765. dispose(): void;
  118766. }
  118767. }
  118768. declare module BABYLON {
  118769. /**
  118770. * Interface used to define scene explorer extensibility option
  118771. */
  118772. export interface IExplorerExtensibilityOption {
  118773. /**
  118774. * Define the option label
  118775. */
  118776. label: string;
  118777. /**
  118778. * Defines the action to execute on click
  118779. */
  118780. action: (entity: any) => void;
  118781. }
  118782. /**
  118783. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  118784. */
  118785. export interface IExplorerExtensibilityGroup {
  118786. /**
  118787. * Defines a predicate to test if a given type mut be extended
  118788. */
  118789. predicate: (entity: any) => boolean;
  118790. /**
  118791. * Gets the list of options added to a type
  118792. */
  118793. entries: IExplorerExtensibilityOption[];
  118794. }
  118795. /**
  118796. * Interface used to define the options to use to create the Inspector
  118797. */
  118798. export interface IInspectorOptions {
  118799. /**
  118800. * Display in overlay mode (default: false)
  118801. */
  118802. overlay?: boolean;
  118803. /**
  118804. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  118805. */
  118806. globalRoot?: HTMLElement;
  118807. /**
  118808. * Display the Scene explorer
  118809. */
  118810. showExplorer?: boolean;
  118811. /**
  118812. * Display the property inspector
  118813. */
  118814. showInspector?: boolean;
  118815. /**
  118816. * Display in embed mode (both panes on the right)
  118817. */
  118818. embedMode?: boolean;
  118819. /**
  118820. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  118821. */
  118822. handleResize?: boolean;
  118823. /**
  118824. * Allow the panes to popup (default: true)
  118825. */
  118826. enablePopup?: boolean;
  118827. /**
  118828. * Allow the panes to be closed by users (default: true)
  118829. */
  118830. enableClose?: boolean;
  118831. /**
  118832. * Optional list of extensibility entries
  118833. */
  118834. explorerExtensibility?: IExplorerExtensibilityGroup[];
  118835. /**
  118836. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  118837. */
  118838. inspectorURL?: string;
  118839. /**
  118840. * Optional initial tab (default to DebugLayerTab.Properties)
  118841. */
  118842. initialTab?: DebugLayerTab;
  118843. }
  118844. interface Scene {
  118845. /**
  118846. * @hidden
  118847. * Backing field
  118848. */
  118849. _debugLayer: DebugLayer;
  118850. /**
  118851. * Gets the debug layer (aka Inspector) associated with the scene
  118852. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118853. */
  118854. debugLayer: DebugLayer;
  118855. }
  118856. /**
  118857. * Enum of inspector action tab
  118858. */
  118859. export enum DebugLayerTab {
  118860. /**
  118861. * Properties tag (default)
  118862. */
  118863. Properties = 0,
  118864. /**
  118865. * Debug tab
  118866. */
  118867. Debug = 1,
  118868. /**
  118869. * Statistics tab
  118870. */
  118871. Statistics = 2,
  118872. /**
  118873. * Tools tab
  118874. */
  118875. Tools = 3,
  118876. /**
  118877. * Settings tab
  118878. */
  118879. Settings = 4
  118880. }
  118881. /**
  118882. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118883. * what is happening in your scene
  118884. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118885. */
  118886. export class DebugLayer {
  118887. /**
  118888. * Define the url to get the inspector script from.
  118889. * By default it uses the babylonjs CDN.
  118890. * @ignoreNaming
  118891. */
  118892. static InspectorURL: string;
  118893. private _scene;
  118894. private BJSINSPECTOR;
  118895. private _onPropertyChangedObservable?;
  118896. /**
  118897. * Observable triggered when a property is changed through the inspector.
  118898. */
  118899. get onPropertyChangedObservable(): any;
  118900. /**
  118901. * Instantiates a new debug layer.
  118902. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118903. * what is happening in your scene
  118904. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118905. * @param scene Defines the scene to inspect
  118906. */
  118907. constructor(scene: Scene);
  118908. /** Creates the inspector window. */
  118909. private _createInspector;
  118910. /**
  118911. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  118912. * @param entity defines the entity to select
  118913. * @param lineContainerTitle defines the specific block to highlight
  118914. */
  118915. select(entity: any, lineContainerTitle?: string): void;
  118916. /** Get the inspector from bundle or global */
  118917. private _getGlobalInspector;
  118918. /**
  118919. * Get if the inspector is visible or not.
  118920. * @returns true if visible otherwise, false
  118921. */
  118922. isVisible(): boolean;
  118923. /**
  118924. * Hide the inspector and close its window.
  118925. */
  118926. hide(): void;
  118927. /**
  118928. * Launch the debugLayer.
  118929. * @param config Define the configuration of the inspector
  118930. * @return a promise fulfilled when the debug layer is visible
  118931. */
  118932. show(config?: IInspectorOptions): Promise<DebugLayer>;
  118933. }
  118934. }
  118935. declare module BABYLON {
  118936. /**
  118937. * Class containing static functions to help procedurally build meshes
  118938. */
  118939. export class BoxBuilder {
  118940. /**
  118941. * Creates a box mesh
  118942. * * The parameter `size` sets the size (float) of each box side (default 1)
  118943. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118944. * * 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)
  118945. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118949. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118950. * @param name defines the name of the mesh
  118951. * @param options defines the options used to create the mesh
  118952. * @param scene defines the hosting scene
  118953. * @returns the box mesh
  118954. */
  118955. static CreateBox(name: string, options: {
  118956. size?: number;
  118957. width?: number;
  118958. height?: number;
  118959. depth?: number;
  118960. faceUV?: Vector4[];
  118961. faceColors?: Color4[];
  118962. sideOrientation?: number;
  118963. frontUVs?: Vector4;
  118964. backUVs?: Vector4;
  118965. wrap?: boolean;
  118966. topBaseAt?: number;
  118967. bottomBaseAt?: number;
  118968. updatable?: boolean;
  118969. }, scene?: Nullable<Scene>): Mesh;
  118970. }
  118971. }
  118972. declare module BABYLON.Debug {
  118973. /**
  118974. * Used to show the physics impostor around the specific mesh
  118975. */
  118976. export class PhysicsViewer {
  118977. /** @hidden */
  118978. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  118979. /** @hidden */
  118980. protected _meshes: Array<Nullable<AbstractMesh>>;
  118981. /** @hidden */
  118982. protected _scene: Nullable<Scene>;
  118983. /** @hidden */
  118984. protected _numMeshes: number;
  118985. /** @hidden */
  118986. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  118987. private _renderFunction;
  118988. private _utilityLayer;
  118989. private _debugBoxMesh;
  118990. private _debugSphereMesh;
  118991. private _debugCylinderMesh;
  118992. private _debugMaterial;
  118993. private _debugMeshMeshes;
  118994. /**
  118995. * Creates a new PhysicsViewer
  118996. * @param scene defines the hosting scene
  118997. */
  118998. constructor(scene: Scene);
  118999. /** @hidden */
  119000. protected _updateDebugMeshes(): void;
  119001. /**
  119002. * Renders a specified physic impostor
  119003. * @param impostor defines the impostor to render
  119004. * @param targetMesh defines the mesh represented by the impostor
  119005. * @returns the new debug mesh used to render the impostor
  119006. */
  119007. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119008. /**
  119009. * Hides a specified physic impostor
  119010. * @param impostor defines the impostor to hide
  119011. */
  119012. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119013. private _getDebugMaterial;
  119014. private _getDebugBoxMesh;
  119015. private _getDebugSphereMesh;
  119016. private _getDebugCylinderMesh;
  119017. private _getDebugMeshMesh;
  119018. private _getDebugMesh;
  119019. /** Releases all resources */
  119020. dispose(): void;
  119021. }
  119022. }
  119023. declare module BABYLON {
  119024. /**
  119025. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119026. * in order to better appreciate the issue one might have.
  119027. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119028. */
  119029. export class RayHelper {
  119030. /**
  119031. * Defines the ray we are currently tryin to visualize.
  119032. */
  119033. ray: Nullable<Ray>;
  119034. private _renderPoints;
  119035. private _renderLine;
  119036. private _renderFunction;
  119037. private _scene;
  119038. private _updateToMeshFunction;
  119039. private _attachedToMesh;
  119040. private _meshSpaceDirection;
  119041. private _meshSpaceOrigin;
  119042. /**
  119043. * Helper function to create a colored helper in a scene in one line.
  119044. * @param ray Defines the ray we are currently tryin to visualize
  119045. * @param scene Defines the scene the ray is used in
  119046. * @param color Defines the color we want to see the ray in
  119047. * @returns The newly created ray helper.
  119048. */
  119049. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119050. /**
  119051. * Instantiate a new ray helper.
  119052. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119053. * in order to better appreciate the issue one might have.
  119054. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119055. * @param ray Defines the ray we are currently tryin to visualize
  119056. */
  119057. constructor(ray: Ray);
  119058. /**
  119059. * Shows the ray we are willing to debug.
  119060. * @param scene Defines the scene the ray needs to be rendered in
  119061. * @param color Defines the color the ray needs to be rendered in
  119062. */
  119063. show(scene: Scene, color?: Color3): void;
  119064. /**
  119065. * Hides the ray we are debugging.
  119066. */
  119067. hide(): void;
  119068. private _render;
  119069. /**
  119070. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119071. * @param mesh Defines the mesh we want the helper attached to
  119072. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119073. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119074. * @param length Defines the length of the ray
  119075. */
  119076. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119077. /**
  119078. * Detach the ray helper from the mesh it has previously been attached to.
  119079. */
  119080. detachFromMesh(): void;
  119081. private _updateToMesh;
  119082. /**
  119083. * Dispose the helper and release its associated resources.
  119084. */
  119085. dispose(): void;
  119086. }
  119087. }
  119088. declare module BABYLON.Debug {
  119089. /**
  119090. * Class used to render a debug view of a given skeleton
  119091. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119092. */
  119093. export class SkeletonViewer {
  119094. /** defines the skeleton to render */
  119095. skeleton: Skeleton;
  119096. /** defines the mesh attached to the skeleton */
  119097. mesh: AbstractMesh;
  119098. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119099. autoUpdateBonesMatrices: boolean;
  119100. /** defines the rendering group id to use with the viewer */
  119101. renderingGroupId: number;
  119102. /** Gets or sets the color used to render the skeleton */
  119103. color: Color3;
  119104. private _scene;
  119105. private _debugLines;
  119106. private _debugMesh;
  119107. private _isEnabled;
  119108. private _renderFunction;
  119109. private _utilityLayer;
  119110. /**
  119111. * Returns the mesh used to render the bones
  119112. */
  119113. get debugMesh(): Nullable<LinesMesh>;
  119114. /**
  119115. * Creates a new SkeletonViewer
  119116. * @param skeleton defines the skeleton to render
  119117. * @param mesh defines the mesh attached to the skeleton
  119118. * @param scene defines the hosting scene
  119119. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119120. * @param renderingGroupId defines the rendering group id to use with the viewer
  119121. */
  119122. constructor(
  119123. /** defines the skeleton to render */
  119124. skeleton: Skeleton,
  119125. /** defines the mesh attached to the skeleton */
  119126. mesh: AbstractMesh, scene: Scene,
  119127. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119128. autoUpdateBonesMatrices?: boolean,
  119129. /** defines the rendering group id to use with the viewer */
  119130. renderingGroupId?: number);
  119131. /** Gets or sets a boolean indicating if the viewer is enabled */
  119132. set isEnabled(value: boolean);
  119133. get isEnabled(): boolean;
  119134. private _getBonePosition;
  119135. private _getLinesForBonesWithLength;
  119136. private _getLinesForBonesNoLength;
  119137. /** Update the viewer to sync with current skeleton state */
  119138. update(): void;
  119139. /** Release associated resources */
  119140. dispose(): void;
  119141. }
  119142. }
  119143. declare module BABYLON {
  119144. /**
  119145. * Options to create the null engine
  119146. */
  119147. export class NullEngineOptions {
  119148. /**
  119149. * Render width (Default: 512)
  119150. */
  119151. renderWidth: number;
  119152. /**
  119153. * Render height (Default: 256)
  119154. */
  119155. renderHeight: number;
  119156. /**
  119157. * Texture size (Default: 512)
  119158. */
  119159. textureSize: number;
  119160. /**
  119161. * If delta time between frames should be constant
  119162. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119163. */
  119164. deterministicLockstep: boolean;
  119165. /**
  119166. * Maximum about of steps between frames (Default: 4)
  119167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119168. */
  119169. lockstepMaxSteps: number;
  119170. }
  119171. /**
  119172. * The null engine class provides support for headless version of babylon.js.
  119173. * This can be used in server side scenario or for testing purposes
  119174. */
  119175. export class NullEngine extends Engine {
  119176. private _options;
  119177. /**
  119178. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119180. * @returns true if engine is in deterministic lock step mode
  119181. */
  119182. isDeterministicLockStep(): boolean;
  119183. /**
  119184. * Gets the max steps when engine is running in deterministic lock step
  119185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119186. * @returns the max steps
  119187. */
  119188. getLockstepMaxSteps(): number;
  119189. /**
  119190. * Gets the current hardware scaling level.
  119191. * By default the hardware scaling level is computed from the window device ratio.
  119192. * 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.
  119193. * @returns a number indicating the current hardware scaling level
  119194. */
  119195. getHardwareScalingLevel(): number;
  119196. constructor(options?: NullEngineOptions);
  119197. /**
  119198. * Creates a vertex buffer
  119199. * @param vertices the data for the vertex buffer
  119200. * @returns the new WebGL static buffer
  119201. */
  119202. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119203. /**
  119204. * Creates a new index buffer
  119205. * @param indices defines the content of the index buffer
  119206. * @param updatable defines if the index buffer must be updatable
  119207. * @returns a new webGL buffer
  119208. */
  119209. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119210. /**
  119211. * Clear the current render buffer or the current render target (if any is set up)
  119212. * @param color defines the color to use
  119213. * @param backBuffer defines if the back buffer must be cleared
  119214. * @param depth defines if the depth buffer must be cleared
  119215. * @param stencil defines if the stencil buffer must be cleared
  119216. */
  119217. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119218. /**
  119219. * Gets the current render width
  119220. * @param useScreen defines if screen size must be used (or the current render target if any)
  119221. * @returns a number defining the current render width
  119222. */
  119223. getRenderWidth(useScreen?: boolean): number;
  119224. /**
  119225. * Gets the current render height
  119226. * @param useScreen defines if screen size must be used (or the current render target if any)
  119227. * @returns a number defining the current render height
  119228. */
  119229. getRenderHeight(useScreen?: boolean): number;
  119230. /**
  119231. * Set the WebGL's viewport
  119232. * @param viewport defines the viewport element to be used
  119233. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119234. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119235. */
  119236. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119237. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119238. /**
  119239. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119240. * @param pipelineContext defines the pipeline context to use
  119241. * @param uniformsNames defines the list of uniform names
  119242. * @returns an array of webGL uniform locations
  119243. */
  119244. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119245. /**
  119246. * Gets the lsit of active attributes for a given webGL program
  119247. * @param pipelineContext defines the pipeline context to use
  119248. * @param attributesNames defines the list of attribute names to get
  119249. * @returns an array of indices indicating the offset of each attribute
  119250. */
  119251. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119252. /**
  119253. * Binds an effect to the webGL context
  119254. * @param effect defines the effect to bind
  119255. */
  119256. bindSamplers(effect: Effect): void;
  119257. /**
  119258. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119259. * @param effect defines the effect to activate
  119260. */
  119261. enableEffect(effect: Effect): void;
  119262. /**
  119263. * Set various states to the webGL context
  119264. * @param culling defines backface culling state
  119265. * @param zOffset defines the value to apply to zOffset (0 by default)
  119266. * @param force defines if states must be applied even if cache is up to date
  119267. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119268. */
  119269. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119270. /**
  119271. * Set the value of an uniform to an array of int32
  119272. * @param uniform defines the webGL uniform location where to store the value
  119273. * @param array defines the array of int32 to store
  119274. */
  119275. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119276. /**
  119277. * Set the value of an uniform to an array of int32 (stored as vec2)
  119278. * @param uniform defines the webGL uniform location where to store the value
  119279. * @param array defines the array of int32 to store
  119280. */
  119281. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119282. /**
  119283. * Set the value of an uniform to an array of int32 (stored as vec3)
  119284. * @param uniform defines the webGL uniform location where to store the value
  119285. * @param array defines the array of int32 to store
  119286. */
  119287. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119288. /**
  119289. * Set the value of an uniform to an array of int32 (stored as vec4)
  119290. * @param uniform defines the webGL uniform location where to store the value
  119291. * @param array defines the array of int32 to store
  119292. */
  119293. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119294. /**
  119295. * Set the value of an uniform to an array of float32
  119296. * @param uniform defines the webGL uniform location where to store the value
  119297. * @param array defines the array of float32 to store
  119298. */
  119299. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119300. /**
  119301. * Set the value of an uniform to an array of float32 (stored as vec2)
  119302. * @param uniform defines the webGL uniform location where to store the value
  119303. * @param array defines the array of float32 to store
  119304. */
  119305. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119306. /**
  119307. * Set the value of an uniform to an array of float32 (stored as vec3)
  119308. * @param uniform defines the webGL uniform location where to store the value
  119309. * @param array defines the array of float32 to store
  119310. */
  119311. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119312. /**
  119313. * Set the value of an uniform to an array of float32 (stored as vec4)
  119314. * @param uniform defines the webGL uniform location where to store the value
  119315. * @param array defines the array of float32 to store
  119316. */
  119317. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119318. /**
  119319. * Set the value of an uniform to an array of number
  119320. * @param uniform defines the webGL uniform location where to store the value
  119321. * @param array defines the array of number to store
  119322. */
  119323. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119324. /**
  119325. * Set the value of an uniform to an array of number (stored as vec2)
  119326. * @param uniform defines the webGL uniform location where to store the value
  119327. * @param array defines the array of number to store
  119328. */
  119329. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119330. /**
  119331. * Set the value of an uniform to an array of number (stored as vec3)
  119332. * @param uniform defines the webGL uniform location where to store the value
  119333. * @param array defines the array of number to store
  119334. */
  119335. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119336. /**
  119337. * Set the value of an uniform to an array of number (stored as vec4)
  119338. * @param uniform defines the webGL uniform location where to store the value
  119339. * @param array defines the array of number to store
  119340. */
  119341. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119342. /**
  119343. * Set the value of an uniform to an array of float32 (stored as matrices)
  119344. * @param uniform defines the webGL uniform location where to store the value
  119345. * @param matrices defines the array of float32 to store
  119346. */
  119347. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119348. /**
  119349. * Set the value of an uniform to a matrix (3x3)
  119350. * @param uniform defines the webGL uniform location where to store the value
  119351. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119352. */
  119353. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119354. /**
  119355. * Set the value of an uniform to a matrix (2x2)
  119356. * @param uniform defines the webGL uniform location where to store the value
  119357. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119358. */
  119359. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119360. /**
  119361. * Set the value of an uniform to a number (float)
  119362. * @param uniform defines the webGL uniform location where to store the value
  119363. * @param value defines the float number to store
  119364. */
  119365. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119366. /**
  119367. * Set the value of an uniform to a vec2
  119368. * @param uniform defines the webGL uniform location where to store the value
  119369. * @param x defines the 1st component of the value
  119370. * @param y defines the 2nd component of the value
  119371. */
  119372. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119373. /**
  119374. * Set the value of an uniform to a vec3
  119375. * @param uniform defines the webGL uniform location where to store the value
  119376. * @param x defines the 1st component of the value
  119377. * @param y defines the 2nd component of the value
  119378. * @param z defines the 3rd component of the value
  119379. */
  119380. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119381. /**
  119382. * Set the value of an uniform to a boolean
  119383. * @param uniform defines the webGL uniform location where to store the value
  119384. * @param bool defines the boolean to store
  119385. */
  119386. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119387. /**
  119388. * Set the value of an uniform to a vec4
  119389. * @param uniform defines the webGL uniform location where to store the value
  119390. * @param x defines the 1st component of the value
  119391. * @param y defines the 2nd component of the value
  119392. * @param z defines the 3rd component of the value
  119393. * @param w defines the 4th component of the value
  119394. */
  119395. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119396. /**
  119397. * Sets the current alpha mode
  119398. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119399. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119400. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119401. */
  119402. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119403. /**
  119404. * Bind webGl buffers directly to the webGL context
  119405. * @param vertexBuffers defines the vertex buffer to bind
  119406. * @param indexBuffer defines the index buffer to bind
  119407. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119408. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119409. * @param effect defines the effect associated with the vertex buffer
  119410. */
  119411. bindBuffers(vertexBuffers: {
  119412. [key: string]: VertexBuffer;
  119413. }, indexBuffer: DataBuffer, effect: Effect): void;
  119414. /**
  119415. * Force the entire cache to be cleared
  119416. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119417. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119418. */
  119419. wipeCaches(bruteForce?: boolean): void;
  119420. /**
  119421. * Send a draw order
  119422. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119423. * @param indexStart defines the starting index
  119424. * @param indexCount defines the number of index to draw
  119425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119426. */
  119427. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119428. /**
  119429. * Draw a list of indexed primitives
  119430. * @param fillMode defines the primitive to use
  119431. * @param indexStart defines the starting index
  119432. * @param indexCount defines the number of index to draw
  119433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119434. */
  119435. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119436. /**
  119437. * Draw a list of unindexed primitives
  119438. * @param fillMode defines the primitive to use
  119439. * @param verticesStart defines the index of first vertex to draw
  119440. * @param verticesCount defines the count of vertices to draw
  119441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119442. */
  119443. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119444. /** @hidden */
  119445. _createTexture(): WebGLTexture;
  119446. /** @hidden */
  119447. _releaseTexture(texture: InternalTexture): void;
  119448. /**
  119449. * Usually called from Texture.ts.
  119450. * Passed information to create a WebGLTexture
  119451. * @param urlArg defines a value which contains one of the following:
  119452. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119453. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119454. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119455. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119456. * @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)
  119457. * @param scene needed for loading to the correct scene
  119458. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119459. * @param onLoad optional callback to be called upon successful completion
  119460. * @param onError optional callback to be called upon failure
  119461. * @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
  119462. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119463. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119464. * @param forcedExtension defines the extension to use to pick the right loader
  119465. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119466. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119467. */
  119468. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  119469. /**
  119470. * Creates a new render target texture
  119471. * @param size defines the size of the texture
  119472. * @param options defines the options used to create the texture
  119473. * @returns a new render target texture stored in an InternalTexture
  119474. */
  119475. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119476. /**
  119477. * Update the sampling mode of a given texture
  119478. * @param samplingMode defines the required sampling mode
  119479. * @param texture defines the texture to update
  119480. */
  119481. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119482. /**
  119483. * Binds the frame buffer to the specified texture.
  119484. * @param texture The texture to render to or null for the default canvas
  119485. * @param faceIndex The face of the texture to render to in case of cube texture
  119486. * @param requiredWidth The width of the target to render to
  119487. * @param requiredHeight The height of the target to render to
  119488. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119489. * @param lodLevel defines le lod level to bind to the frame buffer
  119490. */
  119491. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119492. /**
  119493. * Unbind the current render target texture from the webGL context
  119494. * @param texture defines the render target texture to unbind
  119495. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119496. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119497. */
  119498. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119499. /**
  119500. * Creates a dynamic vertex buffer
  119501. * @param vertices the data for the dynamic vertex buffer
  119502. * @returns the new WebGL dynamic buffer
  119503. */
  119504. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119505. /**
  119506. * Update the content of a dynamic texture
  119507. * @param texture defines the texture to update
  119508. * @param canvas defines the canvas containing the source
  119509. * @param invertY defines if data must be stored with Y axis inverted
  119510. * @param premulAlpha defines if alpha is stored as premultiplied
  119511. * @param format defines the format of the data
  119512. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119513. */
  119514. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119515. /**
  119516. * Gets a boolean indicating if all created effects are ready
  119517. * @returns true if all effects are ready
  119518. */
  119519. areAllEffectsReady(): boolean;
  119520. /**
  119521. * @hidden
  119522. * Get the current error code of the webGL context
  119523. * @returns the error code
  119524. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119525. */
  119526. getError(): number;
  119527. /** @hidden */
  119528. _getUnpackAlignement(): number;
  119529. /** @hidden */
  119530. _unpackFlipY(value: boolean): void;
  119531. /**
  119532. * Update a dynamic index buffer
  119533. * @param indexBuffer defines the target index buffer
  119534. * @param indices defines the data to update
  119535. * @param offset defines the offset in the target index buffer where update should start
  119536. */
  119537. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  119538. /**
  119539. * Updates a dynamic vertex buffer.
  119540. * @param vertexBuffer the vertex buffer to update
  119541. * @param vertices the data used to update the vertex buffer
  119542. * @param byteOffset the byte offset of the data (optional)
  119543. * @param byteLength the byte length of the data (optional)
  119544. */
  119545. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  119546. /** @hidden */
  119547. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  119548. /** @hidden */
  119549. _bindTexture(channel: number, texture: InternalTexture): void;
  119550. protected _deleteBuffer(buffer: WebGLBuffer): void;
  119551. /**
  119552. * 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
  119553. */
  119554. releaseEffects(): void;
  119555. displayLoadingUI(): void;
  119556. hideLoadingUI(): void;
  119557. /** @hidden */
  119558. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119559. /** @hidden */
  119560. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119561. /** @hidden */
  119562. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119563. /** @hidden */
  119564. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  119565. }
  119566. }
  119567. declare module BABYLON {
  119568. /** @hidden */
  119569. export class _OcclusionDataStorage {
  119570. /** @hidden */
  119571. occlusionInternalRetryCounter: number;
  119572. /** @hidden */
  119573. isOcclusionQueryInProgress: boolean;
  119574. /** @hidden */
  119575. isOccluded: boolean;
  119576. /** @hidden */
  119577. occlusionRetryCount: number;
  119578. /** @hidden */
  119579. occlusionType: number;
  119580. /** @hidden */
  119581. occlusionQueryAlgorithmType: number;
  119582. }
  119583. interface Engine {
  119584. /**
  119585. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  119586. * @return the new query
  119587. */
  119588. createQuery(): WebGLQuery;
  119589. /**
  119590. * Delete and release a webGL query
  119591. * @param query defines the query to delete
  119592. * @return the current engine
  119593. */
  119594. deleteQuery(query: WebGLQuery): Engine;
  119595. /**
  119596. * Check if a given query has resolved and got its value
  119597. * @param query defines the query to check
  119598. * @returns true if the query got its value
  119599. */
  119600. isQueryResultAvailable(query: WebGLQuery): boolean;
  119601. /**
  119602. * Gets the value of a given query
  119603. * @param query defines the query to check
  119604. * @returns the value of the query
  119605. */
  119606. getQueryResult(query: WebGLQuery): number;
  119607. /**
  119608. * Initiates an occlusion query
  119609. * @param algorithmType defines the algorithm to use
  119610. * @param query defines the query to use
  119611. * @returns the current engine
  119612. * @see http://doc.babylonjs.com/features/occlusionquery
  119613. */
  119614. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  119615. /**
  119616. * Ends an occlusion query
  119617. * @see http://doc.babylonjs.com/features/occlusionquery
  119618. * @param algorithmType defines the algorithm to use
  119619. * @returns the current engine
  119620. */
  119621. endOcclusionQuery(algorithmType: number): Engine;
  119622. /**
  119623. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  119624. * Please note that only one query can be issued at a time
  119625. * @returns a time token used to track the time span
  119626. */
  119627. startTimeQuery(): Nullable<_TimeToken>;
  119628. /**
  119629. * Ends a time query
  119630. * @param token defines the token used to measure the time span
  119631. * @returns the time spent (in ns)
  119632. */
  119633. endTimeQuery(token: _TimeToken): int;
  119634. /** @hidden */
  119635. _currentNonTimestampToken: Nullable<_TimeToken>;
  119636. /** @hidden */
  119637. _createTimeQuery(): WebGLQuery;
  119638. /** @hidden */
  119639. _deleteTimeQuery(query: WebGLQuery): void;
  119640. /** @hidden */
  119641. _getGlAlgorithmType(algorithmType: number): number;
  119642. /** @hidden */
  119643. _getTimeQueryResult(query: WebGLQuery): any;
  119644. /** @hidden */
  119645. _getTimeQueryAvailability(query: WebGLQuery): any;
  119646. }
  119647. interface AbstractMesh {
  119648. /**
  119649. * Backing filed
  119650. * @hidden
  119651. */
  119652. __occlusionDataStorage: _OcclusionDataStorage;
  119653. /**
  119654. * Access property
  119655. * @hidden
  119656. */
  119657. _occlusionDataStorage: _OcclusionDataStorage;
  119658. /**
  119659. * 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.
  119660. * The default value is -1 which means don't break the query and wait till the result
  119661. * @see http://doc.babylonjs.com/features/occlusionquery
  119662. */
  119663. occlusionRetryCount: number;
  119664. /**
  119665. * 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:
  119666. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  119667. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  119668. * * 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.
  119669. * @see http://doc.babylonjs.com/features/occlusionquery
  119670. */
  119671. occlusionType: number;
  119672. /**
  119673. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  119674. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  119675. * * 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.
  119676. * @see http://doc.babylonjs.com/features/occlusionquery
  119677. */
  119678. occlusionQueryAlgorithmType: number;
  119679. /**
  119680. * 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
  119681. * @see http://doc.babylonjs.com/features/occlusionquery
  119682. */
  119683. isOccluded: boolean;
  119684. /**
  119685. * Flag to check the progress status of the query
  119686. * @see http://doc.babylonjs.com/features/occlusionquery
  119687. */
  119688. isOcclusionQueryInProgress: boolean;
  119689. }
  119690. }
  119691. declare module BABYLON {
  119692. /** @hidden */
  119693. export var _forceTransformFeedbackToBundle: boolean;
  119694. interface Engine {
  119695. /**
  119696. * Creates a webGL transform feedback object
  119697. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  119698. * @returns the webGL transform feedback object
  119699. */
  119700. createTransformFeedback(): WebGLTransformFeedback;
  119701. /**
  119702. * Delete a webGL transform feedback object
  119703. * @param value defines the webGL transform feedback object to delete
  119704. */
  119705. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  119706. /**
  119707. * Bind a webGL transform feedback object to the webgl context
  119708. * @param value defines the webGL transform feedback object to bind
  119709. */
  119710. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  119711. /**
  119712. * Begins a transform feedback operation
  119713. * @param usePoints defines if points or triangles must be used
  119714. */
  119715. beginTransformFeedback(usePoints: boolean): void;
  119716. /**
  119717. * Ends a transform feedback operation
  119718. */
  119719. endTransformFeedback(): void;
  119720. /**
  119721. * Specify the varyings to use with transform feedback
  119722. * @param program defines the associated webGL program
  119723. * @param value defines the list of strings representing the varying names
  119724. */
  119725. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  119726. /**
  119727. * Bind a webGL buffer for a transform feedback operation
  119728. * @param value defines the webGL buffer to bind
  119729. */
  119730. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  119731. }
  119732. }
  119733. declare module BABYLON {
  119734. /**
  119735. * Creation options of the multi render target texture.
  119736. */
  119737. export interface IMultiRenderTargetOptions {
  119738. /**
  119739. * Define if the texture needs to create mip maps after render.
  119740. */
  119741. generateMipMaps?: boolean;
  119742. /**
  119743. * Define the types of all the draw buffers we want to create
  119744. */
  119745. types?: number[];
  119746. /**
  119747. * Define the sampling modes of all the draw buffers we want to create
  119748. */
  119749. samplingModes?: number[];
  119750. /**
  119751. * Define if a depth buffer is required
  119752. */
  119753. generateDepthBuffer?: boolean;
  119754. /**
  119755. * Define if a stencil buffer is required
  119756. */
  119757. generateStencilBuffer?: boolean;
  119758. /**
  119759. * Define if a depth texture is required instead of a depth buffer
  119760. */
  119761. generateDepthTexture?: boolean;
  119762. /**
  119763. * Define the number of desired draw buffers
  119764. */
  119765. textureCount?: number;
  119766. /**
  119767. * Define if aspect ratio should be adapted to the texture or stay the scene one
  119768. */
  119769. doNotChangeAspectRatio?: boolean;
  119770. /**
  119771. * Define the default type of the buffers we are creating
  119772. */
  119773. defaultType?: number;
  119774. }
  119775. /**
  119776. * A multi render target, like a render target provides the ability to render to a texture.
  119777. * Unlike the render target, it can render to several draw buffers in one draw.
  119778. * This is specially interesting in deferred rendering or for any effects requiring more than
  119779. * just one color from a single pass.
  119780. */
  119781. export class MultiRenderTarget extends RenderTargetTexture {
  119782. private _internalTextures;
  119783. private _textures;
  119784. private _multiRenderTargetOptions;
  119785. /**
  119786. * Get if draw buffers are currently supported by the used hardware and browser.
  119787. */
  119788. get isSupported(): boolean;
  119789. /**
  119790. * Get the list of textures generated by the multi render target.
  119791. */
  119792. get textures(): Texture[];
  119793. /**
  119794. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  119795. */
  119796. get depthTexture(): Texture;
  119797. /**
  119798. * Set the wrapping mode on U of all the textures we are rendering to.
  119799. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119800. */
  119801. set wrapU(wrap: number);
  119802. /**
  119803. * Set the wrapping mode on V of all the textures we are rendering to.
  119804. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119805. */
  119806. set wrapV(wrap: number);
  119807. /**
  119808. * Instantiate a new multi render target texture.
  119809. * A multi render target, like a render target provides the ability to render to a texture.
  119810. * Unlike the render target, it can render to several draw buffers in one draw.
  119811. * This is specially interesting in deferred rendering or for any effects requiring more than
  119812. * just one color from a single pass.
  119813. * @param name Define the name of the texture
  119814. * @param size Define the size of the buffers to render to
  119815. * @param count Define the number of target we are rendering into
  119816. * @param scene Define the scene the texture belongs to
  119817. * @param options Define the options used to create the multi render target
  119818. */
  119819. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  119820. /** @hidden */
  119821. _rebuild(): void;
  119822. private _createInternalTextures;
  119823. private _createTextures;
  119824. /**
  119825. * Define the number of samples used if MSAA is enabled.
  119826. */
  119827. get samples(): number;
  119828. set samples(value: number);
  119829. /**
  119830. * Resize all the textures in the multi render target.
  119831. * Be carrefull as it will recreate all the data in the new texture.
  119832. * @param size Define the new size
  119833. */
  119834. resize(size: any): void;
  119835. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119836. /**
  119837. * Dispose the render targets and their associated resources
  119838. */
  119839. dispose(): void;
  119840. /**
  119841. * Release all the underlying texture used as draw buffers.
  119842. */
  119843. releaseInternalTextures(): void;
  119844. }
  119845. }
  119846. declare module BABYLON {
  119847. interface ThinEngine {
  119848. /**
  119849. * Unbind a list of render target textures from the webGL context
  119850. * This is used only when drawBuffer extension or webGL2 are active
  119851. * @param textures defines the render target textures to unbind
  119852. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119853. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119854. */
  119855. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  119856. /**
  119857. * Create a multi render target texture
  119858. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  119859. * @param size defines the size of the texture
  119860. * @param options defines the creation options
  119861. * @returns the cube texture as an InternalTexture
  119862. */
  119863. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  119864. /**
  119865. * Update the sample count for a given multiple render target texture
  119866. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  119867. * @param textures defines the textures to update
  119868. * @param samples defines the sample count to set
  119869. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  119870. */
  119871. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  119872. }
  119873. }
  119874. declare module BABYLON {
  119875. /**
  119876. * Class used to define an additional view for the engine
  119877. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119878. */
  119879. export class EngineView {
  119880. /** Defines the canvas where to render the view */
  119881. target: HTMLCanvasElement;
  119882. /** Defines an optional camera used to render the view (will use active camera else) */
  119883. camera?: Camera;
  119884. }
  119885. interface Engine {
  119886. /**
  119887. * Gets or sets the HTML element to use for attaching events
  119888. */
  119889. inputElement: Nullable<HTMLElement>;
  119890. /**
  119891. * Gets the current engine view
  119892. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119893. */
  119894. activeView: Nullable<EngineView>;
  119895. /** Gets or sets the list of views */
  119896. views: EngineView[];
  119897. /**
  119898. * Register a new child canvas
  119899. * @param canvas defines the canvas to register
  119900. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  119901. * @returns the associated view
  119902. */
  119903. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  119904. /**
  119905. * Remove a registered child canvas
  119906. * @param canvas defines the canvas to remove
  119907. * @returns the current engine
  119908. */
  119909. unRegisterView(canvas: HTMLCanvasElement): Engine;
  119910. }
  119911. }
  119912. declare module BABYLON {
  119913. /**
  119914. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  119915. */
  119916. export interface CubeMapInfo {
  119917. /**
  119918. * The pixel array for the front face.
  119919. * This is stored in format, left to right, up to down format.
  119920. */
  119921. front: Nullable<ArrayBufferView>;
  119922. /**
  119923. * The pixel array for the back face.
  119924. * This is stored in format, left to right, up to down format.
  119925. */
  119926. back: Nullable<ArrayBufferView>;
  119927. /**
  119928. * The pixel array for the left face.
  119929. * This is stored in format, left to right, up to down format.
  119930. */
  119931. left: Nullable<ArrayBufferView>;
  119932. /**
  119933. * The pixel array for the right face.
  119934. * This is stored in format, left to right, up to down format.
  119935. */
  119936. right: Nullable<ArrayBufferView>;
  119937. /**
  119938. * The pixel array for the up face.
  119939. * This is stored in format, left to right, up to down format.
  119940. */
  119941. up: Nullable<ArrayBufferView>;
  119942. /**
  119943. * The pixel array for the down face.
  119944. * This is stored in format, left to right, up to down format.
  119945. */
  119946. down: Nullable<ArrayBufferView>;
  119947. /**
  119948. * The size of the cubemap stored.
  119949. *
  119950. * Each faces will be size * size pixels.
  119951. */
  119952. size: number;
  119953. /**
  119954. * The format of the texture.
  119955. *
  119956. * RGBA, RGB.
  119957. */
  119958. format: number;
  119959. /**
  119960. * The type of the texture data.
  119961. *
  119962. * UNSIGNED_INT, FLOAT.
  119963. */
  119964. type: number;
  119965. /**
  119966. * Specifies whether the texture is in gamma space.
  119967. */
  119968. gammaSpace: boolean;
  119969. }
  119970. /**
  119971. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  119972. */
  119973. export class PanoramaToCubeMapTools {
  119974. private static FACE_FRONT;
  119975. private static FACE_BACK;
  119976. private static FACE_RIGHT;
  119977. private static FACE_LEFT;
  119978. private static FACE_DOWN;
  119979. private static FACE_UP;
  119980. /**
  119981. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  119982. *
  119983. * @param float32Array The source data.
  119984. * @param inputWidth The width of the input panorama.
  119985. * @param inputHeight The height of the input panorama.
  119986. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  119987. * @return The cubemap data
  119988. */
  119989. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  119990. private static CreateCubemapTexture;
  119991. private static CalcProjectionSpherical;
  119992. }
  119993. }
  119994. declare module BABYLON {
  119995. /**
  119996. * Helper class dealing with the extraction of spherical polynomial dataArray
  119997. * from a cube map.
  119998. */
  119999. export class CubeMapToSphericalPolynomialTools {
  120000. private static FileFaces;
  120001. /**
  120002. * Converts a texture to the according Spherical Polynomial data.
  120003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120004. *
  120005. * @param texture The texture to extract the information from.
  120006. * @return The Spherical Polynomial data.
  120007. */
  120008. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120009. /**
  120010. * Converts a cubemap to the according Spherical Polynomial data.
  120011. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120012. *
  120013. * @param cubeInfo The Cube map to extract the information from.
  120014. * @return The Spherical Polynomial data.
  120015. */
  120016. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120017. }
  120018. }
  120019. declare module BABYLON {
  120020. interface BaseTexture {
  120021. /**
  120022. * Get the polynomial representation of the texture data.
  120023. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120024. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120025. */
  120026. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120027. }
  120028. }
  120029. declare module BABYLON {
  120030. /** @hidden */
  120031. export var rgbdEncodePixelShader: {
  120032. name: string;
  120033. shader: string;
  120034. };
  120035. }
  120036. declare module BABYLON {
  120037. /** @hidden */
  120038. export var rgbdDecodePixelShader: {
  120039. name: string;
  120040. shader: string;
  120041. };
  120042. }
  120043. declare module BABYLON {
  120044. /**
  120045. * Raw texture data and descriptor sufficient for WebGL texture upload
  120046. */
  120047. export interface EnvironmentTextureInfo {
  120048. /**
  120049. * Version of the environment map
  120050. */
  120051. version: number;
  120052. /**
  120053. * Width of image
  120054. */
  120055. width: number;
  120056. /**
  120057. * Irradiance information stored in the file.
  120058. */
  120059. irradiance: any;
  120060. /**
  120061. * Specular information stored in the file.
  120062. */
  120063. specular: any;
  120064. }
  120065. /**
  120066. * Defines One Image in the file. It requires only the position in the file
  120067. * as well as the length.
  120068. */
  120069. interface BufferImageData {
  120070. /**
  120071. * Length of the image data.
  120072. */
  120073. length: number;
  120074. /**
  120075. * Position of the data from the null terminator delimiting the end of the JSON.
  120076. */
  120077. position: number;
  120078. }
  120079. /**
  120080. * Defines the specular data enclosed in the file.
  120081. * This corresponds to the version 1 of the data.
  120082. */
  120083. export interface EnvironmentTextureSpecularInfoV1 {
  120084. /**
  120085. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120086. */
  120087. specularDataPosition?: number;
  120088. /**
  120089. * This contains all the images data needed to reconstruct the cubemap.
  120090. */
  120091. mipmaps: Array<BufferImageData>;
  120092. /**
  120093. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120094. */
  120095. lodGenerationScale: number;
  120096. }
  120097. /**
  120098. * Sets of helpers addressing the serialization and deserialization of environment texture
  120099. * stored in a BabylonJS env file.
  120100. * Those files are usually stored as .env files.
  120101. */
  120102. export class EnvironmentTextureTools {
  120103. /**
  120104. * Magic number identifying the env file.
  120105. */
  120106. private static _MagicBytes;
  120107. /**
  120108. * Gets the environment info from an env file.
  120109. * @param data The array buffer containing the .env bytes.
  120110. * @returns the environment file info (the json header) if successfully parsed.
  120111. */
  120112. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120113. /**
  120114. * Creates an environment texture from a loaded cube texture.
  120115. * @param texture defines the cube texture to convert in env file
  120116. * @return a promise containing the environment data if succesfull.
  120117. */
  120118. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120119. /**
  120120. * Creates a JSON representation of the spherical data.
  120121. * @param texture defines the texture containing the polynomials
  120122. * @return the JSON representation of the spherical info
  120123. */
  120124. private static _CreateEnvTextureIrradiance;
  120125. /**
  120126. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120127. * @param data the image data
  120128. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120129. * @return the views described by info providing access to the underlying buffer
  120130. */
  120131. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120132. /**
  120133. * Uploads the texture info contained in the env file to the GPU.
  120134. * @param texture defines the internal texture to upload to
  120135. * @param data defines the data to load
  120136. * @param info defines the texture info retrieved through the GetEnvInfo method
  120137. * @returns a promise
  120138. */
  120139. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120140. private static _OnImageReadyAsync;
  120141. /**
  120142. * Uploads the levels of image data to the GPU.
  120143. * @param texture defines the internal texture to upload to
  120144. * @param imageData defines the array buffer views of image data [mipmap][face]
  120145. * @returns a promise
  120146. */
  120147. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120148. /**
  120149. * Uploads spherical polynomials information to the texture.
  120150. * @param texture defines the texture we are trying to upload the information to
  120151. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120152. */
  120153. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120154. /** @hidden */
  120155. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120156. }
  120157. }
  120158. declare module BABYLON {
  120159. /**
  120160. * Contains position and normal vectors for a vertex
  120161. */
  120162. export class PositionNormalVertex {
  120163. /** the position of the vertex (defaut: 0,0,0) */
  120164. position: Vector3;
  120165. /** the normal of the vertex (defaut: 0,1,0) */
  120166. normal: Vector3;
  120167. /**
  120168. * Creates a PositionNormalVertex
  120169. * @param position the position of the vertex (defaut: 0,0,0)
  120170. * @param normal the normal of the vertex (defaut: 0,1,0)
  120171. */
  120172. constructor(
  120173. /** the position of the vertex (defaut: 0,0,0) */
  120174. position?: Vector3,
  120175. /** the normal of the vertex (defaut: 0,1,0) */
  120176. normal?: Vector3);
  120177. /**
  120178. * Clones the PositionNormalVertex
  120179. * @returns the cloned PositionNormalVertex
  120180. */
  120181. clone(): PositionNormalVertex;
  120182. }
  120183. /**
  120184. * Contains position, normal and uv vectors for a vertex
  120185. */
  120186. export class PositionNormalTextureVertex {
  120187. /** the position of the vertex (defaut: 0,0,0) */
  120188. position: Vector3;
  120189. /** the normal of the vertex (defaut: 0,1,0) */
  120190. normal: Vector3;
  120191. /** the uv of the vertex (default: 0,0) */
  120192. uv: Vector2;
  120193. /**
  120194. * Creates a PositionNormalTextureVertex
  120195. * @param position the position of the vertex (defaut: 0,0,0)
  120196. * @param normal the normal of the vertex (defaut: 0,1,0)
  120197. * @param uv the uv of the vertex (default: 0,0)
  120198. */
  120199. constructor(
  120200. /** the position of the vertex (defaut: 0,0,0) */
  120201. position?: Vector3,
  120202. /** the normal of the vertex (defaut: 0,1,0) */
  120203. normal?: Vector3,
  120204. /** the uv of the vertex (default: 0,0) */
  120205. uv?: Vector2);
  120206. /**
  120207. * Clones the PositionNormalTextureVertex
  120208. * @returns the cloned PositionNormalTextureVertex
  120209. */
  120210. clone(): PositionNormalTextureVertex;
  120211. }
  120212. }
  120213. declare module BABYLON {
  120214. /** @hidden */
  120215. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120216. private _genericAttributeLocation;
  120217. private _varyingLocationCount;
  120218. private _varyingLocationMap;
  120219. private _replacements;
  120220. private _textureCount;
  120221. private _uniforms;
  120222. lineProcessor(line: string): string;
  120223. attributeProcessor(attribute: string): string;
  120224. varyingProcessor(varying: string, isFragment: boolean): string;
  120225. uniformProcessor(uniform: string): string;
  120226. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120227. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120228. }
  120229. }
  120230. declare module BABYLON {
  120231. /**
  120232. * Container for accessors for natively-stored mesh data buffers.
  120233. */
  120234. class NativeDataBuffer extends DataBuffer {
  120235. /**
  120236. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120237. */
  120238. nativeIndexBuffer?: any;
  120239. /**
  120240. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120241. */
  120242. nativeVertexBuffer?: any;
  120243. }
  120244. /** @hidden */
  120245. class NativeTexture extends InternalTexture {
  120246. getInternalTexture(): InternalTexture;
  120247. getViewCount(): number;
  120248. }
  120249. /** @hidden */
  120250. export class NativeEngine extends Engine {
  120251. private readonly _native;
  120252. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120253. private readonly INVALID_HANDLE;
  120254. getHardwareScalingLevel(): number;
  120255. constructor();
  120256. /**
  120257. * Can be used to override the current requestAnimationFrame requester.
  120258. * @hidden
  120259. */
  120260. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120261. /**
  120262. * Override default engine behavior.
  120263. * @param color
  120264. * @param backBuffer
  120265. * @param depth
  120266. * @param stencil
  120267. */
  120268. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120269. /**
  120270. * Gets host document
  120271. * @returns the host document object
  120272. */
  120273. getHostDocument(): Nullable<Document>;
  120274. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120275. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120276. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120277. recordVertexArrayObject(vertexBuffers: {
  120278. [key: string]: VertexBuffer;
  120279. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120280. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120281. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120282. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120283. /**
  120284. * Draw a list of indexed primitives
  120285. * @param fillMode defines the primitive to use
  120286. * @param indexStart defines the starting index
  120287. * @param indexCount defines the number of index to draw
  120288. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120289. */
  120290. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120291. /**
  120292. * Draw a list of unindexed primitives
  120293. * @param fillMode defines the primitive to use
  120294. * @param verticesStart defines the index of first vertex to draw
  120295. * @param verticesCount defines the count of vertices to draw
  120296. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120297. */
  120298. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120299. createPipelineContext(): IPipelineContext;
  120300. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120301. /** @hidden */
  120302. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120303. /** @hidden */
  120304. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120305. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120306. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120307. protected _setProgram(program: WebGLProgram): void;
  120308. _releaseEffect(effect: Effect): void;
  120309. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120310. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120311. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120312. bindSamplers(effect: Effect): void;
  120313. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120314. getRenderWidth(useScreen?: boolean): number;
  120315. getRenderHeight(useScreen?: boolean): number;
  120316. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120317. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120318. /**
  120319. * Set the z offset to apply to current rendering
  120320. * @param value defines the offset to apply
  120321. */
  120322. setZOffset(value: number): void;
  120323. /**
  120324. * Gets the current value of the zOffset
  120325. * @returns the current zOffset state
  120326. */
  120327. getZOffset(): number;
  120328. /**
  120329. * Enable or disable depth buffering
  120330. * @param enable defines the state to set
  120331. */
  120332. setDepthBuffer(enable: boolean): void;
  120333. /**
  120334. * Gets a boolean indicating if depth writing is enabled
  120335. * @returns the current depth writing state
  120336. */
  120337. getDepthWrite(): boolean;
  120338. /**
  120339. * Enable or disable depth writing
  120340. * @param enable defines the state to set
  120341. */
  120342. setDepthWrite(enable: boolean): void;
  120343. /**
  120344. * Enable or disable color writing
  120345. * @param enable defines the state to set
  120346. */
  120347. setColorWrite(enable: boolean): void;
  120348. /**
  120349. * Gets a boolean indicating if color writing is enabled
  120350. * @returns the current color writing state
  120351. */
  120352. getColorWrite(): boolean;
  120353. /**
  120354. * Sets alpha constants used by some alpha blending modes
  120355. * @param r defines the red component
  120356. * @param g defines the green component
  120357. * @param b defines the blue component
  120358. * @param a defines the alpha component
  120359. */
  120360. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120361. /**
  120362. * Sets the current alpha mode
  120363. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120364. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120365. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120366. */
  120367. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120368. /**
  120369. * Gets the current alpha mode
  120370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120371. * @returns the current alpha mode
  120372. */
  120373. getAlphaMode(): number;
  120374. setInt(uniform: WebGLUniformLocation, int: number): void;
  120375. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120376. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120377. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120378. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120379. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120380. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120381. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120382. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120383. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120384. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120385. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120386. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120387. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120388. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120389. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120390. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120391. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120392. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120393. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120394. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120395. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120396. wipeCaches(bruteForce?: boolean): void;
  120397. _createTexture(): WebGLTexture;
  120398. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120399. /**
  120400. * Usually called from BABYLON.Texture.ts.
  120401. * Passed information to create a WebGLTexture
  120402. * @param urlArg defines a value which contains one of the following:
  120403. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120404. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120405. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120406. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120407. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120408. * @param scene needed for loading to the correct scene
  120409. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120410. * @param onLoad optional callback to be called upon successful completion
  120411. * @param onError optional callback to be called upon failure
  120412. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120413. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120414. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120415. * @param forcedExtension defines the extension to use to pick the right loader
  120416. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120417. */
  120418. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  120419. /**
  120420. * Creates a cube texture
  120421. * @param rootUrl defines the url where the files to load is located
  120422. * @param scene defines the current scene
  120423. * @param files defines the list of files to load (1 per face)
  120424. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120425. * @param onLoad defines an optional callback raised when the texture is loaded
  120426. * @param onError defines an optional callback raised if there is an issue to load the texture
  120427. * @param format defines the format of the data
  120428. * @param forcedExtension defines the extension to use to pick the right loader
  120429. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120430. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120431. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120432. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120433. * @returns the cube texture as an InternalTexture
  120434. */
  120435. 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;
  120436. private _getSamplingFilter;
  120437. private static _GetNativeTextureFormat;
  120438. createRenderTargetTexture(size: number | {
  120439. width: number;
  120440. height: number;
  120441. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120442. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120443. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120444. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120445. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120446. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120447. /**
  120448. * Updates a dynamic vertex buffer.
  120449. * @param vertexBuffer the vertex buffer to update
  120450. * @param data the data used to update the vertex buffer
  120451. * @param byteOffset the byte offset of the data (optional)
  120452. * @param byteLength the byte length of the data (optional)
  120453. */
  120454. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120455. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120456. private _updateAnisotropicLevel;
  120457. private _getAddressMode;
  120458. /** @hidden */
  120459. _bindTexture(channel: number, texture: InternalTexture): void;
  120460. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120461. releaseEffects(): void;
  120462. /** @hidden */
  120463. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120464. /** @hidden */
  120465. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120466. /** @hidden */
  120467. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120468. /** @hidden */
  120469. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120470. }
  120471. }
  120472. declare module BABYLON {
  120473. /**
  120474. * Gather the list of clipboard event types as constants.
  120475. */
  120476. export class ClipboardEventTypes {
  120477. /**
  120478. * The clipboard event is fired when a copy command is active (pressed).
  120479. */
  120480. static readonly COPY: number;
  120481. /**
  120482. * The clipboard event is fired when a cut command is active (pressed).
  120483. */
  120484. static readonly CUT: number;
  120485. /**
  120486. * The clipboard event is fired when a paste command is active (pressed).
  120487. */
  120488. static readonly PASTE: number;
  120489. }
  120490. /**
  120491. * This class is used to store clipboard related info for the onClipboardObservable event.
  120492. */
  120493. export class ClipboardInfo {
  120494. /**
  120495. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120496. */
  120497. type: number;
  120498. /**
  120499. * Defines the related dom event
  120500. */
  120501. event: ClipboardEvent;
  120502. /**
  120503. *Creates an instance of ClipboardInfo.
  120504. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120505. * @param event Defines the related dom event
  120506. */
  120507. constructor(
  120508. /**
  120509. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120510. */
  120511. type: number,
  120512. /**
  120513. * Defines the related dom event
  120514. */
  120515. event: ClipboardEvent);
  120516. /**
  120517. * Get the clipboard event's type from the keycode.
  120518. * @param keyCode Defines the keyCode for the current keyboard event.
  120519. * @return {number}
  120520. */
  120521. static GetTypeFromCharacter(keyCode: number): number;
  120522. }
  120523. }
  120524. declare module BABYLON {
  120525. /**
  120526. * Google Daydream controller
  120527. */
  120528. export class DaydreamController extends WebVRController {
  120529. /**
  120530. * Base Url for the controller model.
  120531. */
  120532. static MODEL_BASE_URL: string;
  120533. /**
  120534. * File name for the controller model.
  120535. */
  120536. static MODEL_FILENAME: string;
  120537. /**
  120538. * Gamepad Id prefix used to identify Daydream Controller.
  120539. */
  120540. static readonly GAMEPAD_ID_PREFIX: string;
  120541. /**
  120542. * Creates a new DaydreamController from a gamepad
  120543. * @param vrGamepad the gamepad that the controller should be created from
  120544. */
  120545. constructor(vrGamepad: any);
  120546. /**
  120547. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120548. * @param scene scene in which to add meshes
  120549. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120550. */
  120551. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120552. /**
  120553. * Called once for each button that changed state since the last frame
  120554. * @param buttonIdx Which button index changed
  120555. * @param state New state of the button
  120556. * @param changes Which properties on the state changed since last frame
  120557. */
  120558. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120559. }
  120560. }
  120561. declare module BABYLON {
  120562. /**
  120563. * Gear VR Controller
  120564. */
  120565. export class GearVRController extends WebVRController {
  120566. /**
  120567. * Base Url for the controller model.
  120568. */
  120569. static MODEL_BASE_URL: string;
  120570. /**
  120571. * File name for the controller model.
  120572. */
  120573. static MODEL_FILENAME: string;
  120574. /**
  120575. * Gamepad Id prefix used to identify this controller.
  120576. */
  120577. static readonly GAMEPAD_ID_PREFIX: string;
  120578. private readonly _buttonIndexToObservableNameMap;
  120579. /**
  120580. * Creates a new GearVRController from a gamepad
  120581. * @param vrGamepad the gamepad that the controller should be created from
  120582. */
  120583. constructor(vrGamepad: any);
  120584. /**
  120585. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120586. * @param scene scene in which to add meshes
  120587. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120588. */
  120589. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120590. /**
  120591. * Called once for each button that changed state since the last frame
  120592. * @param buttonIdx Which button index changed
  120593. * @param state New state of the button
  120594. * @param changes Which properties on the state changed since last frame
  120595. */
  120596. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120597. }
  120598. }
  120599. declare module BABYLON {
  120600. /**
  120601. * Generic Controller
  120602. */
  120603. export class GenericController extends WebVRController {
  120604. /**
  120605. * Base Url for the controller model.
  120606. */
  120607. static readonly MODEL_BASE_URL: string;
  120608. /**
  120609. * File name for the controller model.
  120610. */
  120611. static readonly MODEL_FILENAME: string;
  120612. /**
  120613. * Creates a new GenericController from a gamepad
  120614. * @param vrGamepad the gamepad that the controller should be created from
  120615. */
  120616. constructor(vrGamepad: any);
  120617. /**
  120618. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120619. * @param scene scene in which to add meshes
  120620. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120621. */
  120622. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120623. /**
  120624. * Called once for each button that changed state since the last frame
  120625. * @param buttonIdx Which button index changed
  120626. * @param state New state of the button
  120627. * @param changes Which properties on the state changed since last frame
  120628. */
  120629. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120630. }
  120631. }
  120632. declare module BABYLON {
  120633. /**
  120634. * Oculus Touch Controller
  120635. */
  120636. export class OculusTouchController extends WebVRController {
  120637. /**
  120638. * Base Url for the controller model.
  120639. */
  120640. static MODEL_BASE_URL: string;
  120641. /**
  120642. * File name for the left controller model.
  120643. */
  120644. static MODEL_LEFT_FILENAME: string;
  120645. /**
  120646. * File name for the right controller model.
  120647. */
  120648. static MODEL_RIGHT_FILENAME: string;
  120649. /**
  120650. * Base Url for the Quest controller model.
  120651. */
  120652. static QUEST_MODEL_BASE_URL: string;
  120653. /**
  120654. * @hidden
  120655. * If the controllers are running on a device that needs the updated Quest controller models
  120656. */
  120657. static _IsQuest: boolean;
  120658. /**
  120659. * Fired when the secondary trigger on this controller is modified
  120660. */
  120661. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  120662. /**
  120663. * Fired when the thumb rest on this controller is modified
  120664. */
  120665. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  120666. /**
  120667. * Creates a new OculusTouchController from a gamepad
  120668. * @param vrGamepad the gamepad that the controller should be created from
  120669. */
  120670. constructor(vrGamepad: any);
  120671. /**
  120672. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120673. * @param scene scene in which to add meshes
  120674. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120675. */
  120676. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120677. /**
  120678. * Fired when the A button on this controller is modified
  120679. */
  120680. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120681. /**
  120682. * Fired when the B button on this controller is modified
  120683. */
  120684. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120685. /**
  120686. * Fired when the X button on this controller is modified
  120687. */
  120688. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120689. /**
  120690. * Fired when the Y button on this controller is modified
  120691. */
  120692. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120693. /**
  120694. * Called once for each button that changed state since the last frame
  120695. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  120696. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  120697. * 2) secondary trigger (same)
  120698. * 3) A (right) X (left), touch, pressed = value
  120699. * 4) B / Y
  120700. * 5) thumb rest
  120701. * @param buttonIdx Which button index changed
  120702. * @param state New state of the button
  120703. * @param changes Which properties on the state changed since last frame
  120704. */
  120705. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120706. }
  120707. }
  120708. declare module BABYLON {
  120709. /**
  120710. * Vive Controller
  120711. */
  120712. export class ViveController extends WebVRController {
  120713. /**
  120714. * Base Url for the controller model.
  120715. */
  120716. static MODEL_BASE_URL: string;
  120717. /**
  120718. * File name for the controller model.
  120719. */
  120720. static MODEL_FILENAME: string;
  120721. /**
  120722. * Creates a new ViveController from a gamepad
  120723. * @param vrGamepad the gamepad that the controller should be created from
  120724. */
  120725. constructor(vrGamepad: any);
  120726. /**
  120727. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120728. * @param scene scene in which to add meshes
  120729. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120730. */
  120731. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120732. /**
  120733. * Fired when the left button on this controller is modified
  120734. */
  120735. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120736. /**
  120737. * Fired when the right button on this controller is modified
  120738. */
  120739. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120740. /**
  120741. * Fired when the menu button on this controller is modified
  120742. */
  120743. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120744. /**
  120745. * Called once for each button that changed state since the last frame
  120746. * Vive mapping:
  120747. * 0: touchpad
  120748. * 1: trigger
  120749. * 2: left AND right buttons
  120750. * 3: menu button
  120751. * @param buttonIdx Which button index changed
  120752. * @param state New state of the button
  120753. * @param changes Which properties on the state changed since last frame
  120754. */
  120755. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120756. }
  120757. }
  120758. declare module BABYLON {
  120759. /**
  120760. * Defines the WindowsMotionController object that the state of the windows motion controller
  120761. */
  120762. export class WindowsMotionController extends WebVRController {
  120763. /**
  120764. * The base url used to load the left and right controller models
  120765. */
  120766. static MODEL_BASE_URL: string;
  120767. /**
  120768. * The name of the left controller model file
  120769. */
  120770. static MODEL_LEFT_FILENAME: string;
  120771. /**
  120772. * The name of the right controller model file
  120773. */
  120774. static MODEL_RIGHT_FILENAME: string;
  120775. /**
  120776. * The controller name prefix for this controller type
  120777. */
  120778. static readonly GAMEPAD_ID_PREFIX: string;
  120779. /**
  120780. * The controller id pattern for this controller type
  120781. */
  120782. private static readonly GAMEPAD_ID_PATTERN;
  120783. private _loadedMeshInfo;
  120784. protected readonly _mapping: {
  120785. buttons: string[];
  120786. buttonMeshNames: {
  120787. 'trigger': string;
  120788. 'menu': string;
  120789. 'grip': string;
  120790. 'thumbstick': string;
  120791. 'trackpad': string;
  120792. };
  120793. buttonObservableNames: {
  120794. 'trigger': string;
  120795. 'menu': string;
  120796. 'grip': string;
  120797. 'thumbstick': string;
  120798. 'trackpad': string;
  120799. };
  120800. axisMeshNames: string[];
  120801. pointingPoseMeshName: string;
  120802. };
  120803. /**
  120804. * Fired when the trackpad on this controller is clicked
  120805. */
  120806. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120807. /**
  120808. * Fired when the trackpad on this controller is modified
  120809. */
  120810. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120811. /**
  120812. * The current x and y values of this controller's trackpad
  120813. */
  120814. trackpad: StickValues;
  120815. /**
  120816. * Creates a new WindowsMotionController from a gamepad
  120817. * @param vrGamepad the gamepad that the controller should be created from
  120818. */
  120819. constructor(vrGamepad: any);
  120820. /**
  120821. * Fired when the trigger on this controller is modified
  120822. */
  120823. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120824. /**
  120825. * Fired when the menu button on this controller is modified
  120826. */
  120827. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120828. /**
  120829. * Fired when the grip button on this controller is modified
  120830. */
  120831. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120832. /**
  120833. * Fired when the thumbstick button on this controller is modified
  120834. */
  120835. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120836. /**
  120837. * Fired when the touchpad button on this controller is modified
  120838. */
  120839. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120840. /**
  120841. * Fired when the touchpad values on this controller are modified
  120842. */
  120843. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  120844. protected _updateTrackpad(): void;
  120845. /**
  120846. * Called once per frame by the engine.
  120847. */
  120848. update(): void;
  120849. /**
  120850. * Called once for each button that changed state since the last frame
  120851. * @param buttonIdx Which button index changed
  120852. * @param state New state of the button
  120853. * @param changes Which properties on the state changed since last frame
  120854. */
  120855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120856. /**
  120857. * Moves the buttons on the controller mesh based on their current state
  120858. * @param buttonName the name of the button to move
  120859. * @param buttonValue the value of the button which determines the buttons new position
  120860. */
  120861. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  120862. /**
  120863. * Moves the axis on the controller mesh based on its current state
  120864. * @param axis the index of the axis
  120865. * @param axisValue the value of the axis which determines the meshes new position
  120866. * @hidden
  120867. */
  120868. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  120869. /**
  120870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120871. * @param scene scene in which to add meshes
  120872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120873. */
  120874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  120875. /**
  120876. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  120877. * can be transformed by button presses and axes values, based on this._mapping.
  120878. *
  120879. * @param scene scene in which the meshes exist
  120880. * @param meshes list of meshes that make up the controller model to process
  120881. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  120882. */
  120883. private processModel;
  120884. private createMeshInfo;
  120885. /**
  120886. * Gets the ray of the controller in the direction the controller is pointing
  120887. * @param length the length the resulting ray should be
  120888. * @returns a ray in the direction the controller is pointing
  120889. */
  120890. getForwardRay(length?: number): Ray;
  120891. /**
  120892. * Disposes of the controller
  120893. */
  120894. dispose(): void;
  120895. }
  120896. /**
  120897. * This class represents a new windows motion controller in XR.
  120898. */
  120899. export class XRWindowsMotionController extends WindowsMotionController {
  120900. /**
  120901. * Changing the original WIndowsMotionController mapping to fir the new mapping
  120902. */
  120903. protected readonly _mapping: {
  120904. buttons: string[];
  120905. buttonMeshNames: {
  120906. 'trigger': string;
  120907. 'menu': string;
  120908. 'grip': string;
  120909. 'thumbstick': string;
  120910. 'trackpad': string;
  120911. };
  120912. buttonObservableNames: {
  120913. 'trigger': string;
  120914. 'menu': string;
  120915. 'grip': string;
  120916. 'thumbstick': string;
  120917. 'trackpad': string;
  120918. };
  120919. axisMeshNames: string[];
  120920. pointingPoseMeshName: string;
  120921. };
  120922. /**
  120923. * Construct a new XR-Based windows motion controller
  120924. *
  120925. * @param gamepadInfo the gamepad object from the browser
  120926. */
  120927. constructor(gamepadInfo: any);
  120928. /**
  120929. * holds the thumbstick values (X,Y)
  120930. */
  120931. thumbstickValues: StickValues;
  120932. /**
  120933. * Fired when the thumbstick on this controller is clicked
  120934. */
  120935. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  120936. /**
  120937. * Fired when the thumbstick on this controller is modified
  120938. */
  120939. onThumbstickValuesChangedObservable: Observable<StickValues>;
  120940. /**
  120941. * Fired when the touchpad button on this controller is modified
  120942. */
  120943. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120944. /**
  120945. * Fired when the touchpad values on this controller are modified
  120946. */
  120947. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120948. /**
  120949. * Fired when the thumbstick button on this controller is modified
  120950. * here to prevent breaking changes
  120951. */
  120952. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120953. /**
  120954. * updating the thumbstick(!) and not the trackpad.
  120955. * This is named this way due to the difference between WebVR and XR and to avoid
  120956. * changing the parent class.
  120957. */
  120958. protected _updateTrackpad(): void;
  120959. /**
  120960. * Disposes the class with joy
  120961. */
  120962. dispose(): void;
  120963. }
  120964. }
  120965. declare module BABYLON {
  120966. /**
  120967. * Class containing static functions to help procedurally build meshes
  120968. */
  120969. export class PolyhedronBuilder {
  120970. /**
  120971. * Creates a polyhedron mesh
  120972. * * 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
  120973. * * The parameter `size` (positive float, default 1) sets the polygon size
  120974. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120975. * * 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`
  120976. * * 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
  120977. * * 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)`)
  120978. * * 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
  120979. * * 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
  120980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120983. * @param name defines the name of the mesh
  120984. * @param options defines the options used to create the mesh
  120985. * @param scene defines the hosting scene
  120986. * @returns the polyhedron mesh
  120987. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120988. */
  120989. static CreatePolyhedron(name: string, options: {
  120990. type?: number;
  120991. size?: number;
  120992. sizeX?: number;
  120993. sizeY?: number;
  120994. sizeZ?: number;
  120995. custom?: any;
  120996. faceUV?: Vector4[];
  120997. faceColors?: Color4[];
  120998. flat?: boolean;
  120999. updatable?: boolean;
  121000. sideOrientation?: number;
  121001. frontUVs?: Vector4;
  121002. backUVs?: Vector4;
  121003. }, scene?: Nullable<Scene>): Mesh;
  121004. }
  121005. }
  121006. declare module BABYLON {
  121007. /**
  121008. * Gizmo that enables scaling a mesh along 3 axis
  121009. */
  121010. export class ScaleGizmo extends Gizmo {
  121011. /**
  121012. * Internal gizmo used for interactions on the x axis
  121013. */
  121014. xGizmo: AxisScaleGizmo;
  121015. /**
  121016. * Internal gizmo used for interactions on the y axis
  121017. */
  121018. yGizmo: AxisScaleGizmo;
  121019. /**
  121020. * Internal gizmo used for interactions on the z axis
  121021. */
  121022. zGizmo: AxisScaleGizmo;
  121023. /**
  121024. * Internal gizmo used to scale all axis equally
  121025. */
  121026. uniformScaleGizmo: AxisScaleGizmo;
  121027. private _meshAttached;
  121028. private _updateGizmoRotationToMatchAttachedMesh;
  121029. private _snapDistance;
  121030. private _scaleRatio;
  121031. private _uniformScalingMesh;
  121032. private _octahedron;
  121033. private _sensitivity;
  121034. /** Fires an event when any of it's sub gizmos are dragged */
  121035. onDragStartObservable: Observable<unknown>;
  121036. /** Fires an event when any of it's sub gizmos are released from dragging */
  121037. onDragEndObservable: Observable<unknown>;
  121038. get attachedMesh(): Nullable<AbstractMesh>;
  121039. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121040. /**
  121041. * Creates a ScaleGizmo
  121042. * @param gizmoLayer The utility layer the gizmo will be added to
  121043. */
  121044. constructor(gizmoLayer?: UtilityLayerRenderer);
  121045. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121046. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121047. /**
  121048. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121049. */
  121050. set snapDistance(value: number);
  121051. get snapDistance(): number;
  121052. /**
  121053. * Ratio for the scale of the gizmo (Default: 1)
  121054. */
  121055. set scaleRatio(value: number);
  121056. get scaleRatio(): number;
  121057. /**
  121058. * Sensitivity factor for dragging (Default: 1)
  121059. */
  121060. set sensitivity(value: number);
  121061. get sensitivity(): number;
  121062. /**
  121063. * Disposes of the gizmo
  121064. */
  121065. dispose(): void;
  121066. }
  121067. }
  121068. declare module BABYLON {
  121069. /**
  121070. * Single axis scale gizmo
  121071. */
  121072. export class AxisScaleGizmo extends Gizmo {
  121073. /**
  121074. * Drag behavior responsible for the gizmos dragging interactions
  121075. */
  121076. dragBehavior: PointerDragBehavior;
  121077. private _pointerObserver;
  121078. /**
  121079. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121080. */
  121081. snapDistance: number;
  121082. /**
  121083. * Event that fires each time the gizmo snaps to a new location.
  121084. * * snapDistance is the the change in distance
  121085. */
  121086. onSnapObservable: Observable<{
  121087. snapDistance: number;
  121088. }>;
  121089. /**
  121090. * If the scaling operation should be done on all axis (default: false)
  121091. */
  121092. uniformScaling: boolean;
  121093. /**
  121094. * Custom sensitivity value for the drag strength
  121095. */
  121096. sensitivity: number;
  121097. private _isEnabled;
  121098. private _parent;
  121099. private _arrow;
  121100. private _coloredMaterial;
  121101. private _hoverMaterial;
  121102. /**
  121103. * Creates an AxisScaleGizmo
  121104. * @param gizmoLayer The utility layer the gizmo will be added to
  121105. * @param dragAxis The axis which the gizmo will be able to scale on
  121106. * @param color The color of the gizmo
  121107. */
  121108. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121109. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121110. /**
  121111. * If the gizmo is enabled
  121112. */
  121113. set isEnabled(value: boolean);
  121114. get isEnabled(): boolean;
  121115. /**
  121116. * Disposes of the gizmo
  121117. */
  121118. dispose(): void;
  121119. /**
  121120. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121121. * @param mesh The mesh to replace the default mesh of the gizmo
  121122. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121123. */
  121124. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121125. }
  121126. }
  121127. declare module BABYLON {
  121128. /**
  121129. * Bounding box gizmo
  121130. */
  121131. export class BoundingBoxGizmo extends Gizmo {
  121132. private _lineBoundingBox;
  121133. private _rotateSpheresParent;
  121134. private _scaleBoxesParent;
  121135. private _boundingDimensions;
  121136. private _renderObserver;
  121137. private _pointerObserver;
  121138. private _scaleDragSpeed;
  121139. private _tmpQuaternion;
  121140. private _tmpVector;
  121141. private _tmpRotationMatrix;
  121142. /**
  121143. * 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)
  121144. */
  121145. ignoreChildren: boolean;
  121146. /**
  121147. * 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)
  121148. */
  121149. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121150. /**
  121151. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121152. */
  121153. rotationSphereSize: number;
  121154. /**
  121155. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121156. */
  121157. scaleBoxSize: number;
  121158. /**
  121159. * 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)
  121160. */
  121161. fixedDragMeshScreenSize: boolean;
  121162. /**
  121163. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121164. */
  121165. fixedDragMeshScreenSizeDistanceFactor: number;
  121166. /**
  121167. * Fired when a rotation sphere or scale box is dragged
  121168. */
  121169. onDragStartObservable: Observable<{}>;
  121170. /**
  121171. * Fired when a scale box is dragged
  121172. */
  121173. onScaleBoxDragObservable: Observable<{}>;
  121174. /**
  121175. * Fired when a scale box drag is ended
  121176. */
  121177. onScaleBoxDragEndObservable: Observable<{}>;
  121178. /**
  121179. * Fired when a rotation sphere is dragged
  121180. */
  121181. onRotationSphereDragObservable: Observable<{}>;
  121182. /**
  121183. * Fired when a rotation sphere drag is ended
  121184. */
  121185. onRotationSphereDragEndObservable: Observable<{}>;
  121186. /**
  121187. * 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)
  121188. */
  121189. scalePivot: Nullable<Vector3>;
  121190. /**
  121191. * Mesh used as a pivot to rotate the attached mesh
  121192. */
  121193. private _anchorMesh;
  121194. private _existingMeshScale;
  121195. private _dragMesh;
  121196. private pointerDragBehavior;
  121197. private coloredMaterial;
  121198. private hoverColoredMaterial;
  121199. /**
  121200. * Sets the color of the bounding box gizmo
  121201. * @param color the color to set
  121202. */
  121203. setColor(color: Color3): void;
  121204. /**
  121205. * Creates an BoundingBoxGizmo
  121206. * @param gizmoLayer The utility layer the gizmo will be added to
  121207. * @param color The color of the gizmo
  121208. */
  121209. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121210. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121211. private _selectNode;
  121212. /**
  121213. * Updates the bounding box information for the Gizmo
  121214. */
  121215. updateBoundingBox(): void;
  121216. private _updateRotationSpheres;
  121217. private _updateScaleBoxes;
  121218. /**
  121219. * Enables rotation on the specified axis and disables rotation on the others
  121220. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121221. */
  121222. setEnabledRotationAxis(axis: string): void;
  121223. /**
  121224. * Enables/disables scaling
  121225. * @param enable if scaling should be enabled
  121226. */
  121227. setEnabledScaling(enable: boolean): void;
  121228. private _updateDummy;
  121229. /**
  121230. * Enables a pointer drag behavior on the bounding box of the gizmo
  121231. */
  121232. enableDragBehavior(): void;
  121233. /**
  121234. * Disposes of the gizmo
  121235. */
  121236. dispose(): void;
  121237. /**
  121238. * 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)
  121239. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121240. * @returns the bounding box mesh with the passed in mesh as a child
  121241. */
  121242. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121243. /**
  121244. * CustomMeshes are not supported by this gizmo
  121245. * @param mesh The mesh to replace the default mesh of the gizmo
  121246. */
  121247. setCustomMesh(mesh: Mesh): void;
  121248. }
  121249. }
  121250. declare module BABYLON {
  121251. /**
  121252. * Single plane rotation gizmo
  121253. */
  121254. export class PlaneRotationGizmo extends Gizmo {
  121255. /**
  121256. * Drag behavior responsible for the gizmos dragging interactions
  121257. */
  121258. dragBehavior: PointerDragBehavior;
  121259. private _pointerObserver;
  121260. /**
  121261. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121262. */
  121263. snapDistance: number;
  121264. /**
  121265. * Event that fires each time the gizmo snaps to a new location.
  121266. * * snapDistance is the the change in distance
  121267. */
  121268. onSnapObservable: Observable<{
  121269. snapDistance: number;
  121270. }>;
  121271. private _isEnabled;
  121272. private _parent;
  121273. /**
  121274. * Creates a PlaneRotationGizmo
  121275. * @param gizmoLayer The utility layer the gizmo will be added to
  121276. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121277. * @param color The color of the gizmo
  121278. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121279. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121280. */
  121281. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121282. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121283. /**
  121284. * If the gizmo is enabled
  121285. */
  121286. set isEnabled(value: boolean);
  121287. get isEnabled(): boolean;
  121288. /**
  121289. * Disposes of the gizmo
  121290. */
  121291. dispose(): void;
  121292. }
  121293. }
  121294. declare module BABYLON {
  121295. /**
  121296. * Gizmo that enables rotating a mesh along 3 axis
  121297. */
  121298. export class RotationGizmo extends Gizmo {
  121299. /**
  121300. * Internal gizmo used for interactions on the x axis
  121301. */
  121302. xGizmo: PlaneRotationGizmo;
  121303. /**
  121304. * Internal gizmo used for interactions on the y axis
  121305. */
  121306. yGizmo: PlaneRotationGizmo;
  121307. /**
  121308. * Internal gizmo used for interactions on the z axis
  121309. */
  121310. zGizmo: PlaneRotationGizmo;
  121311. /** Fires an event when any of it's sub gizmos are dragged */
  121312. onDragStartObservable: Observable<unknown>;
  121313. /** Fires an event when any of it's sub gizmos are released from dragging */
  121314. onDragEndObservable: Observable<unknown>;
  121315. private _meshAttached;
  121316. get attachedMesh(): Nullable<AbstractMesh>;
  121317. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121318. /**
  121319. * Creates a RotationGizmo
  121320. * @param gizmoLayer The utility layer the gizmo will be added to
  121321. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121322. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121323. */
  121324. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121325. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121326. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121327. /**
  121328. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121329. */
  121330. set snapDistance(value: number);
  121331. get snapDistance(): number;
  121332. /**
  121333. * Ratio for the scale of the gizmo (Default: 1)
  121334. */
  121335. set scaleRatio(value: number);
  121336. get scaleRatio(): number;
  121337. /**
  121338. * Disposes of the gizmo
  121339. */
  121340. dispose(): void;
  121341. /**
  121342. * CustomMeshes are not supported by this gizmo
  121343. * @param mesh The mesh to replace the default mesh of the gizmo
  121344. */
  121345. setCustomMesh(mesh: Mesh): void;
  121346. }
  121347. }
  121348. declare module BABYLON {
  121349. /**
  121350. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121351. */
  121352. export class GizmoManager implements IDisposable {
  121353. private scene;
  121354. /**
  121355. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121356. */
  121357. gizmos: {
  121358. positionGizmo: Nullable<PositionGizmo>;
  121359. rotationGizmo: Nullable<RotationGizmo>;
  121360. scaleGizmo: Nullable<ScaleGizmo>;
  121361. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121362. };
  121363. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121364. clearGizmoOnEmptyPointerEvent: boolean;
  121365. /** Fires an event when the manager is attached to a mesh */
  121366. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121367. private _gizmosEnabled;
  121368. private _pointerObserver;
  121369. private _attachedMesh;
  121370. private _boundingBoxColor;
  121371. private _defaultUtilityLayer;
  121372. private _defaultKeepDepthUtilityLayer;
  121373. /**
  121374. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121375. */
  121376. boundingBoxDragBehavior: SixDofDragBehavior;
  121377. /**
  121378. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121379. */
  121380. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121381. /**
  121382. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121383. */
  121384. usePointerToAttachGizmos: boolean;
  121385. /**
  121386. * Utility layer that the bounding box gizmo belongs to
  121387. */
  121388. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121389. /**
  121390. * Utility layer that all gizmos besides bounding box belong to
  121391. */
  121392. get utilityLayer(): UtilityLayerRenderer;
  121393. /**
  121394. * Instatiates a gizmo manager
  121395. * @param scene the scene to overlay the gizmos on top of
  121396. */
  121397. constructor(scene: Scene);
  121398. /**
  121399. * Attaches a set of gizmos to the specified mesh
  121400. * @param mesh The mesh the gizmo's should be attached to
  121401. */
  121402. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121403. /**
  121404. * If the position gizmo is enabled
  121405. */
  121406. set positionGizmoEnabled(value: boolean);
  121407. get positionGizmoEnabled(): boolean;
  121408. /**
  121409. * If the rotation gizmo is enabled
  121410. */
  121411. set rotationGizmoEnabled(value: boolean);
  121412. get rotationGizmoEnabled(): boolean;
  121413. /**
  121414. * If the scale gizmo is enabled
  121415. */
  121416. set scaleGizmoEnabled(value: boolean);
  121417. get scaleGizmoEnabled(): boolean;
  121418. /**
  121419. * If the boundingBox gizmo is enabled
  121420. */
  121421. set boundingBoxGizmoEnabled(value: boolean);
  121422. get boundingBoxGizmoEnabled(): boolean;
  121423. /**
  121424. * Disposes of the gizmo manager
  121425. */
  121426. dispose(): void;
  121427. }
  121428. }
  121429. declare module BABYLON {
  121430. /**
  121431. * A directional light is defined by a direction (what a surprise!).
  121432. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121433. * 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.
  121434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121435. */
  121436. export class DirectionalLight extends ShadowLight {
  121437. private _shadowFrustumSize;
  121438. /**
  121439. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121440. */
  121441. get shadowFrustumSize(): number;
  121442. /**
  121443. * Specifies a fix frustum size for the shadow generation.
  121444. */
  121445. set shadowFrustumSize(value: number);
  121446. private _shadowOrthoScale;
  121447. /**
  121448. * Gets the shadow projection scale against the optimal computed one.
  121449. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121450. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121451. */
  121452. get shadowOrthoScale(): number;
  121453. /**
  121454. * Sets the shadow projection scale against the optimal computed one.
  121455. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121456. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121457. */
  121458. set shadowOrthoScale(value: number);
  121459. /**
  121460. * Automatically compute the projection matrix to best fit (including all the casters)
  121461. * on each frame.
  121462. */
  121463. autoUpdateExtends: boolean;
  121464. /**
  121465. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121466. * on each frame. autoUpdateExtends must be set to true for this to work
  121467. */
  121468. autoCalcShadowZBounds: boolean;
  121469. private _orthoLeft;
  121470. private _orthoRight;
  121471. private _orthoTop;
  121472. private _orthoBottom;
  121473. /**
  121474. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121475. * The directional light is emitted from everywhere in the given direction.
  121476. * It can cast shadows.
  121477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121478. * @param name The friendly name of the light
  121479. * @param direction The direction of the light
  121480. * @param scene The scene the light belongs to
  121481. */
  121482. constructor(name: string, direction: Vector3, scene: Scene);
  121483. /**
  121484. * Returns the string "DirectionalLight".
  121485. * @return The class name
  121486. */
  121487. getClassName(): string;
  121488. /**
  121489. * Returns the integer 1.
  121490. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121491. */
  121492. getTypeID(): number;
  121493. /**
  121494. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121495. * Returns the DirectionalLight Shadow projection matrix.
  121496. */
  121497. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121498. /**
  121499. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121500. * Returns the DirectionalLight Shadow projection matrix.
  121501. */
  121502. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121503. /**
  121504. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121505. * Returns the DirectionalLight Shadow projection matrix.
  121506. */
  121507. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121508. protected _buildUniformLayout(): void;
  121509. /**
  121510. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121511. * @param effect The effect to update
  121512. * @param lightIndex The index of the light in the effect to update
  121513. * @returns The directional light
  121514. */
  121515. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  121516. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  121517. /**
  121518. * Gets the minZ used for shadow according to both the scene and the light.
  121519. *
  121520. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121521. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121522. * @param activeCamera The camera we are returning the min for
  121523. * @returns the depth min z
  121524. */
  121525. getDepthMinZ(activeCamera: Camera): number;
  121526. /**
  121527. * Gets the maxZ used for shadow according to both the scene and the light.
  121528. *
  121529. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121530. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121531. * @param activeCamera The camera we are returning the max for
  121532. * @returns the depth max z
  121533. */
  121534. getDepthMaxZ(activeCamera: Camera): number;
  121535. /**
  121536. * Prepares the list of defines specific to the light type.
  121537. * @param defines the list of defines
  121538. * @param lightIndex defines the index of the light for the effect
  121539. */
  121540. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121541. }
  121542. }
  121543. declare module BABYLON {
  121544. /**
  121545. * Class containing static functions to help procedurally build meshes
  121546. */
  121547. export class HemisphereBuilder {
  121548. /**
  121549. * Creates a hemisphere mesh
  121550. * @param name defines the name of the mesh
  121551. * @param options defines the options used to create the mesh
  121552. * @param scene defines the hosting scene
  121553. * @returns the hemisphere mesh
  121554. */
  121555. static CreateHemisphere(name: string, options: {
  121556. segments?: number;
  121557. diameter?: number;
  121558. sideOrientation?: number;
  121559. }, scene: any): Mesh;
  121560. }
  121561. }
  121562. declare module BABYLON {
  121563. /**
  121564. * A spot light is defined by a position, a direction, an angle, and an exponent.
  121565. * These values define a cone of light starting from the position, emitting toward the direction.
  121566. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  121567. * and the exponent defines the speed of the decay of the light with distance (reach).
  121568. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121569. */
  121570. export class SpotLight extends ShadowLight {
  121571. private _angle;
  121572. private _innerAngle;
  121573. private _cosHalfAngle;
  121574. private _lightAngleScale;
  121575. private _lightAngleOffset;
  121576. /**
  121577. * Gets the cone angle of the spot light in Radians.
  121578. */
  121579. get angle(): number;
  121580. /**
  121581. * Sets the cone angle of the spot light in Radians.
  121582. */
  121583. set angle(value: number);
  121584. /**
  121585. * Only used in gltf falloff mode, this defines the angle where
  121586. * the directional falloff will start before cutting at angle which could be seen
  121587. * as outer angle.
  121588. */
  121589. get innerAngle(): number;
  121590. /**
  121591. * Only used in gltf falloff mode, this defines the angle where
  121592. * the directional falloff will start before cutting at angle which could be seen
  121593. * as outer angle.
  121594. */
  121595. set innerAngle(value: number);
  121596. private _shadowAngleScale;
  121597. /**
  121598. * Allows scaling the angle of the light for shadow generation only.
  121599. */
  121600. get shadowAngleScale(): number;
  121601. /**
  121602. * Allows scaling the angle of the light for shadow generation only.
  121603. */
  121604. set shadowAngleScale(value: number);
  121605. /**
  121606. * The light decay speed with the distance from the emission spot.
  121607. */
  121608. exponent: number;
  121609. private _projectionTextureMatrix;
  121610. /**
  121611. * Allows reading the projecton texture
  121612. */
  121613. get projectionTextureMatrix(): Matrix;
  121614. protected _projectionTextureLightNear: number;
  121615. /**
  121616. * Gets the near clip of the Spotlight for texture projection.
  121617. */
  121618. get projectionTextureLightNear(): number;
  121619. /**
  121620. * Sets the near clip of the Spotlight for texture projection.
  121621. */
  121622. set projectionTextureLightNear(value: number);
  121623. protected _projectionTextureLightFar: number;
  121624. /**
  121625. * Gets the far clip of the Spotlight for texture projection.
  121626. */
  121627. get projectionTextureLightFar(): number;
  121628. /**
  121629. * Sets the far clip of the Spotlight for texture projection.
  121630. */
  121631. set projectionTextureLightFar(value: number);
  121632. protected _projectionTextureUpDirection: Vector3;
  121633. /**
  121634. * Gets the Up vector of the Spotlight for texture projection.
  121635. */
  121636. get projectionTextureUpDirection(): Vector3;
  121637. /**
  121638. * Sets the Up vector of the Spotlight for texture projection.
  121639. */
  121640. set projectionTextureUpDirection(value: Vector3);
  121641. private _projectionTexture;
  121642. /**
  121643. * Gets the projection texture of the light.
  121644. */
  121645. get projectionTexture(): Nullable<BaseTexture>;
  121646. /**
  121647. * Sets the projection texture of the light.
  121648. */
  121649. set projectionTexture(value: Nullable<BaseTexture>);
  121650. private _projectionTextureViewLightDirty;
  121651. private _projectionTextureProjectionLightDirty;
  121652. private _projectionTextureDirty;
  121653. private _projectionTextureViewTargetVector;
  121654. private _projectionTextureViewLightMatrix;
  121655. private _projectionTextureProjectionLightMatrix;
  121656. private _projectionTextureScalingMatrix;
  121657. /**
  121658. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  121659. * It can cast shadows.
  121660. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121661. * @param name The light friendly name
  121662. * @param position The position of the spot light in the scene
  121663. * @param direction The direction of the light in the scene
  121664. * @param angle The cone angle of the light in Radians
  121665. * @param exponent The light decay speed with the distance from the emission spot
  121666. * @param scene The scene the lights belongs to
  121667. */
  121668. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  121669. /**
  121670. * Returns the string "SpotLight".
  121671. * @returns the class name
  121672. */
  121673. getClassName(): string;
  121674. /**
  121675. * Returns the integer 2.
  121676. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121677. */
  121678. getTypeID(): number;
  121679. /**
  121680. * Overrides the direction setter to recompute the projection texture view light Matrix.
  121681. */
  121682. protected _setDirection(value: Vector3): void;
  121683. /**
  121684. * Overrides the position setter to recompute the projection texture view light Matrix.
  121685. */
  121686. protected _setPosition(value: Vector3): void;
  121687. /**
  121688. * 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.
  121689. * Returns the SpotLight.
  121690. */
  121691. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121692. protected _computeProjectionTextureViewLightMatrix(): void;
  121693. protected _computeProjectionTextureProjectionLightMatrix(): void;
  121694. /**
  121695. * Main function for light texture projection matrix computing.
  121696. */
  121697. protected _computeProjectionTextureMatrix(): void;
  121698. protected _buildUniformLayout(): void;
  121699. private _computeAngleValues;
  121700. /**
  121701. * Sets the passed Effect "effect" with the Light textures.
  121702. * @param effect The effect to update
  121703. * @param lightIndex The index of the light in the effect to update
  121704. * @returns The light
  121705. */
  121706. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  121707. /**
  121708. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  121709. * @param effect The effect to update
  121710. * @param lightIndex The index of the light in the effect to update
  121711. * @returns The spot light
  121712. */
  121713. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  121714. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121715. /**
  121716. * Disposes the light and the associated resources.
  121717. */
  121718. dispose(): void;
  121719. /**
  121720. * Prepares the list of defines specific to the light type.
  121721. * @param defines the list of defines
  121722. * @param lightIndex defines the index of the light for the effect
  121723. */
  121724. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121725. }
  121726. }
  121727. declare module BABYLON {
  121728. /**
  121729. * Gizmo that enables viewing a light
  121730. */
  121731. export class LightGizmo extends Gizmo {
  121732. private _lightMesh;
  121733. private _material;
  121734. private _cachedPosition;
  121735. private _cachedForward;
  121736. private _attachedMeshParent;
  121737. /**
  121738. * Creates a LightGizmo
  121739. * @param gizmoLayer The utility layer the gizmo will be added to
  121740. */
  121741. constructor(gizmoLayer?: UtilityLayerRenderer);
  121742. private _light;
  121743. /**
  121744. * The light that the gizmo is attached to
  121745. */
  121746. set light(light: Nullable<Light>);
  121747. get light(): Nullable<Light>;
  121748. /**
  121749. * Gets the material used to render the light gizmo
  121750. */
  121751. get material(): StandardMaterial;
  121752. /**
  121753. * @hidden
  121754. * Updates the gizmo to match the attached mesh's position/rotation
  121755. */
  121756. protected _update(): void;
  121757. private static _Scale;
  121758. /**
  121759. * Creates the lines for a light mesh
  121760. */
  121761. private static _CreateLightLines;
  121762. /**
  121763. * Disposes of the light gizmo
  121764. */
  121765. dispose(): void;
  121766. private static _CreateHemisphericLightMesh;
  121767. private static _CreatePointLightMesh;
  121768. private static _CreateSpotLightMesh;
  121769. private static _CreateDirectionalLightMesh;
  121770. }
  121771. }
  121772. declare module BABYLON {
  121773. /** @hidden */
  121774. export var backgroundFragmentDeclaration: {
  121775. name: string;
  121776. shader: string;
  121777. };
  121778. }
  121779. declare module BABYLON {
  121780. /** @hidden */
  121781. export var backgroundUboDeclaration: {
  121782. name: string;
  121783. shader: string;
  121784. };
  121785. }
  121786. declare module BABYLON {
  121787. /** @hidden */
  121788. export var backgroundPixelShader: {
  121789. name: string;
  121790. shader: string;
  121791. };
  121792. }
  121793. declare module BABYLON {
  121794. /** @hidden */
  121795. export var backgroundVertexDeclaration: {
  121796. name: string;
  121797. shader: string;
  121798. };
  121799. }
  121800. declare module BABYLON {
  121801. /** @hidden */
  121802. export var backgroundVertexShader: {
  121803. name: string;
  121804. shader: string;
  121805. };
  121806. }
  121807. declare module BABYLON {
  121808. /**
  121809. * Background material used to create an efficient environement around your scene.
  121810. */
  121811. export class BackgroundMaterial extends PushMaterial {
  121812. /**
  121813. * Standard reflectance value at parallel view angle.
  121814. */
  121815. static StandardReflectance0: number;
  121816. /**
  121817. * Standard reflectance value at grazing angle.
  121818. */
  121819. static StandardReflectance90: number;
  121820. protected _primaryColor: Color3;
  121821. /**
  121822. * Key light Color (multiply against the environement texture)
  121823. */
  121824. primaryColor: Color3;
  121825. protected __perceptualColor: Nullable<Color3>;
  121826. /**
  121827. * Experimental Internal Use Only.
  121828. *
  121829. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  121830. * This acts as a helper to set the primary color to a more "human friendly" value.
  121831. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  121832. * output color as close as possible from the chosen value.
  121833. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  121834. * part of lighting setup.)
  121835. */
  121836. get _perceptualColor(): Nullable<Color3>;
  121837. set _perceptualColor(value: Nullable<Color3>);
  121838. protected _primaryColorShadowLevel: float;
  121839. /**
  121840. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  121841. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  121842. */
  121843. get primaryColorShadowLevel(): float;
  121844. set primaryColorShadowLevel(value: float);
  121845. protected _primaryColorHighlightLevel: float;
  121846. /**
  121847. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  121848. * The primary color is used at the level chosen to define what the white area would look.
  121849. */
  121850. get primaryColorHighlightLevel(): float;
  121851. set primaryColorHighlightLevel(value: float);
  121852. protected _reflectionTexture: Nullable<BaseTexture>;
  121853. /**
  121854. * Reflection Texture used in the material.
  121855. * Should be author in a specific way for the best result (refer to the documentation).
  121856. */
  121857. reflectionTexture: Nullable<BaseTexture>;
  121858. protected _reflectionBlur: float;
  121859. /**
  121860. * Reflection Texture level of blur.
  121861. *
  121862. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  121863. * texture twice.
  121864. */
  121865. reflectionBlur: float;
  121866. protected _diffuseTexture: Nullable<BaseTexture>;
  121867. /**
  121868. * Diffuse Texture used in the material.
  121869. * Should be author in a specific way for the best result (refer to the documentation).
  121870. */
  121871. diffuseTexture: Nullable<BaseTexture>;
  121872. protected _shadowLights: Nullable<IShadowLight[]>;
  121873. /**
  121874. * Specify the list of lights casting shadow on the material.
  121875. * All scene shadow lights will be included if null.
  121876. */
  121877. shadowLights: Nullable<IShadowLight[]>;
  121878. protected _shadowLevel: float;
  121879. /**
  121880. * Helps adjusting the shadow to a softer level if required.
  121881. * 0 means black shadows and 1 means no shadows.
  121882. */
  121883. shadowLevel: float;
  121884. protected _sceneCenter: Vector3;
  121885. /**
  121886. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  121887. * It is usually zero but might be interesting to modify according to your setup.
  121888. */
  121889. sceneCenter: Vector3;
  121890. protected _opacityFresnel: boolean;
  121891. /**
  121892. * This helps specifying that the material is falling off to the sky box at grazing angle.
  121893. * This helps ensuring a nice transition when the camera goes under the ground.
  121894. */
  121895. opacityFresnel: boolean;
  121896. protected _reflectionFresnel: boolean;
  121897. /**
  121898. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  121899. * This helps adding a mirror texture on the ground.
  121900. */
  121901. reflectionFresnel: boolean;
  121902. protected _reflectionFalloffDistance: number;
  121903. /**
  121904. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  121905. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  121906. */
  121907. reflectionFalloffDistance: number;
  121908. protected _reflectionAmount: number;
  121909. /**
  121910. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  121911. */
  121912. reflectionAmount: number;
  121913. protected _reflectionReflectance0: number;
  121914. /**
  121915. * This specifies the weight of the reflection at grazing angle.
  121916. */
  121917. reflectionReflectance0: number;
  121918. protected _reflectionReflectance90: number;
  121919. /**
  121920. * This specifies the weight of the reflection at a perpendicular point of view.
  121921. */
  121922. reflectionReflectance90: number;
  121923. /**
  121924. * Sets the reflection reflectance fresnel values according to the default standard
  121925. * empirically know to work well :-)
  121926. */
  121927. set reflectionStandardFresnelWeight(value: number);
  121928. protected _useRGBColor: boolean;
  121929. /**
  121930. * Helps to directly use the maps channels instead of their level.
  121931. */
  121932. useRGBColor: boolean;
  121933. protected _enableNoise: boolean;
  121934. /**
  121935. * This helps reducing the banding effect that could occur on the background.
  121936. */
  121937. enableNoise: boolean;
  121938. /**
  121939. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121940. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  121941. * Recommended to be keep at 1.0 except for special cases.
  121942. */
  121943. get fovMultiplier(): number;
  121944. set fovMultiplier(value: number);
  121945. private _fovMultiplier;
  121946. /**
  121947. * Enable the FOV adjustment feature controlled by fovMultiplier.
  121948. */
  121949. useEquirectangularFOV: boolean;
  121950. private _maxSimultaneousLights;
  121951. /**
  121952. * Number of Simultaneous lights allowed on the material.
  121953. */
  121954. maxSimultaneousLights: int;
  121955. /**
  121956. * Default configuration related to image processing available in the Background Material.
  121957. */
  121958. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121959. /**
  121960. * Keep track of the image processing observer to allow dispose and replace.
  121961. */
  121962. private _imageProcessingObserver;
  121963. /**
  121964. * Attaches a new image processing configuration to the PBR Material.
  121965. * @param configuration (if null the scene configuration will be use)
  121966. */
  121967. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121968. /**
  121969. * Gets the image processing configuration used either in this material.
  121970. */
  121971. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  121972. /**
  121973. * Sets the Default image processing configuration used either in the this material.
  121974. *
  121975. * If sets to null, the scene one is in use.
  121976. */
  121977. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  121978. /**
  121979. * Gets wether the color curves effect is enabled.
  121980. */
  121981. get cameraColorCurvesEnabled(): boolean;
  121982. /**
  121983. * Sets wether the color curves effect is enabled.
  121984. */
  121985. set cameraColorCurvesEnabled(value: boolean);
  121986. /**
  121987. * Gets wether the color grading effect is enabled.
  121988. */
  121989. get cameraColorGradingEnabled(): boolean;
  121990. /**
  121991. * Gets wether the color grading effect is enabled.
  121992. */
  121993. set cameraColorGradingEnabled(value: boolean);
  121994. /**
  121995. * Gets wether tonemapping is enabled or not.
  121996. */
  121997. get cameraToneMappingEnabled(): boolean;
  121998. /**
  121999. * Sets wether tonemapping is enabled or not
  122000. */
  122001. set cameraToneMappingEnabled(value: boolean);
  122002. /**
  122003. * The camera exposure used on this material.
  122004. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122005. * This corresponds to a photographic exposure.
  122006. */
  122007. get cameraExposure(): float;
  122008. /**
  122009. * The camera exposure used on this material.
  122010. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122011. * This corresponds to a photographic exposure.
  122012. */
  122013. set cameraExposure(value: float);
  122014. /**
  122015. * Gets The camera contrast used on this material.
  122016. */
  122017. get cameraContrast(): float;
  122018. /**
  122019. * Sets The camera contrast used on this material.
  122020. */
  122021. set cameraContrast(value: float);
  122022. /**
  122023. * Gets the Color Grading 2D Lookup Texture.
  122024. */
  122025. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122026. /**
  122027. * Sets the Color Grading 2D Lookup Texture.
  122028. */
  122029. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122030. /**
  122031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122033. * 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;
  122034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122035. */
  122036. get cameraColorCurves(): Nullable<ColorCurves>;
  122037. /**
  122038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122040. * 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;
  122041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122042. */
  122043. set cameraColorCurves(value: Nullable<ColorCurves>);
  122044. /**
  122045. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122046. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122047. */
  122048. switchToBGR: boolean;
  122049. private _renderTargets;
  122050. private _reflectionControls;
  122051. private _white;
  122052. private _primaryShadowColor;
  122053. private _primaryHighlightColor;
  122054. /**
  122055. * Instantiates a Background Material in the given scene
  122056. * @param name The friendly name of the material
  122057. * @param scene The scene to add the material to
  122058. */
  122059. constructor(name: string, scene: Scene);
  122060. /**
  122061. * Gets a boolean indicating that current material needs to register RTT
  122062. */
  122063. get hasRenderTargetTextures(): boolean;
  122064. /**
  122065. * The entire material has been created in order to prevent overdraw.
  122066. * @returns false
  122067. */
  122068. needAlphaTesting(): boolean;
  122069. /**
  122070. * The entire material has been created in order to prevent overdraw.
  122071. * @returns true if blending is enable
  122072. */
  122073. needAlphaBlending(): boolean;
  122074. /**
  122075. * Checks wether the material is ready to be rendered for a given mesh.
  122076. * @param mesh The mesh to render
  122077. * @param subMesh The submesh to check against
  122078. * @param useInstances Specify wether or not the material is used with instances
  122079. * @returns true if all the dependencies are ready (Textures, Effects...)
  122080. */
  122081. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122082. /**
  122083. * Compute the primary color according to the chosen perceptual color.
  122084. */
  122085. private _computePrimaryColorFromPerceptualColor;
  122086. /**
  122087. * Compute the highlights and shadow colors according to their chosen levels.
  122088. */
  122089. private _computePrimaryColors;
  122090. /**
  122091. * Build the uniform buffer used in the material.
  122092. */
  122093. buildUniformLayout(): void;
  122094. /**
  122095. * Unbind the material.
  122096. */
  122097. unbind(): void;
  122098. /**
  122099. * Bind only the world matrix to the material.
  122100. * @param world The world matrix to bind.
  122101. */
  122102. bindOnlyWorldMatrix(world: Matrix): void;
  122103. /**
  122104. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122105. * @param world The world matrix to bind.
  122106. * @param subMesh The submesh to bind for.
  122107. */
  122108. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122109. /**
  122110. * Checks to see if a texture is used in the material.
  122111. * @param texture - Base texture to use.
  122112. * @returns - Boolean specifying if a texture is used in the material.
  122113. */
  122114. hasTexture(texture: BaseTexture): boolean;
  122115. /**
  122116. * Dispose the material.
  122117. * @param forceDisposeEffect Force disposal of the associated effect.
  122118. * @param forceDisposeTextures Force disposal of the associated textures.
  122119. */
  122120. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122121. /**
  122122. * Clones the material.
  122123. * @param name The cloned name.
  122124. * @returns The cloned material.
  122125. */
  122126. clone(name: string): BackgroundMaterial;
  122127. /**
  122128. * Serializes the current material to its JSON representation.
  122129. * @returns The JSON representation.
  122130. */
  122131. serialize(): any;
  122132. /**
  122133. * Gets the class name of the material
  122134. * @returns "BackgroundMaterial"
  122135. */
  122136. getClassName(): string;
  122137. /**
  122138. * Parse a JSON input to create back a background material.
  122139. * @param source The JSON data to parse
  122140. * @param scene The scene to create the parsed material in
  122141. * @param rootUrl The root url of the assets the material depends upon
  122142. * @returns the instantiated BackgroundMaterial.
  122143. */
  122144. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122145. }
  122146. }
  122147. declare module BABYLON {
  122148. /**
  122149. * Represents the different options available during the creation of
  122150. * a Environment helper.
  122151. *
  122152. * This can control the default ground, skybox and image processing setup of your scene.
  122153. */
  122154. export interface IEnvironmentHelperOptions {
  122155. /**
  122156. * Specifies whether or not to create a ground.
  122157. * True by default.
  122158. */
  122159. createGround: boolean;
  122160. /**
  122161. * Specifies the ground size.
  122162. * 15 by default.
  122163. */
  122164. groundSize: number;
  122165. /**
  122166. * The texture used on the ground for the main color.
  122167. * Comes from the BabylonJS CDN by default.
  122168. *
  122169. * Remarks: Can be either a texture or a url.
  122170. */
  122171. groundTexture: string | BaseTexture;
  122172. /**
  122173. * The color mixed in the ground texture by default.
  122174. * BabylonJS clearColor by default.
  122175. */
  122176. groundColor: Color3;
  122177. /**
  122178. * Specifies the ground opacity.
  122179. * 1 by default.
  122180. */
  122181. groundOpacity: number;
  122182. /**
  122183. * Enables the ground to receive shadows.
  122184. * True by default.
  122185. */
  122186. enableGroundShadow: boolean;
  122187. /**
  122188. * Helps preventing the shadow to be fully black on the ground.
  122189. * 0.5 by default.
  122190. */
  122191. groundShadowLevel: number;
  122192. /**
  122193. * Creates a mirror texture attach to the ground.
  122194. * false by default.
  122195. */
  122196. enableGroundMirror: boolean;
  122197. /**
  122198. * Specifies the ground mirror size ratio.
  122199. * 0.3 by default as the default kernel is 64.
  122200. */
  122201. groundMirrorSizeRatio: number;
  122202. /**
  122203. * Specifies the ground mirror blur kernel size.
  122204. * 64 by default.
  122205. */
  122206. groundMirrorBlurKernel: number;
  122207. /**
  122208. * Specifies the ground mirror visibility amount.
  122209. * 1 by default
  122210. */
  122211. groundMirrorAmount: number;
  122212. /**
  122213. * Specifies the ground mirror reflectance weight.
  122214. * This uses the standard weight of the background material to setup the fresnel effect
  122215. * of the mirror.
  122216. * 1 by default.
  122217. */
  122218. groundMirrorFresnelWeight: number;
  122219. /**
  122220. * Specifies the ground mirror Falloff distance.
  122221. * This can helps reducing the size of the reflection.
  122222. * 0 by Default.
  122223. */
  122224. groundMirrorFallOffDistance: number;
  122225. /**
  122226. * Specifies the ground mirror texture type.
  122227. * Unsigned Int by Default.
  122228. */
  122229. groundMirrorTextureType: number;
  122230. /**
  122231. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122232. * the shown objects.
  122233. */
  122234. groundYBias: number;
  122235. /**
  122236. * Specifies whether or not to create a skybox.
  122237. * True by default.
  122238. */
  122239. createSkybox: boolean;
  122240. /**
  122241. * Specifies the skybox size.
  122242. * 20 by default.
  122243. */
  122244. skyboxSize: number;
  122245. /**
  122246. * The texture used on the skybox for the main color.
  122247. * Comes from the BabylonJS CDN by default.
  122248. *
  122249. * Remarks: Can be either a texture or a url.
  122250. */
  122251. skyboxTexture: string | BaseTexture;
  122252. /**
  122253. * The color mixed in the skybox texture by default.
  122254. * BabylonJS clearColor by default.
  122255. */
  122256. skyboxColor: Color3;
  122257. /**
  122258. * The background rotation around the Y axis of the scene.
  122259. * This helps aligning the key lights of your scene with the background.
  122260. * 0 by default.
  122261. */
  122262. backgroundYRotation: number;
  122263. /**
  122264. * Compute automatically the size of the elements to best fit with the scene.
  122265. */
  122266. sizeAuto: boolean;
  122267. /**
  122268. * Default position of the rootMesh if autoSize is not true.
  122269. */
  122270. rootPosition: Vector3;
  122271. /**
  122272. * Sets up the image processing in the scene.
  122273. * true by default.
  122274. */
  122275. setupImageProcessing: boolean;
  122276. /**
  122277. * The texture used as your environment texture in the scene.
  122278. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122279. *
  122280. * Remarks: Can be either a texture or a url.
  122281. */
  122282. environmentTexture: string | BaseTexture;
  122283. /**
  122284. * The value of the exposure to apply to the scene.
  122285. * 0.6 by default if setupImageProcessing is true.
  122286. */
  122287. cameraExposure: number;
  122288. /**
  122289. * The value of the contrast to apply to the scene.
  122290. * 1.6 by default if setupImageProcessing is true.
  122291. */
  122292. cameraContrast: number;
  122293. /**
  122294. * Specifies whether or not tonemapping should be enabled in the scene.
  122295. * true by default if setupImageProcessing is true.
  122296. */
  122297. toneMappingEnabled: boolean;
  122298. }
  122299. /**
  122300. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122301. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122302. * It also helps with the default setup of your imageProcessing configuration.
  122303. */
  122304. export class EnvironmentHelper {
  122305. /**
  122306. * Default ground texture URL.
  122307. */
  122308. private static _groundTextureCDNUrl;
  122309. /**
  122310. * Default skybox texture URL.
  122311. */
  122312. private static _skyboxTextureCDNUrl;
  122313. /**
  122314. * Default environment texture URL.
  122315. */
  122316. private static _environmentTextureCDNUrl;
  122317. /**
  122318. * Creates the default options for the helper.
  122319. */
  122320. private static _getDefaultOptions;
  122321. private _rootMesh;
  122322. /**
  122323. * Gets the root mesh created by the helper.
  122324. */
  122325. get rootMesh(): Mesh;
  122326. private _skybox;
  122327. /**
  122328. * Gets the skybox created by the helper.
  122329. */
  122330. get skybox(): Nullable<Mesh>;
  122331. private _skyboxTexture;
  122332. /**
  122333. * Gets the skybox texture created by the helper.
  122334. */
  122335. get skyboxTexture(): Nullable<BaseTexture>;
  122336. private _skyboxMaterial;
  122337. /**
  122338. * Gets the skybox material created by the helper.
  122339. */
  122340. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122341. private _ground;
  122342. /**
  122343. * Gets the ground mesh created by the helper.
  122344. */
  122345. get ground(): Nullable<Mesh>;
  122346. private _groundTexture;
  122347. /**
  122348. * Gets the ground texture created by the helper.
  122349. */
  122350. get groundTexture(): Nullable<BaseTexture>;
  122351. private _groundMirror;
  122352. /**
  122353. * Gets the ground mirror created by the helper.
  122354. */
  122355. get groundMirror(): Nullable<MirrorTexture>;
  122356. /**
  122357. * Gets the ground mirror render list to helps pushing the meshes
  122358. * you wish in the ground reflection.
  122359. */
  122360. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122361. private _groundMaterial;
  122362. /**
  122363. * Gets the ground material created by the helper.
  122364. */
  122365. get groundMaterial(): Nullable<BackgroundMaterial>;
  122366. /**
  122367. * Stores the creation options.
  122368. */
  122369. private readonly _scene;
  122370. private _options;
  122371. /**
  122372. * This observable will be notified with any error during the creation of the environment,
  122373. * mainly texture creation errors.
  122374. */
  122375. onErrorObservable: Observable<{
  122376. message?: string;
  122377. exception?: any;
  122378. }>;
  122379. /**
  122380. * constructor
  122381. * @param options Defines the options we want to customize the helper
  122382. * @param scene The scene to add the material to
  122383. */
  122384. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122385. /**
  122386. * Updates the background according to the new options
  122387. * @param options
  122388. */
  122389. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122390. /**
  122391. * Sets the primary color of all the available elements.
  122392. * @param color the main color to affect to the ground and the background
  122393. */
  122394. setMainColor(color: Color3): void;
  122395. /**
  122396. * Setup the image processing according to the specified options.
  122397. */
  122398. private _setupImageProcessing;
  122399. /**
  122400. * Setup the environment texture according to the specified options.
  122401. */
  122402. private _setupEnvironmentTexture;
  122403. /**
  122404. * Setup the background according to the specified options.
  122405. */
  122406. private _setupBackground;
  122407. /**
  122408. * Get the scene sizes according to the setup.
  122409. */
  122410. private _getSceneSize;
  122411. /**
  122412. * Setup the ground according to the specified options.
  122413. */
  122414. private _setupGround;
  122415. /**
  122416. * Setup the ground material according to the specified options.
  122417. */
  122418. private _setupGroundMaterial;
  122419. /**
  122420. * Setup the ground diffuse texture according to the specified options.
  122421. */
  122422. private _setupGroundDiffuseTexture;
  122423. /**
  122424. * Setup the ground mirror texture according to the specified options.
  122425. */
  122426. private _setupGroundMirrorTexture;
  122427. /**
  122428. * Setup the ground to receive the mirror texture.
  122429. */
  122430. private _setupMirrorInGroundMaterial;
  122431. /**
  122432. * Setup the skybox according to the specified options.
  122433. */
  122434. private _setupSkybox;
  122435. /**
  122436. * Setup the skybox material according to the specified options.
  122437. */
  122438. private _setupSkyboxMaterial;
  122439. /**
  122440. * Setup the skybox reflection texture according to the specified options.
  122441. */
  122442. private _setupSkyboxReflectionTexture;
  122443. private _errorHandler;
  122444. /**
  122445. * Dispose all the elements created by the Helper.
  122446. */
  122447. dispose(): void;
  122448. }
  122449. }
  122450. declare module BABYLON {
  122451. /**
  122452. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122453. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122454. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122455. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122456. */
  122457. export class PhotoDome extends TransformNode {
  122458. /**
  122459. * Define the image as a Monoscopic panoramic 360 image.
  122460. */
  122461. static readonly MODE_MONOSCOPIC: number;
  122462. /**
  122463. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122464. */
  122465. static readonly MODE_TOPBOTTOM: number;
  122466. /**
  122467. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122468. */
  122469. static readonly MODE_SIDEBYSIDE: number;
  122470. private _useDirectMapping;
  122471. /**
  122472. * The texture being displayed on the sphere
  122473. */
  122474. protected _photoTexture: Texture;
  122475. /**
  122476. * Gets or sets the texture being displayed on the sphere
  122477. */
  122478. get photoTexture(): Texture;
  122479. set photoTexture(value: Texture);
  122480. /**
  122481. * Observable raised when an error occured while loading the 360 image
  122482. */
  122483. onLoadErrorObservable: Observable<string>;
  122484. /**
  122485. * The skybox material
  122486. */
  122487. protected _material: BackgroundMaterial;
  122488. /**
  122489. * The surface used for the skybox
  122490. */
  122491. protected _mesh: Mesh;
  122492. /**
  122493. * Gets the mesh used for the skybox.
  122494. */
  122495. get mesh(): Mesh;
  122496. /**
  122497. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122498. * Also see the options.resolution property.
  122499. */
  122500. get fovMultiplier(): number;
  122501. set fovMultiplier(value: number);
  122502. private _imageMode;
  122503. /**
  122504. * Gets or set the current video mode for the video. It can be:
  122505. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122506. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122507. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122508. */
  122509. get imageMode(): number;
  122510. set imageMode(value: number);
  122511. /**
  122512. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  122513. * @param name Element's name, child elements will append suffixes for their own names.
  122514. * @param urlsOfPhoto defines the url of the photo to display
  122515. * @param options defines an object containing optional or exposed sub element properties
  122516. * @param onError defines a callback called when an error occured while loading the texture
  122517. */
  122518. constructor(name: string, urlOfPhoto: string, options: {
  122519. resolution?: number;
  122520. size?: number;
  122521. useDirectMapping?: boolean;
  122522. faceForward?: boolean;
  122523. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  122524. private _onBeforeCameraRenderObserver;
  122525. private _changeImageMode;
  122526. /**
  122527. * Releases resources associated with this node.
  122528. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122529. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122530. */
  122531. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122532. }
  122533. }
  122534. declare module BABYLON {
  122535. /**
  122536. * Class used to host RGBD texture specific utilities
  122537. */
  122538. export class RGBDTextureTools {
  122539. /**
  122540. * Expand the RGBD Texture from RGBD to Half Float if possible.
  122541. * @param texture the texture to expand.
  122542. */
  122543. static ExpandRGBDTexture(texture: Texture): void;
  122544. }
  122545. }
  122546. declare module BABYLON {
  122547. /**
  122548. * Class used to host texture specific utilities
  122549. */
  122550. export class BRDFTextureTools {
  122551. /**
  122552. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  122553. * @param scene defines the hosting scene
  122554. * @returns the environment BRDF texture
  122555. */
  122556. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  122557. private static _environmentBRDFBase64Texture;
  122558. }
  122559. }
  122560. declare module BABYLON {
  122561. /**
  122562. * @hidden
  122563. */
  122564. export interface IMaterialClearCoatDefines {
  122565. CLEARCOAT: boolean;
  122566. CLEARCOAT_DEFAULTIOR: boolean;
  122567. CLEARCOAT_TEXTURE: boolean;
  122568. CLEARCOAT_TEXTUREDIRECTUV: number;
  122569. CLEARCOAT_BUMP: boolean;
  122570. CLEARCOAT_BUMPDIRECTUV: number;
  122571. CLEARCOAT_TINT: boolean;
  122572. CLEARCOAT_TINT_TEXTURE: boolean;
  122573. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  122574. /** @hidden */
  122575. _areTexturesDirty: boolean;
  122576. }
  122577. /**
  122578. * Define the code related to the clear coat parameters of the pbr material.
  122579. */
  122580. export class PBRClearCoatConfiguration {
  122581. /**
  122582. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122583. * The default fits with a polyurethane material.
  122584. */
  122585. private static readonly _DefaultIndexOfRefraction;
  122586. private _isEnabled;
  122587. /**
  122588. * Defines if the clear coat is enabled in the material.
  122589. */
  122590. isEnabled: boolean;
  122591. /**
  122592. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  122593. */
  122594. intensity: number;
  122595. /**
  122596. * Defines the clear coat layer roughness.
  122597. */
  122598. roughness: number;
  122599. private _indexOfRefraction;
  122600. /**
  122601. * Defines the index of refraction of the clear coat.
  122602. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122603. * The default fits with a polyurethane material.
  122604. * Changing the default value is more performance intensive.
  122605. */
  122606. indexOfRefraction: number;
  122607. private _texture;
  122608. /**
  122609. * Stores the clear coat values in a texture.
  122610. */
  122611. texture: Nullable<BaseTexture>;
  122612. private _bumpTexture;
  122613. /**
  122614. * Define the clear coat specific bump texture.
  122615. */
  122616. bumpTexture: Nullable<BaseTexture>;
  122617. private _isTintEnabled;
  122618. /**
  122619. * Defines if the clear coat tint is enabled in the material.
  122620. */
  122621. isTintEnabled: boolean;
  122622. /**
  122623. * Defines the clear coat tint of the material.
  122624. * This is only use if tint is enabled
  122625. */
  122626. tintColor: Color3;
  122627. /**
  122628. * Defines the distance at which the tint color should be found in the
  122629. * clear coat media.
  122630. * This is only use if tint is enabled
  122631. */
  122632. tintColorAtDistance: number;
  122633. /**
  122634. * Defines the clear coat layer thickness.
  122635. * This is only use if tint is enabled
  122636. */
  122637. tintThickness: number;
  122638. private _tintTexture;
  122639. /**
  122640. * Stores the clear tint values in a texture.
  122641. * rgb is tint
  122642. * a is a thickness factor
  122643. */
  122644. tintTexture: Nullable<BaseTexture>;
  122645. /** @hidden */
  122646. private _internalMarkAllSubMeshesAsTexturesDirty;
  122647. /** @hidden */
  122648. _markAllSubMeshesAsTexturesDirty(): void;
  122649. /**
  122650. * Instantiate a new istance of clear coat configuration.
  122651. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122652. */
  122653. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122654. /**
  122655. * Gets wehter the submesh is ready to be used or not.
  122656. * @param defines the list of "defines" to update.
  122657. * @param scene defines the scene the material belongs to.
  122658. * @param engine defines the engine the material belongs to.
  122659. * @param disableBumpMap defines wether the material disables bump or not.
  122660. * @returns - boolean indicating that the submesh is ready or not.
  122661. */
  122662. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  122663. /**
  122664. * Checks to see if a texture is used in the material.
  122665. * @param defines the list of "defines" to update.
  122666. * @param scene defines the scene to the material belongs to.
  122667. */
  122668. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  122669. /**
  122670. * Binds the material data.
  122671. * @param uniformBuffer defines the Uniform buffer to fill in.
  122672. * @param scene defines the scene the material belongs to.
  122673. * @param engine defines the engine the material belongs to.
  122674. * @param disableBumpMap defines wether the material disables bump or not.
  122675. * @param isFrozen defines wether the material is frozen or not.
  122676. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122677. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122678. */
  122679. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  122680. /**
  122681. * Checks to see if a texture is used in the material.
  122682. * @param texture - Base texture to use.
  122683. * @returns - Boolean specifying if a texture is used in the material.
  122684. */
  122685. hasTexture(texture: BaseTexture): boolean;
  122686. /**
  122687. * Returns an array of the actively used textures.
  122688. * @param activeTextures Array of BaseTextures
  122689. */
  122690. getActiveTextures(activeTextures: BaseTexture[]): void;
  122691. /**
  122692. * Returns the animatable textures.
  122693. * @param animatables Array of animatable textures.
  122694. */
  122695. getAnimatables(animatables: IAnimatable[]): void;
  122696. /**
  122697. * Disposes the resources of the material.
  122698. * @param forceDisposeTextures - Forces the disposal of all textures.
  122699. */
  122700. dispose(forceDisposeTextures?: boolean): void;
  122701. /**
  122702. * Get the current class name of the texture useful for serialization or dynamic coding.
  122703. * @returns "PBRClearCoatConfiguration"
  122704. */
  122705. getClassName(): string;
  122706. /**
  122707. * Add fallbacks to the effect fallbacks list.
  122708. * @param defines defines the Base texture to use.
  122709. * @param fallbacks defines the current fallback list.
  122710. * @param currentRank defines the current fallback rank.
  122711. * @returns the new fallback rank.
  122712. */
  122713. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122714. /**
  122715. * Add the required uniforms to the current list.
  122716. * @param uniforms defines the current uniform list.
  122717. */
  122718. static AddUniforms(uniforms: string[]): void;
  122719. /**
  122720. * Add the required samplers to the current list.
  122721. * @param samplers defines the current sampler list.
  122722. */
  122723. static AddSamplers(samplers: string[]): void;
  122724. /**
  122725. * Add the required uniforms to the current buffer.
  122726. * @param uniformBuffer defines the current uniform buffer.
  122727. */
  122728. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122729. /**
  122730. * Makes a duplicate of the current configuration into another one.
  122731. * @param clearCoatConfiguration define the config where to copy the info
  122732. */
  122733. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  122734. /**
  122735. * Serializes this clear coat configuration.
  122736. * @returns - An object with the serialized config.
  122737. */
  122738. serialize(): any;
  122739. /**
  122740. * Parses a anisotropy Configuration from a serialized object.
  122741. * @param source - Serialized object.
  122742. * @param scene Defines the scene we are parsing for
  122743. * @param rootUrl Defines the rootUrl to load from
  122744. */
  122745. parse(source: any, scene: Scene, rootUrl: string): void;
  122746. }
  122747. }
  122748. declare module BABYLON {
  122749. /**
  122750. * @hidden
  122751. */
  122752. export interface IMaterialAnisotropicDefines {
  122753. ANISOTROPIC: boolean;
  122754. ANISOTROPIC_TEXTURE: boolean;
  122755. ANISOTROPIC_TEXTUREDIRECTUV: number;
  122756. MAINUV1: boolean;
  122757. _areTexturesDirty: boolean;
  122758. _needUVs: boolean;
  122759. }
  122760. /**
  122761. * Define the code related to the anisotropic parameters of the pbr material.
  122762. */
  122763. export class PBRAnisotropicConfiguration {
  122764. private _isEnabled;
  122765. /**
  122766. * Defines if the anisotropy is enabled in the material.
  122767. */
  122768. isEnabled: boolean;
  122769. /**
  122770. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  122771. */
  122772. intensity: number;
  122773. /**
  122774. * Defines if the effect is along the tangents, bitangents or in between.
  122775. * By default, the effect is "strectching" the highlights along the tangents.
  122776. */
  122777. direction: Vector2;
  122778. private _texture;
  122779. /**
  122780. * Stores the anisotropy values in a texture.
  122781. * rg is direction (like normal from -1 to 1)
  122782. * b is a intensity
  122783. */
  122784. texture: Nullable<BaseTexture>;
  122785. /** @hidden */
  122786. private _internalMarkAllSubMeshesAsTexturesDirty;
  122787. /** @hidden */
  122788. _markAllSubMeshesAsTexturesDirty(): void;
  122789. /**
  122790. * Instantiate a new istance of anisotropy configuration.
  122791. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122792. */
  122793. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122794. /**
  122795. * Specifies that the submesh is ready to be used.
  122796. * @param defines the list of "defines" to update.
  122797. * @param scene defines the scene the material belongs to.
  122798. * @returns - boolean indicating that the submesh is ready or not.
  122799. */
  122800. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  122801. /**
  122802. * Checks to see if a texture is used in the material.
  122803. * @param defines the list of "defines" to update.
  122804. * @param mesh the mesh we are preparing the defines for.
  122805. * @param scene defines the scene the material belongs to.
  122806. */
  122807. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  122808. /**
  122809. * Binds the material data.
  122810. * @param uniformBuffer defines the Uniform buffer to fill in.
  122811. * @param scene defines the scene the material belongs to.
  122812. * @param isFrozen defines wether the material is frozen or not.
  122813. */
  122814. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  122815. /**
  122816. * Checks to see if a texture is used in the material.
  122817. * @param texture - Base texture to use.
  122818. * @returns - Boolean specifying if a texture is used in the material.
  122819. */
  122820. hasTexture(texture: BaseTexture): boolean;
  122821. /**
  122822. * Returns an array of the actively used textures.
  122823. * @param activeTextures Array of BaseTextures
  122824. */
  122825. getActiveTextures(activeTextures: BaseTexture[]): void;
  122826. /**
  122827. * Returns the animatable textures.
  122828. * @param animatables Array of animatable textures.
  122829. */
  122830. getAnimatables(animatables: IAnimatable[]): void;
  122831. /**
  122832. * Disposes the resources of the material.
  122833. * @param forceDisposeTextures - Forces the disposal of all textures.
  122834. */
  122835. dispose(forceDisposeTextures?: boolean): void;
  122836. /**
  122837. * Get the current class name of the texture useful for serialization or dynamic coding.
  122838. * @returns "PBRAnisotropicConfiguration"
  122839. */
  122840. getClassName(): string;
  122841. /**
  122842. * Add fallbacks to the effect fallbacks list.
  122843. * @param defines defines the Base texture to use.
  122844. * @param fallbacks defines the current fallback list.
  122845. * @param currentRank defines the current fallback rank.
  122846. * @returns the new fallback rank.
  122847. */
  122848. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122849. /**
  122850. * Add the required uniforms to the current list.
  122851. * @param uniforms defines the current uniform list.
  122852. */
  122853. static AddUniforms(uniforms: string[]): void;
  122854. /**
  122855. * Add the required uniforms to the current buffer.
  122856. * @param uniformBuffer defines the current uniform buffer.
  122857. */
  122858. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122859. /**
  122860. * Add the required samplers to the current list.
  122861. * @param samplers defines the current sampler list.
  122862. */
  122863. static AddSamplers(samplers: string[]): void;
  122864. /**
  122865. * Makes a duplicate of the current configuration into another one.
  122866. * @param anisotropicConfiguration define the config where to copy the info
  122867. */
  122868. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  122869. /**
  122870. * Serializes this anisotropy configuration.
  122871. * @returns - An object with the serialized config.
  122872. */
  122873. serialize(): any;
  122874. /**
  122875. * Parses a anisotropy Configuration from a serialized object.
  122876. * @param source - Serialized object.
  122877. * @param scene Defines the scene we are parsing for
  122878. * @param rootUrl Defines the rootUrl to load from
  122879. */
  122880. parse(source: any, scene: Scene, rootUrl: string): void;
  122881. }
  122882. }
  122883. declare module BABYLON {
  122884. /**
  122885. * @hidden
  122886. */
  122887. export interface IMaterialBRDFDefines {
  122888. BRDF_V_HEIGHT_CORRELATED: boolean;
  122889. MS_BRDF_ENERGY_CONSERVATION: boolean;
  122890. SPHERICAL_HARMONICS: boolean;
  122891. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  122892. /** @hidden */
  122893. _areMiscDirty: boolean;
  122894. }
  122895. /**
  122896. * Define the code related to the BRDF parameters of the pbr material.
  122897. */
  122898. export class PBRBRDFConfiguration {
  122899. /**
  122900. * Default value used for the energy conservation.
  122901. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122902. */
  122903. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  122904. /**
  122905. * Default value used for the Smith Visibility Height Correlated mode.
  122906. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122907. */
  122908. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  122909. /**
  122910. * Default value used for the IBL diffuse part.
  122911. * This can help switching back to the polynomials mode globally which is a tiny bit
  122912. * less GPU intensive at the drawback of a lower quality.
  122913. */
  122914. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  122915. /**
  122916. * Default value used for activating energy conservation for the specular workflow.
  122917. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122918. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122919. */
  122920. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  122921. private _useEnergyConservation;
  122922. /**
  122923. * Defines if the material uses energy conservation.
  122924. */
  122925. useEnergyConservation: boolean;
  122926. private _useSmithVisibilityHeightCorrelated;
  122927. /**
  122928. * LEGACY Mode set to false
  122929. * Defines if the material uses height smith correlated visibility term.
  122930. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  122931. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  122932. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  122933. * Not relying on height correlated will also disable energy conservation.
  122934. */
  122935. useSmithVisibilityHeightCorrelated: boolean;
  122936. private _useSphericalHarmonics;
  122937. /**
  122938. * LEGACY Mode set to false
  122939. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  122940. * diffuse part of the IBL.
  122941. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  122942. * to the ground truth.
  122943. */
  122944. useSphericalHarmonics: boolean;
  122945. private _useSpecularGlossinessInputEnergyConservation;
  122946. /**
  122947. * Defines if the material uses energy conservation, when the specular workflow is active.
  122948. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122949. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122950. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  122951. */
  122952. useSpecularGlossinessInputEnergyConservation: boolean;
  122953. /** @hidden */
  122954. private _internalMarkAllSubMeshesAsMiscDirty;
  122955. /** @hidden */
  122956. _markAllSubMeshesAsMiscDirty(): void;
  122957. /**
  122958. * Instantiate a new istance of clear coat configuration.
  122959. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  122960. */
  122961. constructor(markAllSubMeshesAsMiscDirty: () => void);
  122962. /**
  122963. * Checks to see if a texture is used in the material.
  122964. * @param defines the list of "defines" to update.
  122965. */
  122966. prepareDefines(defines: IMaterialBRDFDefines): void;
  122967. /**
  122968. * Get the current class name of the texture useful for serialization or dynamic coding.
  122969. * @returns "PBRClearCoatConfiguration"
  122970. */
  122971. getClassName(): string;
  122972. /**
  122973. * Makes a duplicate of the current configuration into another one.
  122974. * @param brdfConfiguration define the config where to copy the info
  122975. */
  122976. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  122977. /**
  122978. * Serializes this BRDF configuration.
  122979. * @returns - An object with the serialized config.
  122980. */
  122981. serialize(): any;
  122982. /**
  122983. * Parses a anisotropy Configuration from a serialized object.
  122984. * @param source - Serialized object.
  122985. * @param scene Defines the scene we are parsing for
  122986. * @param rootUrl Defines the rootUrl to load from
  122987. */
  122988. parse(source: any, scene: Scene, rootUrl: string): void;
  122989. }
  122990. }
  122991. declare module BABYLON {
  122992. /**
  122993. * @hidden
  122994. */
  122995. export interface IMaterialSheenDefines {
  122996. SHEEN: boolean;
  122997. SHEEN_TEXTURE: boolean;
  122998. SHEEN_TEXTUREDIRECTUV: number;
  122999. SHEEN_LINKWITHALBEDO: boolean;
  123000. /** @hidden */
  123001. _areTexturesDirty: boolean;
  123002. }
  123003. /**
  123004. * Define the code related to the Sheen parameters of the pbr material.
  123005. */
  123006. export class PBRSheenConfiguration {
  123007. private _isEnabled;
  123008. /**
  123009. * Defines if the material uses sheen.
  123010. */
  123011. isEnabled: boolean;
  123012. private _linkSheenWithAlbedo;
  123013. /**
  123014. * Defines if the sheen is linked to the sheen color.
  123015. */
  123016. linkSheenWithAlbedo: boolean;
  123017. /**
  123018. * Defines the sheen intensity.
  123019. */
  123020. intensity: number;
  123021. /**
  123022. * Defines the sheen color.
  123023. */
  123024. color: Color3;
  123025. private _texture;
  123026. /**
  123027. * Stores the sheen tint values in a texture.
  123028. * rgb is tint
  123029. * a is a intensity
  123030. */
  123031. texture: Nullable<BaseTexture>;
  123032. /** @hidden */
  123033. private _internalMarkAllSubMeshesAsTexturesDirty;
  123034. /** @hidden */
  123035. _markAllSubMeshesAsTexturesDirty(): void;
  123036. /**
  123037. * Instantiate a new istance of clear coat configuration.
  123038. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123039. */
  123040. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123041. /**
  123042. * Specifies that the submesh is ready to be used.
  123043. * @param defines the list of "defines" to update.
  123044. * @param scene defines the scene the material belongs to.
  123045. * @returns - boolean indicating that the submesh is ready or not.
  123046. */
  123047. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123048. /**
  123049. * Checks to see if a texture is used in the material.
  123050. * @param defines the list of "defines" to update.
  123051. * @param scene defines the scene the material belongs to.
  123052. */
  123053. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123054. /**
  123055. * Binds the material data.
  123056. * @param uniformBuffer defines the Uniform buffer to fill in.
  123057. * @param scene defines the scene the material belongs to.
  123058. * @param isFrozen defines wether the material is frozen or not.
  123059. */
  123060. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123061. /**
  123062. * Checks to see if a texture is used in the material.
  123063. * @param texture - Base texture to use.
  123064. * @returns - Boolean specifying if a texture is used in the material.
  123065. */
  123066. hasTexture(texture: BaseTexture): boolean;
  123067. /**
  123068. * Returns an array of the actively used textures.
  123069. * @param activeTextures Array of BaseTextures
  123070. */
  123071. getActiveTextures(activeTextures: BaseTexture[]): void;
  123072. /**
  123073. * Returns the animatable textures.
  123074. * @param animatables Array of animatable textures.
  123075. */
  123076. getAnimatables(animatables: IAnimatable[]): void;
  123077. /**
  123078. * Disposes the resources of the material.
  123079. * @param forceDisposeTextures - Forces the disposal of all textures.
  123080. */
  123081. dispose(forceDisposeTextures?: boolean): void;
  123082. /**
  123083. * Get the current class name of the texture useful for serialization or dynamic coding.
  123084. * @returns "PBRSheenConfiguration"
  123085. */
  123086. getClassName(): string;
  123087. /**
  123088. * Add fallbacks to the effect fallbacks list.
  123089. * @param defines defines the Base texture to use.
  123090. * @param fallbacks defines the current fallback list.
  123091. * @param currentRank defines the current fallback rank.
  123092. * @returns the new fallback rank.
  123093. */
  123094. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123095. /**
  123096. * Add the required uniforms to the current list.
  123097. * @param uniforms defines the current uniform list.
  123098. */
  123099. static AddUniforms(uniforms: string[]): void;
  123100. /**
  123101. * Add the required uniforms to the current buffer.
  123102. * @param uniformBuffer defines the current uniform buffer.
  123103. */
  123104. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123105. /**
  123106. * Add the required samplers to the current list.
  123107. * @param samplers defines the current sampler list.
  123108. */
  123109. static AddSamplers(samplers: string[]): void;
  123110. /**
  123111. * Makes a duplicate of the current configuration into another one.
  123112. * @param sheenConfiguration define the config where to copy the info
  123113. */
  123114. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123115. /**
  123116. * Serializes this BRDF configuration.
  123117. * @returns - An object with the serialized config.
  123118. */
  123119. serialize(): any;
  123120. /**
  123121. * Parses a anisotropy Configuration from a serialized object.
  123122. * @param source - Serialized object.
  123123. * @param scene Defines the scene we are parsing for
  123124. * @param rootUrl Defines the rootUrl to load from
  123125. */
  123126. parse(source: any, scene: Scene, rootUrl: string): void;
  123127. }
  123128. }
  123129. declare module BABYLON {
  123130. /**
  123131. * @hidden
  123132. */
  123133. export interface IMaterialSubSurfaceDefines {
  123134. SUBSURFACE: boolean;
  123135. SS_REFRACTION: boolean;
  123136. SS_TRANSLUCENCY: boolean;
  123137. SS_SCATERRING: boolean;
  123138. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123139. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123140. SS_REFRACTIONMAP_3D: boolean;
  123141. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123142. SS_LODINREFRACTIONALPHA: boolean;
  123143. SS_GAMMAREFRACTION: boolean;
  123144. SS_RGBDREFRACTION: boolean;
  123145. SS_LINEARSPECULARREFRACTION: boolean;
  123146. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123147. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123148. /** @hidden */
  123149. _areTexturesDirty: boolean;
  123150. }
  123151. /**
  123152. * Define the code related to the sub surface parameters of the pbr material.
  123153. */
  123154. export class PBRSubSurfaceConfiguration {
  123155. private _isRefractionEnabled;
  123156. /**
  123157. * Defines if the refraction is enabled in the material.
  123158. */
  123159. isRefractionEnabled: boolean;
  123160. private _isTranslucencyEnabled;
  123161. /**
  123162. * Defines if the translucency is enabled in the material.
  123163. */
  123164. isTranslucencyEnabled: boolean;
  123165. private _isScatteringEnabled;
  123166. /**
  123167. * Defines the refraction intensity of the material.
  123168. * The refraction when enabled replaces the Diffuse part of the material.
  123169. * The intensity helps transitionning between diffuse and refraction.
  123170. */
  123171. refractionIntensity: number;
  123172. /**
  123173. * Defines the translucency intensity of the material.
  123174. * When translucency has been enabled, this defines how much of the "translucency"
  123175. * is addded to the diffuse part of the material.
  123176. */
  123177. translucencyIntensity: number;
  123178. /**
  123179. * Defines the scattering intensity of the material.
  123180. * When scattering has been enabled, this defines how much of the "scattered light"
  123181. * is addded to the diffuse part of the material.
  123182. */
  123183. scatteringIntensity: number;
  123184. private _thicknessTexture;
  123185. /**
  123186. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123187. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123188. * 0 would mean minimumThickness
  123189. * 1 would mean maximumThickness
  123190. * The other channels might be use as a mask to vary the different effects intensity.
  123191. */
  123192. thicknessTexture: Nullable<BaseTexture>;
  123193. private _refractionTexture;
  123194. /**
  123195. * Defines the texture to use for refraction.
  123196. */
  123197. refractionTexture: Nullable<BaseTexture>;
  123198. private _indexOfRefraction;
  123199. /**
  123200. * Defines the index of refraction used in the material.
  123201. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123202. */
  123203. indexOfRefraction: number;
  123204. private _invertRefractionY;
  123205. /**
  123206. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123207. */
  123208. invertRefractionY: boolean;
  123209. private _linkRefractionWithTransparency;
  123210. /**
  123211. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123212. * Materials half opaque for instance using refraction could benefit from this control.
  123213. */
  123214. linkRefractionWithTransparency: boolean;
  123215. /**
  123216. * Defines the minimum thickness stored in the thickness map.
  123217. * If no thickness map is defined, this value will be used to simulate thickness.
  123218. */
  123219. minimumThickness: number;
  123220. /**
  123221. * Defines the maximum thickness stored in the thickness map.
  123222. */
  123223. maximumThickness: number;
  123224. /**
  123225. * Defines the volume tint of the material.
  123226. * This is used for both translucency and scattering.
  123227. */
  123228. tintColor: Color3;
  123229. /**
  123230. * Defines the distance at which the tint color should be found in the media.
  123231. * This is used for refraction only.
  123232. */
  123233. tintColorAtDistance: number;
  123234. /**
  123235. * Defines how far each channel transmit through the media.
  123236. * It is defined as a color to simplify it selection.
  123237. */
  123238. diffusionDistance: Color3;
  123239. private _useMaskFromThicknessTexture;
  123240. /**
  123241. * Stores the intensity of the different subsurface effects in the thickness texture.
  123242. * * the green channel is the translucency intensity.
  123243. * * the blue channel is the scattering intensity.
  123244. * * the alpha channel is the refraction intensity.
  123245. */
  123246. useMaskFromThicknessTexture: boolean;
  123247. /** @hidden */
  123248. private _internalMarkAllSubMeshesAsTexturesDirty;
  123249. /** @hidden */
  123250. _markAllSubMeshesAsTexturesDirty(): void;
  123251. /**
  123252. * Instantiate a new istance of sub surface configuration.
  123253. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123254. */
  123255. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123256. /**
  123257. * Gets wehter the submesh is ready to be used or not.
  123258. * @param defines the list of "defines" to update.
  123259. * @param scene defines the scene the material belongs to.
  123260. * @returns - boolean indicating that the submesh is ready or not.
  123261. */
  123262. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123263. /**
  123264. * Checks to see if a texture is used in the material.
  123265. * @param defines the list of "defines" to update.
  123266. * @param scene defines the scene to the material belongs to.
  123267. */
  123268. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123269. /**
  123270. * Binds the material data.
  123271. * @param uniformBuffer defines the Uniform buffer to fill in.
  123272. * @param scene defines the scene the material belongs to.
  123273. * @param engine defines the engine the material belongs to.
  123274. * @param isFrozen defines wether the material is frozen or not.
  123275. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123276. */
  123277. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123278. /**
  123279. * Unbinds the material from the mesh.
  123280. * @param activeEffect defines the effect that should be unbound from.
  123281. * @returns true if unbound, otherwise false
  123282. */
  123283. unbind(activeEffect: Effect): boolean;
  123284. /**
  123285. * Returns the texture used for refraction or null if none is used.
  123286. * @param scene defines the scene the material belongs to.
  123287. * @returns - Refraction texture if present. If no refraction texture and refraction
  123288. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123289. */
  123290. private _getRefractionTexture;
  123291. /**
  123292. * Returns true if alpha blending should be disabled.
  123293. */
  123294. get disableAlphaBlending(): boolean;
  123295. /**
  123296. * Fills the list of render target textures.
  123297. * @param renderTargets the list of render targets to update
  123298. */
  123299. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123300. /**
  123301. * Checks to see if a texture is used in the material.
  123302. * @param texture - Base texture to use.
  123303. * @returns - Boolean specifying if a texture is used in the material.
  123304. */
  123305. hasTexture(texture: BaseTexture): boolean;
  123306. /**
  123307. * Gets a boolean indicating that current material needs to register RTT
  123308. * @returns true if this uses a render target otherwise false.
  123309. */
  123310. hasRenderTargetTextures(): boolean;
  123311. /**
  123312. * Returns an array of the actively used textures.
  123313. * @param activeTextures Array of BaseTextures
  123314. */
  123315. getActiveTextures(activeTextures: BaseTexture[]): void;
  123316. /**
  123317. * Returns the animatable textures.
  123318. * @param animatables Array of animatable textures.
  123319. */
  123320. getAnimatables(animatables: IAnimatable[]): void;
  123321. /**
  123322. * Disposes the resources of the material.
  123323. * @param forceDisposeTextures - Forces the disposal of all textures.
  123324. */
  123325. dispose(forceDisposeTextures?: boolean): void;
  123326. /**
  123327. * Get the current class name of the texture useful for serialization or dynamic coding.
  123328. * @returns "PBRSubSurfaceConfiguration"
  123329. */
  123330. getClassName(): string;
  123331. /**
  123332. * Add fallbacks to the effect fallbacks list.
  123333. * @param defines defines the Base texture to use.
  123334. * @param fallbacks defines the current fallback list.
  123335. * @param currentRank defines the current fallback rank.
  123336. * @returns the new fallback rank.
  123337. */
  123338. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123339. /**
  123340. * Add the required uniforms to the current list.
  123341. * @param uniforms defines the current uniform list.
  123342. */
  123343. static AddUniforms(uniforms: string[]): void;
  123344. /**
  123345. * Add the required samplers to the current list.
  123346. * @param samplers defines the current sampler list.
  123347. */
  123348. static AddSamplers(samplers: string[]): void;
  123349. /**
  123350. * Add the required uniforms to the current buffer.
  123351. * @param uniformBuffer defines the current uniform buffer.
  123352. */
  123353. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123354. /**
  123355. * Makes a duplicate of the current configuration into another one.
  123356. * @param configuration define the config where to copy the info
  123357. */
  123358. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123359. /**
  123360. * Serializes this Sub Surface configuration.
  123361. * @returns - An object with the serialized config.
  123362. */
  123363. serialize(): any;
  123364. /**
  123365. * Parses a anisotropy Configuration from a serialized object.
  123366. * @param source - Serialized object.
  123367. * @param scene Defines the scene we are parsing for
  123368. * @param rootUrl Defines the rootUrl to load from
  123369. */
  123370. parse(source: any, scene: Scene, rootUrl: string): void;
  123371. }
  123372. }
  123373. declare module BABYLON {
  123374. /** @hidden */
  123375. export var pbrFragmentDeclaration: {
  123376. name: string;
  123377. shader: string;
  123378. };
  123379. }
  123380. declare module BABYLON {
  123381. /** @hidden */
  123382. export var pbrUboDeclaration: {
  123383. name: string;
  123384. shader: string;
  123385. };
  123386. }
  123387. declare module BABYLON {
  123388. /** @hidden */
  123389. export var pbrFragmentExtraDeclaration: {
  123390. name: string;
  123391. shader: string;
  123392. };
  123393. }
  123394. declare module BABYLON {
  123395. /** @hidden */
  123396. export var pbrFragmentSamplersDeclaration: {
  123397. name: string;
  123398. shader: string;
  123399. };
  123400. }
  123401. declare module BABYLON {
  123402. /** @hidden */
  123403. export var pbrHelperFunctions: {
  123404. name: string;
  123405. shader: string;
  123406. };
  123407. }
  123408. declare module BABYLON {
  123409. /** @hidden */
  123410. export var harmonicsFunctions: {
  123411. name: string;
  123412. shader: string;
  123413. };
  123414. }
  123415. declare module BABYLON {
  123416. /** @hidden */
  123417. export var pbrDirectLightingSetupFunctions: {
  123418. name: string;
  123419. shader: string;
  123420. };
  123421. }
  123422. declare module BABYLON {
  123423. /** @hidden */
  123424. export var pbrDirectLightingFalloffFunctions: {
  123425. name: string;
  123426. shader: string;
  123427. };
  123428. }
  123429. declare module BABYLON {
  123430. /** @hidden */
  123431. export var pbrBRDFFunctions: {
  123432. name: string;
  123433. shader: string;
  123434. };
  123435. }
  123436. declare module BABYLON {
  123437. /** @hidden */
  123438. export var pbrDirectLightingFunctions: {
  123439. name: string;
  123440. shader: string;
  123441. };
  123442. }
  123443. declare module BABYLON {
  123444. /** @hidden */
  123445. export var pbrIBLFunctions: {
  123446. name: string;
  123447. shader: string;
  123448. };
  123449. }
  123450. declare module BABYLON {
  123451. /** @hidden */
  123452. export var pbrDebug: {
  123453. name: string;
  123454. shader: string;
  123455. };
  123456. }
  123457. declare module BABYLON {
  123458. /** @hidden */
  123459. export var pbrPixelShader: {
  123460. name: string;
  123461. shader: string;
  123462. };
  123463. }
  123464. declare module BABYLON {
  123465. /** @hidden */
  123466. export var pbrVertexDeclaration: {
  123467. name: string;
  123468. shader: string;
  123469. };
  123470. }
  123471. declare module BABYLON {
  123472. /** @hidden */
  123473. export var pbrVertexShader: {
  123474. name: string;
  123475. shader: string;
  123476. };
  123477. }
  123478. declare module BABYLON {
  123479. /**
  123480. * Manages the defines for the PBR Material.
  123481. * @hidden
  123482. */
  123483. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123484. PBR: boolean;
  123485. MAINUV1: boolean;
  123486. MAINUV2: boolean;
  123487. UV1: boolean;
  123488. UV2: boolean;
  123489. ALBEDO: boolean;
  123490. ALBEDODIRECTUV: number;
  123491. VERTEXCOLOR: boolean;
  123492. AMBIENT: boolean;
  123493. AMBIENTDIRECTUV: number;
  123494. AMBIENTINGRAYSCALE: boolean;
  123495. OPACITY: boolean;
  123496. VERTEXALPHA: boolean;
  123497. OPACITYDIRECTUV: number;
  123498. OPACITYRGB: boolean;
  123499. ALPHATEST: boolean;
  123500. DEPTHPREPASS: boolean;
  123501. ALPHABLEND: boolean;
  123502. ALPHAFROMALBEDO: boolean;
  123503. ALPHATESTVALUE: string;
  123504. SPECULAROVERALPHA: boolean;
  123505. RADIANCEOVERALPHA: boolean;
  123506. ALPHAFRESNEL: boolean;
  123507. LINEARALPHAFRESNEL: boolean;
  123508. PREMULTIPLYALPHA: boolean;
  123509. EMISSIVE: boolean;
  123510. EMISSIVEDIRECTUV: number;
  123511. REFLECTIVITY: boolean;
  123512. REFLECTIVITYDIRECTUV: number;
  123513. SPECULARTERM: boolean;
  123514. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  123515. MICROSURFACEAUTOMATIC: boolean;
  123516. LODBASEDMICROSFURACE: boolean;
  123517. MICROSURFACEMAP: boolean;
  123518. MICROSURFACEMAPDIRECTUV: number;
  123519. METALLICWORKFLOW: boolean;
  123520. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  123521. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  123522. METALLNESSSTOREINMETALMAPBLUE: boolean;
  123523. AOSTOREINMETALMAPRED: boolean;
  123524. METALLICF0FACTORFROMMETALLICMAP: boolean;
  123525. ENVIRONMENTBRDF: boolean;
  123526. ENVIRONMENTBRDF_RGBD: boolean;
  123527. NORMAL: boolean;
  123528. TANGENT: boolean;
  123529. BUMP: boolean;
  123530. BUMPDIRECTUV: number;
  123531. OBJECTSPACE_NORMALMAP: boolean;
  123532. PARALLAX: boolean;
  123533. PARALLAXOCCLUSION: boolean;
  123534. NORMALXYSCALE: boolean;
  123535. LIGHTMAP: boolean;
  123536. LIGHTMAPDIRECTUV: number;
  123537. USELIGHTMAPASSHADOWMAP: boolean;
  123538. GAMMALIGHTMAP: boolean;
  123539. RGBDLIGHTMAP: boolean;
  123540. REFLECTION: boolean;
  123541. REFLECTIONMAP_3D: boolean;
  123542. REFLECTIONMAP_SPHERICAL: boolean;
  123543. REFLECTIONMAP_PLANAR: boolean;
  123544. REFLECTIONMAP_CUBIC: boolean;
  123545. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  123546. REFLECTIONMAP_PROJECTION: boolean;
  123547. REFLECTIONMAP_SKYBOX: boolean;
  123548. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  123549. REFLECTIONMAP_EXPLICIT: boolean;
  123550. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  123551. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  123552. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  123553. INVERTCUBICMAP: boolean;
  123554. USESPHERICALFROMREFLECTIONMAP: boolean;
  123555. USEIRRADIANCEMAP: boolean;
  123556. SPHERICAL_HARMONICS: boolean;
  123557. USESPHERICALINVERTEX: boolean;
  123558. REFLECTIONMAP_OPPOSITEZ: boolean;
  123559. LODINREFLECTIONALPHA: boolean;
  123560. GAMMAREFLECTION: boolean;
  123561. RGBDREFLECTION: boolean;
  123562. LINEARSPECULARREFLECTION: boolean;
  123563. RADIANCEOCCLUSION: boolean;
  123564. HORIZONOCCLUSION: boolean;
  123565. INSTANCES: boolean;
  123566. NUM_BONE_INFLUENCERS: number;
  123567. BonesPerMesh: number;
  123568. BONETEXTURE: boolean;
  123569. NONUNIFORMSCALING: boolean;
  123570. MORPHTARGETS: boolean;
  123571. MORPHTARGETS_NORMAL: boolean;
  123572. MORPHTARGETS_TANGENT: boolean;
  123573. MORPHTARGETS_UV: boolean;
  123574. NUM_MORPH_INFLUENCERS: number;
  123575. IMAGEPROCESSING: boolean;
  123576. VIGNETTE: boolean;
  123577. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123578. VIGNETTEBLENDMODEOPAQUE: boolean;
  123579. TONEMAPPING: boolean;
  123580. TONEMAPPING_ACES: boolean;
  123581. CONTRAST: boolean;
  123582. COLORCURVES: boolean;
  123583. COLORGRADING: boolean;
  123584. COLORGRADING3D: boolean;
  123585. SAMPLER3DGREENDEPTH: boolean;
  123586. SAMPLER3DBGRMAP: boolean;
  123587. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123588. EXPOSURE: boolean;
  123589. MULTIVIEW: boolean;
  123590. USEPHYSICALLIGHTFALLOFF: boolean;
  123591. USEGLTFLIGHTFALLOFF: boolean;
  123592. TWOSIDEDLIGHTING: boolean;
  123593. SHADOWFLOAT: boolean;
  123594. CLIPPLANE: boolean;
  123595. CLIPPLANE2: boolean;
  123596. CLIPPLANE3: boolean;
  123597. CLIPPLANE4: boolean;
  123598. CLIPPLANE5: boolean;
  123599. CLIPPLANE6: boolean;
  123600. POINTSIZE: boolean;
  123601. FOG: boolean;
  123602. LOGARITHMICDEPTH: boolean;
  123603. FORCENORMALFORWARD: boolean;
  123604. SPECULARAA: boolean;
  123605. CLEARCOAT: boolean;
  123606. CLEARCOAT_DEFAULTIOR: boolean;
  123607. CLEARCOAT_TEXTURE: boolean;
  123608. CLEARCOAT_TEXTUREDIRECTUV: number;
  123609. CLEARCOAT_BUMP: boolean;
  123610. CLEARCOAT_BUMPDIRECTUV: number;
  123611. CLEARCOAT_TINT: boolean;
  123612. CLEARCOAT_TINT_TEXTURE: boolean;
  123613. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123614. ANISOTROPIC: boolean;
  123615. ANISOTROPIC_TEXTURE: boolean;
  123616. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123617. BRDF_V_HEIGHT_CORRELATED: boolean;
  123618. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123619. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123620. SHEEN: boolean;
  123621. SHEEN_TEXTURE: boolean;
  123622. SHEEN_TEXTUREDIRECTUV: number;
  123623. SHEEN_LINKWITHALBEDO: boolean;
  123624. SUBSURFACE: boolean;
  123625. SS_REFRACTION: boolean;
  123626. SS_TRANSLUCENCY: boolean;
  123627. SS_SCATERRING: boolean;
  123628. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123629. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123630. SS_REFRACTIONMAP_3D: boolean;
  123631. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123632. SS_LODINREFRACTIONALPHA: boolean;
  123633. SS_GAMMAREFRACTION: boolean;
  123634. SS_RGBDREFRACTION: boolean;
  123635. SS_LINEARSPECULARREFRACTION: boolean;
  123636. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123637. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123638. UNLIT: boolean;
  123639. DEBUGMODE: number;
  123640. /**
  123641. * Initializes the PBR Material defines.
  123642. */
  123643. constructor();
  123644. /**
  123645. * Resets the PBR Material defines.
  123646. */
  123647. reset(): void;
  123648. }
  123649. /**
  123650. * The Physically based material base class of BJS.
  123651. *
  123652. * This offers the main features of a standard PBR material.
  123653. * For more information, please refer to the documentation :
  123654. * https://doc.babylonjs.com/how_to/physically_based_rendering
  123655. */
  123656. export abstract class PBRBaseMaterial extends PushMaterial {
  123657. /**
  123658. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  123659. */
  123660. static readonly PBRMATERIAL_OPAQUE: number;
  123661. /**
  123662. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  123663. */
  123664. static readonly PBRMATERIAL_ALPHATEST: number;
  123665. /**
  123666. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123667. */
  123668. static readonly PBRMATERIAL_ALPHABLEND: number;
  123669. /**
  123670. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123671. * They are also discarded below the alpha cutoff threshold to improve performances.
  123672. */
  123673. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  123674. /**
  123675. * Defines the default value of how much AO map is occluding the analytical lights
  123676. * (point spot...).
  123677. */
  123678. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  123679. /**
  123680. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  123681. */
  123682. static readonly LIGHTFALLOFF_PHYSICAL: number;
  123683. /**
  123684. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  123685. * to enhance interoperability with other engines.
  123686. */
  123687. static readonly LIGHTFALLOFF_GLTF: number;
  123688. /**
  123689. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  123690. * to enhance interoperability with other materials.
  123691. */
  123692. static readonly LIGHTFALLOFF_STANDARD: number;
  123693. /**
  123694. * Intensity of the direct lights e.g. the four lights available in your scene.
  123695. * This impacts both the direct diffuse and specular highlights.
  123696. */
  123697. protected _directIntensity: number;
  123698. /**
  123699. * Intensity of the emissive part of the material.
  123700. * This helps controlling the emissive effect without modifying the emissive color.
  123701. */
  123702. protected _emissiveIntensity: number;
  123703. /**
  123704. * Intensity of the environment e.g. how much the environment will light the object
  123705. * either through harmonics for rough material or through the refelction for shiny ones.
  123706. */
  123707. protected _environmentIntensity: number;
  123708. /**
  123709. * This is a special control allowing the reduction of the specular highlights coming from the
  123710. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  123711. */
  123712. protected _specularIntensity: number;
  123713. /**
  123714. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  123715. */
  123716. private _lightingInfos;
  123717. /**
  123718. * Debug Control allowing disabling the bump map on this material.
  123719. */
  123720. protected _disableBumpMap: boolean;
  123721. /**
  123722. * AKA Diffuse Texture in standard nomenclature.
  123723. */
  123724. protected _albedoTexture: Nullable<BaseTexture>;
  123725. /**
  123726. * AKA Occlusion Texture in other nomenclature.
  123727. */
  123728. protected _ambientTexture: Nullable<BaseTexture>;
  123729. /**
  123730. * AKA Occlusion Texture Intensity in other nomenclature.
  123731. */
  123732. protected _ambientTextureStrength: number;
  123733. /**
  123734. * Defines how much the AO map is occluding the analytical lights (point spot...).
  123735. * 1 means it completely occludes it
  123736. * 0 mean it has no impact
  123737. */
  123738. protected _ambientTextureImpactOnAnalyticalLights: number;
  123739. /**
  123740. * Stores the alpha values in a texture.
  123741. */
  123742. protected _opacityTexture: Nullable<BaseTexture>;
  123743. /**
  123744. * Stores the reflection values in a texture.
  123745. */
  123746. protected _reflectionTexture: Nullable<BaseTexture>;
  123747. /**
  123748. * Stores the emissive values in a texture.
  123749. */
  123750. protected _emissiveTexture: Nullable<BaseTexture>;
  123751. /**
  123752. * AKA Specular texture in other nomenclature.
  123753. */
  123754. protected _reflectivityTexture: Nullable<BaseTexture>;
  123755. /**
  123756. * Used to switch from specular/glossiness to metallic/roughness workflow.
  123757. */
  123758. protected _metallicTexture: Nullable<BaseTexture>;
  123759. /**
  123760. * Specifies the metallic scalar of the metallic/roughness workflow.
  123761. * Can also be used to scale the metalness values of the metallic texture.
  123762. */
  123763. protected _metallic: Nullable<number>;
  123764. /**
  123765. * Specifies the roughness scalar of the metallic/roughness workflow.
  123766. * Can also be used to scale the roughness values of the metallic texture.
  123767. */
  123768. protected _roughness: Nullable<number>;
  123769. /**
  123770. * Specifies the an F0 factor to help configuring the material F0.
  123771. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  123772. * to 0.5 the previously hard coded value stays the same.
  123773. * Can also be used to scale the F0 values of the metallic texture.
  123774. */
  123775. protected _metallicF0Factor: number;
  123776. /**
  123777. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  123778. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  123779. * your expectation as it multiplies with the texture data.
  123780. */
  123781. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  123782. /**
  123783. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  123784. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  123785. */
  123786. protected _microSurfaceTexture: Nullable<BaseTexture>;
  123787. /**
  123788. * Stores surface normal data used to displace a mesh in a texture.
  123789. */
  123790. protected _bumpTexture: Nullable<BaseTexture>;
  123791. /**
  123792. * Stores the pre-calculated light information of a mesh in a texture.
  123793. */
  123794. protected _lightmapTexture: Nullable<BaseTexture>;
  123795. /**
  123796. * The color of a material in ambient lighting.
  123797. */
  123798. protected _ambientColor: Color3;
  123799. /**
  123800. * AKA Diffuse Color in other nomenclature.
  123801. */
  123802. protected _albedoColor: Color3;
  123803. /**
  123804. * AKA Specular Color in other nomenclature.
  123805. */
  123806. protected _reflectivityColor: Color3;
  123807. /**
  123808. * The color applied when light is reflected from a material.
  123809. */
  123810. protected _reflectionColor: Color3;
  123811. /**
  123812. * The color applied when light is emitted from a material.
  123813. */
  123814. protected _emissiveColor: Color3;
  123815. /**
  123816. * AKA Glossiness in other nomenclature.
  123817. */
  123818. protected _microSurface: number;
  123819. /**
  123820. * Specifies that the material will use the light map as a show map.
  123821. */
  123822. protected _useLightmapAsShadowmap: boolean;
  123823. /**
  123824. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  123825. * makes the reflect vector face the model (under horizon).
  123826. */
  123827. protected _useHorizonOcclusion: boolean;
  123828. /**
  123829. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  123830. * too much the area relying on ambient texture to define their ambient occlusion.
  123831. */
  123832. protected _useRadianceOcclusion: boolean;
  123833. /**
  123834. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  123835. */
  123836. protected _useAlphaFromAlbedoTexture: boolean;
  123837. /**
  123838. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  123839. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  123840. */
  123841. protected _useSpecularOverAlpha: boolean;
  123842. /**
  123843. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  123844. */
  123845. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  123846. /**
  123847. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  123848. */
  123849. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  123850. /**
  123851. * Specifies if the metallic texture contains the roughness information in its green channel.
  123852. */
  123853. protected _useRoughnessFromMetallicTextureGreen: boolean;
  123854. /**
  123855. * Specifies if the metallic texture contains the metallness information in its blue channel.
  123856. */
  123857. protected _useMetallnessFromMetallicTextureBlue: boolean;
  123858. /**
  123859. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  123860. */
  123861. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  123862. /**
  123863. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  123864. */
  123865. protected _useAmbientInGrayScale: boolean;
  123866. /**
  123867. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  123868. * The material will try to infer what glossiness each pixel should be.
  123869. */
  123870. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  123871. /**
  123872. * Defines the falloff type used in this material.
  123873. * It by default is Physical.
  123874. */
  123875. protected _lightFalloff: number;
  123876. /**
  123877. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  123878. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  123879. */
  123880. protected _useRadianceOverAlpha: boolean;
  123881. /**
  123882. * Allows using an object space normal map (instead of tangent space).
  123883. */
  123884. protected _useObjectSpaceNormalMap: boolean;
  123885. /**
  123886. * Allows using the bump map in parallax mode.
  123887. */
  123888. protected _useParallax: boolean;
  123889. /**
  123890. * Allows using the bump map in parallax occlusion mode.
  123891. */
  123892. protected _useParallaxOcclusion: boolean;
  123893. /**
  123894. * Controls the scale bias of the parallax mode.
  123895. */
  123896. protected _parallaxScaleBias: number;
  123897. /**
  123898. * If sets to true, disables all the lights affecting the material.
  123899. */
  123900. protected _disableLighting: boolean;
  123901. /**
  123902. * Number of Simultaneous lights allowed on the material.
  123903. */
  123904. protected _maxSimultaneousLights: number;
  123905. /**
  123906. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123907. */
  123908. protected _invertNormalMapX: boolean;
  123909. /**
  123910. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123911. */
  123912. protected _invertNormalMapY: boolean;
  123913. /**
  123914. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  123915. */
  123916. protected _twoSidedLighting: boolean;
  123917. /**
  123918. * Defines the alpha limits in alpha test mode.
  123919. */
  123920. protected _alphaCutOff: number;
  123921. /**
  123922. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  123923. */
  123924. protected _forceAlphaTest: boolean;
  123925. /**
  123926. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123927. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  123928. */
  123929. protected _useAlphaFresnel: boolean;
  123930. /**
  123931. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123932. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  123933. */
  123934. protected _useLinearAlphaFresnel: boolean;
  123935. /**
  123936. * The transparency mode of the material.
  123937. */
  123938. protected _transparencyMode: Nullable<number>;
  123939. /**
  123940. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  123941. * from cos thetav and roughness:
  123942. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  123943. */
  123944. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  123945. /**
  123946. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  123947. */
  123948. protected _forceIrradianceInFragment: boolean;
  123949. /**
  123950. * Force normal to face away from face.
  123951. */
  123952. protected _forceNormalForward: boolean;
  123953. /**
  123954. * Enables specular anti aliasing in the PBR shader.
  123955. * It will both interacts on the Geometry for analytical and IBL lighting.
  123956. * It also prefilter the roughness map based on the bump values.
  123957. */
  123958. protected _enableSpecularAntiAliasing: boolean;
  123959. /**
  123960. * Default configuration related to image processing available in the PBR Material.
  123961. */
  123962. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123963. /**
  123964. * Keep track of the image processing observer to allow dispose and replace.
  123965. */
  123966. private _imageProcessingObserver;
  123967. /**
  123968. * Attaches a new image processing configuration to the PBR Material.
  123969. * @param configuration
  123970. */
  123971. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123972. /**
  123973. * Stores the available render targets.
  123974. */
  123975. private _renderTargets;
  123976. /**
  123977. * Sets the global ambient color for the material used in lighting calculations.
  123978. */
  123979. private _globalAmbientColor;
  123980. /**
  123981. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  123982. */
  123983. private _useLogarithmicDepth;
  123984. /**
  123985. * If set to true, no lighting calculations will be applied.
  123986. */
  123987. private _unlit;
  123988. private _debugMode;
  123989. /**
  123990. * @hidden
  123991. * This is reserved for the inspector.
  123992. * Defines the material debug mode.
  123993. * It helps seeing only some components of the material while troubleshooting.
  123994. */
  123995. debugMode: number;
  123996. /**
  123997. * @hidden
  123998. * This is reserved for the inspector.
  123999. * Specify from where on screen the debug mode should start.
  124000. * The value goes from -1 (full screen) to 1 (not visible)
  124001. * It helps with side by side comparison against the final render
  124002. * This defaults to -1
  124003. */
  124004. private debugLimit;
  124005. /**
  124006. * @hidden
  124007. * This is reserved for the inspector.
  124008. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124009. * You can use the factor to better multiply the final value.
  124010. */
  124011. private debugFactor;
  124012. /**
  124013. * Defines the clear coat layer parameters for the material.
  124014. */
  124015. readonly clearCoat: PBRClearCoatConfiguration;
  124016. /**
  124017. * Defines the anisotropic parameters for the material.
  124018. */
  124019. readonly anisotropy: PBRAnisotropicConfiguration;
  124020. /**
  124021. * Defines the BRDF parameters for the material.
  124022. */
  124023. readonly brdf: PBRBRDFConfiguration;
  124024. /**
  124025. * Defines the Sheen parameters for the material.
  124026. */
  124027. readonly sheen: PBRSheenConfiguration;
  124028. /**
  124029. * Defines the SubSurface parameters for the material.
  124030. */
  124031. readonly subSurface: PBRSubSurfaceConfiguration;
  124032. /**
  124033. * Custom callback helping to override the default shader used in the material.
  124034. */
  124035. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124036. protected _rebuildInParallel: boolean;
  124037. /**
  124038. * Instantiates a new PBRMaterial instance.
  124039. *
  124040. * @param name The material name
  124041. * @param scene The scene the material will be use in.
  124042. */
  124043. constructor(name: string, scene: Scene);
  124044. /**
  124045. * Gets a boolean indicating that current material needs to register RTT
  124046. */
  124047. get hasRenderTargetTextures(): boolean;
  124048. /**
  124049. * Gets the name of the material class.
  124050. */
  124051. getClassName(): string;
  124052. /**
  124053. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124054. */
  124055. get useLogarithmicDepth(): boolean;
  124056. /**
  124057. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124058. */
  124059. set useLogarithmicDepth(value: boolean);
  124060. /**
  124061. * Gets the current transparency mode.
  124062. */
  124063. get transparencyMode(): Nullable<number>;
  124064. /**
  124065. * Sets the transparency mode of the material.
  124066. *
  124067. * | Value | Type | Description |
  124068. * | ----- | ----------------------------------- | ----------- |
  124069. * | 0 | OPAQUE | |
  124070. * | 1 | ALPHATEST | |
  124071. * | 2 | ALPHABLEND | |
  124072. * | 3 | ALPHATESTANDBLEND | |
  124073. *
  124074. */
  124075. set transparencyMode(value: Nullable<number>);
  124076. /**
  124077. * Returns true if alpha blending should be disabled.
  124078. */
  124079. private get _disableAlphaBlending();
  124080. /**
  124081. * Specifies whether or not this material should be rendered in alpha blend mode.
  124082. */
  124083. needAlphaBlending(): boolean;
  124084. /**
  124085. * Specifies if the mesh will require alpha blending.
  124086. * @param mesh - BJS mesh.
  124087. */
  124088. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124089. /**
  124090. * Specifies whether or not this material should be rendered in alpha test mode.
  124091. */
  124092. needAlphaTesting(): boolean;
  124093. /**
  124094. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124095. */
  124096. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124097. /**
  124098. * Gets the texture used for the alpha test.
  124099. */
  124100. getAlphaTestTexture(): Nullable<BaseTexture>;
  124101. /**
  124102. * Specifies that the submesh is ready to be used.
  124103. * @param mesh - BJS mesh.
  124104. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124105. * @param useInstances - Specifies that instances should be used.
  124106. * @returns - boolean indicating that the submesh is ready or not.
  124107. */
  124108. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124109. /**
  124110. * Specifies if the material uses metallic roughness workflow.
  124111. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124112. */
  124113. isMetallicWorkflow(): boolean;
  124114. private _prepareEffect;
  124115. private _prepareDefines;
  124116. /**
  124117. * Force shader compilation
  124118. */
  124119. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124120. /**
  124121. * Initializes the uniform buffer layout for the shader.
  124122. */
  124123. buildUniformLayout(): void;
  124124. /**
  124125. * Unbinds the material from the mesh
  124126. */
  124127. unbind(): void;
  124128. /**
  124129. * Binds the submesh data.
  124130. * @param world - The world matrix.
  124131. * @param mesh - The BJS mesh.
  124132. * @param subMesh - A submesh of the BJS mesh.
  124133. */
  124134. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124135. /**
  124136. * Returns the animatable textures.
  124137. * @returns - Array of animatable textures.
  124138. */
  124139. getAnimatables(): IAnimatable[];
  124140. /**
  124141. * Returns the texture used for reflections.
  124142. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124143. */
  124144. private _getReflectionTexture;
  124145. /**
  124146. * Returns an array of the actively used textures.
  124147. * @returns - Array of BaseTextures
  124148. */
  124149. getActiveTextures(): BaseTexture[];
  124150. /**
  124151. * Checks to see if a texture is used in the material.
  124152. * @param texture - Base texture to use.
  124153. * @returns - Boolean specifying if a texture is used in the material.
  124154. */
  124155. hasTexture(texture: BaseTexture): boolean;
  124156. /**
  124157. * Disposes the resources of the material.
  124158. * @param forceDisposeEffect - Forces the disposal of effects.
  124159. * @param forceDisposeTextures - Forces the disposal of all textures.
  124160. */
  124161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124162. }
  124163. }
  124164. declare module BABYLON {
  124165. /**
  124166. * The Physically based material of BJS.
  124167. *
  124168. * This offers the main features of a standard PBR material.
  124169. * For more information, please refer to the documentation :
  124170. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124171. */
  124172. export class PBRMaterial extends PBRBaseMaterial {
  124173. /**
  124174. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124175. */
  124176. static readonly PBRMATERIAL_OPAQUE: number;
  124177. /**
  124178. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124179. */
  124180. static readonly PBRMATERIAL_ALPHATEST: number;
  124181. /**
  124182. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124183. */
  124184. static readonly PBRMATERIAL_ALPHABLEND: number;
  124185. /**
  124186. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124187. * They are also discarded below the alpha cutoff threshold to improve performances.
  124188. */
  124189. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124190. /**
  124191. * Defines the default value of how much AO map is occluding the analytical lights
  124192. * (point spot...).
  124193. */
  124194. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124195. /**
  124196. * Intensity of the direct lights e.g. the four lights available in your scene.
  124197. * This impacts both the direct diffuse and specular highlights.
  124198. */
  124199. directIntensity: number;
  124200. /**
  124201. * Intensity of the emissive part of the material.
  124202. * This helps controlling the emissive effect without modifying the emissive color.
  124203. */
  124204. emissiveIntensity: number;
  124205. /**
  124206. * Intensity of the environment e.g. how much the environment will light the object
  124207. * either through harmonics for rough material or through the refelction for shiny ones.
  124208. */
  124209. environmentIntensity: number;
  124210. /**
  124211. * This is a special control allowing the reduction of the specular highlights coming from the
  124212. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124213. */
  124214. specularIntensity: number;
  124215. /**
  124216. * Debug Control allowing disabling the bump map on this material.
  124217. */
  124218. disableBumpMap: boolean;
  124219. /**
  124220. * AKA Diffuse Texture in standard nomenclature.
  124221. */
  124222. albedoTexture: BaseTexture;
  124223. /**
  124224. * AKA Occlusion Texture in other nomenclature.
  124225. */
  124226. ambientTexture: BaseTexture;
  124227. /**
  124228. * AKA Occlusion Texture Intensity in other nomenclature.
  124229. */
  124230. ambientTextureStrength: number;
  124231. /**
  124232. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124233. * 1 means it completely occludes it
  124234. * 0 mean it has no impact
  124235. */
  124236. ambientTextureImpactOnAnalyticalLights: number;
  124237. /**
  124238. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124239. */
  124240. opacityTexture: BaseTexture;
  124241. /**
  124242. * Stores the reflection values in a texture.
  124243. */
  124244. reflectionTexture: Nullable<BaseTexture>;
  124245. /**
  124246. * Stores the emissive values in a texture.
  124247. */
  124248. emissiveTexture: BaseTexture;
  124249. /**
  124250. * AKA Specular texture in other nomenclature.
  124251. */
  124252. reflectivityTexture: BaseTexture;
  124253. /**
  124254. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124255. */
  124256. metallicTexture: BaseTexture;
  124257. /**
  124258. * Specifies the metallic scalar of the metallic/roughness workflow.
  124259. * Can also be used to scale the metalness values of the metallic texture.
  124260. */
  124261. metallic: Nullable<number>;
  124262. /**
  124263. * Specifies the roughness scalar of the metallic/roughness workflow.
  124264. * Can also be used to scale the roughness values of the metallic texture.
  124265. */
  124266. roughness: Nullable<number>;
  124267. /**
  124268. * Specifies the an F0 factor to help configuring the material F0.
  124269. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124270. * to 0.5 the previously hard coded value stays the same.
  124271. * Can also be used to scale the F0 values of the metallic texture.
  124272. */
  124273. metallicF0Factor: number;
  124274. /**
  124275. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124276. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124277. * your expectation as it multiplies with the texture data.
  124278. */
  124279. useMetallicF0FactorFromMetallicTexture: boolean;
  124280. /**
  124281. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124282. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124283. */
  124284. microSurfaceTexture: BaseTexture;
  124285. /**
  124286. * Stores surface normal data used to displace a mesh in a texture.
  124287. */
  124288. bumpTexture: BaseTexture;
  124289. /**
  124290. * Stores the pre-calculated light information of a mesh in a texture.
  124291. */
  124292. lightmapTexture: BaseTexture;
  124293. /**
  124294. * Stores the refracted light information in a texture.
  124295. */
  124296. get refractionTexture(): Nullable<BaseTexture>;
  124297. set refractionTexture(value: Nullable<BaseTexture>);
  124298. /**
  124299. * The color of a material in ambient lighting.
  124300. */
  124301. ambientColor: Color3;
  124302. /**
  124303. * AKA Diffuse Color in other nomenclature.
  124304. */
  124305. albedoColor: Color3;
  124306. /**
  124307. * AKA Specular Color in other nomenclature.
  124308. */
  124309. reflectivityColor: Color3;
  124310. /**
  124311. * The color reflected from the material.
  124312. */
  124313. reflectionColor: Color3;
  124314. /**
  124315. * The color emitted from the material.
  124316. */
  124317. emissiveColor: Color3;
  124318. /**
  124319. * AKA Glossiness in other nomenclature.
  124320. */
  124321. microSurface: number;
  124322. /**
  124323. * source material index of refraction (IOR)' / 'destination material IOR.
  124324. */
  124325. get indexOfRefraction(): number;
  124326. set indexOfRefraction(value: number);
  124327. /**
  124328. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124329. */
  124330. get invertRefractionY(): boolean;
  124331. set invertRefractionY(value: boolean);
  124332. /**
  124333. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124334. * Materials half opaque for instance using refraction could benefit from this control.
  124335. */
  124336. get linkRefractionWithTransparency(): boolean;
  124337. set linkRefractionWithTransparency(value: boolean);
  124338. /**
  124339. * If true, the light map contains occlusion information instead of lighting info.
  124340. */
  124341. useLightmapAsShadowmap: boolean;
  124342. /**
  124343. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124344. */
  124345. useAlphaFromAlbedoTexture: boolean;
  124346. /**
  124347. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124348. */
  124349. forceAlphaTest: boolean;
  124350. /**
  124351. * Defines the alpha limits in alpha test mode.
  124352. */
  124353. alphaCutOff: number;
  124354. /**
  124355. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124356. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124357. */
  124358. useSpecularOverAlpha: boolean;
  124359. /**
  124360. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124361. */
  124362. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124363. /**
  124364. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124365. */
  124366. useRoughnessFromMetallicTextureAlpha: boolean;
  124367. /**
  124368. * Specifies if the metallic texture contains the roughness information in its green channel.
  124369. */
  124370. useRoughnessFromMetallicTextureGreen: boolean;
  124371. /**
  124372. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124373. */
  124374. useMetallnessFromMetallicTextureBlue: boolean;
  124375. /**
  124376. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124377. */
  124378. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124379. /**
  124380. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124381. */
  124382. useAmbientInGrayScale: boolean;
  124383. /**
  124384. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124385. * The material will try to infer what glossiness each pixel should be.
  124386. */
  124387. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124388. /**
  124389. * BJS is using an harcoded light falloff based on a manually sets up range.
  124390. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124391. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124392. */
  124393. get usePhysicalLightFalloff(): boolean;
  124394. /**
  124395. * BJS is using an harcoded light falloff based on a manually sets up range.
  124396. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124397. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124398. */
  124399. set usePhysicalLightFalloff(value: boolean);
  124400. /**
  124401. * In order to support the falloff compatibility with gltf, a special mode has been added
  124402. * to reproduce the gltf light falloff.
  124403. */
  124404. get useGLTFLightFalloff(): boolean;
  124405. /**
  124406. * In order to support the falloff compatibility with gltf, a special mode has been added
  124407. * to reproduce the gltf light falloff.
  124408. */
  124409. set useGLTFLightFalloff(value: boolean);
  124410. /**
  124411. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124412. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124413. */
  124414. useRadianceOverAlpha: boolean;
  124415. /**
  124416. * Allows using an object space normal map (instead of tangent space).
  124417. */
  124418. useObjectSpaceNormalMap: boolean;
  124419. /**
  124420. * Allows using the bump map in parallax mode.
  124421. */
  124422. useParallax: boolean;
  124423. /**
  124424. * Allows using the bump map in parallax occlusion mode.
  124425. */
  124426. useParallaxOcclusion: boolean;
  124427. /**
  124428. * Controls the scale bias of the parallax mode.
  124429. */
  124430. parallaxScaleBias: number;
  124431. /**
  124432. * If sets to true, disables all the lights affecting the material.
  124433. */
  124434. disableLighting: boolean;
  124435. /**
  124436. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124437. */
  124438. forceIrradianceInFragment: boolean;
  124439. /**
  124440. * Number of Simultaneous lights allowed on the material.
  124441. */
  124442. maxSimultaneousLights: number;
  124443. /**
  124444. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124445. */
  124446. invertNormalMapX: boolean;
  124447. /**
  124448. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124449. */
  124450. invertNormalMapY: boolean;
  124451. /**
  124452. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124453. */
  124454. twoSidedLighting: boolean;
  124455. /**
  124456. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124457. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124458. */
  124459. useAlphaFresnel: boolean;
  124460. /**
  124461. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124462. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124463. */
  124464. useLinearAlphaFresnel: boolean;
  124465. /**
  124466. * Let user defines the brdf lookup texture used for IBL.
  124467. * A default 8bit version is embedded but you could point at :
  124468. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124469. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124470. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124471. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124472. */
  124473. environmentBRDFTexture: Nullable<BaseTexture>;
  124474. /**
  124475. * Force normal to face away from face.
  124476. */
  124477. forceNormalForward: boolean;
  124478. /**
  124479. * Enables specular anti aliasing in the PBR shader.
  124480. * It will both interacts on the Geometry for analytical and IBL lighting.
  124481. * It also prefilter the roughness map based on the bump values.
  124482. */
  124483. enableSpecularAntiAliasing: boolean;
  124484. /**
  124485. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124486. * makes the reflect vector face the model (under horizon).
  124487. */
  124488. useHorizonOcclusion: boolean;
  124489. /**
  124490. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124491. * too much the area relying on ambient texture to define their ambient occlusion.
  124492. */
  124493. useRadianceOcclusion: boolean;
  124494. /**
  124495. * If set to true, no lighting calculations will be applied.
  124496. */
  124497. unlit: boolean;
  124498. /**
  124499. * Gets the image processing configuration used either in this material.
  124500. */
  124501. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124502. /**
  124503. * Sets the Default image processing configuration used either in the this material.
  124504. *
  124505. * If sets to null, the scene one is in use.
  124506. */
  124507. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124508. /**
  124509. * Gets wether the color curves effect is enabled.
  124510. */
  124511. get cameraColorCurvesEnabled(): boolean;
  124512. /**
  124513. * Sets wether the color curves effect is enabled.
  124514. */
  124515. set cameraColorCurvesEnabled(value: boolean);
  124516. /**
  124517. * Gets wether the color grading effect is enabled.
  124518. */
  124519. get cameraColorGradingEnabled(): boolean;
  124520. /**
  124521. * Gets wether the color grading effect is enabled.
  124522. */
  124523. set cameraColorGradingEnabled(value: boolean);
  124524. /**
  124525. * Gets wether tonemapping is enabled or not.
  124526. */
  124527. get cameraToneMappingEnabled(): boolean;
  124528. /**
  124529. * Sets wether tonemapping is enabled or not
  124530. */
  124531. set cameraToneMappingEnabled(value: boolean);
  124532. /**
  124533. * The camera exposure used on this material.
  124534. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124535. * This corresponds to a photographic exposure.
  124536. */
  124537. get cameraExposure(): number;
  124538. /**
  124539. * The camera exposure used on this material.
  124540. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124541. * This corresponds to a photographic exposure.
  124542. */
  124543. set cameraExposure(value: number);
  124544. /**
  124545. * Gets The camera contrast used on this material.
  124546. */
  124547. get cameraContrast(): number;
  124548. /**
  124549. * Sets The camera contrast used on this material.
  124550. */
  124551. set cameraContrast(value: number);
  124552. /**
  124553. * Gets the Color Grading 2D Lookup Texture.
  124554. */
  124555. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124556. /**
  124557. * Sets the Color Grading 2D Lookup Texture.
  124558. */
  124559. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124560. /**
  124561. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124562. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124563. * 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;
  124564. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124565. */
  124566. get cameraColorCurves(): Nullable<ColorCurves>;
  124567. /**
  124568. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124569. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124570. * 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;
  124571. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124572. */
  124573. set cameraColorCurves(value: Nullable<ColorCurves>);
  124574. /**
  124575. * Instantiates a new PBRMaterial instance.
  124576. *
  124577. * @param name The material name
  124578. * @param scene The scene the material will be use in.
  124579. */
  124580. constructor(name: string, scene: Scene);
  124581. /**
  124582. * Returns the name of this material class.
  124583. */
  124584. getClassName(): string;
  124585. /**
  124586. * Makes a duplicate of the current material.
  124587. * @param name - name to use for the new material.
  124588. */
  124589. clone(name: string): PBRMaterial;
  124590. /**
  124591. * Serializes this PBR Material.
  124592. * @returns - An object with the serialized material.
  124593. */
  124594. serialize(): any;
  124595. /**
  124596. * Parses a PBR Material from a serialized object.
  124597. * @param source - Serialized object.
  124598. * @param scene - BJS scene instance.
  124599. * @param rootUrl - url for the scene object
  124600. * @returns - PBRMaterial
  124601. */
  124602. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  124603. }
  124604. }
  124605. declare module BABYLON {
  124606. /**
  124607. * Direct draw surface info
  124608. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  124609. */
  124610. export interface DDSInfo {
  124611. /**
  124612. * Width of the texture
  124613. */
  124614. width: number;
  124615. /**
  124616. * Width of the texture
  124617. */
  124618. height: number;
  124619. /**
  124620. * Number of Mipmaps for the texture
  124621. * @see https://en.wikipedia.org/wiki/Mipmap
  124622. */
  124623. mipmapCount: number;
  124624. /**
  124625. * If the textures format is a known fourCC format
  124626. * @see https://www.fourcc.org/
  124627. */
  124628. isFourCC: boolean;
  124629. /**
  124630. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  124631. */
  124632. isRGB: boolean;
  124633. /**
  124634. * If the texture is a lumincance format
  124635. */
  124636. isLuminance: boolean;
  124637. /**
  124638. * If this is a cube texture
  124639. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  124640. */
  124641. isCube: boolean;
  124642. /**
  124643. * If the texture is a compressed format eg. FOURCC_DXT1
  124644. */
  124645. isCompressed: boolean;
  124646. /**
  124647. * The dxgiFormat of the texture
  124648. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  124649. */
  124650. dxgiFormat: number;
  124651. /**
  124652. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  124653. */
  124654. textureType: number;
  124655. /**
  124656. * Sphericle polynomial created for the dds texture
  124657. */
  124658. sphericalPolynomial?: SphericalPolynomial;
  124659. }
  124660. /**
  124661. * Class used to provide DDS decompression tools
  124662. */
  124663. export class DDSTools {
  124664. /**
  124665. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  124666. */
  124667. static StoreLODInAlphaChannel: boolean;
  124668. /**
  124669. * Gets DDS information from an array buffer
  124670. * @param data defines the array buffer view to read data from
  124671. * @returns the DDS information
  124672. */
  124673. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  124674. private static _FloatView;
  124675. private static _Int32View;
  124676. private static _ToHalfFloat;
  124677. private static _FromHalfFloat;
  124678. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  124679. private static _GetHalfFloatRGBAArrayBuffer;
  124680. private static _GetFloatRGBAArrayBuffer;
  124681. private static _GetFloatAsUIntRGBAArrayBuffer;
  124682. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  124683. private static _GetRGBAArrayBuffer;
  124684. private static _ExtractLongWordOrder;
  124685. private static _GetRGBArrayBuffer;
  124686. private static _GetLuminanceArrayBuffer;
  124687. /**
  124688. * Uploads DDS Levels to a Babylon Texture
  124689. * @hidden
  124690. */
  124691. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  124692. }
  124693. interface ThinEngine {
  124694. /**
  124695. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  124696. * @param rootUrl defines the url where the file to load is located
  124697. * @param scene defines the current scene
  124698. * @param lodScale defines scale to apply to the mip map selection
  124699. * @param lodOffset defines offset to apply to the mip map selection
  124700. * @param onLoad defines an optional callback raised when the texture is loaded
  124701. * @param onError defines an optional callback raised if there is an issue to load the texture
  124702. * @param format defines the format of the data
  124703. * @param forcedExtension defines the extension to use to pick the right loader
  124704. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  124705. * @returns the cube texture as an InternalTexture
  124706. */
  124707. 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;
  124708. }
  124709. }
  124710. declare module BABYLON {
  124711. /**
  124712. * Implementation of the DDS Texture Loader.
  124713. * @hidden
  124714. */
  124715. export class _DDSTextureLoader implements IInternalTextureLoader {
  124716. /**
  124717. * Defines wether the loader supports cascade loading the different faces.
  124718. */
  124719. readonly supportCascades: boolean;
  124720. /**
  124721. * This returns if the loader support the current file information.
  124722. * @param extension defines the file extension of the file being loaded
  124723. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124724. * @param fallback defines the fallback internal texture if any
  124725. * @param isBase64 defines whether the texture is encoded as a base64
  124726. * @param isBuffer defines whether the texture data are stored as a buffer
  124727. * @returns true if the loader can load the specified file
  124728. */
  124729. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124730. /**
  124731. * Transform the url before loading if required.
  124732. * @param rootUrl the url of the texture
  124733. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124734. * @returns the transformed texture
  124735. */
  124736. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124737. /**
  124738. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124739. * @param rootUrl the url of the texture
  124740. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124741. * @returns the fallback texture
  124742. */
  124743. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124744. /**
  124745. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124746. * @param data contains the texture data
  124747. * @param texture defines the BabylonJS internal texture
  124748. * @param createPolynomials will be true if polynomials have been requested
  124749. * @param onLoad defines the callback to trigger once the texture is ready
  124750. * @param onError defines the callback to trigger in case of error
  124751. */
  124752. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124753. /**
  124754. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124755. * @param data contains the texture data
  124756. * @param texture defines the BabylonJS internal texture
  124757. * @param callback defines the method to call once ready to upload
  124758. */
  124759. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124760. }
  124761. }
  124762. declare module BABYLON {
  124763. /**
  124764. * Implementation of the ENV Texture Loader.
  124765. * @hidden
  124766. */
  124767. export class _ENVTextureLoader implements IInternalTextureLoader {
  124768. /**
  124769. * Defines wether the loader supports cascade loading the different faces.
  124770. */
  124771. readonly supportCascades: boolean;
  124772. /**
  124773. * This returns if the loader support the current file information.
  124774. * @param extension defines the file extension of the file being loaded
  124775. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124776. * @param fallback defines the fallback internal texture if any
  124777. * @param isBase64 defines whether the texture is encoded as a base64
  124778. * @param isBuffer defines whether the texture data are stored as a buffer
  124779. * @returns true if the loader can load the specified file
  124780. */
  124781. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124782. /**
  124783. * Transform the url before loading if required.
  124784. * @param rootUrl the url of the texture
  124785. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124786. * @returns the transformed texture
  124787. */
  124788. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124789. /**
  124790. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124791. * @param rootUrl the url of the texture
  124792. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124793. * @returns the fallback texture
  124794. */
  124795. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124796. /**
  124797. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124798. * @param data contains the texture data
  124799. * @param texture defines the BabylonJS internal texture
  124800. * @param createPolynomials will be true if polynomials have been requested
  124801. * @param onLoad defines the callback to trigger once the texture is ready
  124802. * @param onError defines the callback to trigger in case of error
  124803. */
  124804. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124805. /**
  124806. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124807. * @param data contains the texture data
  124808. * @param texture defines the BabylonJS internal texture
  124809. * @param callback defines the method to call once ready to upload
  124810. */
  124811. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124812. }
  124813. }
  124814. declare module BABYLON {
  124815. /**
  124816. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  124817. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  124818. */
  124819. export class KhronosTextureContainer {
  124820. /** contents of the KTX container file */
  124821. data: ArrayBufferView;
  124822. private static HEADER_LEN;
  124823. private static COMPRESSED_2D;
  124824. private static COMPRESSED_3D;
  124825. private static TEX_2D;
  124826. private static TEX_3D;
  124827. /**
  124828. * Gets the openGL type
  124829. */
  124830. glType: number;
  124831. /**
  124832. * Gets the openGL type size
  124833. */
  124834. glTypeSize: number;
  124835. /**
  124836. * Gets the openGL format
  124837. */
  124838. glFormat: number;
  124839. /**
  124840. * Gets the openGL internal format
  124841. */
  124842. glInternalFormat: number;
  124843. /**
  124844. * Gets the base internal format
  124845. */
  124846. glBaseInternalFormat: number;
  124847. /**
  124848. * Gets image width in pixel
  124849. */
  124850. pixelWidth: number;
  124851. /**
  124852. * Gets image height in pixel
  124853. */
  124854. pixelHeight: number;
  124855. /**
  124856. * Gets image depth in pixels
  124857. */
  124858. pixelDepth: number;
  124859. /**
  124860. * Gets the number of array elements
  124861. */
  124862. numberOfArrayElements: number;
  124863. /**
  124864. * Gets the number of faces
  124865. */
  124866. numberOfFaces: number;
  124867. /**
  124868. * Gets the number of mipmap levels
  124869. */
  124870. numberOfMipmapLevels: number;
  124871. /**
  124872. * Gets the bytes of key value data
  124873. */
  124874. bytesOfKeyValueData: number;
  124875. /**
  124876. * Gets the load type
  124877. */
  124878. loadType: number;
  124879. /**
  124880. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  124881. */
  124882. isInvalid: boolean;
  124883. /**
  124884. * Creates a new KhronosTextureContainer
  124885. * @param data contents of the KTX container file
  124886. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  124887. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  124888. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  124889. */
  124890. constructor(
  124891. /** contents of the KTX container file */
  124892. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  124893. /**
  124894. * Uploads KTX content to a Babylon Texture.
  124895. * It is assumed that the texture has already been created & is currently bound
  124896. * @hidden
  124897. */
  124898. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  124899. private _upload2DCompressedLevels;
  124900. }
  124901. }
  124902. declare module BABYLON {
  124903. /**
  124904. * Implementation of the KTX Texture Loader.
  124905. * @hidden
  124906. */
  124907. export class _KTXTextureLoader implements IInternalTextureLoader {
  124908. /**
  124909. * Defines wether the loader supports cascade loading the different faces.
  124910. */
  124911. readonly supportCascades: boolean;
  124912. /**
  124913. * This returns if the loader support the current file information.
  124914. * @param extension defines the file extension of the file being loaded
  124915. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124916. * @param fallback defines the fallback internal texture if any
  124917. * @param isBase64 defines whether the texture is encoded as a base64
  124918. * @param isBuffer defines whether the texture data are stored as a buffer
  124919. * @returns true if the loader can load the specified file
  124920. */
  124921. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124922. /**
  124923. * Transform the url before loading if required.
  124924. * @param rootUrl the url of the texture
  124925. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124926. * @returns the transformed texture
  124927. */
  124928. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124929. /**
  124930. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124931. * @param rootUrl the url of the texture
  124932. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124933. * @returns the fallback texture
  124934. */
  124935. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124936. /**
  124937. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124938. * @param data contains the texture data
  124939. * @param texture defines the BabylonJS internal texture
  124940. * @param createPolynomials will be true if polynomials have been requested
  124941. * @param onLoad defines the callback to trigger once the texture is ready
  124942. * @param onError defines the callback to trigger in case of error
  124943. */
  124944. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124945. /**
  124946. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124947. * @param data contains the texture data
  124948. * @param texture defines the BabylonJS internal texture
  124949. * @param callback defines the method to call once ready to upload
  124950. */
  124951. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  124952. }
  124953. }
  124954. declare module BABYLON {
  124955. /** @hidden */
  124956. export var _forceSceneHelpersToBundle: boolean;
  124957. interface Scene {
  124958. /**
  124959. * Creates a default light for the scene.
  124960. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  124961. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  124962. */
  124963. createDefaultLight(replace?: boolean): void;
  124964. /**
  124965. * Creates a default camera for the scene.
  124966. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  124967. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124968. * @param replace has default false, when true replaces the active camera in the scene
  124969. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  124970. */
  124971. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124972. /**
  124973. * Creates a default camera and a default light.
  124974. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  124975. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124976. * @param replace has the default false, when true replaces the active camera/light in the scene
  124977. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  124978. */
  124979. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124980. /**
  124981. * Creates a new sky box
  124982. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  124983. * @param environmentTexture defines the texture to use as environment texture
  124984. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  124985. * @param scale defines the overall scale of the skybox
  124986. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  124987. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  124988. * @returns a new mesh holding the sky box
  124989. */
  124990. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  124991. /**
  124992. * Creates a new environment
  124993. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  124994. * @param options defines the options you can use to configure the environment
  124995. * @returns the new EnvironmentHelper
  124996. */
  124997. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  124998. /**
  124999. * Creates a new VREXperienceHelper
  125000. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125001. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125002. * @returns a new VREXperienceHelper
  125003. */
  125004. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125005. /**
  125006. * Creates a new WebXRDefaultExperience
  125007. * @see http://doc.babylonjs.com/how_to/webxr
  125008. * @param options experience options
  125009. * @returns a promise for a new WebXRDefaultExperience
  125010. */
  125011. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125012. }
  125013. }
  125014. declare module BABYLON {
  125015. /**
  125016. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125017. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125018. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125019. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125020. */
  125021. export class VideoDome extends TransformNode {
  125022. /**
  125023. * Define the video source as a Monoscopic panoramic 360 video.
  125024. */
  125025. static readonly MODE_MONOSCOPIC: number;
  125026. /**
  125027. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125028. */
  125029. static readonly MODE_TOPBOTTOM: number;
  125030. /**
  125031. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125032. */
  125033. static readonly MODE_SIDEBYSIDE: number;
  125034. private _halfDome;
  125035. private _useDirectMapping;
  125036. /**
  125037. * The video texture being displayed on the sphere
  125038. */
  125039. protected _videoTexture: VideoTexture;
  125040. /**
  125041. * Gets the video texture being displayed on the sphere
  125042. */
  125043. get videoTexture(): VideoTexture;
  125044. /**
  125045. * The skybox material
  125046. */
  125047. protected _material: BackgroundMaterial;
  125048. /**
  125049. * The surface used for the skybox
  125050. */
  125051. protected _mesh: Mesh;
  125052. /**
  125053. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125054. */
  125055. private _halfDomeMask;
  125056. /**
  125057. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125058. * Also see the options.resolution property.
  125059. */
  125060. get fovMultiplier(): number;
  125061. set fovMultiplier(value: number);
  125062. private _videoMode;
  125063. /**
  125064. * Gets or set the current video mode for the video. It can be:
  125065. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125066. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125067. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125068. */
  125069. get videoMode(): number;
  125070. set videoMode(value: number);
  125071. /**
  125072. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125073. *
  125074. */
  125075. get halfDome(): boolean;
  125076. /**
  125077. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125078. */
  125079. set halfDome(enabled: boolean);
  125080. /**
  125081. * Oberserver used in Stereoscopic VR Mode.
  125082. */
  125083. private _onBeforeCameraRenderObserver;
  125084. /**
  125085. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125086. * @param name Element's name, child elements will append suffixes for their own names.
  125087. * @param urlsOrVideo defines the url(s) or the video element to use
  125088. * @param options An object containing optional or exposed sub element properties
  125089. */
  125090. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125091. resolution?: number;
  125092. clickToPlay?: boolean;
  125093. autoPlay?: boolean;
  125094. loop?: boolean;
  125095. size?: number;
  125096. poster?: string;
  125097. faceForward?: boolean;
  125098. useDirectMapping?: boolean;
  125099. halfDomeMode?: boolean;
  125100. }, scene: Scene);
  125101. private _changeVideoMode;
  125102. /**
  125103. * Releases resources associated with this node.
  125104. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125105. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125106. */
  125107. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125108. }
  125109. }
  125110. declare module BABYLON {
  125111. /**
  125112. * This class can be used to get instrumentation data from a Babylon engine
  125113. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125114. */
  125115. export class EngineInstrumentation implements IDisposable {
  125116. /**
  125117. * Define the instrumented engine.
  125118. */
  125119. engine: Engine;
  125120. private _captureGPUFrameTime;
  125121. private _gpuFrameTimeToken;
  125122. private _gpuFrameTime;
  125123. private _captureShaderCompilationTime;
  125124. private _shaderCompilationTime;
  125125. private _onBeginFrameObserver;
  125126. private _onEndFrameObserver;
  125127. private _onBeforeShaderCompilationObserver;
  125128. private _onAfterShaderCompilationObserver;
  125129. /**
  125130. * Gets the perf counter used for GPU frame time
  125131. */
  125132. get gpuFrameTimeCounter(): PerfCounter;
  125133. /**
  125134. * Gets the GPU frame time capture status
  125135. */
  125136. get captureGPUFrameTime(): boolean;
  125137. /**
  125138. * Enable or disable the GPU frame time capture
  125139. */
  125140. set captureGPUFrameTime(value: boolean);
  125141. /**
  125142. * Gets the perf counter used for shader compilation time
  125143. */
  125144. get shaderCompilationTimeCounter(): PerfCounter;
  125145. /**
  125146. * Gets the shader compilation time capture status
  125147. */
  125148. get captureShaderCompilationTime(): boolean;
  125149. /**
  125150. * Enable or disable the shader compilation time capture
  125151. */
  125152. set captureShaderCompilationTime(value: boolean);
  125153. /**
  125154. * Instantiates a new engine instrumentation.
  125155. * This class can be used to get instrumentation data from a Babylon engine
  125156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125157. * @param engine Defines the engine to instrument
  125158. */
  125159. constructor(
  125160. /**
  125161. * Define the instrumented engine.
  125162. */
  125163. engine: Engine);
  125164. /**
  125165. * Dispose and release associated resources.
  125166. */
  125167. dispose(): void;
  125168. }
  125169. }
  125170. declare module BABYLON {
  125171. /**
  125172. * This class can be used to get instrumentation data from a Babylon engine
  125173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125174. */
  125175. export class SceneInstrumentation implements IDisposable {
  125176. /**
  125177. * Defines the scene to instrument
  125178. */
  125179. scene: Scene;
  125180. private _captureActiveMeshesEvaluationTime;
  125181. private _activeMeshesEvaluationTime;
  125182. private _captureRenderTargetsRenderTime;
  125183. private _renderTargetsRenderTime;
  125184. private _captureFrameTime;
  125185. private _frameTime;
  125186. private _captureRenderTime;
  125187. private _renderTime;
  125188. private _captureInterFrameTime;
  125189. private _interFrameTime;
  125190. private _captureParticlesRenderTime;
  125191. private _particlesRenderTime;
  125192. private _captureSpritesRenderTime;
  125193. private _spritesRenderTime;
  125194. private _capturePhysicsTime;
  125195. private _physicsTime;
  125196. private _captureAnimationsTime;
  125197. private _animationsTime;
  125198. private _captureCameraRenderTime;
  125199. private _cameraRenderTime;
  125200. private _onBeforeActiveMeshesEvaluationObserver;
  125201. private _onAfterActiveMeshesEvaluationObserver;
  125202. private _onBeforeRenderTargetsRenderObserver;
  125203. private _onAfterRenderTargetsRenderObserver;
  125204. private _onAfterRenderObserver;
  125205. private _onBeforeDrawPhaseObserver;
  125206. private _onAfterDrawPhaseObserver;
  125207. private _onBeforeAnimationsObserver;
  125208. private _onBeforeParticlesRenderingObserver;
  125209. private _onAfterParticlesRenderingObserver;
  125210. private _onBeforeSpritesRenderingObserver;
  125211. private _onAfterSpritesRenderingObserver;
  125212. private _onBeforePhysicsObserver;
  125213. private _onAfterPhysicsObserver;
  125214. private _onAfterAnimationsObserver;
  125215. private _onBeforeCameraRenderObserver;
  125216. private _onAfterCameraRenderObserver;
  125217. /**
  125218. * Gets the perf counter used for active meshes evaluation time
  125219. */
  125220. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125221. /**
  125222. * Gets the active meshes evaluation time capture status
  125223. */
  125224. get captureActiveMeshesEvaluationTime(): boolean;
  125225. /**
  125226. * Enable or disable the active meshes evaluation time capture
  125227. */
  125228. set captureActiveMeshesEvaluationTime(value: boolean);
  125229. /**
  125230. * Gets the perf counter used for render targets render time
  125231. */
  125232. get renderTargetsRenderTimeCounter(): PerfCounter;
  125233. /**
  125234. * Gets the render targets render time capture status
  125235. */
  125236. get captureRenderTargetsRenderTime(): boolean;
  125237. /**
  125238. * Enable or disable the render targets render time capture
  125239. */
  125240. set captureRenderTargetsRenderTime(value: boolean);
  125241. /**
  125242. * Gets the perf counter used for particles render time
  125243. */
  125244. get particlesRenderTimeCounter(): PerfCounter;
  125245. /**
  125246. * Gets the particles render time capture status
  125247. */
  125248. get captureParticlesRenderTime(): boolean;
  125249. /**
  125250. * Enable or disable the particles render time capture
  125251. */
  125252. set captureParticlesRenderTime(value: boolean);
  125253. /**
  125254. * Gets the perf counter used for sprites render time
  125255. */
  125256. get spritesRenderTimeCounter(): PerfCounter;
  125257. /**
  125258. * Gets the sprites render time capture status
  125259. */
  125260. get captureSpritesRenderTime(): boolean;
  125261. /**
  125262. * Enable or disable the sprites render time capture
  125263. */
  125264. set captureSpritesRenderTime(value: boolean);
  125265. /**
  125266. * Gets the perf counter used for physics time
  125267. */
  125268. get physicsTimeCounter(): PerfCounter;
  125269. /**
  125270. * Gets the physics time capture status
  125271. */
  125272. get capturePhysicsTime(): boolean;
  125273. /**
  125274. * Enable or disable the physics time capture
  125275. */
  125276. set capturePhysicsTime(value: boolean);
  125277. /**
  125278. * Gets the perf counter used for animations time
  125279. */
  125280. get animationsTimeCounter(): PerfCounter;
  125281. /**
  125282. * Gets the animations time capture status
  125283. */
  125284. get captureAnimationsTime(): boolean;
  125285. /**
  125286. * Enable or disable the animations time capture
  125287. */
  125288. set captureAnimationsTime(value: boolean);
  125289. /**
  125290. * Gets the perf counter used for frame time capture
  125291. */
  125292. get frameTimeCounter(): PerfCounter;
  125293. /**
  125294. * Gets the frame time capture status
  125295. */
  125296. get captureFrameTime(): boolean;
  125297. /**
  125298. * Enable or disable the frame time capture
  125299. */
  125300. set captureFrameTime(value: boolean);
  125301. /**
  125302. * Gets the perf counter used for inter-frames time capture
  125303. */
  125304. get interFrameTimeCounter(): PerfCounter;
  125305. /**
  125306. * Gets the inter-frames time capture status
  125307. */
  125308. get captureInterFrameTime(): boolean;
  125309. /**
  125310. * Enable or disable the inter-frames time capture
  125311. */
  125312. set captureInterFrameTime(value: boolean);
  125313. /**
  125314. * Gets the perf counter used for render time capture
  125315. */
  125316. get renderTimeCounter(): PerfCounter;
  125317. /**
  125318. * Gets the render time capture status
  125319. */
  125320. get captureRenderTime(): boolean;
  125321. /**
  125322. * Enable or disable the render time capture
  125323. */
  125324. set captureRenderTime(value: boolean);
  125325. /**
  125326. * Gets the perf counter used for camera render time capture
  125327. */
  125328. get cameraRenderTimeCounter(): PerfCounter;
  125329. /**
  125330. * Gets the camera render time capture status
  125331. */
  125332. get captureCameraRenderTime(): boolean;
  125333. /**
  125334. * Enable or disable the camera render time capture
  125335. */
  125336. set captureCameraRenderTime(value: boolean);
  125337. /**
  125338. * Gets the perf counter used for draw calls
  125339. */
  125340. get drawCallsCounter(): PerfCounter;
  125341. /**
  125342. * Instantiates a new scene instrumentation.
  125343. * This class can be used to get instrumentation data from a Babylon engine
  125344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125345. * @param scene Defines the scene to instrument
  125346. */
  125347. constructor(
  125348. /**
  125349. * Defines the scene to instrument
  125350. */
  125351. scene: Scene);
  125352. /**
  125353. * Dispose and release associated resources.
  125354. */
  125355. dispose(): void;
  125356. }
  125357. }
  125358. declare module BABYLON {
  125359. /** @hidden */
  125360. export var glowMapGenerationPixelShader: {
  125361. name: string;
  125362. shader: string;
  125363. };
  125364. }
  125365. declare module BABYLON {
  125366. /** @hidden */
  125367. export var glowMapGenerationVertexShader: {
  125368. name: string;
  125369. shader: string;
  125370. };
  125371. }
  125372. declare module BABYLON {
  125373. /**
  125374. * Effect layer options. This helps customizing the behaviour
  125375. * of the effect layer.
  125376. */
  125377. export interface IEffectLayerOptions {
  125378. /**
  125379. * Multiplication factor apply to the canvas size to compute the render target size
  125380. * used to generated the objects (the smaller the faster).
  125381. */
  125382. mainTextureRatio: number;
  125383. /**
  125384. * Enforces a fixed size texture to ensure effect stability across devices.
  125385. */
  125386. mainTextureFixedSize?: number;
  125387. /**
  125388. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125389. */
  125390. alphaBlendingMode: number;
  125391. /**
  125392. * The camera attached to the layer.
  125393. */
  125394. camera: Nullable<Camera>;
  125395. /**
  125396. * The rendering group to draw the layer in.
  125397. */
  125398. renderingGroupId: number;
  125399. }
  125400. /**
  125401. * The effect layer Helps adding post process effect blended with the main pass.
  125402. *
  125403. * This can be for instance use to generate glow or higlight effects on the scene.
  125404. *
  125405. * The effect layer class can not be used directly and is intented to inherited from to be
  125406. * customized per effects.
  125407. */
  125408. export abstract class EffectLayer {
  125409. private _vertexBuffers;
  125410. private _indexBuffer;
  125411. private _cachedDefines;
  125412. private _effectLayerMapGenerationEffect;
  125413. private _effectLayerOptions;
  125414. private _mergeEffect;
  125415. protected _scene: Scene;
  125416. protected _engine: Engine;
  125417. protected _maxSize: number;
  125418. protected _mainTextureDesiredSize: ISize;
  125419. protected _mainTexture: RenderTargetTexture;
  125420. protected _shouldRender: boolean;
  125421. protected _postProcesses: PostProcess[];
  125422. protected _textures: BaseTexture[];
  125423. protected _emissiveTextureAndColor: {
  125424. texture: Nullable<BaseTexture>;
  125425. color: Color4;
  125426. };
  125427. /**
  125428. * The name of the layer
  125429. */
  125430. name: string;
  125431. /**
  125432. * The clear color of the texture used to generate the glow map.
  125433. */
  125434. neutralColor: Color4;
  125435. /**
  125436. * Specifies whether the highlight layer is enabled or not.
  125437. */
  125438. isEnabled: boolean;
  125439. /**
  125440. * Gets the camera attached to the layer.
  125441. */
  125442. get camera(): Nullable<Camera>;
  125443. /**
  125444. * Gets the rendering group id the layer should render in.
  125445. */
  125446. get renderingGroupId(): number;
  125447. set renderingGroupId(renderingGroupId: number);
  125448. /**
  125449. * An event triggered when the effect layer has been disposed.
  125450. */
  125451. onDisposeObservable: Observable<EffectLayer>;
  125452. /**
  125453. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125454. */
  125455. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125456. /**
  125457. * An event triggered when the generated texture is being merged in the scene.
  125458. */
  125459. onBeforeComposeObservable: Observable<EffectLayer>;
  125460. /**
  125461. * An event triggered when the mesh is rendered into the effect render target.
  125462. */
  125463. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125464. /**
  125465. * An event triggered after the mesh has been rendered into the effect render target.
  125466. */
  125467. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125468. /**
  125469. * An event triggered when the generated texture has been merged in the scene.
  125470. */
  125471. onAfterComposeObservable: Observable<EffectLayer>;
  125472. /**
  125473. * An event triggered when the efffect layer changes its size.
  125474. */
  125475. onSizeChangedObservable: Observable<EffectLayer>;
  125476. /** @hidden */
  125477. static _SceneComponentInitialization: (scene: Scene) => void;
  125478. /**
  125479. * Instantiates a new effect Layer and references it in the scene.
  125480. * @param name The name of the layer
  125481. * @param scene The scene to use the layer in
  125482. */
  125483. constructor(
  125484. /** The Friendly of the effect in the scene */
  125485. name: string, scene: Scene);
  125486. /**
  125487. * Get the effect name of the layer.
  125488. * @return The effect name
  125489. */
  125490. abstract getEffectName(): string;
  125491. /**
  125492. * Checks for the readiness of the element composing the layer.
  125493. * @param subMesh the mesh to check for
  125494. * @param useInstances specify whether or not to use instances to render the mesh
  125495. * @return true if ready otherwise, false
  125496. */
  125497. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125498. /**
  125499. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125500. * @returns true if the effect requires stencil during the main canvas render pass.
  125501. */
  125502. abstract needStencil(): boolean;
  125503. /**
  125504. * Create the merge effect. This is the shader use to blit the information back
  125505. * to the main canvas at the end of the scene rendering.
  125506. * @returns The effect containing the shader used to merge the effect on the main canvas
  125507. */
  125508. protected abstract _createMergeEffect(): Effect;
  125509. /**
  125510. * Creates the render target textures and post processes used in the effect layer.
  125511. */
  125512. protected abstract _createTextureAndPostProcesses(): void;
  125513. /**
  125514. * Implementation specific of rendering the generating effect on the main canvas.
  125515. * @param effect The effect used to render through
  125516. */
  125517. protected abstract _internalRender(effect: Effect): void;
  125518. /**
  125519. * Sets the required values for both the emissive texture and and the main color.
  125520. */
  125521. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125522. /**
  125523. * Free any resources and references associated to a mesh.
  125524. * Internal use
  125525. * @param mesh The mesh to free.
  125526. */
  125527. abstract _disposeMesh(mesh: Mesh): void;
  125528. /**
  125529. * Serializes this layer (Glow or Highlight for example)
  125530. * @returns a serialized layer object
  125531. */
  125532. abstract serialize?(): any;
  125533. /**
  125534. * Initializes the effect layer with the required options.
  125535. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  125536. */
  125537. protected _init(options: Partial<IEffectLayerOptions>): void;
  125538. /**
  125539. * Generates the index buffer of the full screen quad blending to the main canvas.
  125540. */
  125541. private _generateIndexBuffer;
  125542. /**
  125543. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  125544. */
  125545. private _generateVertexBuffer;
  125546. /**
  125547. * Sets the main texture desired size which is the closest power of two
  125548. * of the engine canvas size.
  125549. */
  125550. private _setMainTextureSize;
  125551. /**
  125552. * Creates the main texture for the effect layer.
  125553. */
  125554. protected _createMainTexture(): void;
  125555. /**
  125556. * Adds specific effects defines.
  125557. * @param defines The defines to add specifics to.
  125558. */
  125559. protected _addCustomEffectDefines(defines: string[]): void;
  125560. /**
  125561. * Checks for the readiness of the element composing the layer.
  125562. * @param subMesh the mesh to check for
  125563. * @param useInstances specify whether or not to use instances to render the mesh
  125564. * @param emissiveTexture the associated emissive texture used to generate the glow
  125565. * @return true if ready otherwise, false
  125566. */
  125567. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  125568. /**
  125569. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  125570. */
  125571. render(): void;
  125572. /**
  125573. * Determine if a given mesh will be used in the current effect.
  125574. * @param mesh mesh to test
  125575. * @returns true if the mesh will be used
  125576. */
  125577. hasMesh(mesh: AbstractMesh): boolean;
  125578. /**
  125579. * Returns true if the layer contains information to display, otherwise false.
  125580. * @returns true if the glow layer should be rendered
  125581. */
  125582. shouldRender(): boolean;
  125583. /**
  125584. * Returns true if the mesh should render, otherwise false.
  125585. * @param mesh The mesh to render
  125586. * @returns true if it should render otherwise false
  125587. */
  125588. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  125589. /**
  125590. * Returns true if the mesh can be rendered, otherwise false.
  125591. * @param mesh The mesh to render
  125592. * @param material The material used on the mesh
  125593. * @returns true if it can be rendered otherwise false
  125594. */
  125595. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125596. /**
  125597. * Returns true if the mesh should render, otherwise false.
  125598. * @param mesh The mesh to render
  125599. * @returns true if it should render otherwise false
  125600. */
  125601. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  125602. /**
  125603. * Renders the submesh passed in parameter to the generation map.
  125604. */
  125605. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  125606. /**
  125607. * Defines whether the current material of the mesh should be use to render the effect.
  125608. * @param mesh defines the current mesh to render
  125609. */
  125610. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125611. /**
  125612. * Rebuild the required buffers.
  125613. * @hidden Internal use only.
  125614. */
  125615. _rebuild(): void;
  125616. /**
  125617. * Dispose only the render target textures and post process.
  125618. */
  125619. private _disposeTextureAndPostProcesses;
  125620. /**
  125621. * Dispose the highlight layer and free resources.
  125622. */
  125623. dispose(): void;
  125624. /**
  125625. * Gets the class name of the effect layer
  125626. * @returns the string with the class name of the effect layer
  125627. */
  125628. getClassName(): string;
  125629. /**
  125630. * Creates an effect layer from parsed effect layer data
  125631. * @param parsedEffectLayer defines effect layer data
  125632. * @param scene defines the current scene
  125633. * @param rootUrl defines the root URL containing the effect layer information
  125634. * @returns a parsed effect Layer
  125635. */
  125636. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  125637. }
  125638. }
  125639. declare module BABYLON {
  125640. interface AbstractScene {
  125641. /**
  125642. * The list of effect layers (highlights/glow) added to the scene
  125643. * @see http://doc.babylonjs.com/how_to/highlight_layer
  125644. * @see http://doc.babylonjs.com/how_to/glow_layer
  125645. */
  125646. effectLayers: Array<EffectLayer>;
  125647. /**
  125648. * Removes the given effect layer from this scene.
  125649. * @param toRemove defines the effect layer to remove
  125650. * @returns the index of the removed effect layer
  125651. */
  125652. removeEffectLayer(toRemove: EffectLayer): number;
  125653. /**
  125654. * Adds the given effect layer to this scene
  125655. * @param newEffectLayer defines the effect layer to add
  125656. */
  125657. addEffectLayer(newEffectLayer: EffectLayer): void;
  125658. }
  125659. /**
  125660. * Defines the layer scene component responsible to manage any effect layers
  125661. * in a given scene.
  125662. */
  125663. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  125664. /**
  125665. * The component name helpfull to identify the component in the list of scene components.
  125666. */
  125667. readonly name: string;
  125668. /**
  125669. * The scene the component belongs to.
  125670. */
  125671. scene: Scene;
  125672. private _engine;
  125673. private _renderEffects;
  125674. private _needStencil;
  125675. private _previousStencilState;
  125676. /**
  125677. * Creates a new instance of the component for the given scene
  125678. * @param scene Defines the scene to register the component in
  125679. */
  125680. constructor(scene: Scene);
  125681. /**
  125682. * Registers the component in a given scene
  125683. */
  125684. register(): void;
  125685. /**
  125686. * Rebuilds the elements related to this component in case of
  125687. * context lost for instance.
  125688. */
  125689. rebuild(): void;
  125690. /**
  125691. * Serializes the component data to the specified json object
  125692. * @param serializationObject The object to serialize to
  125693. */
  125694. serialize(serializationObject: any): void;
  125695. /**
  125696. * Adds all the elements from the container to the scene
  125697. * @param container the container holding the elements
  125698. */
  125699. addFromContainer(container: AbstractScene): void;
  125700. /**
  125701. * Removes all the elements in the container from the scene
  125702. * @param container contains the elements to remove
  125703. * @param dispose if the removed element should be disposed (default: false)
  125704. */
  125705. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125706. /**
  125707. * Disposes the component and the associated ressources.
  125708. */
  125709. dispose(): void;
  125710. private _isReadyForMesh;
  125711. private _renderMainTexture;
  125712. private _setStencil;
  125713. private _setStencilBack;
  125714. private _draw;
  125715. private _drawCamera;
  125716. private _drawRenderingGroup;
  125717. }
  125718. }
  125719. declare module BABYLON {
  125720. /** @hidden */
  125721. export var glowMapMergePixelShader: {
  125722. name: string;
  125723. shader: string;
  125724. };
  125725. }
  125726. declare module BABYLON {
  125727. /** @hidden */
  125728. export var glowMapMergeVertexShader: {
  125729. name: string;
  125730. shader: string;
  125731. };
  125732. }
  125733. declare module BABYLON {
  125734. interface AbstractScene {
  125735. /**
  125736. * Return a the first highlight layer of the scene with a given name.
  125737. * @param name The name of the highlight layer to look for.
  125738. * @return The highlight layer if found otherwise null.
  125739. */
  125740. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  125741. }
  125742. /**
  125743. * Glow layer options. This helps customizing the behaviour
  125744. * of the glow layer.
  125745. */
  125746. export interface IGlowLayerOptions {
  125747. /**
  125748. * Multiplication factor apply to the canvas size to compute the render target size
  125749. * used to generated the glowing objects (the smaller the faster).
  125750. */
  125751. mainTextureRatio: number;
  125752. /**
  125753. * Enforces a fixed size texture to ensure resize independant blur.
  125754. */
  125755. mainTextureFixedSize?: number;
  125756. /**
  125757. * How big is the kernel of the blur texture.
  125758. */
  125759. blurKernelSize: number;
  125760. /**
  125761. * The camera attached to the layer.
  125762. */
  125763. camera: Nullable<Camera>;
  125764. /**
  125765. * Enable MSAA by chosing the number of samples.
  125766. */
  125767. mainTextureSamples?: number;
  125768. /**
  125769. * The rendering group to draw the layer in.
  125770. */
  125771. renderingGroupId: number;
  125772. }
  125773. /**
  125774. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  125775. *
  125776. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  125777. *
  125778. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  125779. */
  125780. export class GlowLayer extends EffectLayer {
  125781. /**
  125782. * Effect Name of the layer.
  125783. */
  125784. static readonly EffectName: string;
  125785. /**
  125786. * The default blur kernel size used for the glow.
  125787. */
  125788. static DefaultBlurKernelSize: number;
  125789. /**
  125790. * The default texture size ratio used for the glow.
  125791. */
  125792. static DefaultTextureRatio: number;
  125793. /**
  125794. * Sets the kernel size of the blur.
  125795. */
  125796. set blurKernelSize(value: number);
  125797. /**
  125798. * Gets the kernel size of the blur.
  125799. */
  125800. get blurKernelSize(): number;
  125801. /**
  125802. * Sets the glow intensity.
  125803. */
  125804. set intensity(value: number);
  125805. /**
  125806. * Gets the glow intensity.
  125807. */
  125808. get intensity(): number;
  125809. private _options;
  125810. private _intensity;
  125811. private _horizontalBlurPostprocess1;
  125812. private _verticalBlurPostprocess1;
  125813. private _horizontalBlurPostprocess2;
  125814. private _verticalBlurPostprocess2;
  125815. private _blurTexture1;
  125816. private _blurTexture2;
  125817. private _postProcesses1;
  125818. private _postProcesses2;
  125819. private _includedOnlyMeshes;
  125820. private _excludedMeshes;
  125821. private _meshesUsingTheirOwnMaterials;
  125822. /**
  125823. * Callback used to let the user override the color selection on a per mesh basis
  125824. */
  125825. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  125826. /**
  125827. * Callback used to let the user override the texture selection on a per mesh basis
  125828. */
  125829. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  125830. /**
  125831. * Instantiates a new glow Layer and references it to the scene.
  125832. * @param name The name of the layer
  125833. * @param scene The scene to use the layer in
  125834. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  125835. */
  125836. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  125837. /**
  125838. * Get the effect name of the layer.
  125839. * @return The effect name
  125840. */
  125841. getEffectName(): string;
  125842. /**
  125843. * Create the merge effect. This is the shader use to blit the information back
  125844. * to the main canvas at the end of the scene rendering.
  125845. */
  125846. protected _createMergeEffect(): Effect;
  125847. /**
  125848. * Creates the render target textures and post processes used in the glow layer.
  125849. */
  125850. protected _createTextureAndPostProcesses(): void;
  125851. /**
  125852. * Checks for the readiness of the element composing the layer.
  125853. * @param subMesh the mesh to check for
  125854. * @param useInstances specify wether or not to use instances to render the mesh
  125855. * @param emissiveTexture the associated emissive texture used to generate the glow
  125856. * @return true if ready otherwise, false
  125857. */
  125858. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125859. /**
  125860. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125861. */
  125862. needStencil(): boolean;
  125863. /**
  125864. * Returns true if the mesh can be rendered, otherwise false.
  125865. * @param mesh The mesh to render
  125866. * @param material The material used on the mesh
  125867. * @returns true if it can be rendered otherwise false
  125868. */
  125869. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125870. /**
  125871. * Implementation specific of rendering the generating effect on the main canvas.
  125872. * @param effect The effect used to render through
  125873. */
  125874. protected _internalRender(effect: Effect): void;
  125875. /**
  125876. * Sets the required values for both the emissive texture and and the main color.
  125877. */
  125878. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125879. /**
  125880. * Returns true if the mesh should render, otherwise false.
  125881. * @param mesh The mesh to render
  125882. * @returns true if it should render otherwise false
  125883. */
  125884. protected _shouldRenderMesh(mesh: Mesh): boolean;
  125885. /**
  125886. * Adds specific effects defines.
  125887. * @param defines The defines to add specifics to.
  125888. */
  125889. protected _addCustomEffectDefines(defines: string[]): void;
  125890. /**
  125891. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  125892. * @param mesh The mesh to exclude from the glow layer
  125893. */
  125894. addExcludedMesh(mesh: Mesh): void;
  125895. /**
  125896. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  125897. * @param mesh The mesh to remove
  125898. */
  125899. removeExcludedMesh(mesh: Mesh): void;
  125900. /**
  125901. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  125902. * @param mesh The mesh to include in the glow layer
  125903. */
  125904. addIncludedOnlyMesh(mesh: Mesh): void;
  125905. /**
  125906. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  125907. * @param mesh The mesh to remove
  125908. */
  125909. removeIncludedOnlyMesh(mesh: Mesh): void;
  125910. /**
  125911. * Determine if a given mesh will be used in the glow layer
  125912. * @param mesh The mesh to test
  125913. * @returns true if the mesh will be highlighted by the current glow layer
  125914. */
  125915. hasMesh(mesh: AbstractMesh): boolean;
  125916. /**
  125917. * Defines whether the current material of the mesh should be use to render the effect.
  125918. * @param mesh defines the current mesh to render
  125919. */
  125920. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125921. /**
  125922. * Add a mesh to be rendered through its own material and not with emissive only.
  125923. * @param mesh The mesh for which we need to use its material
  125924. */
  125925. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  125926. /**
  125927. * Remove a mesh from being rendered through its own material and not with emissive only.
  125928. * @param mesh The mesh for which we need to not use its material
  125929. */
  125930. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  125931. /**
  125932. * Free any resources and references associated to a mesh.
  125933. * Internal use
  125934. * @param mesh The mesh to free.
  125935. * @hidden
  125936. */
  125937. _disposeMesh(mesh: Mesh): void;
  125938. /**
  125939. * Gets the class name of the effect layer
  125940. * @returns the string with the class name of the effect layer
  125941. */
  125942. getClassName(): string;
  125943. /**
  125944. * Serializes this glow layer
  125945. * @returns a serialized glow layer object
  125946. */
  125947. serialize(): any;
  125948. /**
  125949. * Creates a Glow Layer from parsed glow layer data
  125950. * @param parsedGlowLayer defines glow layer data
  125951. * @param scene defines the current scene
  125952. * @param rootUrl defines the root URL containing the glow layer information
  125953. * @returns a parsed Glow Layer
  125954. */
  125955. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  125956. }
  125957. }
  125958. declare module BABYLON {
  125959. /** @hidden */
  125960. export var glowBlurPostProcessPixelShader: {
  125961. name: string;
  125962. shader: string;
  125963. };
  125964. }
  125965. declare module BABYLON {
  125966. interface AbstractScene {
  125967. /**
  125968. * Return a the first highlight layer of the scene with a given name.
  125969. * @param name The name of the highlight layer to look for.
  125970. * @return The highlight layer if found otherwise null.
  125971. */
  125972. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  125973. }
  125974. /**
  125975. * Highlight layer options. This helps customizing the behaviour
  125976. * of the highlight layer.
  125977. */
  125978. export interface IHighlightLayerOptions {
  125979. /**
  125980. * Multiplication factor apply to the canvas size to compute the render target size
  125981. * used to generated the glowing objects (the smaller the faster).
  125982. */
  125983. mainTextureRatio: number;
  125984. /**
  125985. * Enforces a fixed size texture to ensure resize independant blur.
  125986. */
  125987. mainTextureFixedSize?: number;
  125988. /**
  125989. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  125990. * of the picture to blur (the smaller the faster).
  125991. */
  125992. blurTextureSizeRatio: number;
  125993. /**
  125994. * How big in texel of the blur texture is the vertical blur.
  125995. */
  125996. blurVerticalSize: number;
  125997. /**
  125998. * How big in texel of the blur texture is the horizontal blur.
  125999. */
  126000. blurHorizontalSize: number;
  126001. /**
  126002. * Alpha blending mode used to apply the blur. Default is combine.
  126003. */
  126004. alphaBlendingMode: number;
  126005. /**
  126006. * The camera attached to the layer.
  126007. */
  126008. camera: Nullable<Camera>;
  126009. /**
  126010. * Should we display highlight as a solid stroke?
  126011. */
  126012. isStroke?: boolean;
  126013. /**
  126014. * The rendering group to draw the layer in.
  126015. */
  126016. renderingGroupId: number;
  126017. }
  126018. /**
  126019. * The highlight layer Helps adding a glow effect around a mesh.
  126020. *
  126021. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126022. * glowy meshes to your scene.
  126023. *
  126024. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126025. */
  126026. export class HighlightLayer extends EffectLayer {
  126027. name: string;
  126028. /**
  126029. * Effect Name of the highlight layer.
  126030. */
  126031. static readonly EffectName: string;
  126032. /**
  126033. * The neutral color used during the preparation of the glow effect.
  126034. * This is black by default as the blend operation is a blend operation.
  126035. */
  126036. static NeutralColor: Color4;
  126037. /**
  126038. * Stencil value used for glowing meshes.
  126039. */
  126040. static GlowingMeshStencilReference: number;
  126041. /**
  126042. * Stencil value used for the other meshes in the scene.
  126043. */
  126044. static NormalMeshStencilReference: number;
  126045. /**
  126046. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126047. */
  126048. innerGlow: boolean;
  126049. /**
  126050. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126051. */
  126052. outerGlow: boolean;
  126053. /**
  126054. * Specifies the horizontal size of the blur.
  126055. */
  126056. set blurHorizontalSize(value: number);
  126057. /**
  126058. * Specifies the vertical size of the blur.
  126059. */
  126060. set blurVerticalSize(value: number);
  126061. /**
  126062. * Gets the horizontal size of the blur.
  126063. */
  126064. get blurHorizontalSize(): number;
  126065. /**
  126066. * Gets the vertical size of the blur.
  126067. */
  126068. get blurVerticalSize(): number;
  126069. /**
  126070. * An event triggered when the highlight layer is being blurred.
  126071. */
  126072. onBeforeBlurObservable: Observable<HighlightLayer>;
  126073. /**
  126074. * An event triggered when the highlight layer has been blurred.
  126075. */
  126076. onAfterBlurObservable: Observable<HighlightLayer>;
  126077. private _instanceGlowingMeshStencilReference;
  126078. private _options;
  126079. private _downSamplePostprocess;
  126080. private _horizontalBlurPostprocess;
  126081. private _verticalBlurPostprocess;
  126082. private _blurTexture;
  126083. private _meshes;
  126084. private _excludedMeshes;
  126085. /**
  126086. * Instantiates a new highlight Layer and references it to the scene..
  126087. * @param name The name of the layer
  126088. * @param scene The scene to use the layer in
  126089. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126090. */
  126091. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126092. /**
  126093. * Get the effect name of the layer.
  126094. * @return The effect name
  126095. */
  126096. getEffectName(): string;
  126097. /**
  126098. * Create the merge effect. This is the shader use to blit the information back
  126099. * to the main canvas at the end of the scene rendering.
  126100. */
  126101. protected _createMergeEffect(): Effect;
  126102. /**
  126103. * Creates the render target textures and post processes used in the highlight layer.
  126104. */
  126105. protected _createTextureAndPostProcesses(): void;
  126106. /**
  126107. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126108. */
  126109. needStencil(): boolean;
  126110. /**
  126111. * Checks for the readiness of the element composing the layer.
  126112. * @param subMesh the mesh to check for
  126113. * @param useInstances specify wether or not to use instances to render the mesh
  126114. * @param emissiveTexture the associated emissive texture used to generate the glow
  126115. * @return true if ready otherwise, false
  126116. */
  126117. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126118. /**
  126119. * Implementation specific of rendering the generating effect on the main canvas.
  126120. * @param effect The effect used to render through
  126121. */
  126122. protected _internalRender(effect: Effect): void;
  126123. /**
  126124. * Returns true if the layer contains information to display, otherwise false.
  126125. */
  126126. shouldRender(): boolean;
  126127. /**
  126128. * Returns true if the mesh should render, otherwise false.
  126129. * @param mesh The mesh to render
  126130. * @returns true if it should render otherwise false
  126131. */
  126132. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126133. /**
  126134. * Sets the required values for both the emissive texture and and the main color.
  126135. */
  126136. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126137. /**
  126138. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126139. * @param mesh The mesh to exclude from the highlight layer
  126140. */
  126141. addExcludedMesh(mesh: Mesh): void;
  126142. /**
  126143. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126144. * @param mesh The mesh to highlight
  126145. */
  126146. removeExcludedMesh(mesh: Mesh): void;
  126147. /**
  126148. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126149. * @param mesh mesh to test
  126150. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126151. */
  126152. hasMesh(mesh: AbstractMesh): boolean;
  126153. /**
  126154. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126155. * @param mesh The mesh to highlight
  126156. * @param color The color of the highlight
  126157. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126158. */
  126159. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126160. /**
  126161. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126162. * @param mesh The mesh to highlight
  126163. */
  126164. removeMesh(mesh: Mesh): void;
  126165. /**
  126166. * Force the stencil to the normal expected value for none glowing parts
  126167. */
  126168. private _defaultStencilReference;
  126169. /**
  126170. * Free any resources and references associated to a mesh.
  126171. * Internal use
  126172. * @param mesh The mesh to free.
  126173. * @hidden
  126174. */
  126175. _disposeMesh(mesh: Mesh): void;
  126176. /**
  126177. * Dispose the highlight layer and free resources.
  126178. */
  126179. dispose(): void;
  126180. /**
  126181. * Gets the class name of the effect layer
  126182. * @returns the string with the class name of the effect layer
  126183. */
  126184. getClassName(): string;
  126185. /**
  126186. * Serializes this Highlight layer
  126187. * @returns a serialized Highlight layer object
  126188. */
  126189. serialize(): any;
  126190. /**
  126191. * Creates a Highlight layer from parsed Highlight layer data
  126192. * @param parsedHightlightLayer defines the Highlight layer data
  126193. * @param scene defines the current scene
  126194. * @param rootUrl defines the root URL containing the Highlight layer information
  126195. * @returns a parsed Highlight layer
  126196. */
  126197. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126198. }
  126199. }
  126200. declare module BABYLON {
  126201. interface AbstractScene {
  126202. /**
  126203. * The list of layers (background and foreground) of the scene
  126204. */
  126205. layers: Array<Layer>;
  126206. }
  126207. /**
  126208. * Defines the layer scene component responsible to manage any layers
  126209. * in a given scene.
  126210. */
  126211. export class LayerSceneComponent implements ISceneComponent {
  126212. /**
  126213. * The component name helpfull to identify the component in the list of scene components.
  126214. */
  126215. readonly name: string;
  126216. /**
  126217. * The scene the component belongs to.
  126218. */
  126219. scene: Scene;
  126220. private _engine;
  126221. /**
  126222. * Creates a new instance of the component for the given scene
  126223. * @param scene Defines the scene to register the component in
  126224. */
  126225. constructor(scene: Scene);
  126226. /**
  126227. * Registers the component in a given scene
  126228. */
  126229. register(): void;
  126230. /**
  126231. * Rebuilds the elements related to this component in case of
  126232. * context lost for instance.
  126233. */
  126234. rebuild(): void;
  126235. /**
  126236. * Disposes the component and the associated ressources.
  126237. */
  126238. dispose(): void;
  126239. private _draw;
  126240. private _drawCameraPredicate;
  126241. private _drawCameraBackground;
  126242. private _drawCameraForeground;
  126243. private _drawRenderTargetPredicate;
  126244. private _drawRenderTargetBackground;
  126245. private _drawRenderTargetForeground;
  126246. /**
  126247. * Adds all the elements from the container to the scene
  126248. * @param container the container holding the elements
  126249. */
  126250. addFromContainer(container: AbstractScene): void;
  126251. /**
  126252. * Removes all the elements in the container from the scene
  126253. * @param container contains the elements to remove
  126254. * @param dispose if the removed element should be disposed (default: false)
  126255. */
  126256. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126257. }
  126258. }
  126259. declare module BABYLON {
  126260. /** @hidden */
  126261. export var layerPixelShader: {
  126262. name: string;
  126263. shader: string;
  126264. };
  126265. }
  126266. declare module BABYLON {
  126267. /** @hidden */
  126268. export var layerVertexShader: {
  126269. name: string;
  126270. shader: string;
  126271. };
  126272. }
  126273. declare module BABYLON {
  126274. /**
  126275. * This represents a full screen 2d layer.
  126276. * This can be useful to display a picture in the background of your scene for instance.
  126277. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126278. */
  126279. export class Layer {
  126280. /**
  126281. * Define the name of the layer.
  126282. */
  126283. name: string;
  126284. /**
  126285. * Define the texture the layer should display.
  126286. */
  126287. texture: Nullable<Texture>;
  126288. /**
  126289. * Is the layer in background or foreground.
  126290. */
  126291. isBackground: boolean;
  126292. /**
  126293. * Define the color of the layer (instead of texture).
  126294. */
  126295. color: Color4;
  126296. /**
  126297. * Define the scale of the layer in order to zoom in out of the texture.
  126298. */
  126299. scale: Vector2;
  126300. /**
  126301. * Define an offset for the layer in order to shift the texture.
  126302. */
  126303. offset: Vector2;
  126304. /**
  126305. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126306. */
  126307. alphaBlendingMode: number;
  126308. /**
  126309. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126310. * Alpha test will not mix with the background color in case of transparency.
  126311. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126312. */
  126313. alphaTest: boolean;
  126314. /**
  126315. * Define a mask to restrict the layer to only some of the scene cameras.
  126316. */
  126317. layerMask: number;
  126318. /**
  126319. * Define the list of render target the layer is visible into.
  126320. */
  126321. renderTargetTextures: RenderTargetTexture[];
  126322. /**
  126323. * Define if the layer is only used in renderTarget or if it also
  126324. * renders in the main frame buffer of the canvas.
  126325. */
  126326. renderOnlyInRenderTargetTextures: boolean;
  126327. private _scene;
  126328. private _vertexBuffers;
  126329. private _indexBuffer;
  126330. private _effect;
  126331. private _previousDefines;
  126332. /**
  126333. * An event triggered when the layer is disposed.
  126334. */
  126335. onDisposeObservable: Observable<Layer>;
  126336. private _onDisposeObserver;
  126337. /**
  126338. * Back compatibility with callback before the onDisposeObservable existed.
  126339. * The set callback will be triggered when the layer has been disposed.
  126340. */
  126341. set onDispose(callback: () => void);
  126342. /**
  126343. * An event triggered before rendering the scene
  126344. */
  126345. onBeforeRenderObservable: Observable<Layer>;
  126346. private _onBeforeRenderObserver;
  126347. /**
  126348. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126349. * The set callback will be triggered just before rendering the layer.
  126350. */
  126351. set onBeforeRender(callback: () => void);
  126352. /**
  126353. * An event triggered after rendering the scene
  126354. */
  126355. onAfterRenderObservable: Observable<Layer>;
  126356. private _onAfterRenderObserver;
  126357. /**
  126358. * Back compatibility with callback before the onAfterRenderObservable existed.
  126359. * The set callback will be triggered just after rendering the layer.
  126360. */
  126361. set onAfterRender(callback: () => void);
  126362. /**
  126363. * Instantiates a new layer.
  126364. * This represents a full screen 2d layer.
  126365. * This can be useful to display a picture in the background of your scene for instance.
  126366. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126367. * @param name Define the name of the layer in the scene
  126368. * @param imgUrl Define the url of the texture to display in the layer
  126369. * @param scene Define the scene the layer belongs to
  126370. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126371. * @param color Defines a color for the layer
  126372. */
  126373. constructor(
  126374. /**
  126375. * Define the name of the layer.
  126376. */
  126377. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126378. private _createIndexBuffer;
  126379. /** @hidden */
  126380. _rebuild(): void;
  126381. /**
  126382. * Renders the layer in the scene.
  126383. */
  126384. render(): void;
  126385. /**
  126386. * Disposes and releases the associated ressources.
  126387. */
  126388. dispose(): void;
  126389. }
  126390. }
  126391. declare module BABYLON {
  126392. /** @hidden */
  126393. export var lensFlarePixelShader: {
  126394. name: string;
  126395. shader: string;
  126396. };
  126397. }
  126398. declare module BABYLON {
  126399. /** @hidden */
  126400. export var lensFlareVertexShader: {
  126401. name: string;
  126402. shader: string;
  126403. };
  126404. }
  126405. declare module BABYLON {
  126406. /**
  126407. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126408. * It is usually composed of several `lensFlare`.
  126409. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126410. */
  126411. export class LensFlareSystem {
  126412. /**
  126413. * Define the name of the lens flare system
  126414. */
  126415. name: string;
  126416. /**
  126417. * List of lens flares used in this system.
  126418. */
  126419. lensFlares: LensFlare[];
  126420. /**
  126421. * Define a limit from the border the lens flare can be visible.
  126422. */
  126423. borderLimit: number;
  126424. /**
  126425. * Define a viewport border we do not want to see the lens flare in.
  126426. */
  126427. viewportBorder: number;
  126428. /**
  126429. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126430. */
  126431. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126432. /**
  126433. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126434. */
  126435. layerMask: number;
  126436. /**
  126437. * Define the id of the lens flare system in the scene.
  126438. * (equal to name by default)
  126439. */
  126440. id: string;
  126441. private _scene;
  126442. private _emitter;
  126443. private _vertexBuffers;
  126444. private _indexBuffer;
  126445. private _effect;
  126446. private _positionX;
  126447. private _positionY;
  126448. private _isEnabled;
  126449. /** @hidden */
  126450. static _SceneComponentInitialization: (scene: Scene) => void;
  126451. /**
  126452. * Instantiates a lens flare system.
  126453. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126454. * It is usually composed of several `lensFlare`.
  126455. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126456. * @param name Define the name of the lens flare system in the scene
  126457. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126458. * @param scene Define the scene the lens flare system belongs to
  126459. */
  126460. constructor(
  126461. /**
  126462. * Define the name of the lens flare system
  126463. */
  126464. name: string, emitter: any, scene: Scene);
  126465. /**
  126466. * Define if the lens flare system is enabled.
  126467. */
  126468. get isEnabled(): boolean;
  126469. set isEnabled(value: boolean);
  126470. /**
  126471. * Get the scene the effects belongs to.
  126472. * @returns the scene holding the lens flare system
  126473. */
  126474. getScene(): Scene;
  126475. /**
  126476. * Get the emitter of the lens flare system.
  126477. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126478. * @returns the emitter of the lens flare system
  126479. */
  126480. getEmitter(): any;
  126481. /**
  126482. * Set the emitter of the lens flare system.
  126483. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126484. * @param newEmitter Define the new emitter of the system
  126485. */
  126486. setEmitter(newEmitter: any): void;
  126487. /**
  126488. * Get the lens flare system emitter position.
  126489. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126490. * @returns the position
  126491. */
  126492. getEmitterPosition(): Vector3;
  126493. /**
  126494. * @hidden
  126495. */
  126496. computeEffectivePosition(globalViewport: Viewport): boolean;
  126497. /** @hidden */
  126498. _isVisible(): boolean;
  126499. /**
  126500. * @hidden
  126501. */
  126502. render(): boolean;
  126503. /**
  126504. * Dispose and release the lens flare with its associated resources.
  126505. */
  126506. dispose(): void;
  126507. /**
  126508. * Parse a lens flare system from a JSON repressentation
  126509. * @param parsedLensFlareSystem Define the JSON to parse
  126510. * @param scene Define the scene the parsed system should be instantiated in
  126511. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126512. * @returns the parsed system
  126513. */
  126514. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126515. /**
  126516. * Serialize the current Lens Flare System into a JSON representation.
  126517. * @returns the serialized JSON
  126518. */
  126519. serialize(): any;
  126520. }
  126521. }
  126522. declare module BABYLON {
  126523. /**
  126524. * This represents one of the lens effect in a `lensFlareSystem`.
  126525. * It controls one of the indiviual texture used in the effect.
  126526. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126527. */
  126528. export class LensFlare {
  126529. /**
  126530. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126531. */
  126532. size: number;
  126533. /**
  126534. * 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.
  126535. */
  126536. position: number;
  126537. /**
  126538. * Define the lens color.
  126539. */
  126540. color: Color3;
  126541. /**
  126542. * Define the lens texture.
  126543. */
  126544. texture: Nullable<Texture>;
  126545. /**
  126546. * Define the alpha mode to render this particular lens.
  126547. */
  126548. alphaMode: number;
  126549. private _system;
  126550. /**
  126551. * Creates a new Lens Flare.
  126552. * This represents one of the lens effect in a `lensFlareSystem`.
  126553. * It controls one of the indiviual texture used in the effect.
  126554. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126555. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  126556. * @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.
  126557. * @param color Define the lens color
  126558. * @param imgUrl Define the lens texture url
  126559. * @param system Define the `lensFlareSystem` this flare is part of
  126560. * @returns The newly created Lens Flare
  126561. */
  126562. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  126563. /**
  126564. * Instantiates a new Lens Flare.
  126565. * This represents one of the lens effect in a `lensFlareSystem`.
  126566. * It controls one of the indiviual texture used in the effect.
  126567. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126568. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  126569. * @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.
  126570. * @param color Define the lens color
  126571. * @param imgUrl Define the lens texture url
  126572. * @param system Define the `lensFlareSystem` this flare is part of
  126573. */
  126574. constructor(
  126575. /**
  126576. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126577. */
  126578. size: number,
  126579. /**
  126580. * 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.
  126581. */
  126582. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  126583. /**
  126584. * Dispose and release the lens flare with its associated resources.
  126585. */
  126586. dispose(): void;
  126587. }
  126588. }
  126589. declare module BABYLON {
  126590. interface AbstractScene {
  126591. /**
  126592. * The list of lens flare system added to the scene
  126593. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126594. */
  126595. lensFlareSystems: Array<LensFlareSystem>;
  126596. /**
  126597. * Removes the given lens flare system from this scene.
  126598. * @param toRemove The lens flare system to remove
  126599. * @returns The index of the removed lens flare system
  126600. */
  126601. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  126602. /**
  126603. * Adds the given lens flare system to this scene
  126604. * @param newLensFlareSystem The lens flare system to add
  126605. */
  126606. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  126607. /**
  126608. * Gets a lens flare system using its name
  126609. * @param name defines the name to look for
  126610. * @returns the lens flare system or null if not found
  126611. */
  126612. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  126613. /**
  126614. * Gets a lens flare system using its id
  126615. * @param id defines the id to look for
  126616. * @returns the lens flare system or null if not found
  126617. */
  126618. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  126619. }
  126620. /**
  126621. * Defines the lens flare scene component responsible to manage any lens flares
  126622. * in a given scene.
  126623. */
  126624. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  126625. /**
  126626. * The component name helpfull to identify the component in the list of scene components.
  126627. */
  126628. readonly name: string;
  126629. /**
  126630. * The scene the component belongs to.
  126631. */
  126632. scene: Scene;
  126633. /**
  126634. * Creates a new instance of the component for the given scene
  126635. * @param scene Defines the scene to register the component in
  126636. */
  126637. constructor(scene: Scene);
  126638. /**
  126639. * Registers the component in a given scene
  126640. */
  126641. register(): void;
  126642. /**
  126643. * Rebuilds the elements related to this component in case of
  126644. * context lost for instance.
  126645. */
  126646. rebuild(): void;
  126647. /**
  126648. * Adds all the elements from the container to the scene
  126649. * @param container the container holding the elements
  126650. */
  126651. addFromContainer(container: AbstractScene): void;
  126652. /**
  126653. * Removes all the elements in the container from the scene
  126654. * @param container contains the elements to remove
  126655. * @param dispose if the removed element should be disposed (default: false)
  126656. */
  126657. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126658. /**
  126659. * Serializes the component data to the specified json object
  126660. * @param serializationObject The object to serialize to
  126661. */
  126662. serialize(serializationObject: any): void;
  126663. /**
  126664. * Disposes the component and the associated ressources.
  126665. */
  126666. dispose(): void;
  126667. private _draw;
  126668. }
  126669. }
  126670. declare module BABYLON {
  126671. /** @hidden */
  126672. export var depthPixelShader: {
  126673. name: string;
  126674. shader: string;
  126675. };
  126676. }
  126677. declare module BABYLON {
  126678. /** @hidden */
  126679. export var depthVertexShader: {
  126680. name: string;
  126681. shader: string;
  126682. };
  126683. }
  126684. declare module BABYLON {
  126685. /**
  126686. * This represents a depth renderer in Babylon.
  126687. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126688. */
  126689. export class DepthRenderer {
  126690. private _scene;
  126691. private _depthMap;
  126692. private _effect;
  126693. private readonly _storeNonLinearDepth;
  126694. private readonly _clearColor;
  126695. /** Get if the depth renderer is using packed depth or not */
  126696. readonly isPacked: boolean;
  126697. private _cachedDefines;
  126698. private _camera;
  126699. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  126700. enabled: boolean;
  126701. /**
  126702. * Specifiess that the depth renderer will only be used within
  126703. * the camera it is created for.
  126704. * This can help forcing its rendering during the camera processing.
  126705. */
  126706. useOnlyInActiveCamera: boolean;
  126707. /** @hidden */
  126708. static _SceneComponentInitialization: (scene: Scene) => void;
  126709. /**
  126710. * Instantiates a depth renderer
  126711. * @param scene The scene the renderer belongs to
  126712. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126713. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126714. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126715. */
  126716. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126717. /**
  126718. * Creates the depth rendering effect and checks if the effect is ready.
  126719. * @param subMesh The submesh to be used to render the depth map of
  126720. * @param useInstances If multiple world instances should be used
  126721. * @returns if the depth renderer is ready to render the depth map
  126722. */
  126723. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126724. /**
  126725. * Gets the texture which the depth map will be written to.
  126726. * @returns The depth map texture
  126727. */
  126728. getDepthMap(): RenderTargetTexture;
  126729. /**
  126730. * Disposes of the depth renderer.
  126731. */
  126732. dispose(): void;
  126733. }
  126734. }
  126735. declare module BABYLON {
  126736. /** @hidden */
  126737. export var minmaxReduxPixelShader: {
  126738. name: string;
  126739. shader: string;
  126740. };
  126741. }
  126742. declare module BABYLON {
  126743. /**
  126744. * This class computes a min/max reduction from a texture: it means it computes the minimum
  126745. * and maximum values from all values of the texture.
  126746. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  126747. * The source values are read from the red channel of the texture.
  126748. */
  126749. export class MinMaxReducer {
  126750. /**
  126751. * Observable triggered when the computation has been performed
  126752. */
  126753. onAfterReductionPerformed: Observable<{
  126754. min: number;
  126755. max: number;
  126756. }>;
  126757. protected _camera: Camera;
  126758. protected _sourceTexture: Nullable<RenderTargetTexture>;
  126759. protected _reductionSteps: Nullable<Array<PostProcess>>;
  126760. protected _postProcessManager: PostProcessManager;
  126761. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  126762. protected _forceFullscreenViewport: boolean;
  126763. /**
  126764. * Creates a min/max reducer
  126765. * @param camera The camera to use for the post processes
  126766. */
  126767. constructor(camera: Camera);
  126768. /**
  126769. * Gets the texture used to read the values from.
  126770. */
  126771. get sourceTexture(): Nullable<RenderTargetTexture>;
  126772. /**
  126773. * Sets the source texture to read the values from.
  126774. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  126775. * because in such textures '1' value must not be taken into account to compute the maximum
  126776. * as this value is used to clear the texture.
  126777. * Note that the computation is not activated by calling this function, you must call activate() for that!
  126778. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  126779. * @param depthRedux Indicates if the texture is a depth texture or not
  126780. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  126781. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126782. */
  126783. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126784. /**
  126785. * Defines the refresh rate of the computation.
  126786. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  126787. */
  126788. get refreshRate(): number;
  126789. set refreshRate(value: number);
  126790. protected _activated: boolean;
  126791. /**
  126792. * Gets the activation status of the reducer
  126793. */
  126794. get activated(): boolean;
  126795. /**
  126796. * Activates the reduction computation.
  126797. * When activated, the observers registered in onAfterReductionPerformed are
  126798. * called after the compuation is performed
  126799. */
  126800. activate(): void;
  126801. /**
  126802. * Deactivates the reduction computation.
  126803. */
  126804. deactivate(): void;
  126805. /**
  126806. * Disposes the min/max reducer
  126807. * @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.
  126808. */
  126809. dispose(disposeAll?: boolean): void;
  126810. }
  126811. }
  126812. declare module BABYLON {
  126813. /**
  126814. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  126815. */
  126816. export class DepthReducer extends MinMaxReducer {
  126817. private _depthRenderer;
  126818. private _depthRendererId;
  126819. /**
  126820. * Gets the depth renderer used for the computation.
  126821. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  126822. */
  126823. get depthRenderer(): Nullable<DepthRenderer>;
  126824. /**
  126825. * Creates a depth reducer
  126826. * @param camera The camera used to render the depth texture
  126827. */
  126828. constructor(camera: Camera);
  126829. /**
  126830. * Sets the depth renderer to use to generate the depth map
  126831. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  126832. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  126833. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126834. */
  126835. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  126836. /** @hidden */
  126837. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126838. /**
  126839. * Activates the reduction computation.
  126840. * When activated, the observers registered in onAfterReductionPerformed are
  126841. * called after the compuation is performed
  126842. */
  126843. activate(): void;
  126844. /**
  126845. * Deactivates the reduction computation.
  126846. */
  126847. deactivate(): void;
  126848. /**
  126849. * Disposes the depth reducer
  126850. * @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.
  126851. */
  126852. dispose(disposeAll?: boolean): void;
  126853. }
  126854. }
  126855. declare module BABYLON {
  126856. /**
  126857. * A CSM implementation allowing casting shadows on large scenes.
  126858. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  126859. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  126860. */
  126861. export class CascadedShadowGenerator extends ShadowGenerator {
  126862. private static readonly frustumCornersNDCSpace;
  126863. /**
  126864. * Name of the CSM class
  126865. */
  126866. static CLASSNAME: string;
  126867. /**
  126868. * Defines the default number of cascades used by the CSM.
  126869. */
  126870. static readonly DEFAULT_CASCADES_COUNT: number;
  126871. /**
  126872. * Defines the minimum number of cascades used by the CSM.
  126873. */
  126874. static readonly MIN_CASCADES_COUNT: number;
  126875. /**
  126876. * Defines the maximum number of cascades used by the CSM.
  126877. */
  126878. static readonly MAX_CASCADES_COUNT: number;
  126879. protected _validateFilter(filter: number): number;
  126880. /**
  126881. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  126882. */
  126883. penumbraDarkness: number;
  126884. private _numCascades;
  126885. /**
  126886. * Gets or set the number of cascades used by the CSM.
  126887. */
  126888. get numCascades(): number;
  126889. set numCascades(value: number);
  126890. /**
  126891. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  126892. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  126893. */
  126894. stabilizeCascades: boolean;
  126895. private _freezeShadowCastersBoundingInfo;
  126896. private _freezeShadowCastersBoundingInfoObservable;
  126897. /**
  126898. * Enables or disables the shadow casters bounding info computation.
  126899. * If your shadow casters don't move, you can disable this feature.
  126900. * If it is enabled, the bounding box computation is done every frame.
  126901. */
  126902. get freezeShadowCastersBoundingInfo(): boolean;
  126903. set freezeShadowCastersBoundingInfo(freeze: boolean);
  126904. private _scbiMin;
  126905. private _scbiMax;
  126906. protected _computeShadowCastersBoundingInfo(): void;
  126907. protected _shadowCastersBoundingInfo: BoundingInfo;
  126908. /**
  126909. * Gets or sets the shadow casters bounding info.
  126910. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  126911. * so that the system won't overwrite the bounds you provide
  126912. */
  126913. get shadowCastersBoundingInfo(): BoundingInfo;
  126914. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  126915. protected _breaksAreDirty: boolean;
  126916. protected _minDistance: number;
  126917. protected _maxDistance: number;
  126918. /**
  126919. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  126920. *
  126921. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  126922. * If you don't know these values, simply leave them to their defaults and don't call this function.
  126923. * @param min minimal distance for the breaks (default to 0.)
  126924. * @param max maximal distance for the breaks (default to 1.)
  126925. */
  126926. setMinMaxDistance(min: number, max: number): void;
  126927. /** Gets the minimal distance used in the cascade break computation */
  126928. get minDistance(): number;
  126929. /** Gets the maximal distance used in the cascade break computation */
  126930. get maxDistance(): number;
  126931. /**
  126932. * Gets the class name of that object
  126933. * @returns "CascadedShadowGenerator"
  126934. */
  126935. getClassName(): string;
  126936. private _cascadeMinExtents;
  126937. private _cascadeMaxExtents;
  126938. /**
  126939. * Gets a cascade minimum extents
  126940. * @param cascadeIndex index of the cascade
  126941. * @returns the minimum cascade extents
  126942. */
  126943. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  126944. /**
  126945. * Gets a cascade maximum extents
  126946. * @param cascadeIndex index of the cascade
  126947. * @returns the maximum cascade extents
  126948. */
  126949. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  126950. private _cascades;
  126951. private _currentLayer;
  126952. private _viewSpaceFrustumsZ;
  126953. private _viewMatrices;
  126954. private _projectionMatrices;
  126955. private _transformMatrices;
  126956. private _transformMatricesAsArray;
  126957. private _frustumLengths;
  126958. private _lightSizeUVCorrection;
  126959. private _depthCorrection;
  126960. private _frustumCornersWorldSpace;
  126961. private _frustumCenter;
  126962. private _shadowCameraPos;
  126963. private _shadowMaxZ;
  126964. /**
  126965. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  126966. * It defaults to camera.maxZ
  126967. */
  126968. get shadowMaxZ(): number;
  126969. /**
  126970. * Sets the shadow max z distance.
  126971. */
  126972. set shadowMaxZ(value: number);
  126973. protected _debug: boolean;
  126974. /**
  126975. * Gets or sets the debug flag.
  126976. * When enabled, the cascades are materialized by different colors on the screen.
  126977. */
  126978. get debug(): boolean;
  126979. set debug(dbg: boolean);
  126980. private _depthClamp;
  126981. /**
  126982. * Gets or sets the depth clamping value.
  126983. *
  126984. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  126985. * to account for the shadow casters far away.
  126986. *
  126987. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  126988. */
  126989. get depthClamp(): boolean;
  126990. set depthClamp(value: boolean);
  126991. private _cascadeBlendPercentage;
  126992. /**
  126993. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  126994. * It defaults to 0.1 (10% blending).
  126995. */
  126996. get cascadeBlendPercentage(): number;
  126997. set cascadeBlendPercentage(value: number);
  126998. private _lambda;
  126999. /**
  127000. * Gets or set the lambda parameter.
  127001. * This parameter is used to split the camera frustum and create the cascades.
  127002. * 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.
  127003. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127004. */
  127005. get lambda(): number;
  127006. set lambda(value: number);
  127007. /**
  127008. * Gets the view matrix corresponding to a given cascade
  127009. * @param cascadeNum cascade to retrieve the view matrix from
  127010. * @returns the cascade view matrix
  127011. */
  127012. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127013. /**
  127014. * Gets the projection matrix corresponding to a given cascade
  127015. * @param cascadeNum cascade to retrieve the projection matrix from
  127016. * @returns the cascade projection matrix
  127017. */
  127018. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127019. /**
  127020. * Gets the transformation matrix corresponding to a given cascade
  127021. * @param cascadeNum cascade to retrieve the transformation matrix from
  127022. * @returns the cascade transformation matrix
  127023. */
  127024. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127025. private _depthRenderer;
  127026. /**
  127027. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127028. *
  127029. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127030. *
  127031. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127032. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127033. * @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
  127034. */
  127035. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127036. private _depthReducer;
  127037. private _autoCalcDepthBounds;
  127038. /**
  127039. * Gets or sets the autoCalcDepthBounds property.
  127040. *
  127041. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127042. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127043. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127044. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127045. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127046. */
  127047. get autoCalcDepthBounds(): boolean;
  127048. set autoCalcDepthBounds(value: boolean);
  127049. /**
  127050. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127051. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127052. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127053. * for setting the refresh rate on the renderer yourself!
  127054. */
  127055. get autoCalcDepthBoundsRefreshRate(): number;
  127056. set autoCalcDepthBoundsRefreshRate(value: number);
  127057. /**
  127058. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127059. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127060. * you change the camera near/far planes!
  127061. */
  127062. splitFrustum(): void;
  127063. private _splitFrustum;
  127064. private _computeMatrices;
  127065. private _computeFrustumInWorldSpace;
  127066. private _computeCascadeFrustum;
  127067. /** @hidden */
  127068. static _SceneComponentInitialization: (scene: Scene) => void;
  127069. /**
  127070. * Creates a Cascaded Shadow Generator object.
  127071. * A ShadowGenerator is the required tool to use the shadows.
  127072. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127073. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127074. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127075. * @param light The directional light object generating the shadows.
  127076. * @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.
  127077. */
  127078. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127079. protected _initializeGenerator(): void;
  127080. protected _createTargetRenderTexture(): void;
  127081. protected _initializeShadowMap(): void;
  127082. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127083. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127084. /**
  127085. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127086. * @param defines Defines of the material we want to update
  127087. * @param lightIndex Index of the light in the enabled light list of the material
  127088. */
  127089. prepareDefines(defines: any, lightIndex: number): void;
  127090. /**
  127091. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127092. * defined in the generator but impacting the effect).
  127093. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127094. * @param effect The effect we are binfing the information for
  127095. */
  127096. bindShadowLight(lightIndex: string, effect: Effect): void;
  127097. /**
  127098. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127099. * (eq to view projection * shadow projection matrices)
  127100. * @returns The transform matrix used to create the shadow map
  127101. */
  127102. getTransformMatrix(): Matrix;
  127103. /**
  127104. * Disposes the ShadowGenerator.
  127105. * Returns nothing.
  127106. */
  127107. dispose(): void;
  127108. /**
  127109. * Serializes the shadow generator setup to a json object.
  127110. * @returns The serialized JSON object
  127111. */
  127112. serialize(): any;
  127113. /**
  127114. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127115. * @param parsedShadowGenerator The JSON object to parse
  127116. * @param scene The scene to create the shadow map for
  127117. * @returns The parsed shadow generator
  127118. */
  127119. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127120. }
  127121. }
  127122. declare module BABYLON {
  127123. /**
  127124. * Defines the shadow generator component responsible to manage any shadow generators
  127125. * in a given scene.
  127126. */
  127127. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127128. /**
  127129. * The component name helpfull to identify the component in the list of scene components.
  127130. */
  127131. readonly name: string;
  127132. /**
  127133. * The scene the component belongs to.
  127134. */
  127135. scene: Scene;
  127136. /**
  127137. * Creates a new instance of the component for the given scene
  127138. * @param scene Defines the scene to register the component in
  127139. */
  127140. constructor(scene: Scene);
  127141. /**
  127142. * Registers the component in a given scene
  127143. */
  127144. register(): void;
  127145. /**
  127146. * Rebuilds the elements related to this component in case of
  127147. * context lost for instance.
  127148. */
  127149. rebuild(): void;
  127150. /**
  127151. * Serializes the component data to the specified json object
  127152. * @param serializationObject The object to serialize to
  127153. */
  127154. serialize(serializationObject: any): void;
  127155. /**
  127156. * Adds all the elements from the container to the scene
  127157. * @param container the container holding the elements
  127158. */
  127159. addFromContainer(container: AbstractScene): void;
  127160. /**
  127161. * Removes all the elements in the container from the scene
  127162. * @param container contains the elements to remove
  127163. * @param dispose if the removed element should be disposed (default: false)
  127164. */
  127165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127166. /**
  127167. * Rebuilds the elements related to this component in case of
  127168. * context lost for instance.
  127169. */
  127170. dispose(): void;
  127171. private _gatherRenderTargets;
  127172. }
  127173. }
  127174. declare module BABYLON {
  127175. /**
  127176. * A point light is a light defined by an unique point in world space.
  127177. * The light is emitted in every direction from this point.
  127178. * A good example of a point light is a standard light bulb.
  127179. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127180. */
  127181. export class PointLight extends ShadowLight {
  127182. private _shadowAngle;
  127183. /**
  127184. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127185. * This specifies what angle the shadow will use to be created.
  127186. *
  127187. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127188. */
  127189. get shadowAngle(): number;
  127190. /**
  127191. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127192. * This specifies what angle the shadow will use to be created.
  127193. *
  127194. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127195. */
  127196. set shadowAngle(value: number);
  127197. /**
  127198. * Gets the direction if it has been set.
  127199. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127200. */
  127201. get direction(): Vector3;
  127202. /**
  127203. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127204. */
  127205. set direction(value: Vector3);
  127206. /**
  127207. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127208. * A PointLight emits the light in every direction.
  127209. * It can cast shadows.
  127210. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127211. * ```javascript
  127212. * var pointLight = new PointLight("pl", camera.position, scene);
  127213. * ```
  127214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127215. * @param name The light friendly name
  127216. * @param position The position of the point light in the scene
  127217. * @param scene The scene the lights belongs to
  127218. */
  127219. constructor(name: string, position: Vector3, scene: Scene);
  127220. /**
  127221. * Returns the string "PointLight"
  127222. * @returns the class name
  127223. */
  127224. getClassName(): string;
  127225. /**
  127226. * Returns the integer 0.
  127227. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127228. */
  127229. getTypeID(): number;
  127230. /**
  127231. * Specifies wether or not the shadowmap should be a cube texture.
  127232. * @returns true if the shadowmap needs to be a cube texture.
  127233. */
  127234. needCube(): boolean;
  127235. /**
  127236. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127237. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127238. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127239. */
  127240. getShadowDirection(faceIndex?: number): Vector3;
  127241. /**
  127242. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127243. * - fov = PI / 2
  127244. * - aspect ratio : 1.0
  127245. * - z-near and far equal to the active camera minZ and maxZ.
  127246. * Returns the PointLight.
  127247. */
  127248. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127249. protected _buildUniformLayout(): void;
  127250. /**
  127251. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127252. * @param effect The effect to update
  127253. * @param lightIndex The index of the light in the effect to update
  127254. * @returns The point light
  127255. */
  127256. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127257. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127258. /**
  127259. * Prepares the list of defines specific to the light type.
  127260. * @param defines the list of defines
  127261. * @param lightIndex defines the index of the light for the effect
  127262. */
  127263. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127264. }
  127265. }
  127266. declare module BABYLON {
  127267. /**
  127268. * Header information of HDR texture files.
  127269. */
  127270. export interface HDRInfo {
  127271. /**
  127272. * The height of the texture in pixels.
  127273. */
  127274. height: number;
  127275. /**
  127276. * The width of the texture in pixels.
  127277. */
  127278. width: number;
  127279. /**
  127280. * The index of the beginning of the data in the binary file.
  127281. */
  127282. dataPosition: number;
  127283. }
  127284. /**
  127285. * This groups tools to convert HDR texture to native colors array.
  127286. */
  127287. export class HDRTools {
  127288. private static Ldexp;
  127289. private static Rgbe2float;
  127290. private static readStringLine;
  127291. /**
  127292. * Reads header information from an RGBE texture stored in a native array.
  127293. * More information on this format are available here:
  127294. * https://en.wikipedia.org/wiki/RGBE_image_format
  127295. *
  127296. * @param uint8array The binary file stored in native array.
  127297. * @return The header information.
  127298. */
  127299. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127300. /**
  127301. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127302. * This RGBE texture needs to store the information as a panorama.
  127303. *
  127304. * More information on this format are available here:
  127305. * https://en.wikipedia.org/wiki/RGBE_image_format
  127306. *
  127307. * @param buffer The binary file stored in an array buffer.
  127308. * @param size The expected size of the extracted cubemap.
  127309. * @return The Cube Map information.
  127310. */
  127311. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127312. /**
  127313. * Returns the pixels data extracted from an RGBE texture.
  127314. * This pixels will be stored left to right up to down in the R G B order in one array.
  127315. *
  127316. * More information on this format are available here:
  127317. * https://en.wikipedia.org/wiki/RGBE_image_format
  127318. *
  127319. * @param uint8array The binary file stored in an array buffer.
  127320. * @param hdrInfo The header information of the file.
  127321. * @return The pixels data in RGB right to left up to down order.
  127322. */
  127323. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127324. private static RGBE_ReadPixels_RLE;
  127325. }
  127326. }
  127327. declare module BABYLON {
  127328. /**
  127329. * This represents a texture coming from an HDR input.
  127330. *
  127331. * The only supported format is currently panorama picture stored in RGBE format.
  127332. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127333. */
  127334. export class HDRCubeTexture extends BaseTexture {
  127335. private static _facesMapping;
  127336. private _generateHarmonics;
  127337. private _noMipmap;
  127338. private _textureMatrix;
  127339. private _size;
  127340. private _onLoad;
  127341. private _onError;
  127342. /**
  127343. * The texture URL.
  127344. */
  127345. url: string;
  127346. /**
  127347. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127348. */
  127349. coordinatesMode: number;
  127350. protected _isBlocking: boolean;
  127351. /**
  127352. * Sets wether or not the texture is blocking during loading.
  127353. */
  127354. set isBlocking(value: boolean);
  127355. /**
  127356. * Gets wether or not the texture is blocking during loading.
  127357. */
  127358. get isBlocking(): boolean;
  127359. protected _rotationY: number;
  127360. /**
  127361. * Sets texture matrix rotation angle around Y axis in radians.
  127362. */
  127363. set rotationY(value: number);
  127364. /**
  127365. * Gets texture matrix rotation angle around Y axis radians.
  127366. */
  127367. get rotationY(): number;
  127368. /**
  127369. * Gets or sets the center of the bounding box associated with the cube texture
  127370. * It must define where the camera used to render the texture was set
  127371. */
  127372. boundingBoxPosition: Vector3;
  127373. private _boundingBoxSize;
  127374. /**
  127375. * Gets or sets the size of the bounding box associated with the cube texture
  127376. * When defined, the cubemap will switch to local mode
  127377. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127378. * @example https://www.babylonjs-playground.com/#RNASML
  127379. */
  127380. set boundingBoxSize(value: Vector3);
  127381. get boundingBoxSize(): Vector3;
  127382. /**
  127383. * Instantiates an HDRTexture from the following parameters.
  127384. *
  127385. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127386. * @param scene The scene the texture will be used in
  127387. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127388. * @param noMipmap Forces to not generate the mipmap if true
  127389. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127390. * @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)
  127391. * @param reserved Reserved flag for internal use.
  127392. */
  127393. 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>);
  127394. /**
  127395. * Get the current class name of the texture useful for serialization or dynamic coding.
  127396. * @returns "HDRCubeTexture"
  127397. */
  127398. getClassName(): string;
  127399. /**
  127400. * Occurs when the file is raw .hdr file.
  127401. */
  127402. private loadTexture;
  127403. clone(): HDRCubeTexture;
  127404. delayLoad(): void;
  127405. /**
  127406. * Get the texture reflection matrix used to rotate/transform the reflection.
  127407. * @returns the reflection matrix
  127408. */
  127409. getReflectionTextureMatrix(): Matrix;
  127410. /**
  127411. * Set the texture reflection matrix used to rotate/transform the reflection.
  127412. * @param value Define the reflection matrix to set
  127413. */
  127414. setReflectionTextureMatrix(value: Matrix): void;
  127415. /**
  127416. * Parses a JSON representation of an HDR Texture in order to create the texture
  127417. * @param parsedTexture Define the JSON representation
  127418. * @param scene Define the scene the texture should be created in
  127419. * @param rootUrl Define the root url in case we need to load relative dependencies
  127420. * @returns the newly created texture after parsing
  127421. */
  127422. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127423. serialize(): any;
  127424. }
  127425. }
  127426. declare module BABYLON {
  127427. /**
  127428. * Class used to control physics engine
  127429. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127430. */
  127431. export class PhysicsEngine implements IPhysicsEngine {
  127432. private _physicsPlugin;
  127433. /**
  127434. * Global value used to control the smallest number supported by the simulation
  127435. */
  127436. static Epsilon: number;
  127437. private _impostors;
  127438. private _joints;
  127439. private _subTimeStep;
  127440. /**
  127441. * Gets the gravity vector used by the simulation
  127442. */
  127443. gravity: Vector3;
  127444. /**
  127445. * Factory used to create the default physics plugin.
  127446. * @returns The default physics plugin
  127447. */
  127448. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127449. /**
  127450. * Creates a new Physics Engine
  127451. * @param gravity defines the gravity vector used by the simulation
  127452. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127453. */
  127454. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127455. /**
  127456. * Sets the gravity vector used by the simulation
  127457. * @param gravity defines the gravity vector to use
  127458. */
  127459. setGravity(gravity: Vector3): void;
  127460. /**
  127461. * Set the time step of the physics engine.
  127462. * Default is 1/60.
  127463. * To slow it down, enter 1/600 for example.
  127464. * To speed it up, 1/30
  127465. * @param newTimeStep defines the new timestep to apply to this world.
  127466. */
  127467. setTimeStep(newTimeStep?: number): void;
  127468. /**
  127469. * Get the time step of the physics engine.
  127470. * @returns the current time step
  127471. */
  127472. getTimeStep(): number;
  127473. /**
  127474. * Set the sub time step of the physics engine.
  127475. * Default is 0 meaning there is no sub steps
  127476. * To increase physics resolution precision, set a small value (like 1 ms)
  127477. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127478. */
  127479. setSubTimeStep(subTimeStep?: number): void;
  127480. /**
  127481. * Get the sub time step of the physics engine.
  127482. * @returns the current sub time step
  127483. */
  127484. getSubTimeStep(): number;
  127485. /**
  127486. * Release all resources
  127487. */
  127488. dispose(): void;
  127489. /**
  127490. * Gets the name of the current physics plugin
  127491. * @returns the name of the plugin
  127492. */
  127493. getPhysicsPluginName(): string;
  127494. /**
  127495. * Adding a new impostor for the impostor tracking.
  127496. * This will be done by the impostor itself.
  127497. * @param impostor the impostor to add
  127498. */
  127499. addImpostor(impostor: PhysicsImpostor): void;
  127500. /**
  127501. * Remove an impostor from the engine.
  127502. * This impostor and its mesh will not longer be updated by the physics engine.
  127503. * @param impostor the impostor to remove
  127504. */
  127505. removeImpostor(impostor: PhysicsImpostor): void;
  127506. /**
  127507. * Add a joint to the physics engine
  127508. * @param mainImpostor defines the main impostor to which the joint is added.
  127509. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127510. * @param joint defines the joint that will connect both impostors.
  127511. */
  127512. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127513. /**
  127514. * Removes a joint from the simulation
  127515. * @param mainImpostor defines the impostor used with the joint
  127516. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127517. * @param joint defines the joint to remove
  127518. */
  127519. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127520. /**
  127521. * Called by the scene. No need to call it.
  127522. * @param delta defines the timespam between frames
  127523. */
  127524. _step(delta: number): void;
  127525. /**
  127526. * Gets the current plugin used to run the simulation
  127527. * @returns current plugin
  127528. */
  127529. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127530. /**
  127531. * Gets the list of physic impostors
  127532. * @returns an array of PhysicsImpostor
  127533. */
  127534. getImpostors(): Array<PhysicsImpostor>;
  127535. /**
  127536. * Gets the impostor for a physics enabled object
  127537. * @param object defines the object impersonated by the impostor
  127538. * @returns the PhysicsImpostor or null if not found
  127539. */
  127540. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  127541. /**
  127542. * Gets the impostor for a physics body object
  127543. * @param body defines physics body used by the impostor
  127544. * @returns the PhysicsImpostor or null if not found
  127545. */
  127546. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  127547. /**
  127548. * Does a raycast in the physics world
  127549. * @param from when should the ray start?
  127550. * @param to when should the ray end?
  127551. * @returns PhysicsRaycastResult
  127552. */
  127553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127554. }
  127555. }
  127556. declare module BABYLON {
  127557. /** @hidden */
  127558. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  127559. private _useDeltaForWorldStep;
  127560. world: any;
  127561. name: string;
  127562. private _physicsMaterials;
  127563. private _fixedTimeStep;
  127564. private _cannonRaycastResult;
  127565. private _raycastResult;
  127566. private _physicsBodysToRemoveAfterStep;
  127567. BJSCANNON: any;
  127568. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  127569. setGravity(gravity: Vector3): void;
  127570. setTimeStep(timeStep: number): void;
  127571. getTimeStep(): number;
  127572. executeStep(delta: number): void;
  127573. private _removeMarkedPhysicsBodiesFromWorld;
  127574. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127575. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127576. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127577. private _processChildMeshes;
  127578. removePhysicsBody(impostor: PhysicsImpostor): void;
  127579. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127580. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127581. private _addMaterial;
  127582. private _checkWithEpsilon;
  127583. private _createShape;
  127584. private _createHeightmap;
  127585. private _minus90X;
  127586. private _plus90X;
  127587. private _tmpPosition;
  127588. private _tmpDeltaPosition;
  127589. private _tmpUnityRotation;
  127590. private _updatePhysicsBodyTransformation;
  127591. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127592. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127593. isSupported(): boolean;
  127594. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127595. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127596. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127597. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127598. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127599. getBodyMass(impostor: PhysicsImpostor): number;
  127600. getBodyFriction(impostor: PhysicsImpostor): number;
  127601. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127602. getBodyRestitution(impostor: PhysicsImpostor): number;
  127603. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127604. sleepBody(impostor: PhysicsImpostor): void;
  127605. wakeUpBody(impostor: PhysicsImpostor): void;
  127606. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  127607. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  127608. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  127609. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127610. getRadius(impostor: PhysicsImpostor): number;
  127611. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127612. dispose(): void;
  127613. private _extendNamespace;
  127614. /**
  127615. * Does a raycast in the physics world
  127616. * @param from when should the ray start?
  127617. * @param to when should the ray end?
  127618. * @returns PhysicsRaycastResult
  127619. */
  127620. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127621. }
  127622. }
  127623. declare module BABYLON {
  127624. /** @hidden */
  127625. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  127626. world: any;
  127627. name: string;
  127628. BJSOIMO: any;
  127629. private _raycastResult;
  127630. constructor(iterations?: number, oimoInjection?: any);
  127631. setGravity(gravity: Vector3): void;
  127632. setTimeStep(timeStep: number): void;
  127633. getTimeStep(): number;
  127634. private _tmpImpostorsArray;
  127635. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127636. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127637. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127638. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127639. private _tmpPositionVector;
  127640. removePhysicsBody(impostor: PhysicsImpostor): void;
  127641. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127642. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127643. isSupported(): boolean;
  127644. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127645. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127646. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127647. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127648. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127649. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127650. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127651. getBodyMass(impostor: PhysicsImpostor): number;
  127652. getBodyFriction(impostor: PhysicsImpostor): number;
  127653. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127654. getBodyRestitution(impostor: PhysicsImpostor): number;
  127655. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127656. sleepBody(impostor: PhysicsImpostor): void;
  127657. wakeUpBody(impostor: PhysicsImpostor): void;
  127658. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  127659. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  127660. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  127661. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127662. getRadius(impostor: PhysicsImpostor): number;
  127663. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127664. dispose(): void;
  127665. /**
  127666. * Does a raycast in the physics world
  127667. * @param from when should the ray start?
  127668. * @param to when should the ray end?
  127669. * @returns PhysicsRaycastResult
  127670. */
  127671. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127672. }
  127673. }
  127674. declare module BABYLON {
  127675. /**
  127676. * Class containing static functions to help procedurally build meshes
  127677. */
  127678. export class RibbonBuilder {
  127679. /**
  127680. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127681. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127682. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127683. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127684. * * 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
  127685. * * 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
  127686. * * 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
  127687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127690. * * 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
  127691. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127692. * * 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
  127693. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127695. * @param name defines the name of the mesh
  127696. * @param options defines the options used to create the mesh
  127697. * @param scene defines the hosting scene
  127698. * @returns the ribbon mesh
  127699. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127700. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127701. */
  127702. static CreateRibbon(name: string, options: {
  127703. pathArray: Vector3[][];
  127704. closeArray?: boolean;
  127705. closePath?: boolean;
  127706. offset?: number;
  127707. updatable?: boolean;
  127708. sideOrientation?: number;
  127709. frontUVs?: Vector4;
  127710. backUVs?: Vector4;
  127711. instance?: Mesh;
  127712. invertUV?: boolean;
  127713. uvs?: Vector2[];
  127714. colors?: Color4[];
  127715. }, scene?: Nullable<Scene>): Mesh;
  127716. }
  127717. }
  127718. declare module BABYLON {
  127719. /**
  127720. * Class containing static functions to help procedurally build meshes
  127721. */
  127722. export class ShapeBuilder {
  127723. /**
  127724. * 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.
  127725. * * 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.
  127726. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127727. * * 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.
  127728. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127729. * * 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
  127730. * * 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
  127731. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127736. * @param name defines the name of the mesh
  127737. * @param options defines the options used to create the mesh
  127738. * @param scene defines the hosting scene
  127739. * @returns the extruded shape mesh
  127740. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127742. */
  127743. static ExtrudeShape(name: string, options: {
  127744. shape: Vector3[];
  127745. path: Vector3[];
  127746. scale?: number;
  127747. rotation?: number;
  127748. cap?: number;
  127749. updatable?: boolean;
  127750. sideOrientation?: number;
  127751. frontUVs?: Vector4;
  127752. backUVs?: Vector4;
  127753. instance?: Mesh;
  127754. invertUV?: boolean;
  127755. }, scene?: Nullable<Scene>): Mesh;
  127756. /**
  127757. * Creates an custom extruded shape mesh.
  127758. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127759. * * 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.
  127760. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127761. * * 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
  127762. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127763. * * 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
  127764. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127765. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127766. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127767. * * 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
  127768. * * 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
  127769. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127772. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127774. * @param name defines the name of the mesh
  127775. * @param options defines the options used to create the mesh
  127776. * @param scene defines the hosting scene
  127777. * @returns the custom extruded shape mesh
  127778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127781. */
  127782. static ExtrudeShapeCustom(name: string, options: {
  127783. shape: Vector3[];
  127784. path: Vector3[];
  127785. scaleFunction?: any;
  127786. rotationFunction?: any;
  127787. ribbonCloseArray?: boolean;
  127788. ribbonClosePath?: boolean;
  127789. cap?: number;
  127790. updatable?: boolean;
  127791. sideOrientation?: number;
  127792. frontUVs?: Vector4;
  127793. backUVs?: Vector4;
  127794. instance?: Mesh;
  127795. invertUV?: boolean;
  127796. }, scene?: Nullable<Scene>): Mesh;
  127797. private static _ExtrudeShapeGeneric;
  127798. }
  127799. }
  127800. declare module BABYLON {
  127801. /**
  127802. * AmmoJS Physics plugin
  127803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  127804. * @see https://github.com/kripken/ammo.js/
  127805. */
  127806. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  127807. private _useDeltaForWorldStep;
  127808. /**
  127809. * Reference to the Ammo library
  127810. */
  127811. bjsAMMO: any;
  127812. /**
  127813. * Created ammoJS world which physics bodies are added to
  127814. */
  127815. world: any;
  127816. /**
  127817. * Name of the plugin
  127818. */
  127819. name: string;
  127820. private _timeStep;
  127821. private _fixedTimeStep;
  127822. private _maxSteps;
  127823. private _tmpQuaternion;
  127824. private _tmpAmmoTransform;
  127825. private _tmpAmmoQuaternion;
  127826. private _tmpAmmoConcreteContactResultCallback;
  127827. private _collisionConfiguration;
  127828. private _dispatcher;
  127829. private _overlappingPairCache;
  127830. private _solver;
  127831. private _softBodySolver;
  127832. private _tmpAmmoVectorA;
  127833. private _tmpAmmoVectorB;
  127834. private _tmpAmmoVectorC;
  127835. private _tmpAmmoVectorD;
  127836. private _tmpContactCallbackResult;
  127837. private _tmpAmmoVectorRCA;
  127838. private _tmpAmmoVectorRCB;
  127839. private _raycastResult;
  127840. private static readonly DISABLE_COLLISION_FLAG;
  127841. private static readonly KINEMATIC_FLAG;
  127842. private static readonly DISABLE_DEACTIVATION_FLAG;
  127843. /**
  127844. * Initializes the ammoJS plugin
  127845. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  127846. * @param ammoInjection can be used to inject your own ammo reference
  127847. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  127848. */
  127849. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  127850. /**
  127851. * Sets the gravity of the physics world (m/(s^2))
  127852. * @param gravity Gravity to set
  127853. */
  127854. setGravity(gravity: Vector3): void;
  127855. /**
  127856. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  127857. * @param timeStep timestep to use in seconds
  127858. */
  127859. setTimeStep(timeStep: number): void;
  127860. /**
  127861. * 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)
  127862. * @param fixedTimeStep fixedTimeStep to use in seconds
  127863. */
  127864. setFixedTimeStep(fixedTimeStep: number): void;
  127865. /**
  127866. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  127867. * @param maxSteps the maximum number of steps by the physics engine per frame
  127868. */
  127869. setMaxSteps(maxSteps: number): void;
  127870. /**
  127871. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  127872. * @returns the current timestep in seconds
  127873. */
  127874. getTimeStep(): number;
  127875. /**
  127876. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  127877. */
  127878. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  127879. private _isImpostorInContact;
  127880. private _isImpostorPairInContact;
  127881. private _stepSimulation;
  127882. /**
  127883. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  127884. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  127885. * After the step the babylon meshes are set to the position of the physics imposters
  127886. * @param delta amount of time to step forward
  127887. * @param impostors array of imposters to update before/after the step
  127888. */
  127889. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127890. /**
  127891. * Update babylon mesh to match physics world object
  127892. * @param impostor imposter to match
  127893. */
  127894. private _afterSoftStep;
  127895. /**
  127896. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127897. * @param impostor imposter to match
  127898. */
  127899. private _ropeStep;
  127900. /**
  127901. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127902. * @param impostor imposter to match
  127903. */
  127904. private _softbodyOrClothStep;
  127905. private _tmpVector;
  127906. private _tmpMatrix;
  127907. /**
  127908. * Applies an impulse on the imposter
  127909. * @param impostor imposter to apply impulse to
  127910. * @param force amount of force to be applied to the imposter
  127911. * @param contactPoint the location to apply the impulse on the imposter
  127912. */
  127913. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127914. /**
  127915. * Applies a force on the imposter
  127916. * @param impostor imposter to apply force
  127917. * @param force amount of force to be applied to the imposter
  127918. * @param contactPoint the location to apply the force on the imposter
  127919. */
  127920. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127921. /**
  127922. * Creates a physics body using the plugin
  127923. * @param impostor the imposter to create the physics body on
  127924. */
  127925. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127926. /**
  127927. * Removes the physics body from the imposter and disposes of the body's memory
  127928. * @param impostor imposter to remove the physics body from
  127929. */
  127930. removePhysicsBody(impostor: PhysicsImpostor): void;
  127931. /**
  127932. * Generates a joint
  127933. * @param impostorJoint the imposter joint to create the joint with
  127934. */
  127935. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127936. /**
  127937. * Removes a joint
  127938. * @param impostorJoint the imposter joint to remove the joint from
  127939. */
  127940. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127941. private _addMeshVerts;
  127942. /**
  127943. * Initialise the soft body vertices to match its object's (mesh) vertices
  127944. * Softbody vertices (nodes) are in world space and to match this
  127945. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  127946. * @param impostor to create the softbody for
  127947. */
  127948. private _softVertexData;
  127949. /**
  127950. * Create an impostor's soft body
  127951. * @param impostor to create the softbody for
  127952. */
  127953. private _createSoftbody;
  127954. /**
  127955. * Create cloth for an impostor
  127956. * @param impostor to create the softbody for
  127957. */
  127958. private _createCloth;
  127959. /**
  127960. * Create rope for an impostor
  127961. * @param impostor to create the softbody for
  127962. */
  127963. private _createRope;
  127964. /**
  127965. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  127966. * @param impostor to create the custom physics shape for
  127967. */
  127968. private _createCustom;
  127969. private _addHullVerts;
  127970. private _createShape;
  127971. /**
  127972. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  127973. * @param impostor imposter containing the physics body and babylon object
  127974. */
  127975. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127976. /**
  127977. * Sets the babylon object's position/rotation from the physics body's position/rotation
  127978. * @param impostor imposter containing the physics body and babylon object
  127979. * @param newPosition new position
  127980. * @param newRotation new rotation
  127981. */
  127982. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127983. /**
  127984. * If this plugin is supported
  127985. * @returns true if its supported
  127986. */
  127987. isSupported(): boolean;
  127988. /**
  127989. * Sets the linear velocity of the physics body
  127990. * @param impostor imposter to set the velocity on
  127991. * @param velocity velocity to set
  127992. */
  127993. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127994. /**
  127995. * Sets the angular velocity of the physics body
  127996. * @param impostor imposter to set the velocity on
  127997. * @param velocity velocity to set
  127998. */
  127999. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128000. /**
  128001. * gets the linear velocity
  128002. * @param impostor imposter to get linear velocity from
  128003. * @returns linear velocity
  128004. */
  128005. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128006. /**
  128007. * gets the angular velocity
  128008. * @param impostor imposter to get angular velocity from
  128009. * @returns angular velocity
  128010. */
  128011. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128012. /**
  128013. * Sets the mass of physics body
  128014. * @param impostor imposter to set the mass on
  128015. * @param mass mass to set
  128016. */
  128017. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128018. /**
  128019. * Gets the mass of the physics body
  128020. * @param impostor imposter to get the mass from
  128021. * @returns mass
  128022. */
  128023. getBodyMass(impostor: PhysicsImpostor): number;
  128024. /**
  128025. * Gets friction of the impostor
  128026. * @param impostor impostor to get friction from
  128027. * @returns friction value
  128028. */
  128029. getBodyFriction(impostor: PhysicsImpostor): number;
  128030. /**
  128031. * Sets friction of the impostor
  128032. * @param impostor impostor to set friction on
  128033. * @param friction friction value
  128034. */
  128035. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128036. /**
  128037. * Gets restitution of the impostor
  128038. * @param impostor impostor to get restitution from
  128039. * @returns restitution value
  128040. */
  128041. getBodyRestitution(impostor: PhysicsImpostor): number;
  128042. /**
  128043. * Sets resitution of the impostor
  128044. * @param impostor impostor to set resitution on
  128045. * @param restitution resitution value
  128046. */
  128047. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128048. /**
  128049. * Gets pressure inside the impostor
  128050. * @param impostor impostor to get pressure from
  128051. * @returns pressure value
  128052. */
  128053. getBodyPressure(impostor: PhysicsImpostor): number;
  128054. /**
  128055. * Sets pressure inside a soft body impostor
  128056. * Cloth and rope must remain 0 pressure
  128057. * @param impostor impostor to set pressure on
  128058. * @param pressure pressure value
  128059. */
  128060. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128061. /**
  128062. * Gets stiffness of the impostor
  128063. * @param impostor impostor to get stiffness from
  128064. * @returns pressure value
  128065. */
  128066. getBodyStiffness(impostor: PhysicsImpostor): number;
  128067. /**
  128068. * Sets stiffness of the impostor
  128069. * @param impostor impostor to set stiffness on
  128070. * @param stiffness stiffness value from 0 to 1
  128071. */
  128072. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128073. /**
  128074. * Gets velocityIterations of the impostor
  128075. * @param impostor impostor to get velocity iterations from
  128076. * @returns velocityIterations value
  128077. */
  128078. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128079. /**
  128080. * Sets velocityIterations of the impostor
  128081. * @param impostor impostor to set velocity iterations on
  128082. * @param velocityIterations velocityIterations value
  128083. */
  128084. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128085. /**
  128086. * Gets positionIterations of the impostor
  128087. * @param impostor impostor to get position iterations from
  128088. * @returns positionIterations value
  128089. */
  128090. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128091. /**
  128092. * Sets positionIterations of the impostor
  128093. * @param impostor impostor to set position on
  128094. * @param positionIterations positionIterations value
  128095. */
  128096. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128097. /**
  128098. * Append an anchor to a cloth object
  128099. * @param impostor is the cloth impostor to add anchor to
  128100. * @param otherImpostor is the rigid impostor to anchor to
  128101. * @param width ratio across width from 0 to 1
  128102. * @param height ratio up height from 0 to 1
  128103. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128104. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128105. */
  128106. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128107. /**
  128108. * Append an hook to a rope object
  128109. * @param impostor is the rope impostor to add hook to
  128110. * @param otherImpostor is the rigid impostor to hook to
  128111. * @param length ratio along the rope from 0 to 1
  128112. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128113. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128114. */
  128115. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128116. /**
  128117. * Sleeps the physics body and stops it from being active
  128118. * @param impostor impostor to sleep
  128119. */
  128120. sleepBody(impostor: PhysicsImpostor): void;
  128121. /**
  128122. * Activates the physics body
  128123. * @param impostor impostor to activate
  128124. */
  128125. wakeUpBody(impostor: PhysicsImpostor): void;
  128126. /**
  128127. * Updates the distance parameters of the joint
  128128. * @param joint joint to update
  128129. * @param maxDistance maximum distance of the joint
  128130. * @param minDistance minimum distance of the joint
  128131. */
  128132. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128133. /**
  128134. * Sets a motor on the joint
  128135. * @param joint joint to set motor on
  128136. * @param speed speed of the motor
  128137. * @param maxForce maximum force of the motor
  128138. * @param motorIndex index of the motor
  128139. */
  128140. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128141. /**
  128142. * Sets the motors limit
  128143. * @param joint joint to set limit on
  128144. * @param upperLimit upper limit
  128145. * @param lowerLimit lower limit
  128146. */
  128147. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128148. /**
  128149. * Syncs the position and rotation of a mesh with the impostor
  128150. * @param mesh mesh to sync
  128151. * @param impostor impostor to update the mesh with
  128152. */
  128153. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128154. /**
  128155. * Gets the radius of the impostor
  128156. * @param impostor impostor to get radius from
  128157. * @returns the radius
  128158. */
  128159. getRadius(impostor: PhysicsImpostor): number;
  128160. /**
  128161. * Gets the box size of the impostor
  128162. * @param impostor impostor to get box size from
  128163. * @param result the resulting box size
  128164. */
  128165. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128166. /**
  128167. * Disposes of the impostor
  128168. */
  128169. dispose(): void;
  128170. /**
  128171. * Does a raycast in the physics world
  128172. * @param from when should the ray start?
  128173. * @param to when should the ray end?
  128174. * @returns PhysicsRaycastResult
  128175. */
  128176. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128177. }
  128178. }
  128179. declare module BABYLON {
  128180. interface AbstractScene {
  128181. /**
  128182. * The list of reflection probes added to the scene
  128183. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128184. */
  128185. reflectionProbes: Array<ReflectionProbe>;
  128186. /**
  128187. * Removes the given reflection probe from this scene.
  128188. * @param toRemove The reflection probe to remove
  128189. * @returns The index of the removed reflection probe
  128190. */
  128191. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128192. /**
  128193. * Adds the given reflection probe to this scene.
  128194. * @param newReflectionProbe The reflection probe to add
  128195. */
  128196. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128197. }
  128198. /**
  128199. * Class used to generate realtime reflection / refraction cube textures
  128200. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128201. */
  128202. export class ReflectionProbe {
  128203. /** defines the name of the probe */
  128204. name: string;
  128205. private _scene;
  128206. private _renderTargetTexture;
  128207. private _projectionMatrix;
  128208. private _viewMatrix;
  128209. private _target;
  128210. private _add;
  128211. private _attachedMesh;
  128212. private _invertYAxis;
  128213. /** Gets or sets probe position (center of the cube map) */
  128214. position: Vector3;
  128215. /**
  128216. * Creates a new reflection probe
  128217. * @param name defines the name of the probe
  128218. * @param size defines the texture resolution (for each face)
  128219. * @param scene defines the hosting scene
  128220. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128221. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128222. */
  128223. constructor(
  128224. /** defines the name of the probe */
  128225. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128226. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128227. get samples(): number;
  128228. set samples(value: number);
  128229. /** Gets or sets the refresh rate to use (on every frame by default) */
  128230. get refreshRate(): number;
  128231. set refreshRate(value: number);
  128232. /**
  128233. * Gets the hosting scene
  128234. * @returns a Scene
  128235. */
  128236. getScene(): Scene;
  128237. /** Gets the internal CubeTexture used to render to */
  128238. get cubeTexture(): RenderTargetTexture;
  128239. /** Gets the list of meshes to render */
  128240. get renderList(): Nullable<AbstractMesh[]>;
  128241. /**
  128242. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128243. * @param mesh defines the mesh to attach to
  128244. */
  128245. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128246. /**
  128247. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128248. * @param renderingGroupId The rendering group id corresponding to its index
  128249. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128250. */
  128251. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128252. /**
  128253. * Clean all associated resources
  128254. */
  128255. dispose(): void;
  128256. /**
  128257. * Converts the reflection probe information to a readable string for debug purpose.
  128258. * @param fullDetails Supports for multiple levels of logging within scene loading
  128259. * @returns the human readable reflection probe info
  128260. */
  128261. toString(fullDetails?: boolean): string;
  128262. /**
  128263. * Get the class name of the relfection probe.
  128264. * @returns "ReflectionProbe"
  128265. */
  128266. getClassName(): string;
  128267. /**
  128268. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128269. * @returns The JSON representation of the texture
  128270. */
  128271. serialize(): any;
  128272. /**
  128273. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128274. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128275. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128276. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128277. * @returns The parsed reflection probe if successful
  128278. */
  128279. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /** @hidden */
  128284. export var _BabylonLoaderRegistered: boolean;
  128285. /**
  128286. * Helps setting up some configuration for the babylon file loader.
  128287. */
  128288. export class BabylonFileLoaderConfiguration {
  128289. /**
  128290. * The loader does not allow injecting custom physix engine into the plugins.
  128291. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128292. * So you could set this variable to your engine import to make it work.
  128293. */
  128294. static LoaderInjectedPhysicsEngine: any;
  128295. }
  128296. }
  128297. declare module BABYLON {
  128298. /**
  128299. * The Physically based simple base material of BJS.
  128300. *
  128301. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128302. * It is used as the base class for both the specGloss and metalRough conventions.
  128303. */
  128304. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128305. /**
  128306. * Number of Simultaneous lights allowed on the material.
  128307. */
  128308. maxSimultaneousLights: number;
  128309. /**
  128310. * If sets to true, disables all the lights affecting the material.
  128311. */
  128312. disableLighting: boolean;
  128313. /**
  128314. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128315. */
  128316. environmentTexture: BaseTexture;
  128317. /**
  128318. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128319. */
  128320. invertNormalMapX: boolean;
  128321. /**
  128322. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128323. */
  128324. invertNormalMapY: boolean;
  128325. /**
  128326. * Normal map used in the model.
  128327. */
  128328. normalTexture: BaseTexture;
  128329. /**
  128330. * Emissivie color used to self-illuminate the model.
  128331. */
  128332. emissiveColor: Color3;
  128333. /**
  128334. * Emissivie texture used to self-illuminate the model.
  128335. */
  128336. emissiveTexture: BaseTexture;
  128337. /**
  128338. * Occlusion Channel Strenght.
  128339. */
  128340. occlusionStrength: number;
  128341. /**
  128342. * Occlusion Texture of the material (adding extra occlusion effects).
  128343. */
  128344. occlusionTexture: BaseTexture;
  128345. /**
  128346. * Defines the alpha limits in alpha test mode.
  128347. */
  128348. alphaCutOff: number;
  128349. /**
  128350. * Gets the current double sided mode.
  128351. */
  128352. get doubleSided(): boolean;
  128353. /**
  128354. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128355. */
  128356. set doubleSided(value: boolean);
  128357. /**
  128358. * Stores the pre-calculated light information of a mesh in a texture.
  128359. */
  128360. lightmapTexture: BaseTexture;
  128361. /**
  128362. * If true, the light map contains occlusion information instead of lighting info.
  128363. */
  128364. useLightmapAsShadowmap: boolean;
  128365. /**
  128366. * Instantiates a new PBRMaterial instance.
  128367. *
  128368. * @param name The material name
  128369. * @param scene The scene the material will be use in.
  128370. */
  128371. constructor(name: string, scene: Scene);
  128372. getClassName(): string;
  128373. }
  128374. }
  128375. declare module BABYLON {
  128376. /**
  128377. * The PBR material of BJS following the metal roughness convention.
  128378. *
  128379. * This fits to the PBR convention in the GLTF definition:
  128380. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128381. */
  128382. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128383. /**
  128384. * The base color has two different interpretations depending on the value of metalness.
  128385. * When the material is a metal, the base color is the specific measured reflectance value
  128386. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128387. * of the material.
  128388. */
  128389. baseColor: Color3;
  128390. /**
  128391. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128392. * well as opacity information in the alpha channel.
  128393. */
  128394. baseTexture: BaseTexture;
  128395. /**
  128396. * Specifies the metallic scalar value of the material.
  128397. * Can also be used to scale the metalness values of the metallic texture.
  128398. */
  128399. metallic: number;
  128400. /**
  128401. * Specifies the roughness scalar value of the material.
  128402. * Can also be used to scale the roughness values of the metallic texture.
  128403. */
  128404. roughness: number;
  128405. /**
  128406. * Texture containing both the metallic value in the B channel and the
  128407. * roughness value in the G channel to keep better precision.
  128408. */
  128409. metallicRoughnessTexture: BaseTexture;
  128410. /**
  128411. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128412. *
  128413. * @param name The material name
  128414. * @param scene The scene the material will be use in.
  128415. */
  128416. constructor(name: string, scene: Scene);
  128417. /**
  128418. * Return the currrent class name of the material.
  128419. */
  128420. getClassName(): string;
  128421. /**
  128422. * Makes a duplicate of the current material.
  128423. * @param name - name to use for the new material.
  128424. */
  128425. clone(name: string): PBRMetallicRoughnessMaterial;
  128426. /**
  128427. * Serialize the material to a parsable JSON object.
  128428. */
  128429. serialize(): any;
  128430. /**
  128431. * Parses a JSON object correponding to the serialize function.
  128432. */
  128433. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128434. }
  128435. }
  128436. declare module BABYLON {
  128437. /**
  128438. * The PBR material of BJS following the specular glossiness convention.
  128439. *
  128440. * This fits to the PBR convention in the GLTF definition:
  128441. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128442. */
  128443. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128444. /**
  128445. * Specifies the diffuse color of the material.
  128446. */
  128447. diffuseColor: Color3;
  128448. /**
  128449. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128450. * channel.
  128451. */
  128452. diffuseTexture: BaseTexture;
  128453. /**
  128454. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128455. */
  128456. specularColor: Color3;
  128457. /**
  128458. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128459. */
  128460. glossiness: number;
  128461. /**
  128462. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128463. */
  128464. specularGlossinessTexture: BaseTexture;
  128465. /**
  128466. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128467. *
  128468. * @param name The material name
  128469. * @param scene The scene the material will be use in.
  128470. */
  128471. constructor(name: string, scene: Scene);
  128472. /**
  128473. * Return the currrent class name of the material.
  128474. */
  128475. getClassName(): string;
  128476. /**
  128477. * Makes a duplicate of the current material.
  128478. * @param name - name to use for the new material.
  128479. */
  128480. clone(name: string): PBRSpecularGlossinessMaterial;
  128481. /**
  128482. * Serialize the material to a parsable JSON object.
  128483. */
  128484. serialize(): any;
  128485. /**
  128486. * Parses a JSON object correponding to the serialize function.
  128487. */
  128488. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128489. }
  128490. }
  128491. declare module BABYLON {
  128492. /**
  128493. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128494. * It can help converting any input color in a desired output one. This can then be used to create effects
  128495. * from sepia, black and white to sixties or futuristic rendering...
  128496. *
  128497. * The only supported format is currently 3dl.
  128498. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128499. */
  128500. export class ColorGradingTexture extends BaseTexture {
  128501. /**
  128502. * The current texture matrix. (will always be identity in color grading texture)
  128503. */
  128504. private _textureMatrix;
  128505. /**
  128506. * The texture URL.
  128507. */
  128508. url: string;
  128509. /**
  128510. * Empty line regex stored for GC.
  128511. */
  128512. private static _noneEmptyLineRegex;
  128513. private _engine;
  128514. /**
  128515. * Instantiates a ColorGradingTexture from the following parameters.
  128516. *
  128517. * @param url The location of the color gradind data (currently only supporting 3dl)
  128518. * @param scene The scene the texture will be used in
  128519. */
  128520. constructor(url: string, scene: Scene);
  128521. /**
  128522. * Returns the texture matrix used in most of the material.
  128523. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128524. */
  128525. getTextureMatrix(): Matrix;
  128526. /**
  128527. * Occurs when the file being loaded is a .3dl LUT file.
  128528. */
  128529. private load3dlTexture;
  128530. /**
  128531. * Starts the loading process of the texture.
  128532. */
  128533. private loadTexture;
  128534. /**
  128535. * Clones the color gradind texture.
  128536. */
  128537. clone(): ColorGradingTexture;
  128538. /**
  128539. * Called during delayed load for textures.
  128540. */
  128541. delayLoad(): void;
  128542. /**
  128543. * Parses a color grading texture serialized by Babylon.
  128544. * @param parsedTexture The texture information being parsedTexture
  128545. * @param scene The scene to load the texture in
  128546. * @param rootUrl The root url of the data assets to load
  128547. * @return A color gradind texture
  128548. */
  128549. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  128550. /**
  128551. * Serializes the LUT texture to json format.
  128552. */
  128553. serialize(): any;
  128554. }
  128555. }
  128556. declare module BABYLON {
  128557. /**
  128558. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  128559. */
  128560. export class EquiRectangularCubeTexture extends BaseTexture {
  128561. /** The six faces of the cube. */
  128562. private static _FacesMapping;
  128563. private _noMipmap;
  128564. private _onLoad;
  128565. private _onError;
  128566. /** The size of the cubemap. */
  128567. private _size;
  128568. /** The buffer of the image. */
  128569. private _buffer;
  128570. /** The width of the input image. */
  128571. private _width;
  128572. /** The height of the input image. */
  128573. private _height;
  128574. /** The URL to the image. */
  128575. url: string;
  128576. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  128577. coordinatesMode: number;
  128578. /**
  128579. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  128580. * @param url The location of the image
  128581. * @param scene The scene the texture will be used in
  128582. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128583. * @param noMipmap Forces to not generate the mipmap if true
  128584. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128585. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128586. * @param onLoad — defines a callback called when texture is loaded
  128587. * @param onError — defines a callback called if there is an error
  128588. */
  128589. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  128590. /**
  128591. * Load the image data, by putting the image on a canvas and extracting its buffer.
  128592. */
  128593. private loadImage;
  128594. /**
  128595. * Convert the image buffer into a cubemap and create a CubeTexture.
  128596. */
  128597. private loadTexture;
  128598. /**
  128599. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  128600. * @param buffer The ArrayBuffer that should be converted.
  128601. * @returns The buffer as Float32Array.
  128602. */
  128603. private getFloat32ArrayFromArrayBuffer;
  128604. /**
  128605. * Get the current class name of the texture useful for serialization or dynamic coding.
  128606. * @returns "EquiRectangularCubeTexture"
  128607. */
  128608. getClassName(): string;
  128609. /**
  128610. * Create a clone of the current EquiRectangularCubeTexture and return it.
  128611. * @returns A clone of the current EquiRectangularCubeTexture.
  128612. */
  128613. clone(): EquiRectangularCubeTexture;
  128614. }
  128615. }
  128616. declare module BABYLON {
  128617. /**
  128618. * Based on jsTGALoader - Javascript loader for TGA file
  128619. * By Vincent Thibault
  128620. * @see http://blog.robrowser.com/javascript-tga-loader.html
  128621. */
  128622. export class TGATools {
  128623. private static _TYPE_INDEXED;
  128624. private static _TYPE_RGB;
  128625. private static _TYPE_GREY;
  128626. private static _TYPE_RLE_INDEXED;
  128627. private static _TYPE_RLE_RGB;
  128628. private static _TYPE_RLE_GREY;
  128629. private static _ORIGIN_MASK;
  128630. private static _ORIGIN_SHIFT;
  128631. private static _ORIGIN_BL;
  128632. private static _ORIGIN_BR;
  128633. private static _ORIGIN_UL;
  128634. private static _ORIGIN_UR;
  128635. /**
  128636. * Gets the header of a TGA file
  128637. * @param data defines the TGA data
  128638. * @returns the header
  128639. */
  128640. static GetTGAHeader(data: Uint8Array): any;
  128641. /**
  128642. * Uploads TGA content to a Babylon Texture
  128643. * @hidden
  128644. */
  128645. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  128646. /** @hidden */
  128647. 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;
  128648. /** @hidden */
  128649. 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;
  128650. /** @hidden */
  128651. 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;
  128652. /** @hidden */
  128653. 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;
  128654. /** @hidden */
  128655. 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;
  128656. /** @hidden */
  128657. 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;
  128658. }
  128659. }
  128660. declare module BABYLON {
  128661. /**
  128662. * Implementation of the TGA Texture Loader.
  128663. * @hidden
  128664. */
  128665. export class _TGATextureLoader implements IInternalTextureLoader {
  128666. /**
  128667. * Defines wether the loader supports cascade loading the different faces.
  128668. */
  128669. readonly supportCascades: boolean;
  128670. /**
  128671. * This returns if the loader support the current file information.
  128672. * @param extension defines the file extension of the file being loaded
  128673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128674. * @param fallback defines the fallback internal texture if any
  128675. * @param isBase64 defines whether the texture is encoded as a base64
  128676. * @param isBuffer defines whether the texture data are stored as a buffer
  128677. * @returns true if the loader can load the specified file
  128678. */
  128679. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128680. /**
  128681. * Transform the url before loading if required.
  128682. * @param rootUrl the url of the texture
  128683. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128684. * @returns the transformed texture
  128685. */
  128686. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128687. /**
  128688. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128689. * @param rootUrl the url of the texture
  128690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128691. * @returns the fallback texture
  128692. */
  128693. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128694. /**
  128695. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  128696. * @param data contains the texture data
  128697. * @param texture defines the BabylonJS internal texture
  128698. * @param createPolynomials will be true if polynomials have been requested
  128699. * @param onLoad defines the callback to trigger once the texture is ready
  128700. * @param onError defines the callback to trigger in case of error
  128701. */
  128702. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128703. /**
  128704. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128705. * @param data contains the texture data
  128706. * @param texture defines the BabylonJS internal texture
  128707. * @param callback defines the method to call once ready to upload
  128708. */
  128709. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128710. }
  128711. }
  128712. declare module BABYLON {
  128713. /**
  128714. * Info about the .basis files
  128715. */
  128716. class BasisFileInfo {
  128717. /**
  128718. * If the file has alpha
  128719. */
  128720. hasAlpha: boolean;
  128721. /**
  128722. * Info about each image of the basis file
  128723. */
  128724. images: Array<{
  128725. levels: Array<{
  128726. width: number;
  128727. height: number;
  128728. transcodedPixels: ArrayBufferView;
  128729. }>;
  128730. }>;
  128731. }
  128732. /**
  128733. * Result of transcoding a basis file
  128734. */
  128735. class TranscodeResult {
  128736. /**
  128737. * Info about the .basis file
  128738. */
  128739. fileInfo: BasisFileInfo;
  128740. /**
  128741. * Format to use when loading the file
  128742. */
  128743. format: number;
  128744. }
  128745. /**
  128746. * Configuration options for the Basis transcoder
  128747. */
  128748. export class BasisTranscodeConfiguration {
  128749. /**
  128750. * Supported compression formats used to determine the supported output format of the transcoder
  128751. */
  128752. supportedCompressionFormats?: {
  128753. /**
  128754. * etc1 compression format
  128755. */
  128756. etc1?: boolean;
  128757. /**
  128758. * s3tc compression format
  128759. */
  128760. s3tc?: boolean;
  128761. /**
  128762. * pvrtc compression format
  128763. */
  128764. pvrtc?: boolean;
  128765. /**
  128766. * etc2 compression format
  128767. */
  128768. etc2?: boolean;
  128769. };
  128770. /**
  128771. * If mipmap levels should be loaded for transcoded images (Default: true)
  128772. */
  128773. loadMipmapLevels?: boolean;
  128774. /**
  128775. * Index of a single image to load (Default: all images)
  128776. */
  128777. loadSingleImage?: number;
  128778. }
  128779. /**
  128780. * Used to load .Basis files
  128781. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  128782. */
  128783. export class BasisTools {
  128784. private static _IgnoreSupportedFormats;
  128785. /**
  128786. * URL to use when loading the basis transcoder
  128787. */
  128788. static JSModuleURL: string;
  128789. /**
  128790. * URL to use when loading the wasm module for the transcoder
  128791. */
  128792. static WasmModuleURL: string;
  128793. /**
  128794. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  128795. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  128796. * @returns internal format corresponding to the Basis format
  128797. */
  128798. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  128799. private static _WorkerPromise;
  128800. private static _Worker;
  128801. private static _actionId;
  128802. private static _CreateWorkerAsync;
  128803. /**
  128804. * Transcodes a loaded image file to compressed pixel data
  128805. * @param data image data to transcode
  128806. * @param config configuration options for the transcoding
  128807. * @returns a promise resulting in the transcoded image
  128808. */
  128809. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  128810. /**
  128811. * Loads a texture from the transcode result
  128812. * @param texture texture load to
  128813. * @param transcodeResult the result of transcoding the basis file to load from
  128814. */
  128815. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  128816. }
  128817. }
  128818. declare module BABYLON {
  128819. /**
  128820. * Loader for .basis file format
  128821. */
  128822. export class _BasisTextureLoader implements IInternalTextureLoader {
  128823. /**
  128824. * Defines whether the loader supports cascade loading the different faces.
  128825. */
  128826. readonly supportCascades: boolean;
  128827. /**
  128828. * This returns if the loader support the current file information.
  128829. * @param extension defines the file extension of the file being loaded
  128830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128831. * @param fallback defines the fallback internal texture if any
  128832. * @param isBase64 defines whether the texture is encoded as a base64
  128833. * @param isBuffer defines whether the texture data are stored as a buffer
  128834. * @returns true if the loader can load the specified file
  128835. */
  128836. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128837. /**
  128838. * Transform the url before loading if required.
  128839. * @param rootUrl the url of the texture
  128840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128841. * @returns the transformed texture
  128842. */
  128843. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128844. /**
  128845. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128846. * @param rootUrl the url of the texture
  128847. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128848. * @returns the fallback texture
  128849. */
  128850. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128851. /**
  128852. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  128853. * @param data contains the texture data
  128854. * @param texture defines the BabylonJS internal texture
  128855. * @param createPolynomials will be true if polynomials have been requested
  128856. * @param onLoad defines the callback to trigger once the texture is ready
  128857. * @param onError defines the callback to trigger in case of error
  128858. */
  128859. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128860. /**
  128861. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128862. * @param data contains the texture data
  128863. * @param texture defines the BabylonJS internal texture
  128864. * @param callback defines the method to call once ready to upload
  128865. */
  128866. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128867. }
  128868. }
  128869. declare module BABYLON {
  128870. /**
  128871. * 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.
  128872. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128873. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128874. */
  128875. export class CustomProceduralTexture extends ProceduralTexture {
  128876. private _animate;
  128877. private _time;
  128878. private _config;
  128879. private _texturePath;
  128880. /**
  128881. * Instantiates a new Custom Procedural Texture.
  128882. * 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.
  128883. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128884. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128885. * @param name Define the name of the texture
  128886. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  128887. * @param size Define the size of the texture to create
  128888. * @param scene Define the scene the texture belongs to
  128889. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  128890. * @param generateMipMaps Define if the texture should creates mip maps or not
  128891. */
  128892. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128893. private _loadJson;
  128894. /**
  128895. * Is the texture ready to be used ? (rendered at least once)
  128896. * @returns true if ready, otherwise, false.
  128897. */
  128898. isReady(): boolean;
  128899. /**
  128900. * Render the texture to its associated render target.
  128901. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  128902. */
  128903. render(useCameraPostProcess?: boolean): void;
  128904. /**
  128905. * Update the list of dependant textures samplers in the shader.
  128906. */
  128907. updateTextures(): void;
  128908. /**
  128909. * Update the uniform values of the procedural texture in the shader.
  128910. */
  128911. updateShaderUniforms(): void;
  128912. /**
  128913. * Define if the texture animates or not.
  128914. */
  128915. get animate(): boolean;
  128916. set animate(value: boolean);
  128917. }
  128918. }
  128919. declare module BABYLON {
  128920. /** @hidden */
  128921. export var noisePixelShader: {
  128922. name: string;
  128923. shader: string;
  128924. };
  128925. }
  128926. declare module BABYLON {
  128927. /**
  128928. * Class used to generate noise procedural textures
  128929. */
  128930. export class NoiseProceduralTexture extends ProceduralTexture {
  128931. private _time;
  128932. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  128933. brightness: number;
  128934. /** Defines the number of octaves to process */
  128935. octaves: number;
  128936. /** Defines the level of persistence (0.8 by default) */
  128937. persistence: number;
  128938. /** Gets or sets animation speed factor (default is 1) */
  128939. animationSpeedFactor: number;
  128940. /**
  128941. * Creates a new NoiseProceduralTexture
  128942. * @param name defines the name fo the texture
  128943. * @param size defines the size of the texture (default is 256)
  128944. * @param scene defines the hosting scene
  128945. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  128946. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  128947. */
  128948. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128949. private _updateShaderUniforms;
  128950. protected _getDefines(): string;
  128951. /** Generate the current state of the procedural texture */
  128952. render(useCameraPostProcess?: boolean): void;
  128953. /**
  128954. * Serializes this noise procedural texture
  128955. * @returns a serialized noise procedural texture object
  128956. */
  128957. serialize(): any;
  128958. /**
  128959. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  128960. * @param parsedTexture defines parsed texture data
  128961. * @param scene defines the current scene
  128962. * @param rootUrl defines the root URL containing noise procedural texture information
  128963. * @returns a parsed NoiseProceduralTexture
  128964. */
  128965. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  128966. }
  128967. }
  128968. declare module BABYLON {
  128969. /**
  128970. * Raw cube texture where the raw buffers are passed in
  128971. */
  128972. export class RawCubeTexture extends CubeTexture {
  128973. /**
  128974. * Creates a cube texture where the raw buffers are passed in.
  128975. * @param scene defines the scene the texture is attached to
  128976. * @param data defines the array of data to use to create each face
  128977. * @param size defines the size of the textures
  128978. * @param format defines the format of the data
  128979. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  128980. * @param generateMipMaps defines if the engine should generate the mip levels
  128981. * @param invertY defines if data must be stored with Y axis inverted
  128982. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  128983. * @param compression defines the compression used (null by default)
  128984. */
  128985. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  128986. /**
  128987. * Updates the raw cube texture.
  128988. * @param data defines the data to store
  128989. * @param format defines the data format
  128990. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  128991. * @param invertY defines if data must be stored with Y axis inverted
  128992. * @param compression defines the compression used (null by default)
  128993. * @param level defines which level of the texture to update
  128994. */
  128995. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  128996. /**
  128997. * Updates a raw cube texture with RGBD encoded data.
  128998. * @param data defines the array of data [mipmap][face] to use to create each face
  128999. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129000. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129001. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129002. * @returns a promsie that resolves when the operation is complete
  129003. */
  129004. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129005. /**
  129006. * Clones the raw cube texture.
  129007. * @return a new cube texture
  129008. */
  129009. clone(): CubeTexture;
  129010. /** @hidden */
  129011. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129012. }
  129013. }
  129014. declare module BABYLON {
  129015. /**
  129016. * Class used to store 3D textures containing user data
  129017. */
  129018. export class RawTexture3D extends Texture {
  129019. /** Gets or sets the texture format to use */
  129020. format: number;
  129021. private _engine;
  129022. /**
  129023. * Create a new RawTexture3D
  129024. * @param data defines the data of the texture
  129025. * @param width defines the width of the texture
  129026. * @param height defines the height of the texture
  129027. * @param depth defines the depth of the texture
  129028. * @param format defines the texture format to use
  129029. * @param scene defines the hosting scene
  129030. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129031. * @param invertY defines if texture must be stored with Y axis inverted
  129032. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129033. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129034. */
  129035. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129036. /** Gets or sets the texture format to use */
  129037. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129038. /**
  129039. * Update the texture with new data
  129040. * @param data defines the data to store in the texture
  129041. */
  129042. update(data: ArrayBufferView): void;
  129043. }
  129044. }
  129045. declare module BABYLON {
  129046. /**
  129047. * Class used to store 2D array textures containing user data
  129048. */
  129049. export class RawTexture2DArray extends Texture {
  129050. /** Gets or sets the texture format to use */
  129051. format: number;
  129052. private _engine;
  129053. /**
  129054. * Create a new RawTexture2DArray
  129055. * @param data defines the data of the texture
  129056. * @param width defines the width of the texture
  129057. * @param height defines the height of the texture
  129058. * @param depth defines the number of layers of the texture
  129059. * @param format defines the texture format to use
  129060. * @param scene defines the hosting scene
  129061. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129062. * @param invertY defines if texture must be stored with Y axis inverted
  129063. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129064. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129065. */
  129066. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129067. /** Gets or sets the texture format to use */
  129068. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129069. /**
  129070. * Update the texture with new data
  129071. * @param data defines the data to store in the texture
  129072. */
  129073. update(data: ArrayBufferView): void;
  129074. }
  129075. }
  129076. declare module BABYLON {
  129077. /**
  129078. * Creates a refraction texture used by refraction channel of the standard material.
  129079. * It is like a mirror but to see through a material.
  129080. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129081. */
  129082. export class RefractionTexture extends RenderTargetTexture {
  129083. /**
  129084. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129085. * 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.
  129086. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129087. */
  129088. refractionPlane: Plane;
  129089. /**
  129090. * Define how deep under the surface we should see.
  129091. */
  129092. depth: number;
  129093. /**
  129094. * Creates a refraction texture used by refraction channel of the standard material.
  129095. * It is like a mirror but to see through a material.
  129096. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129097. * @param name Define the texture name
  129098. * @param size Define the size of the underlying texture
  129099. * @param scene Define the scene the refraction belongs to
  129100. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129101. */
  129102. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129103. /**
  129104. * Clone the refraction texture.
  129105. * @returns the cloned texture
  129106. */
  129107. clone(): RefractionTexture;
  129108. /**
  129109. * Serialize the texture to a JSON representation you could use in Parse later on
  129110. * @returns the serialized JSON representation
  129111. */
  129112. serialize(): any;
  129113. }
  129114. }
  129115. declare module BABYLON {
  129116. /**
  129117. * Defines the options related to the creation of an HtmlElementTexture
  129118. */
  129119. export interface IHtmlElementTextureOptions {
  129120. /**
  129121. * Defines wether mip maps should be created or not.
  129122. */
  129123. generateMipMaps?: boolean;
  129124. /**
  129125. * Defines the sampling mode of the texture.
  129126. */
  129127. samplingMode?: number;
  129128. /**
  129129. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129130. */
  129131. engine: Nullable<ThinEngine>;
  129132. /**
  129133. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129134. */
  129135. scene: Nullable<Scene>;
  129136. }
  129137. /**
  129138. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129139. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129140. * is automatically managed.
  129141. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129142. * in your application.
  129143. *
  129144. * As the update is not automatic, you need to call them manually.
  129145. */
  129146. export class HtmlElementTexture extends BaseTexture {
  129147. /**
  129148. * The texture URL.
  129149. */
  129150. element: HTMLVideoElement | HTMLCanvasElement;
  129151. private static readonly DefaultOptions;
  129152. private _textureMatrix;
  129153. private _engine;
  129154. private _isVideo;
  129155. private _generateMipMaps;
  129156. private _samplingMode;
  129157. /**
  129158. * Instantiates a HtmlElementTexture from the following parameters.
  129159. *
  129160. * @param name Defines the name of the texture
  129161. * @param element Defines the video or canvas the texture is filled with
  129162. * @param options Defines the other none mandatory texture creation options
  129163. */
  129164. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129165. private _createInternalTexture;
  129166. /**
  129167. * Returns the texture matrix used in most of the material.
  129168. */
  129169. getTextureMatrix(): Matrix;
  129170. /**
  129171. * Updates the content of the texture.
  129172. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129173. */
  129174. update(invertY?: Nullable<boolean>): void;
  129175. }
  129176. }
  129177. declare module BABYLON {
  129178. /**
  129179. * Enum used to define the target of a block
  129180. */
  129181. export enum NodeMaterialBlockTargets {
  129182. /** Vertex shader */
  129183. Vertex = 1,
  129184. /** Fragment shader */
  129185. Fragment = 2,
  129186. /** Neutral */
  129187. Neutral = 4,
  129188. /** Vertex and Fragment */
  129189. VertexAndFragment = 3
  129190. }
  129191. }
  129192. declare module BABYLON {
  129193. /**
  129194. * Defines the kind of connection point for node based material
  129195. */
  129196. export enum NodeMaterialBlockConnectionPointTypes {
  129197. /** Float */
  129198. Float = 1,
  129199. /** Int */
  129200. Int = 2,
  129201. /** Vector2 */
  129202. Vector2 = 4,
  129203. /** Vector3 */
  129204. Vector3 = 8,
  129205. /** Vector4 */
  129206. Vector4 = 16,
  129207. /** Color3 */
  129208. Color3 = 32,
  129209. /** Color4 */
  129210. Color4 = 64,
  129211. /** Matrix */
  129212. Matrix = 128,
  129213. /** Detect type based on connection */
  129214. AutoDetect = 1024,
  129215. /** Output type that will be defined by input type */
  129216. BasedOnInput = 2048
  129217. }
  129218. }
  129219. declare module BABYLON {
  129220. /**
  129221. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129222. */
  129223. export enum NodeMaterialBlockConnectionPointMode {
  129224. /** Value is an uniform */
  129225. Uniform = 0,
  129226. /** Value is a mesh attribute */
  129227. Attribute = 1,
  129228. /** Value is a varying between vertex and fragment shaders */
  129229. Varying = 2,
  129230. /** Mode is undefined */
  129231. Undefined = 3
  129232. }
  129233. }
  129234. declare module BABYLON {
  129235. /**
  129236. * Enum used to define system values e.g. values automatically provided by the system
  129237. */
  129238. export enum NodeMaterialSystemValues {
  129239. /** World */
  129240. World = 1,
  129241. /** View */
  129242. View = 2,
  129243. /** Projection */
  129244. Projection = 3,
  129245. /** ViewProjection */
  129246. ViewProjection = 4,
  129247. /** WorldView */
  129248. WorldView = 5,
  129249. /** WorldViewProjection */
  129250. WorldViewProjection = 6,
  129251. /** CameraPosition */
  129252. CameraPosition = 7,
  129253. /** Fog Color */
  129254. FogColor = 8,
  129255. /** Delta time */
  129256. DeltaTime = 9
  129257. }
  129258. }
  129259. declare module BABYLON {
  129260. /**
  129261. * Root class for all node material optimizers
  129262. */
  129263. export class NodeMaterialOptimizer {
  129264. /**
  129265. * Function used to optimize a NodeMaterial graph
  129266. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129267. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129268. */
  129269. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129270. }
  129271. }
  129272. declare module BABYLON {
  129273. /**
  129274. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129275. */
  129276. export class TransformBlock extends NodeMaterialBlock {
  129277. /**
  129278. * Defines the value to use to complement W value to transform it to a Vector4
  129279. */
  129280. complementW: number;
  129281. /**
  129282. * Defines the value to use to complement z value to transform it to a Vector4
  129283. */
  129284. complementZ: number;
  129285. /**
  129286. * Creates a new TransformBlock
  129287. * @param name defines the block name
  129288. */
  129289. constructor(name: string);
  129290. /**
  129291. * Gets the current class name
  129292. * @returns the class name
  129293. */
  129294. getClassName(): string;
  129295. /**
  129296. * Gets the vector input
  129297. */
  129298. get vector(): NodeMaterialConnectionPoint;
  129299. /**
  129300. * Gets the output component
  129301. */
  129302. get output(): NodeMaterialConnectionPoint;
  129303. /**
  129304. * Gets the matrix transform input
  129305. */
  129306. get transform(): NodeMaterialConnectionPoint;
  129307. protected _buildBlock(state: NodeMaterialBuildState): this;
  129308. serialize(): any;
  129309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129310. protected _dumpPropertiesCode(): string;
  129311. }
  129312. }
  129313. declare module BABYLON {
  129314. /**
  129315. * Block used to output the vertex position
  129316. */
  129317. export class VertexOutputBlock extends NodeMaterialBlock {
  129318. /**
  129319. * Creates a new VertexOutputBlock
  129320. * @param name defines the block name
  129321. */
  129322. constructor(name: string);
  129323. /**
  129324. * Gets the current class name
  129325. * @returns the class name
  129326. */
  129327. getClassName(): string;
  129328. /**
  129329. * Gets the vector input component
  129330. */
  129331. get vector(): NodeMaterialConnectionPoint;
  129332. protected _buildBlock(state: NodeMaterialBuildState): this;
  129333. }
  129334. }
  129335. declare module BABYLON {
  129336. /**
  129337. * Block used to output the final color
  129338. */
  129339. export class FragmentOutputBlock extends NodeMaterialBlock {
  129340. /**
  129341. * Create a new FragmentOutputBlock
  129342. * @param name defines the block name
  129343. */
  129344. constructor(name: string);
  129345. /**
  129346. * Gets the current class name
  129347. * @returns the class name
  129348. */
  129349. getClassName(): string;
  129350. /**
  129351. * Gets the rgba input component
  129352. */
  129353. get rgba(): NodeMaterialConnectionPoint;
  129354. /**
  129355. * Gets the rgb input component
  129356. */
  129357. get rgb(): NodeMaterialConnectionPoint;
  129358. /**
  129359. * Gets the a input component
  129360. */
  129361. get a(): NodeMaterialConnectionPoint;
  129362. protected _buildBlock(state: NodeMaterialBuildState): this;
  129363. }
  129364. }
  129365. declare module BABYLON {
  129366. /**
  129367. * Block used to read a reflection texture from a sampler
  129368. */
  129369. export class ReflectionTextureBlock extends NodeMaterialBlock {
  129370. private _define3DName;
  129371. private _defineCubicName;
  129372. private _defineExplicitName;
  129373. private _defineProjectionName;
  129374. private _defineLocalCubicName;
  129375. private _defineSphericalName;
  129376. private _definePlanarName;
  129377. private _defineEquirectangularName;
  129378. private _defineMirroredEquirectangularFixedName;
  129379. private _defineEquirectangularFixedName;
  129380. private _defineSkyboxName;
  129381. private _cubeSamplerName;
  129382. private _2DSamplerName;
  129383. private _positionUVWName;
  129384. private _directionWName;
  129385. private _reflectionCoordsName;
  129386. private _reflection2DCoordsName;
  129387. private _reflectionColorName;
  129388. private _reflectionMatrixName;
  129389. /**
  129390. * Gets or sets the texture associated with the node
  129391. */
  129392. texture: Nullable<BaseTexture>;
  129393. /**
  129394. * Create a new TextureBlock
  129395. * @param name defines the block name
  129396. */
  129397. constructor(name: string);
  129398. /**
  129399. * Gets the current class name
  129400. * @returns the class name
  129401. */
  129402. getClassName(): string;
  129403. /**
  129404. * Gets the world position input component
  129405. */
  129406. get position(): NodeMaterialConnectionPoint;
  129407. /**
  129408. * Gets the world position input component
  129409. */
  129410. get worldPosition(): NodeMaterialConnectionPoint;
  129411. /**
  129412. * Gets the world normal input component
  129413. */
  129414. get worldNormal(): NodeMaterialConnectionPoint;
  129415. /**
  129416. * Gets the world input component
  129417. */
  129418. get world(): NodeMaterialConnectionPoint;
  129419. /**
  129420. * Gets the camera (or eye) position component
  129421. */
  129422. get cameraPosition(): NodeMaterialConnectionPoint;
  129423. /**
  129424. * Gets the view input component
  129425. */
  129426. get view(): NodeMaterialConnectionPoint;
  129427. /**
  129428. * Gets the rgb output component
  129429. */
  129430. get rgb(): NodeMaterialConnectionPoint;
  129431. /**
  129432. * Gets the r output component
  129433. */
  129434. get r(): NodeMaterialConnectionPoint;
  129435. /**
  129436. * Gets the g output component
  129437. */
  129438. get g(): NodeMaterialConnectionPoint;
  129439. /**
  129440. * Gets the b output component
  129441. */
  129442. get b(): NodeMaterialConnectionPoint;
  129443. autoConfigure(material: NodeMaterial): void;
  129444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129445. isReady(): boolean;
  129446. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129447. private _injectVertexCode;
  129448. private _writeOutput;
  129449. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129450. protected _dumpPropertiesCode(): string;
  129451. serialize(): any;
  129452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129453. }
  129454. }
  129455. declare module BABYLON {
  129456. /**
  129457. * Interface used to configure the node material editor
  129458. */
  129459. export interface INodeMaterialEditorOptions {
  129460. /** Define the URl to load node editor script */
  129461. editorURL?: string;
  129462. }
  129463. /** @hidden */
  129464. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  129465. NORMAL: boolean;
  129466. TANGENT: boolean;
  129467. UV1: boolean;
  129468. /** BONES */
  129469. NUM_BONE_INFLUENCERS: number;
  129470. BonesPerMesh: number;
  129471. BONETEXTURE: boolean;
  129472. /** MORPH TARGETS */
  129473. MORPHTARGETS: boolean;
  129474. MORPHTARGETS_NORMAL: boolean;
  129475. MORPHTARGETS_TANGENT: boolean;
  129476. MORPHTARGETS_UV: boolean;
  129477. NUM_MORPH_INFLUENCERS: number;
  129478. /** IMAGE PROCESSING */
  129479. IMAGEPROCESSING: boolean;
  129480. VIGNETTE: boolean;
  129481. VIGNETTEBLENDMODEMULTIPLY: boolean;
  129482. VIGNETTEBLENDMODEOPAQUE: boolean;
  129483. TONEMAPPING: boolean;
  129484. TONEMAPPING_ACES: boolean;
  129485. CONTRAST: boolean;
  129486. EXPOSURE: boolean;
  129487. COLORCURVES: boolean;
  129488. COLORGRADING: boolean;
  129489. COLORGRADING3D: boolean;
  129490. SAMPLER3DGREENDEPTH: boolean;
  129491. SAMPLER3DBGRMAP: boolean;
  129492. IMAGEPROCESSINGPOSTPROCESS: boolean;
  129493. /** MISC. */
  129494. BUMPDIRECTUV: number;
  129495. constructor();
  129496. setValue(name: string, value: boolean): void;
  129497. }
  129498. /**
  129499. * Class used to configure NodeMaterial
  129500. */
  129501. export interface INodeMaterialOptions {
  129502. /**
  129503. * Defines if blocks should emit comments
  129504. */
  129505. emitComments: boolean;
  129506. }
  129507. /**
  129508. * Class used to create a node based material built by assembling shader blocks
  129509. */
  129510. export class NodeMaterial extends PushMaterial {
  129511. private static _BuildIdGenerator;
  129512. private _options;
  129513. private _vertexCompilationState;
  129514. private _fragmentCompilationState;
  129515. private _sharedData;
  129516. private _buildId;
  129517. private _buildWasSuccessful;
  129518. private _cachedWorldViewMatrix;
  129519. private _cachedWorldViewProjectionMatrix;
  129520. private _optimizers;
  129521. private _animationFrame;
  129522. /** Define the Url to load node editor script */
  129523. static EditorURL: string;
  129524. /** Define the Url to load snippets */
  129525. static SnippetUrl: string;
  129526. private BJSNODEMATERIALEDITOR;
  129527. /** Get the inspector from bundle or global */
  129528. private _getGlobalNodeMaterialEditor;
  129529. /**
  129530. * Gets or sets data used by visual editor
  129531. * @see https://nme.babylonjs.com
  129532. */
  129533. editorData: any;
  129534. /**
  129535. * 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)
  129536. */
  129537. ignoreAlpha: boolean;
  129538. /**
  129539. * Defines the maximum number of lights that can be used in the material
  129540. */
  129541. maxSimultaneousLights: number;
  129542. /**
  129543. * Observable raised when the material is built
  129544. */
  129545. onBuildObservable: Observable<NodeMaterial>;
  129546. /**
  129547. * Gets or sets the root nodes of the material vertex shader
  129548. */
  129549. _vertexOutputNodes: NodeMaterialBlock[];
  129550. /**
  129551. * Gets or sets the root nodes of the material fragment (pixel) shader
  129552. */
  129553. _fragmentOutputNodes: NodeMaterialBlock[];
  129554. /** Gets or sets options to control the node material overall behavior */
  129555. get options(): INodeMaterialOptions;
  129556. set options(options: INodeMaterialOptions);
  129557. /**
  129558. * Default configuration related to image processing available in the standard Material.
  129559. */
  129560. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129561. /**
  129562. * Gets the image processing configuration used either in this material.
  129563. */
  129564. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  129565. /**
  129566. * Sets the Default image processing configuration used either in the this material.
  129567. *
  129568. * If sets to null, the scene one is in use.
  129569. */
  129570. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  129571. /**
  129572. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  129573. */
  129574. attachedBlocks: NodeMaterialBlock[];
  129575. /**
  129576. * Create a new node based material
  129577. * @param name defines the material name
  129578. * @param scene defines the hosting scene
  129579. * @param options defines creation option
  129580. */
  129581. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  129582. /**
  129583. * Gets the current class name of the material e.g. "NodeMaterial"
  129584. * @returns the class name
  129585. */
  129586. getClassName(): string;
  129587. /**
  129588. * Keep track of the image processing observer to allow dispose and replace.
  129589. */
  129590. private _imageProcessingObserver;
  129591. /**
  129592. * Attaches a new image processing configuration to the Standard Material.
  129593. * @param configuration
  129594. */
  129595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129596. /**
  129597. * Get a block by its name
  129598. * @param name defines the name of the block to retrieve
  129599. * @returns the required block or null if not found
  129600. */
  129601. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  129602. /**
  129603. * Get a block by its name
  129604. * @param predicate defines the predicate used to find the good candidate
  129605. * @returns the required block or null if not found
  129606. */
  129607. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  129608. /**
  129609. * Get an input block by its name
  129610. * @param predicate defines the predicate used to find the good candidate
  129611. * @returns the required input block or null if not found
  129612. */
  129613. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  129614. /**
  129615. * Gets the list of input blocks attached to this material
  129616. * @returns an array of InputBlocks
  129617. */
  129618. getInputBlocks(): InputBlock[];
  129619. /**
  129620. * Adds a new optimizer to the list of optimizers
  129621. * @param optimizer defines the optimizers to add
  129622. * @returns the current material
  129623. */
  129624. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129625. /**
  129626. * Remove an optimizer from the list of optimizers
  129627. * @param optimizer defines the optimizers to remove
  129628. * @returns the current material
  129629. */
  129630. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129631. /**
  129632. * Add a new block to the list of output nodes
  129633. * @param node defines the node to add
  129634. * @returns the current material
  129635. */
  129636. addOutputNode(node: NodeMaterialBlock): this;
  129637. /**
  129638. * Remove a block from the list of root nodes
  129639. * @param node defines the node to remove
  129640. * @returns the current material
  129641. */
  129642. removeOutputNode(node: NodeMaterialBlock): this;
  129643. private _addVertexOutputNode;
  129644. private _removeVertexOutputNode;
  129645. private _addFragmentOutputNode;
  129646. private _removeFragmentOutputNode;
  129647. /**
  129648. * Specifies if the material will require alpha blending
  129649. * @returns a boolean specifying if alpha blending is needed
  129650. */
  129651. needAlphaBlending(): boolean;
  129652. /**
  129653. * Specifies if this material should be rendered in alpha test mode
  129654. * @returns a boolean specifying if an alpha test is needed.
  129655. */
  129656. needAlphaTesting(): boolean;
  129657. private _initializeBlock;
  129658. private _resetDualBlocks;
  129659. /**
  129660. * Remove a block from the current node material
  129661. * @param block defines the block to remove
  129662. */
  129663. removeBlock(block: NodeMaterialBlock): void;
  129664. /**
  129665. * Build the material and generates the inner effect
  129666. * @param verbose defines if the build should log activity
  129667. */
  129668. build(verbose?: boolean): void;
  129669. /**
  129670. * Runs an otpimization phase to try to improve the shader code
  129671. */
  129672. optimize(): void;
  129673. private _prepareDefinesForAttributes;
  129674. /**
  129675. * Get if the submesh is ready to be used and all its information available.
  129676. * Child classes can use it to update shaders
  129677. * @param mesh defines the mesh to check
  129678. * @param subMesh defines which submesh to check
  129679. * @param useInstances specifies that instances should be used
  129680. * @returns a boolean indicating that the submesh is ready or not
  129681. */
  129682. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  129683. /**
  129684. * Get a string representing the shaders built by the current node graph
  129685. */
  129686. get compiledShaders(): string;
  129687. /**
  129688. * Binds the world matrix to the material
  129689. * @param world defines the world transformation matrix
  129690. */
  129691. bindOnlyWorldMatrix(world: Matrix): void;
  129692. /**
  129693. * Binds the submesh to this material by preparing the effect and shader to draw
  129694. * @param world defines the world transformation matrix
  129695. * @param mesh defines the mesh containing the submesh
  129696. * @param subMesh defines the submesh to bind the material to
  129697. */
  129698. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  129699. /**
  129700. * Gets the active textures from the material
  129701. * @returns an array of textures
  129702. */
  129703. getActiveTextures(): BaseTexture[];
  129704. /**
  129705. * Gets the list of texture blocks
  129706. * @returns an array of texture blocks
  129707. */
  129708. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  129709. /**
  129710. * Specifies if the material uses a texture
  129711. * @param texture defines the texture to check against the material
  129712. * @returns a boolean specifying if the material uses the texture
  129713. */
  129714. hasTexture(texture: BaseTexture): boolean;
  129715. /**
  129716. * Disposes the material
  129717. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  129718. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  129719. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  129720. */
  129721. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  129722. /** Creates the node editor window. */
  129723. private _createNodeEditor;
  129724. /**
  129725. * Launch the node material editor
  129726. * @param config Define the configuration of the editor
  129727. * @return a promise fulfilled when the node editor is visible
  129728. */
  129729. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  129730. /**
  129731. * Clear the current material
  129732. */
  129733. clear(): void;
  129734. /**
  129735. * Clear the current material and set it to a default state
  129736. */
  129737. setToDefault(): void;
  129738. /**
  129739. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  129740. * @param url defines the url to load from
  129741. * @returns a promise that will fullfil when the material is fully loaded
  129742. */
  129743. loadAsync(url: string): Promise<void>;
  129744. private _gatherBlocks;
  129745. /**
  129746. * Generate a string containing the code declaration required to create an equivalent of this material
  129747. * @returns a string
  129748. */
  129749. generateCode(): string;
  129750. /**
  129751. * Serializes this material in a JSON representation
  129752. * @returns the serialized material object
  129753. */
  129754. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  129755. private _restoreConnections;
  129756. /**
  129757. * Clear the current graph and load a new one from a serialization object
  129758. * @param source defines the JSON representation of the material
  129759. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129760. */
  129761. loadFromSerialization(source: any, rootUrl?: string): void;
  129762. /**
  129763. * Creates a node material from parsed material data
  129764. * @param source defines the JSON representation of the material
  129765. * @param scene defines the hosting scene
  129766. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129767. * @returns a new node material
  129768. */
  129769. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  129770. /**
  129771. * Creates a node material from a snippet saved by the node material editor
  129772. * @param snippetId defines the snippet to load
  129773. * @param scene defines the hosting scene
  129774. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129775. * @returns a promise that will resolve to the new node material
  129776. */
  129777. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  129778. /**
  129779. * Creates a new node material set to default basic configuration
  129780. * @param name defines the name of the material
  129781. * @param scene defines the hosting scene
  129782. * @returns a new NodeMaterial
  129783. */
  129784. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  129785. }
  129786. }
  129787. declare module BABYLON {
  129788. /**
  129789. * Block used to read a texture from a sampler
  129790. */
  129791. export class TextureBlock extends NodeMaterialBlock {
  129792. private _defineName;
  129793. private _linearDefineName;
  129794. private _tempTextureRead;
  129795. private _samplerName;
  129796. private _transformedUVName;
  129797. private _textureTransformName;
  129798. private _textureInfoName;
  129799. private _mainUVName;
  129800. private _mainUVDefineName;
  129801. /**
  129802. * Gets or sets the texture associated with the node
  129803. */
  129804. texture: Nullable<Texture>;
  129805. /**
  129806. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  129807. */
  129808. convertToGammaSpace: boolean;
  129809. /**
  129810. * Create a new TextureBlock
  129811. * @param name defines the block name
  129812. */
  129813. constructor(name: string);
  129814. /**
  129815. * Gets the current class name
  129816. * @returns the class name
  129817. */
  129818. getClassName(): string;
  129819. /**
  129820. * Gets the uv input component
  129821. */
  129822. get uv(): NodeMaterialConnectionPoint;
  129823. /**
  129824. * Gets the rgba output component
  129825. */
  129826. get rgba(): NodeMaterialConnectionPoint;
  129827. /**
  129828. * Gets the rgb output component
  129829. */
  129830. get rgb(): NodeMaterialConnectionPoint;
  129831. /**
  129832. * Gets the r output component
  129833. */
  129834. get r(): NodeMaterialConnectionPoint;
  129835. /**
  129836. * Gets the g output component
  129837. */
  129838. get g(): NodeMaterialConnectionPoint;
  129839. /**
  129840. * Gets the b output component
  129841. */
  129842. get b(): NodeMaterialConnectionPoint;
  129843. /**
  129844. * Gets the a output component
  129845. */
  129846. get a(): NodeMaterialConnectionPoint;
  129847. get target(): NodeMaterialBlockTargets;
  129848. autoConfigure(material: NodeMaterial): void;
  129849. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  129850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129851. isReady(): boolean;
  129852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129853. private get _isMixed();
  129854. private _injectVertexCode;
  129855. private _writeTextureRead;
  129856. private _writeOutput;
  129857. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129858. protected _dumpPropertiesCode(): string;
  129859. serialize(): any;
  129860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129861. }
  129862. }
  129863. declare module BABYLON {
  129864. /**
  129865. * Class used to store shared data between 2 NodeMaterialBuildState
  129866. */
  129867. export class NodeMaterialBuildStateSharedData {
  129868. /**
  129869. * Gets the list of emitted varyings
  129870. */
  129871. temps: string[];
  129872. /**
  129873. * Gets the list of emitted varyings
  129874. */
  129875. varyings: string[];
  129876. /**
  129877. * Gets the varying declaration string
  129878. */
  129879. varyingDeclaration: string;
  129880. /**
  129881. * Input blocks
  129882. */
  129883. inputBlocks: InputBlock[];
  129884. /**
  129885. * Input blocks
  129886. */
  129887. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  129888. /**
  129889. * Bindable blocks (Blocks that need to set data to the effect)
  129890. */
  129891. bindableBlocks: NodeMaterialBlock[];
  129892. /**
  129893. * List of blocks that can provide a compilation fallback
  129894. */
  129895. blocksWithFallbacks: NodeMaterialBlock[];
  129896. /**
  129897. * List of blocks that can provide a define update
  129898. */
  129899. blocksWithDefines: NodeMaterialBlock[];
  129900. /**
  129901. * List of blocks that can provide a repeatable content
  129902. */
  129903. repeatableContentBlocks: NodeMaterialBlock[];
  129904. /**
  129905. * List of blocks that can provide a dynamic list of uniforms
  129906. */
  129907. dynamicUniformBlocks: NodeMaterialBlock[];
  129908. /**
  129909. * List of blocks that can block the isReady function for the material
  129910. */
  129911. blockingBlocks: NodeMaterialBlock[];
  129912. /**
  129913. * Gets the list of animated inputs
  129914. */
  129915. animatedInputs: InputBlock[];
  129916. /**
  129917. * Build Id used to avoid multiple recompilations
  129918. */
  129919. buildId: number;
  129920. /** List of emitted variables */
  129921. variableNames: {
  129922. [key: string]: number;
  129923. };
  129924. /** List of emitted defines */
  129925. defineNames: {
  129926. [key: string]: number;
  129927. };
  129928. /** Should emit comments? */
  129929. emitComments: boolean;
  129930. /** Emit build activity */
  129931. verbose: boolean;
  129932. /** Gets or sets the hosting scene */
  129933. scene: Scene;
  129934. /**
  129935. * Gets the compilation hints emitted at compilation time
  129936. */
  129937. hints: {
  129938. needWorldViewMatrix: boolean;
  129939. needWorldViewProjectionMatrix: boolean;
  129940. needAlphaBlending: boolean;
  129941. needAlphaTesting: boolean;
  129942. };
  129943. /**
  129944. * List of compilation checks
  129945. */
  129946. checks: {
  129947. emitVertex: boolean;
  129948. emitFragment: boolean;
  129949. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  129950. };
  129951. /** Creates a new shared data */
  129952. constructor();
  129953. /**
  129954. * Emits console errors and exceptions if there is a failing check
  129955. */
  129956. emitErrors(): void;
  129957. }
  129958. }
  129959. declare module BABYLON {
  129960. /**
  129961. * Class used to store node based material build state
  129962. */
  129963. export class NodeMaterialBuildState {
  129964. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  129965. supportUniformBuffers: boolean;
  129966. /**
  129967. * Gets the list of emitted attributes
  129968. */
  129969. attributes: string[];
  129970. /**
  129971. * Gets the list of emitted uniforms
  129972. */
  129973. uniforms: string[];
  129974. /**
  129975. * Gets the list of emitted constants
  129976. */
  129977. constants: string[];
  129978. /**
  129979. * Gets the list of emitted samplers
  129980. */
  129981. samplers: string[];
  129982. /**
  129983. * Gets the list of emitted functions
  129984. */
  129985. functions: {
  129986. [key: string]: string;
  129987. };
  129988. /**
  129989. * Gets the list of emitted extensions
  129990. */
  129991. extensions: {
  129992. [key: string]: string;
  129993. };
  129994. /**
  129995. * Gets the target of the compilation state
  129996. */
  129997. target: NodeMaterialBlockTargets;
  129998. /**
  129999. * Gets the list of emitted counters
  130000. */
  130001. counters: {
  130002. [key: string]: number;
  130003. };
  130004. /**
  130005. * Shared data between multiple NodeMaterialBuildState instances
  130006. */
  130007. sharedData: NodeMaterialBuildStateSharedData;
  130008. /** @hidden */
  130009. _vertexState: NodeMaterialBuildState;
  130010. /** @hidden */
  130011. _attributeDeclaration: string;
  130012. /** @hidden */
  130013. _uniformDeclaration: string;
  130014. /** @hidden */
  130015. _constantDeclaration: string;
  130016. /** @hidden */
  130017. _samplerDeclaration: string;
  130018. /** @hidden */
  130019. _varyingTransfer: string;
  130020. private _repeatableContentAnchorIndex;
  130021. /** @hidden */
  130022. _builtCompilationString: string;
  130023. /**
  130024. * Gets the emitted compilation strings
  130025. */
  130026. compilationString: string;
  130027. /**
  130028. * Finalize the compilation strings
  130029. * @param state defines the current compilation state
  130030. */
  130031. finalize(state: NodeMaterialBuildState): void;
  130032. /** @hidden */
  130033. get _repeatableContentAnchor(): string;
  130034. /** @hidden */
  130035. _getFreeVariableName(prefix: string): string;
  130036. /** @hidden */
  130037. _getFreeDefineName(prefix: string): string;
  130038. /** @hidden */
  130039. _excludeVariableName(name: string): void;
  130040. /** @hidden */
  130041. _emit2DSampler(name: string): void;
  130042. /** @hidden */
  130043. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130044. /** @hidden */
  130045. _emitExtension(name: string, extension: string): void;
  130046. /** @hidden */
  130047. _emitFunction(name: string, code: string, comments: string): void;
  130048. /** @hidden */
  130049. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130050. replaceStrings?: {
  130051. search: RegExp;
  130052. replace: string;
  130053. }[];
  130054. repeatKey?: string;
  130055. }): string;
  130056. /** @hidden */
  130057. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130058. repeatKey?: string;
  130059. removeAttributes?: boolean;
  130060. removeUniforms?: boolean;
  130061. removeVaryings?: boolean;
  130062. removeIfDef?: boolean;
  130063. replaceStrings?: {
  130064. search: RegExp;
  130065. replace: string;
  130066. }[];
  130067. }, storeKey?: string): void;
  130068. /** @hidden */
  130069. _registerTempVariable(name: string): boolean;
  130070. /** @hidden */
  130071. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130072. /** @hidden */
  130073. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130074. /** @hidden */
  130075. _emitFloat(value: number): string;
  130076. }
  130077. }
  130078. declare module BABYLON {
  130079. /**
  130080. * Defines a block that can be used inside a node based material
  130081. */
  130082. export class NodeMaterialBlock {
  130083. private _buildId;
  130084. private _buildTarget;
  130085. private _target;
  130086. private _isFinalMerger;
  130087. private _isInput;
  130088. protected _isUnique: boolean;
  130089. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130090. inputsAreExclusive: boolean;
  130091. /** @hidden */
  130092. _codeVariableName: string;
  130093. /** @hidden */
  130094. _inputs: NodeMaterialConnectionPoint[];
  130095. /** @hidden */
  130096. _outputs: NodeMaterialConnectionPoint[];
  130097. /** @hidden */
  130098. _preparationId: number;
  130099. /**
  130100. * Gets or sets the name of the block
  130101. */
  130102. name: string;
  130103. /**
  130104. * Gets or sets the unique id of the node
  130105. */
  130106. uniqueId: number;
  130107. /**
  130108. * Gets or sets the comments associated with this block
  130109. */
  130110. comments: string;
  130111. /**
  130112. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130113. */
  130114. get isUnique(): boolean;
  130115. /**
  130116. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130117. */
  130118. get isFinalMerger(): boolean;
  130119. /**
  130120. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130121. */
  130122. get isInput(): boolean;
  130123. /**
  130124. * Gets or sets the build Id
  130125. */
  130126. get buildId(): number;
  130127. set buildId(value: number);
  130128. /**
  130129. * Gets or sets the target of the block
  130130. */
  130131. get target(): NodeMaterialBlockTargets;
  130132. set target(value: NodeMaterialBlockTargets);
  130133. /**
  130134. * Gets the list of input points
  130135. */
  130136. get inputs(): NodeMaterialConnectionPoint[];
  130137. /** Gets the list of output points */
  130138. get outputs(): NodeMaterialConnectionPoint[];
  130139. /**
  130140. * Find an input by its name
  130141. * @param name defines the name of the input to look for
  130142. * @returns the input or null if not found
  130143. */
  130144. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130145. /**
  130146. * Find an output by its name
  130147. * @param name defines the name of the outputto look for
  130148. * @returns the output or null if not found
  130149. */
  130150. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130151. /**
  130152. * Creates a new NodeMaterialBlock
  130153. * @param name defines the block name
  130154. * @param target defines the target of that block (Vertex by default)
  130155. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130156. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130157. */
  130158. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130159. /**
  130160. * Initialize the block and prepare the context for build
  130161. * @param state defines the state that will be used for the build
  130162. */
  130163. initialize(state: NodeMaterialBuildState): void;
  130164. /**
  130165. * Bind data to effect. Will only be called for blocks with isBindable === true
  130166. * @param effect defines the effect to bind data to
  130167. * @param nodeMaterial defines the hosting NodeMaterial
  130168. * @param mesh defines the mesh that will be rendered
  130169. */
  130170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130171. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130172. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130173. protected _writeFloat(value: number): string;
  130174. /**
  130175. * Gets the current class name e.g. "NodeMaterialBlock"
  130176. * @returns the class name
  130177. */
  130178. getClassName(): string;
  130179. /**
  130180. * Register a new input. Must be called inside a block constructor
  130181. * @param name defines the connection point name
  130182. * @param type defines the connection point type
  130183. * @param isOptional defines a boolean indicating that this input can be omitted
  130184. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130185. * @returns the current block
  130186. */
  130187. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130188. /**
  130189. * Register a new output. Must be called inside a block constructor
  130190. * @param name defines the connection point name
  130191. * @param type defines the connection point type
  130192. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130193. * @returns the current block
  130194. */
  130195. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130196. /**
  130197. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130198. * @param forOutput defines an optional connection point to check compatibility with
  130199. * @returns the first available input or null
  130200. */
  130201. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130202. /**
  130203. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130204. * @param forBlock defines an optional block to check compatibility with
  130205. * @returns the first available input or null
  130206. */
  130207. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130208. /**
  130209. * Gets the sibling of the given output
  130210. * @param current defines the current output
  130211. * @returns the next output in the list or null
  130212. */
  130213. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130214. /**
  130215. * Connect current block with another block
  130216. * @param other defines the block to connect with
  130217. * @param options define the various options to help pick the right connections
  130218. * @returns the current block
  130219. */
  130220. connectTo(other: NodeMaterialBlock, options?: {
  130221. input?: string;
  130222. output?: string;
  130223. outputSwizzle?: string;
  130224. }): this | undefined;
  130225. protected _buildBlock(state: NodeMaterialBuildState): void;
  130226. /**
  130227. * Add uniforms, samplers and uniform buffers at compilation time
  130228. * @param state defines the state to update
  130229. * @param nodeMaterial defines the node material requesting the update
  130230. * @param defines defines the material defines to update
  130231. * @param uniformBuffers defines the list of uniform buffer names
  130232. */
  130233. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130234. /**
  130235. * Add potential fallbacks if shader compilation fails
  130236. * @param mesh defines the mesh to be rendered
  130237. * @param fallbacks defines the current prioritized list of fallbacks
  130238. */
  130239. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130240. /**
  130241. * Initialize defines for shader compilation
  130242. * @param mesh defines the mesh to be rendered
  130243. * @param nodeMaterial defines the node material requesting the update
  130244. * @param defines defines the material defines to update
  130245. * @param useInstances specifies that instances should be used
  130246. */
  130247. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130248. /**
  130249. * Update defines for shader compilation
  130250. * @param mesh defines the mesh to be rendered
  130251. * @param nodeMaterial defines the node material requesting the update
  130252. * @param defines defines the material defines to update
  130253. * @param useInstances specifies that instances should be used
  130254. */
  130255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130256. /**
  130257. * Lets the block try to connect some inputs automatically
  130258. * @param material defines the hosting NodeMaterial
  130259. */
  130260. autoConfigure(material: NodeMaterial): void;
  130261. /**
  130262. * Function called when a block is declared as repeatable content generator
  130263. * @param vertexShaderState defines the current compilation state for the vertex shader
  130264. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130265. * @param mesh defines the mesh to be rendered
  130266. * @param defines defines the material defines to update
  130267. */
  130268. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130269. /**
  130270. * Checks if the block is ready
  130271. * @param mesh defines the mesh to be rendered
  130272. * @param nodeMaterial defines the node material requesting the update
  130273. * @param defines defines the material defines to update
  130274. * @param useInstances specifies that instances should be used
  130275. * @returns true if the block is ready
  130276. */
  130277. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130278. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130279. private _processBuild;
  130280. /**
  130281. * Compile the current node and generate the shader code
  130282. * @param state defines the current compilation state (uniforms, samplers, current string)
  130283. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130284. * @returns true if already built
  130285. */
  130286. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130287. protected _inputRename(name: string): string;
  130288. protected _outputRename(name: string): string;
  130289. protected _dumpPropertiesCode(): string;
  130290. /** @hidden */
  130291. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130292. /** @hidden */
  130293. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130294. /**
  130295. * Clone the current block to a new identical block
  130296. * @param scene defines the hosting scene
  130297. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130298. * @returns a copy of the current block
  130299. */
  130300. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130301. /**
  130302. * Serializes this block in a JSON representation
  130303. * @returns the serialized block object
  130304. */
  130305. serialize(): any;
  130306. /** @hidden */
  130307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130308. /**
  130309. * Release resources
  130310. */
  130311. dispose(): void;
  130312. }
  130313. }
  130314. declare module BABYLON {
  130315. /**
  130316. * Enum defining the type of animations supported by InputBlock
  130317. */
  130318. export enum AnimatedInputBlockTypes {
  130319. /** No animation */
  130320. None = 0,
  130321. /** Time based animation. Will only work for floats */
  130322. Time = 1
  130323. }
  130324. }
  130325. declare module BABYLON {
  130326. /**
  130327. * Block used to expose an input value
  130328. */
  130329. export class InputBlock extends NodeMaterialBlock {
  130330. private _mode;
  130331. private _associatedVariableName;
  130332. private _storedValue;
  130333. private _valueCallback;
  130334. private _type;
  130335. private _animationType;
  130336. /** Gets or set a value used to limit the range of float values */
  130337. min: number;
  130338. /** Gets or set a value used to limit the range of float values */
  130339. max: number;
  130340. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  130341. isBoolean: boolean;
  130342. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  130343. matrixMode: number;
  130344. /** @hidden */
  130345. _systemValue: Nullable<NodeMaterialSystemValues>;
  130346. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  130347. visibleInInspector: boolean;
  130348. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  130349. isConstant: boolean;
  130350. /** Gets or sets the group to use to display this block in the Inspector */
  130351. groupInInspector: string;
  130352. /**
  130353. * Gets or sets the connection point type (default is float)
  130354. */
  130355. get type(): NodeMaterialBlockConnectionPointTypes;
  130356. /**
  130357. * Creates a new InputBlock
  130358. * @param name defines the block name
  130359. * @param target defines the target of that block (Vertex by default)
  130360. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  130361. */
  130362. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  130363. /**
  130364. * Gets the output component
  130365. */
  130366. get output(): NodeMaterialConnectionPoint;
  130367. /**
  130368. * Set the source of this connection point to a vertex attribute
  130369. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  130370. * @returns the current connection point
  130371. */
  130372. setAsAttribute(attributeName?: string): InputBlock;
  130373. /**
  130374. * Set the source of this connection point to a system value
  130375. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  130376. * @returns the current connection point
  130377. */
  130378. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  130379. /**
  130380. * Gets or sets the value of that point.
  130381. * Please note that this value will be ignored if valueCallback is defined
  130382. */
  130383. get value(): any;
  130384. set value(value: any);
  130385. /**
  130386. * Gets or sets a callback used to get the value of that point.
  130387. * Please note that setting this value will force the connection point to ignore the value property
  130388. */
  130389. get valueCallback(): () => any;
  130390. set valueCallback(value: () => any);
  130391. /**
  130392. * Gets or sets the associated variable name in the shader
  130393. */
  130394. get associatedVariableName(): string;
  130395. set associatedVariableName(value: string);
  130396. /** Gets or sets the type of animation applied to the input */
  130397. get animationType(): AnimatedInputBlockTypes;
  130398. set animationType(value: AnimatedInputBlockTypes);
  130399. /**
  130400. * Gets a boolean indicating that this connection point not defined yet
  130401. */
  130402. get isUndefined(): boolean;
  130403. /**
  130404. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  130405. * In this case the connection point name must be the name of the uniform to use.
  130406. * Can only be set on inputs
  130407. */
  130408. get isUniform(): boolean;
  130409. set isUniform(value: boolean);
  130410. /**
  130411. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  130412. * In this case the connection point name must be the name of the attribute to use
  130413. * Can only be set on inputs
  130414. */
  130415. get isAttribute(): boolean;
  130416. set isAttribute(value: boolean);
  130417. /**
  130418. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  130419. * Can only be set on exit points
  130420. */
  130421. get isVarying(): boolean;
  130422. set isVarying(value: boolean);
  130423. /**
  130424. * Gets a boolean indicating that the current connection point is a system value
  130425. */
  130426. get isSystemValue(): boolean;
  130427. /**
  130428. * Gets or sets the current well known value or null if not defined as a system value
  130429. */
  130430. get systemValue(): Nullable<NodeMaterialSystemValues>;
  130431. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  130432. /**
  130433. * Gets the current class name
  130434. * @returns the class name
  130435. */
  130436. getClassName(): string;
  130437. /**
  130438. * Animate the input if animationType !== None
  130439. * @param scene defines the rendering scene
  130440. */
  130441. animate(scene: Scene): void;
  130442. private _emitDefine;
  130443. initialize(state: NodeMaterialBuildState): void;
  130444. /**
  130445. * Set the input block to its default value (based on its type)
  130446. */
  130447. setDefaultValue(): void;
  130448. private _emitConstant;
  130449. private _emit;
  130450. /** @hidden */
  130451. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  130452. /** @hidden */
  130453. _transmit(effect: Effect, scene: Scene): void;
  130454. protected _buildBlock(state: NodeMaterialBuildState): void;
  130455. protected _dumpPropertiesCode(): string;
  130456. serialize(): any;
  130457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130458. }
  130459. }
  130460. declare module BABYLON {
  130461. /**
  130462. * Enum used to define the compatibility state between two connection points
  130463. */
  130464. export enum NodeMaterialConnectionPointCompatibilityStates {
  130465. /** Points are compatibles */
  130466. Compatible = 0,
  130467. /** Points are incompatible because of their types */
  130468. TypeIncompatible = 1,
  130469. /** Points are incompatible because of their targets (vertex vs fragment) */
  130470. TargetIncompatible = 2
  130471. }
  130472. /**
  130473. * Defines the direction of a connection point
  130474. */
  130475. export enum NodeMaterialConnectionPointDirection {
  130476. /** Input */
  130477. Input = 0,
  130478. /** Output */
  130479. Output = 1
  130480. }
  130481. /**
  130482. * Defines a connection point for a block
  130483. */
  130484. export class NodeMaterialConnectionPoint {
  130485. /** @hidden */
  130486. _ownerBlock: NodeMaterialBlock;
  130487. /** @hidden */
  130488. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  130489. private _endpoints;
  130490. private _associatedVariableName;
  130491. private _direction;
  130492. /** @hidden */
  130493. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130494. /** @hidden */
  130495. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130496. private _type;
  130497. /** @hidden */
  130498. _enforceAssociatedVariableName: boolean;
  130499. /** Gets the direction of the point */
  130500. get direction(): NodeMaterialConnectionPointDirection;
  130501. /**
  130502. * Gets or sets the additional types supported by this connection point
  130503. */
  130504. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130505. /**
  130506. * Gets or sets the additional types excluded by this connection point
  130507. */
  130508. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130509. /**
  130510. * Observable triggered when this point is connected
  130511. */
  130512. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  130513. /**
  130514. * Gets or sets the associated variable name in the shader
  130515. */
  130516. get associatedVariableName(): string;
  130517. set associatedVariableName(value: string);
  130518. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  130519. get innerType(): NodeMaterialBlockConnectionPointTypes;
  130520. /**
  130521. * Gets or sets the connection point type (default is float)
  130522. */
  130523. get type(): NodeMaterialBlockConnectionPointTypes;
  130524. set type(value: NodeMaterialBlockConnectionPointTypes);
  130525. /**
  130526. * Gets or sets the connection point name
  130527. */
  130528. name: string;
  130529. /**
  130530. * Gets or sets a boolean indicating that this connection point can be omitted
  130531. */
  130532. isOptional: boolean;
  130533. /**
  130534. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  130535. */
  130536. define: string;
  130537. /** @hidden */
  130538. _prioritizeVertex: boolean;
  130539. private _target;
  130540. /** Gets or sets the target of that connection point */
  130541. get target(): NodeMaterialBlockTargets;
  130542. set target(value: NodeMaterialBlockTargets);
  130543. /**
  130544. * Gets a boolean indicating that the current point is connected
  130545. */
  130546. get isConnected(): boolean;
  130547. /**
  130548. * Gets a boolean indicating that the current point is connected to an input block
  130549. */
  130550. get isConnectedToInputBlock(): boolean;
  130551. /**
  130552. * Gets a the connected input block (if any)
  130553. */
  130554. get connectInputBlock(): Nullable<InputBlock>;
  130555. /** Get the other side of the connection (if any) */
  130556. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  130557. /** Get the block that owns this connection point */
  130558. get ownerBlock(): NodeMaterialBlock;
  130559. /** Get the block connected on the other side of this connection (if any) */
  130560. get sourceBlock(): Nullable<NodeMaterialBlock>;
  130561. /** Get the block connected on the endpoints of this connection (if any) */
  130562. get connectedBlocks(): Array<NodeMaterialBlock>;
  130563. /** Gets the list of connected endpoints */
  130564. get endpoints(): NodeMaterialConnectionPoint[];
  130565. /** Gets a boolean indicating if that output point is connected to at least one input */
  130566. get hasEndpoints(): boolean;
  130567. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  130568. get isConnectedInVertexShader(): boolean;
  130569. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  130570. get isConnectedInFragmentShader(): boolean;
  130571. /**
  130572. * Creates a new connection point
  130573. * @param name defines the connection point name
  130574. * @param ownerBlock defines the block hosting this connection point
  130575. * @param direction defines the direction of the connection point
  130576. */
  130577. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  130578. /**
  130579. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  130580. * @returns the class name
  130581. */
  130582. getClassName(): string;
  130583. /**
  130584. * Gets a boolean indicating if the current point can be connected to another point
  130585. * @param connectionPoint defines the other connection point
  130586. * @returns a boolean
  130587. */
  130588. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  130589. /**
  130590. * Gets a number indicating if the current point can be connected to another point
  130591. * @param connectionPoint defines the other connection point
  130592. * @returns a number defining the compatibility state
  130593. */
  130594. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  130595. /**
  130596. * Connect this point to another connection point
  130597. * @param connectionPoint defines the other connection point
  130598. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  130599. * @returns the current connection point
  130600. */
  130601. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  130602. /**
  130603. * Disconnect this point from one of his endpoint
  130604. * @param endpoint defines the other connection point
  130605. * @returns the current connection point
  130606. */
  130607. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  130608. /**
  130609. * Serializes this point in a JSON representation
  130610. * @returns the serialized point object
  130611. */
  130612. serialize(): any;
  130613. /**
  130614. * Release resources
  130615. */
  130616. dispose(): void;
  130617. }
  130618. }
  130619. declare module BABYLON {
  130620. /**
  130621. * Block used to add support for vertex skinning (bones)
  130622. */
  130623. export class BonesBlock extends NodeMaterialBlock {
  130624. /**
  130625. * Creates a new BonesBlock
  130626. * @param name defines the block name
  130627. */
  130628. constructor(name: string);
  130629. /**
  130630. * Initialize the block and prepare the context for build
  130631. * @param state defines the state that will be used for the build
  130632. */
  130633. initialize(state: NodeMaterialBuildState): void;
  130634. /**
  130635. * Gets the current class name
  130636. * @returns the class name
  130637. */
  130638. getClassName(): string;
  130639. /**
  130640. * Gets the matrix indices input component
  130641. */
  130642. get matricesIndices(): NodeMaterialConnectionPoint;
  130643. /**
  130644. * Gets the matrix weights input component
  130645. */
  130646. get matricesWeights(): NodeMaterialConnectionPoint;
  130647. /**
  130648. * Gets the extra matrix indices input component
  130649. */
  130650. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  130651. /**
  130652. * Gets the extra matrix weights input component
  130653. */
  130654. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  130655. /**
  130656. * Gets the world input component
  130657. */
  130658. get world(): NodeMaterialConnectionPoint;
  130659. /**
  130660. * Gets the output component
  130661. */
  130662. get output(): NodeMaterialConnectionPoint;
  130663. autoConfigure(material: NodeMaterial): void;
  130664. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130667. protected _buildBlock(state: NodeMaterialBuildState): this;
  130668. }
  130669. }
  130670. declare module BABYLON {
  130671. /**
  130672. * Block used to add support for instances
  130673. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  130674. */
  130675. export class InstancesBlock extends NodeMaterialBlock {
  130676. /**
  130677. * Creates a new InstancesBlock
  130678. * @param name defines the block name
  130679. */
  130680. constructor(name: string);
  130681. /**
  130682. * Gets the current class name
  130683. * @returns the class name
  130684. */
  130685. getClassName(): string;
  130686. /**
  130687. * Gets the first world row input component
  130688. */
  130689. get world0(): NodeMaterialConnectionPoint;
  130690. /**
  130691. * Gets the second world row input component
  130692. */
  130693. get world1(): NodeMaterialConnectionPoint;
  130694. /**
  130695. * Gets the third world row input component
  130696. */
  130697. get world2(): NodeMaterialConnectionPoint;
  130698. /**
  130699. * Gets the forth world row input component
  130700. */
  130701. get world3(): NodeMaterialConnectionPoint;
  130702. /**
  130703. * Gets the world input component
  130704. */
  130705. get world(): NodeMaterialConnectionPoint;
  130706. /**
  130707. * Gets the output component
  130708. */
  130709. get output(): NodeMaterialConnectionPoint;
  130710. /**
  130711. * Gets the isntanceID component
  130712. */
  130713. get instanceID(): NodeMaterialConnectionPoint;
  130714. autoConfigure(material: NodeMaterial): void;
  130715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130716. protected _buildBlock(state: NodeMaterialBuildState): this;
  130717. }
  130718. }
  130719. declare module BABYLON {
  130720. /**
  130721. * Block used to add morph targets support to vertex shader
  130722. */
  130723. export class MorphTargetsBlock extends NodeMaterialBlock {
  130724. private _repeatableContentAnchor;
  130725. /**
  130726. * Create a new MorphTargetsBlock
  130727. * @param name defines the block name
  130728. */
  130729. constructor(name: string);
  130730. /**
  130731. * Gets the current class name
  130732. * @returns the class name
  130733. */
  130734. getClassName(): string;
  130735. /**
  130736. * Gets the position input component
  130737. */
  130738. get position(): NodeMaterialConnectionPoint;
  130739. /**
  130740. * Gets the normal input component
  130741. */
  130742. get normal(): NodeMaterialConnectionPoint;
  130743. /**
  130744. * Gets the tangent input component
  130745. */
  130746. get tangent(): NodeMaterialConnectionPoint;
  130747. /**
  130748. * Gets the tangent input component
  130749. */
  130750. get uv(): NodeMaterialConnectionPoint;
  130751. /**
  130752. * Gets the position output component
  130753. */
  130754. get positionOutput(): NodeMaterialConnectionPoint;
  130755. /**
  130756. * Gets the normal output component
  130757. */
  130758. get normalOutput(): NodeMaterialConnectionPoint;
  130759. /**
  130760. * Gets the tangent output component
  130761. */
  130762. get tangentOutput(): NodeMaterialConnectionPoint;
  130763. /**
  130764. * Gets the tangent output component
  130765. */
  130766. get uvOutput(): NodeMaterialConnectionPoint;
  130767. initialize(state: NodeMaterialBuildState): void;
  130768. autoConfigure(material: NodeMaterial): void;
  130769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130770. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130771. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130772. protected _buildBlock(state: NodeMaterialBuildState): this;
  130773. }
  130774. }
  130775. declare module BABYLON {
  130776. /**
  130777. * Block used to get data information from a light
  130778. */
  130779. export class LightInformationBlock extends NodeMaterialBlock {
  130780. private _lightDataUniformName;
  130781. private _lightColorUniformName;
  130782. private _lightTypeDefineName;
  130783. /**
  130784. * Gets or sets the light associated with this block
  130785. */
  130786. light: Nullable<Light>;
  130787. /**
  130788. * Creates a new LightInformationBlock
  130789. * @param name defines the block name
  130790. */
  130791. constructor(name: string);
  130792. /**
  130793. * Gets the current class name
  130794. * @returns the class name
  130795. */
  130796. getClassName(): string;
  130797. /**
  130798. * Gets the world position input component
  130799. */
  130800. get worldPosition(): NodeMaterialConnectionPoint;
  130801. /**
  130802. * Gets the direction output component
  130803. */
  130804. get direction(): NodeMaterialConnectionPoint;
  130805. /**
  130806. * Gets the direction output component
  130807. */
  130808. get color(): NodeMaterialConnectionPoint;
  130809. /**
  130810. * Gets the direction output component
  130811. */
  130812. get intensity(): NodeMaterialConnectionPoint;
  130813. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130815. protected _buildBlock(state: NodeMaterialBuildState): this;
  130816. serialize(): any;
  130817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130818. }
  130819. }
  130820. declare module BABYLON {
  130821. /**
  130822. * Block used to add image processing support to fragment shader
  130823. */
  130824. export class ImageProcessingBlock extends NodeMaterialBlock {
  130825. /**
  130826. * Create a new ImageProcessingBlock
  130827. * @param name defines the block name
  130828. */
  130829. constructor(name: string);
  130830. /**
  130831. * Gets the current class name
  130832. * @returns the class name
  130833. */
  130834. getClassName(): string;
  130835. /**
  130836. * Gets the color input component
  130837. */
  130838. get color(): NodeMaterialConnectionPoint;
  130839. /**
  130840. * Gets the output component
  130841. */
  130842. get output(): NodeMaterialConnectionPoint;
  130843. /**
  130844. * Initialize the block and prepare the context for build
  130845. * @param state defines the state that will be used for the build
  130846. */
  130847. initialize(state: NodeMaterialBuildState): void;
  130848. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  130849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130850. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130851. protected _buildBlock(state: NodeMaterialBuildState): this;
  130852. }
  130853. }
  130854. declare module BABYLON {
  130855. /**
  130856. * Block used to pertub normals based on a normal map
  130857. */
  130858. export class PerturbNormalBlock extends NodeMaterialBlock {
  130859. private _tangentSpaceParameterName;
  130860. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  130861. invertX: boolean;
  130862. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  130863. invertY: boolean;
  130864. /**
  130865. * Create a new PerturbNormalBlock
  130866. * @param name defines the block name
  130867. */
  130868. constructor(name: string);
  130869. /**
  130870. * Gets the current class name
  130871. * @returns the class name
  130872. */
  130873. getClassName(): string;
  130874. /**
  130875. * Gets the world position input component
  130876. */
  130877. get worldPosition(): NodeMaterialConnectionPoint;
  130878. /**
  130879. * Gets the world normal input component
  130880. */
  130881. get worldNormal(): NodeMaterialConnectionPoint;
  130882. /**
  130883. * Gets the world tangent input component
  130884. */
  130885. get worldTangent(): NodeMaterialConnectionPoint;
  130886. /**
  130887. * Gets the uv input component
  130888. */
  130889. get uv(): NodeMaterialConnectionPoint;
  130890. /**
  130891. * Gets the normal map color input component
  130892. */
  130893. get normalMapColor(): NodeMaterialConnectionPoint;
  130894. /**
  130895. * Gets the strength input component
  130896. */
  130897. get strength(): NodeMaterialConnectionPoint;
  130898. /**
  130899. * Gets the output component
  130900. */
  130901. get output(): NodeMaterialConnectionPoint;
  130902. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130903. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130904. autoConfigure(material: NodeMaterial): void;
  130905. protected _buildBlock(state: NodeMaterialBuildState): this;
  130906. protected _dumpPropertiesCode(): string;
  130907. serialize(): any;
  130908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130909. }
  130910. }
  130911. declare module BABYLON {
  130912. /**
  130913. * Block used to discard a pixel if a value is smaller than a cutoff
  130914. */
  130915. export class DiscardBlock extends NodeMaterialBlock {
  130916. /**
  130917. * Create a new DiscardBlock
  130918. * @param name defines the block name
  130919. */
  130920. constructor(name: string);
  130921. /**
  130922. * Gets the current class name
  130923. * @returns the class name
  130924. */
  130925. getClassName(): string;
  130926. /**
  130927. * Gets the color input component
  130928. */
  130929. get value(): NodeMaterialConnectionPoint;
  130930. /**
  130931. * Gets the cutoff input component
  130932. */
  130933. get cutoff(): NodeMaterialConnectionPoint;
  130934. protected _buildBlock(state: NodeMaterialBuildState): this;
  130935. }
  130936. }
  130937. declare module BABYLON {
  130938. /**
  130939. * Block used to test if the fragment shader is front facing
  130940. */
  130941. export class FrontFacingBlock extends NodeMaterialBlock {
  130942. /**
  130943. * Creates a new FrontFacingBlock
  130944. * @param name defines the block name
  130945. */
  130946. constructor(name: string);
  130947. /**
  130948. * Gets the current class name
  130949. * @returns the class name
  130950. */
  130951. getClassName(): string;
  130952. /**
  130953. * Gets the output component
  130954. */
  130955. get output(): NodeMaterialConnectionPoint;
  130956. protected _buildBlock(state: NodeMaterialBuildState): this;
  130957. }
  130958. }
  130959. declare module BABYLON {
  130960. /**
  130961. * Block used to get the derivative value on x and y of a given input
  130962. */
  130963. export class DerivativeBlock extends NodeMaterialBlock {
  130964. /**
  130965. * Create a new DerivativeBlock
  130966. * @param name defines the block name
  130967. */
  130968. constructor(name: string);
  130969. /**
  130970. * Gets the current class name
  130971. * @returns the class name
  130972. */
  130973. getClassName(): string;
  130974. /**
  130975. * Gets the input component
  130976. */
  130977. get input(): NodeMaterialConnectionPoint;
  130978. /**
  130979. * Gets the derivative output on x
  130980. */
  130981. get dx(): NodeMaterialConnectionPoint;
  130982. /**
  130983. * Gets the derivative output on y
  130984. */
  130985. get dy(): NodeMaterialConnectionPoint;
  130986. protected _buildBlock(state: NodeMaterialBuildState): this;
  130987. }
  130988. }
  130989. declare module BABYLON {
  130990. /**
  130991. * Block used to add support for scene fog
  130992. */
  130993. export class FogBlock extends NodeMaterialBlock {
  130994. private _fogDistanceName;
  130995. private _fogParameters;
  130996. /**
  130997. * Create a new FogBlock
  130998. * @param name defines the block name
  130999. */
  131000. constructor(name: string);
  131001. /**
  131002. * Gets the current class name
  131003. * @returns the class name
  131004. */
  131005. getClassName(): string;
  131006. /**
  131007. * Gets the world position input component
  131008. */
  131009. get worldPosition(): NodeMaterialConnectionPoint;
  131010. /**
  131011. * Gets the view input component
  131012. */
  131013. get view(): NodeMaterialConnectionPoint;
  131014. /**
  131015. * Gets the color input component
  131016. */
  131017. get input(): NodeMaterialConnectionPoint;
  131018. /**
  131019. * Gets the fog color input component
  131020. */
  131021. get fogColor(): NodeMaterialConnectionPoint;
  131022. /**
  131023. * Gets the output component
  131024. */
  131025. get output(): NodeMaterialConnectionPoint;
  131026. autoConfigure(material: NodeMaterial): void;
  131027. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131029. protected _buildBlock(state: NodeMaterialBuildState): this;
  131030. }
  131031. }
  131032. declare module BABYLON {
  131033. /**
  131034. * Block used to add light in the fragment shader
  131035. */
  131036. export class LightBlock extends NodeMaterialBlock {
  131037. private _lightId;
  131038. /**
  131039. * Gets or sets the light associated with this block
  131040. */
  131041. light: Nullable<Light>;
  131042. /**
  131043. * Create a new LightBlock
  131044. * @param name defines the block name
  131045. */
  131046. constructor(name: string);
  131047. /**
  131048. * Gets the current class name
  131049. * @returns the class name
  131050. */
  131051. getClassName(): string;
  131052. /**
  131053. * Gets the world position input component
  131054. */
  131055. get worldPosition(): NodeMaterialConnectionPoint;
  131056. /**
  131057. * Gets the world normal input component
  131058. */
  131059. get worldNormal(): NodeMaterialConnectionPoint;
  131060. /**
  131061. * Gets the camera (or eye) position component
  131062. */
  131063. get cameraPosition(): NodeMaterialConnectionPoint;
  131064. /**
  131065. * Gets the glossiness component
  131066. */
  131067. get glossiness(): NodeMaterialConnectionPoint;
  131068. /**
  131069. * Gets the glossinness power component
  131070. */
  131071. get glossPower(): NodeMaterialConnectionPoint;
  131072. /**
  131073. * Gets the diffuse color component
  131074. */
  131075. get diffuseColor(): NodeMaterialConnectionPoint;
  131076. /**
  131077. * Gets the specular color component
  131078. */
  131079. get specularColor(): NodeMaterialConnectionPoint;
  131080. /**
  131081. * Gets the diffuse output component
  131082. */
  131083. get diffuseOutput(): NodeMaterialConnectionPoint;
  131084. /**
  131085. * Gets the specular output component
  131086. */
  131087. get specularOutput(): NodeMaterialConnectionPoint;
  131088. /**
  131089. * Gets the shadow output component
  131090. */
  131091. get shadow(): NodeMaterialConnectionPoint;
  131092. autoConfigure(material: NodeMaterial): void;
  131093. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131094. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131095. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131096. private _injectVertexCode;
  131097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131098. serialize(): any;
  131099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131100. }
  131101. }
  131102. declare module BABYLON {
  131103. /**
  131104. * Block used to multiply 2 values
  131105. */
  131106. export class MultiplyBlock extends NodeMaterialBlock {
  131107. /**
  131108. * Creates a new MultiplyBlock
  131109. * @param name defines the block name
  131110. */
  131111. constructor(name: string);
  131112. /**
  131113. * Gets the current class name
  131114. * @returns the class name
  131115. */
  131116. getClassName(): string;
  131117. /**
  131118. * Gets the left operand input component
  131119. */
  131120. get left(): NodeMaterialConnectionPoint;
  131121. /**
  131122. * Gets the right operand input component
  131123. */
  131124. get right(): NodeMaterialConnectionPoint;
  131125. /**
  131126. * Gets the output component
  131127. */
  131128. get output(): NodeMaterialConnectionPoint;
  131129. protected _buildBlock(state: NodeMaterialBuildState): this;
  131130. }
  131131. }
  131132. declare module BABYLON {
  131133. /**
  131134. * Block used to add 2 vectors
  131135. */
  131136. export class AddBlock extends NodeMaterialBlock {
  131137. /**
  131138. * Creates a new AddBlock
  131139. * @param name defines the block name
  131140. */
  131141. constructor(name: string);
  131142. /**
  131143. * Gets the current class name
  131144. * @returns the class name
  131145. */
  131146. getClassName(): string;
  131147. /**
  131148. * Gets the left operand input component
  131149. */
  131150. get left(): NodeMaterialConnectionPoint;
  131151. /**
  131152. * Gets the right operand input component
  131153. */
  131154. get right(): NodeMaterialConnectionPoint;
  131155. /**
  131156. * Gets the output component
  131157. */
  131158. get output(): NodeMaterialConnectionPoint;
  131159. protected _buildBlock(state: NodeMaterialBuildState): this;
  131160. }
  131161. }
  131162. declare module BABYLON {
  131163. /**
  131164. * Block used to scale a vector by a float
  131165. */
  131166. export class ScaleBlock extends NodeMaterialBlock {
  131167. /**
  131168. * Creates a new ScaleBlock
  131169. * @param name defines the block name
  131170. */
  131171. constructor(name: string);
  131172. /**
  131173. * Gets the current class name
  131174. * @returns the class name
  131175. */
  131176. getClassName(): string;
  131177. /**
  131178. * Gets the input component
  131179. */
  131180. get input(): NodeMaterialConnectionPoint;
  131181. /**
  131182. * Gets the factor input component
  131183. */
  131184. get factor(): NodeMaterialConnectionPoint;
  131185. /**
  131186. * Gets the output component
  131187. */
  131188. get output(): NodeMaterialConnectionPoint;
  131189. protected _buildBlock(state: NodeMaterialBuildState): this;
  131190. }
  131191. }
  131192. declare module BABYLON {
  131193. /**
  131194. * Block used to clamp a float
  131195. */
  131196. export class ClampBlock extends NodeMaterialBlock {
  131197. /** Gets or sets the minimum range */
  131198. minimum: number;
  131199. /** Gets or sets the maximum range */
  131200. maximum: number;
  131201. /**
  131202. * Creates a new ClampBlock
  131203. * @param name defines the block name
  131204. */
  131205. constructor(name: string);
  131206. /**
  131207. * Gets the current class name
  131208. * @returns the class name
  131209. */
  131210. getClassName(): string;
  131211. /**
  131212. * Gets the value input component
  131213. */
  131214. get value(): NodeMaterialConnectionPoint;
  131215. /**
  131216. * Gets the output component
  131217. */
  131218. get output(): NodeMaterialConnectionPoint;
  131219. protected _buildBlock(state: NodeMaterialBuildState): this;
  131220. protected _dumpPropertiesCode(): string;
  131221. serialize(): any;
  131222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131223. }
  131224. }
  131225. declare module BABYLON {
  131226. /**
  131227. * Block used to apply a cross product between 2 vectors
  131228. */
  131229. export class CrossBlock extends NodeMaterialBlock {
  131230. /**
  131231. * Creates a new CrossBlock
  131232. * @param name defines the block name
  131233. */
  131234. constructor(name: string);
  131235. /**
  131236. * Gets the current class name
  131237. * @returns the class name
  131238. */
  131239. getClassName(): string;
  131240. /**
  131241. * Gets the left operand input component
  131242. */
  131243. get left(): NodeMaterialConnectionPoint;
  131244. /**
  131245. * Gets the right operand input component
  131246. */
  131247. get right(): NodeMaterialConnectionPoint;
  131248. /**
  131249. * Gets the output component
  131250. */
  131251. get output(): NodeMaterialConnectionPoint;
  131252. protected _buildBlock(state: NodeMaterialBuildState): this;
  131253. }
  131254. }
  131255. declare module BABYLON {
  131256. /**
  131257. * Block used to apply a dot product between 2 vectors
  131258. */
  131259. export class DotBlock extends NodeMaterialBlock {
  131260. /**
  131261. * Creates a new DotBlock
  131262. * @param name defines the block name
  131263. */
  131264. constructor(name: string);
  131265. /**
  131266. * Gets the current class name
  131267. * @returns the class name
  131268. */
  131269. getClassName(): string;
  131270. /**
  131271. * Gets the left operand input component
  131272. */
  131273. get left(): NodeMaterialConnectionPoint;
  131274. /**
  131275. * Gets the right operand input component
  131276. */
  131277. get right(): NodeMaterialConnectionPoint;
  131278. /**
  131279. * Gets the output component
  131280. */
  131281. get output(): NodeMaterialConnectionPoint;
  131282. protected _buildBlock(state: NodeMaterialBuildState): this;
  131283. }
  131284. }
  131285. declare module BABYLON {
  131286. /**
  131287. * Block used to remap a float from a range to a new one
  131288. */
  131289. export class RemapBlock extends NodeMaterialBlock {
  131290. /**
  131291. * Gets or sets the source range
  131292. */
  131293. sourceRange: Vector2;
  131294. /**
  131295. * Gets or sets the target range
  131296. */
  131297. targetRange: Vector2;
  131298. /**
  131299. * Creates a new RemapBlock
  131300. * @param name defines the block name
  131301. */
  131302. constructor(name: string);
  131303. /**
  131304. * Gets the current class name
  131305. * @returns the class name
  131306. */
  131307. getClassName(): string;
  131308. /**
  131309. * Gets the input component
  131310. */
  131311. get input(): NodeMaterialConnectionPoint;
  131312. /**
  131313. * Gets the source min input component
  131314. */
  131315. get sourceMin(): NodeMaterialConnectionPoint;
  131316. /**
  131317. * Gets the source max input component
  131318. */
  131319. get sourceMax(): NodeMaterialConnectionPoint;
  131320. /**
  131321. * Gets the target min input component
  131322. */
  131323. get targetMin(): NodeMaterialConnectionPoint;
  131324. /**
  131325. * Gets the target max input component
  131326. */
  131327. get targetMax(): NodeMaterialConnectionPoint;
  131328. /**
  131329. * Gets the output component
  131330. */
  131331. get output(): NodeMaterialConnectionPoint;
  131332. protected _buildBlock(state: NodeMaterialBuildState): this;
  131333. protected _dumpPropertiesCode(): string;
  131334. serialize(): any;
  131335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131336. }
  131337. }
  131338. declare module BABYLON {
  131339. /**
  131340. * Block used to normalize a vector
  131341. */
  131342. export class NormalizeBlock extends NodeMaterialBlock {
  131343. /**
  131344. * Creates a new NormalizeBlock
  131345. * @param name defines the block name
  131346. */
  131347. constructor(name: string);
  131348. /**
  131349. * Gets the current class name
  131350. * @returns the class name
  131351. */
  131352. getClassName(): string;
  131353. /**
  131354. * Gets the input component
  131355. */
  131356. get input(): NodeMaterialConnectionPoint;
  131357. /**
  131358. * Gets the output component
  131359. */
  131360. get output(): NodeMaterialConnectionPoint;
  131361. protected _buildBlock(state: NodeMaterialBuildState): this;
  131362. }
  131363. }
  131364. declare module BABYLON {
  131365. /**
  131366. * Operations supported by the Trigonometry block
  131367. */
  131368. export enum TrigonometryBlockOperations {
  131369. /** Cos */
  131370. Cos = 0,
  131371. /** Sin */
  131372. Sin = 1,
  131373. /** Abs */
  131374. Abs = 2,
  131375. /** Exp */
  131376. Exp = 3,
  131377. /** Exp2 */
  131378. Exp2 = 4,
  131379. /** Round */
  131380. Round = 5,
  131381. /** Floor */
  131382. Floor = 6,
  131383. /** Ceiling */
  131384. Ceiling = 7,
  131385. /** Square root */
  131386. Sqrt = 8,
  131387. /** Log */
  131388. Log = 9,
  131389. /** Tangent */
  131390. Tan = 10,
  131391. /** Arc tangent */
  131392. ArcTan = 11,
  131393. /** Arc cosinus */
  131394. ArcCos = 12,
  131395. /** Arc sinus */
  131396. ArcSin = 13,
  131397. /** Fraction */
  131398. Fract = 14,
  131399. /** Sign */
  131400. Sign = 15,
  131401. /** To radians (from degrees) */
  131402. Radians = 16,
  131403. /** To degrees (from radians) */
  131404. Degrees = 17
  131405. }
  131406. /**
  131407. * Block used to apply trigonometry operation to floats
  131408. */
  131409. export class TrigonometryBlock extends NodeMaterialBlock {
  131410. /**
  131411. * Gets or sets the operation applied by the block
  131412. */
  131413. operation: TrigonometryBlockOperations;
  131414. /**
  131415. * Creates a new TrigonometryBlock
  131416. * @param name defines the block name
  131417. */
  131418. constructor(name: string);
  131419. /**
  131420. * Gets the current class name
  131421. * @returns the class name
  131422. */
  131423. getClassName(): string;
  131424. /**
  131425. * Gets the input component
  131426. */
  131427. get input(): NodeMaterialConnectionPoint;
  131428. /**
  131429. * Gets the output component
  131430. */
  131431. get output(): NodeMaterialConnectionPoint;
  131432. protected _buildBlock(state: NodeMaterialBuildState): this;
  131433. serialize(): any;
  131434. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131435. protected _dumpPropertiesCode(): string;
  131436. }
  131437. }
  131438. declare module BABYLON {
  131439. /**
  131440. * Block used to create a Color3/4 out of individual inputs (one for each component)
  131441. */
  131442. export class ColorMergerBlock extends NodeMaterialBlock {
  131443. /**
  131444. * Create a new ColorMergerBlock
  131445. * @param name defines the block name
  131446. */
  131447. constructor(name: string);
  131448. /**
  131449. * Gets the current class name
  131450. * @returns the class name
  131451. */
  131452. getClassName(): string;
  131453. /**
  131454. * Gets the rgb component (input)
  131455. */
  131456. get rgbIn(): NodeMaterialConnectionPoint;
  131457. /**
  131458. * Gets the r component (input)
  131459. */
  131460. get r(): NodeMaterialConnectionPoint;
  131461. /**
  131462. * Gets the g component (input)
  131463. */
  131464. get g(): NodeMaterialConnectionPoint;
  131465. /**
  131466. * Gets the b component (input)
  131467. */
  131468. get b(): NodeMaterialConnectionPoint;
  131469. /**
  131470. * Gets the a component (input)
  131471. */
  131472. get a(): NodeMaterialConnectionPoint;
  131473. /**
  131474. * Gets the rgba component (output)
  131475. */
  131476. get rgba(): NodeMaterialConnectionPoint;
  131477. /**
  131478. * Gets the rgb component (output)
  131479. */
  131480. get rgbOut(): NodeMaterialConnectionPoint;
  131481. /**
  131482. * Gets the rgb component (output)
  131483. * @deprecated Please use rgbOut instead.
  131484. */
  131485. get rgb(): NodeMaterialConnectionPoint;
  131486. protected _buildBlock(state: NodeMaterialBuildState): this;
  131487. }
  131488. }
  131489. declare module BABYLON {
  131490. /**
  131491. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  131492. */
  131493. export class VectorMergerBlock extends NodeMaterialBlock {
  131494. /**
  131495. * Create a new VectorMergerBlock
  131496. * @param name defines the block name
  131497. */
  131498. constructor(name: string);
  131499. /**
  131500. * Gets the current class name
  131501. * @returns the class name
  131502. */
  131503. getClassName(): string;
  131504. /**
  131505. * Gets the xyz component (input)
  131506. */
  131507. get xyzIn(): NodeMaterialConnectionPoint;
  131508. /**
  131509. * Gets the xy component (input)
  131510. */
  131511. get xyIn(): NodeMaterialConnectionPoint;
  131512. /**
  131513. * Gets the x component (input)
  131514. */
  131515. get x(): NodeMaterialConnectionPoint;
  131516. /**
  131517. * Gets the y component (input)
  131518. */
  131519. get y(): NodeMaterialConnectionPoint;
  131520. /**
  131521. * Gets the z component (input)
  131522. */
  131523. get z(): NodeMaterialConnectionPoint;
  131524. /**
  131525. * Gets the w component (input)
  131526. */
  131527. get w(): NodeMaterialConnectionPoint;
  131528. /**
  131529. * Gets the xyzw component (output)
  131530. */
  131531. get xyzw(): NodeMaterialConnectionPoint;
  131532. /**
  131533. * Gets the xyz component (output)
  131534. */
  131535. get xyzOut(): NodeMaterialConnectionPoint;
  131536. /**
  131537. * Gets the xy component (output)
  131538. */
  131539. get xyOut(): NodeMaterialConnectionPoint;
  131540. /**
  131541. * Gets the xy component (output)
  131542. * @deprecated Please use xyOut instead.
  131543. */
  131544. get xy(): NodeMaterialConnectionPoint;
  131545. /**
  131546. * Gets the xyz component (output)
  131547. * @deprecated Please use xyzOut instead.
  131548. */
  131549. get xyz(): NodeMaterialConnectionPoint;
  131550. protected _buildBlock(state: NodeMaterialBuildState): this;
  131551. }
  131552. }
  131553. declare module BABYLON {
  131554. /**
  131555. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  131556. */
  131557. export class ColorSplitterBlock extends NodeMaterialBlock {
  131558. /**
  131559. * Create a new ColorSplitterBlock
  131560. * @param name defines the block name
  131561. */
  131562. constructor(name: string);
  131563. /**
  131564. * Gets the current class name
  131565. * @returns the class name
  131566. */
  131567. getClassName(): string;
  131568. /**
  131569. * Gets the rgba component (input)
  131570. */
  131571. get rgba(): NodeMaterialConnectionPoint;
  131572. /**
  131573. * Gets the rgb component (input)
  131574. */
  131575. get rgbIn(): NodeMaterialConnectionPoint;
  131576. /**
  131577. * Gets the rgb component (output)
  131578. */
  131579. get rgbOut(): NodeMaterialConnectionPoint;
  131580. /**
  131581. * Gets the r component (output)
  131582. */
  131583. get r(): NodeMaterialConnectionPoint;
  131584. /**
  131585. * Gets the g component (output)
  131586. */
  131587. get g(): NodeMaterialConnectionPoint;
  131588. /**
  131589. * Gets the b component (output)
  131590. */
  131591. get b(): NodeMaterialConnectionPoint;
  131592. /**
  131593. * Gets the a component (output)
  131594. */
  131595. get a(): NodeMaterialConnectionPoint;
  131596. protected _inputRename(name: string): string;
  131597. protected _outputRename(name: string): string;
  131598. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131599. }
  131600. }
  131601. declare module BABYLON {
  131602. /**
  131603. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  131604. */
  131605. export class VectorSplitterBlock extends NodeMaterialBlock {
  131606. /**
  131607. * Create a new VectorSplitterBlock
  131608. * @param name defines the block name
  131609. */
  131610. constructor(name: string);
  131611. /**
  131612. * Gets the current class name
  131613. * @returns the class name
  131614. */
  131615. getClassName(): string;
  131616. /**
  131617. * Gets the xyzw component (input)
  131618. */
  131619. get xyzw(): NodeMaterialConnectionPoint;
  131620. /**
  131621. * Gets the xyz component (input)
  131622. */
  131623. get xyzIn(): NodeMaterialConnectionPoint;
  131624. /**
  131625. * Gets the xy component (input)
  131626. */
  131627. get xyIn(): NodeMaterialConnectionPoint;
  131628. /**
  131629. * Gets the xyz component (output)
  131630. */
  131631. get xyzOut(): NodeMaterialConnectionPoint;
  131632. /**
  131633. * Gets the xy component (output)
  131634. */
  131635. get xyOut(): NodeMaterialConnectionPoint;
  131636. /**
  131637. * Gets the x component (output)
  131638. */
  131639. get x(): NodeMaterialConnectionPoint;
  131640. /**
  131641. * Gets the y component (output)
  131642. */
  131643. get y(): NodeMaterialConnectionPoint;
  131644. /**
  131645. * Gets the z component (output)
  131646. */
  131647. get z(): NodeMaterialConnectionPoint;
  131648. /**
  131649. * Gets the w component (output)
  131650. */
  131651. get w(): NodeMaterialConnectionPoint;
  131652. protected _inputRename(name: string): string;
  131653. protected _outputRename(name: string): string;
  131654. protected _buildBlock(state: NodeMaterialBuildState): this;
  131655. }
  131656. }
  131657. declare module BABYLON {
  131658. /**
  131659. * Block used to lerp between 2 values
  131660. */
  131661. export class LerpBlock extends NodeMaterialBlock {
  131662. /**
  131663. * Creates a new LerpBlock
  131664. * @param name defines the block name
  131665. */
  131666. constructor(name: string);
  131667. /**
  131668. * Gets the current class name
  131669. * @returns the class name
  131670. */
  131671. getClassName(): string;
  131672. /**
  131673. * Gets the left operand input component
  131674. */
  131675. get left(): NodeMaterialConnectionPoint;
  131676. /**
  131677. * Gets the right operand input component
  131678. */
  131679. get right(): NodeMaterialConnectionPoint;
  131680. /**
  131681. * Gets the gradient operand input component
  131682. */
  131683. get gradient(): NodeMaterialConnectionPoint;
  131684. /**
  131685. * Gets the output component
  131686. */
  131687. get output(): NodeMaterialConnectionPoint;
  131688. protected _buildBlock(state: NodeMaterialBuildState): this;
  131689. }
  131690. }
  131691. declare module BABYLON {
  131692. /**
  131693. * Block used to divide 2 vectors
  131694. */
  131695. export class DivideBlock extends NodeMaterialBlock {
  131696. /**
  131697. * Creates a new DivideBlock
  131698. * @param name defines the block name
  131699. */
  131700. constructor(name: string);
  131701. /**
  131702. * Gets the current class name
  131703. * @returns the class name
  131704. */
  131705. getClassName(): string;
  131706. /**
  131707. * Gets the left operand input component
  131708. */
  131709. get left(): NodeMaterialConnectionPoint;
  131710. /**
  131711. * Gets the right operand input component
  131712. */
  131713. get right(): NodeMaterialConnectionPoint;
  131714. /**
  131715. * Gets the output component
  131716. */
  131717. get output(): NodeMaterialConnectionPoint;
  131718. protected _buildBlock(state: NodeMaterialBuildState): this;
  131719. }
  131720. }
  131721. declare module BABYLON {
  131722. /**
  131723. * Block used to subtract 2 vectors
  131724. */
  131725. export class SubtractBlock extends NodeMaterialBlock {
  131726. /**
  131727. * Creates a new SubtractBlock
  131728. * @param name defines the block name
  131729. */
  131730. constructor(name: string);
  131731. /**
  131732. * Gets the current class name
  131733. * @returns the class name
  131734. */
  131735. getClassName(): string;
  131736. /**
  131737. * Gets the left operand input component
  131738. */
  131739. get left(): NodeMaterialConnectionPoint;
  131740. /**
  131741. * Gets the right operand input component
  131742. */
  131743. get right(): NodeMaterialConnectionPoint;
  131744. /**
  131745. * Gets the output component
  131746. */
  131747. get output(): NodeMaterialConnectionPoint;
  131748. protected _buildBlock(state: NodeMaterialBuildState): this;
  131749. }
  131750. }
  131751. declare module BABYLON {
  131752. /**
  131753. * Block used to step a value
  131754. */
  131755. export class StepBlock extends NodeMaterialBlock {
  131756. /**
  131757. * Creates a new StepBlock
  131758. * @param name defines the block name
  131759. */
  131760. constructor(name: string);
  131761. /**
  131762. * Gets the current class name
  131763. * @returns the class name
  131764. */
  131765. getClassName(): string;
  131766. /**
  131767. * Gets the value operand input component
  131768. */
  131769. get value(): NodeMaterialConnectionPoint;
  131770. /**
  131771. * Gets the edge operand input component
  131772. */
  131773. get edge(): NodeMaterialConnectionPoint;
  131774. /**
  131775. * Gets the output component
  131776. */
  131777. get output(): NodeMaterialConnectionPoint;
  131778. protected _buildBlock(state: NodeMaterialBuildState): this;
  131779. }
  131780. }
  131781. declare module BABYLON {
  131782. /**
  131783. * Block used to get the opposite (1 - x) of a value
  131784. */
  131785. export class OneMinusBlock extends NodeMaterialBlock {
  131786. /**
  131787. * Creates a new OneMinusBlock
  131788. * @param name defines the block name
  131789. */
  131790. constructor(name: string);
  131791. /**
  131792. * Gets the current class name
  131793. * @returns the class name
  131794. */
  131795. getClassName(): string;
  131796. /**
  131797. * Gets the input component
  131798. */
  131799. get input(): NodeMaterialConnectionPoint;
  131800. /**
  131801. * Gets the output component
  131802. */
  131803. get output(): NodeMaterialConnectionPoint;
  131804. protected _buildBlock(state: NodeMaterialBuildState): this;
  131805. }
  131806. }
  131807. declare module BABYLON {
  131808. /**
  131809. * Block used to get the view direction
  131810. */
  131811. export class ViewDirectionBlock extends NodeMaterialBlock {
  131812. /**
  131813. * Creates a new ViewDirectionBlock
  131814. * @param name defines the block name
  131815. */
  131816. constructor(name: string);
  131817. /**
  131818. * Gets the current class name
  131819. * @returns the class name
  131820. */
  131821. getClassName(): string;
  131822. /**
  131823. * Gets the world position component
  131824. */
  131825. get worldPosition(): NodeMaterialConnectionPoint;
  131826. /**
  131827. * Gets the camera position component
  131828. */
  131829. get cameraPosition(): NodeMaterialConnectionPoint;
  131830. /**
  131831. * Gets the output component
  131832. */
  131833. get output(): NodeMaterialConnectionPoint;
  131834. autoConfigure(material: NodeMaterial): void;
  131835. protected _buildBlock(state: NodeMaterialBuildState): this;
  131836. }
  131837. }
  131838. declare module BABYLON {
  131839. /**
  131840. * Block used to compute fresnel value
  131841. */
  131842. export class FresnelBlock extends NodeMaterialBlock {
  131843. /**
  131844. * Create a new FresnelBlock
  131845. * @param name defines the block name
  131846. */
  131847. constructor(name: string);
  131848. /**
  131849. * Gets the current class name
  131850. * @returns the class name
  131851. */
  131852. getClassName(): string;
  131853. /**
  131854. * Gets the world normal input component
  131855. */
  131856. get worldNormal(): NodeMaterialConnectionPoint;
  131857. /**
  131858. * Gets the view direction input component
  131859. */
  131860. get viewDirection(): NodeMaterialConnectionPoint;
  131861. /**
  131862. * Gets the bias input component
  131863. */
  131864. get bias(): NodeMaterialConnectionPoint;
  131865. /**
  131866. * Gets the camera (or eye) position component
  131867. */
  131868. get power(): NodeMaterialConnectionPoint;
  131869. /**
  131870. * Gets the fresnel output component
  131871. */
  131872. get fresnel(): NodeMaterialConnectionPoint;
  131873. autoConfigure(material: NodeMaterial): void;
  131874. protected _buildBlock(state: NodeMaterialBuildState): this;
  131875. }
  131876. }
  131877. declare module BABYLON {
  131878. /**
  131879. * Block used to get the max of 2 values
  131880. */
  131881. export class MaxBlock extends NodeMaterialBlock {
  131882. /**
  131883. * Creates a new MaxBlock
  131884. * @param name defines the block name
  131885. */
  131886. constructor(name: string);
  131887. /**
  131888. * Gets the current class name
  131889. * @returns the class name
  131890. */
  131891. getClassName(): string;
  131892. /**
  131893. * Gets the left operand input component
  131894. */
  131895. get left(): NodeMaterialConnectionPoint;
  131896. /**
  131897. * Gets the right operand input component
  131898. */
  131899. get right(): NodeMaterialConnectionPoint;
  131900. /**
  131901. * Gets the output component
  131902. */
  131903. get output(): NodeMaterialConnectionPoint;
  131904. protected _buildBlock(state: NodeMaterialBuildState): this;
  131905. }
  131906. }
  131907. declare module BABYLON {
  131908. /**
  131909. * Block used to get the min of 2 values
  131910. */
  131911. export class MinBlock extends NodeMaterialBlock {
  131912. /**
  131913. * Creates a new MinBlock
  131914. * @param name defines the block name
  131915. */
  131916. constructor(name: string);
  131917. /**
  131918. * Gets the current class name
  131919. * @returns the class name
  131920. */
  131921. getClassName(): string;
  131922. /**
  131923. * Gets the left operand input component
  131924. */
  131925. get left(): NodeMaterialConnectionPoint;
  131926. /**
  131927. * Gets the right operand input component
  131928. */
  131929. get right(): NodeMaterialConnectionPoint;
  131930. /**
  131931. * Gets the output component
  131932. */
  131933. get output(): NodeMaterialConnectionPoint;
  131934. protected _buildBlock(state: NodeMaterialBuildState): this;
  131935. }
  131936. }
  131937. declare module BABYLON {
  131938. /**
  131939. * Block used to get the distance between 2 values
  131940. */
  131941. export class DistanceBlock extends NodeMaterialBlock {
  131942. /**
  131943. * Creates a new DistanceBlock
  131944. * @param name defines the block name
  131945. */
  131946. constructor(name: string);
  131947. /**
  131948. * Gets the current class name
  131949. * @returns the class name
  131950. */
  131951. getClassName(): string;
  131952. /**
  131953. * Gets the left operand input component
  131954. */
  131955. get left(): NodeMaterialConnectionPoint;
  131956. /**
  131957. * Gets the right operand input component
  131958. */
  131959. get right(): NodeMaterialConnectionPoint;
  131960. /**
  131961. * Gets the output component
  131962. */
  131963. get output(): NodeMaterialConnectionPoint;
  131964. protected _buildBlock(state: NodeMaterialBuildState): this;
  131965. }
  131966. }
  131967. declare module BABYLON {
  131968. /**
  131969. * Block used to get the length of a vector
  131970. */
  131971. export class LengthBlock extends NodeMaterialBlock {
  131972. /**
  131973. * Creates a new LengthBlock
  131974. * @param name defines the block name
  131975. */
  131976. constructor(name: string);
  131977. /**
  131978. * Gets the current class name
  131979. * @returns the class name
  131980. */
  131981. getClassName(): string;
  131982. /**
  131983. * Gets the value input component
  131984. */
  131985. get value(): NodeMaterialConnectionPoint;
  131986. /**
  131987. * Gets the output component
  131988. */
  131989. get output(): NodeMaterialConnectionPoint;
  131990. protected _buildBlock(state: NodeMaterialBuildState): this;
  131991. }
  131992. }
  131993. declare module BABYLON {
  131994. /**
  131995. * Block used to get negative version of a value (i.e. x * -1)
  131996. */
  131997. export class NegateBlock extends NodeMaterialBlock {
  131998. /**
  131999. * Creates a new NegateBlock
  132000. * @param name defines the block name
  132001. */
  132002. constructor(name: string);
  132003. /**
  132004. * Gets the current class name
  132005. * @returns the class name
  132006. */
  132007. getClassName(): string;
  132008. /**
  132009. * Gets the value input component
  132010. */
  132011. get value(): NodeMaterialConnectionPoint;
  132012. /**
  132013. * Gets the output component
  132014. */
  132015. get output(): NodeMaterialConnectionPoint;
  132016. protected _buildBlock(state: NodeMaterialBuildState): this;
  132017. }
  132018. }
  132019. declare module BABYLON {
  132020. /**
  132021. * Block used to get the value of the first parameter raised to the power of the second
  132022. */
  132023. export class PowBlock extends NodeMaterialBlock {
  132024. /**
  132025. * Creates a new PowBlock
  132026. * @param name defines the block name
  132027. */
  132028. constructor(name: string);
  132029. /**
  132030. * Gets the current class name
  132031. * @returns the class name
  132032. */
  132033. getClassName(): string;
  132034. /**
  132035. * Gets the value operand input component
  132036. */
  132037. get value(): NodeMaterialConnectionPoint;
  132038. /**
  132039. * Gets the power operand input component
  132040. */
  132041. get power(): NodeMaterialConnectionPoint;
  132042. /**
  132043. * Gets the output component
  132044. */
  132045. get output(): NodeMaterialConnectionPoint;
  132046. protected _buildBlock(state: NodeMaterialBuildState): this;
  132047. }
  132048. }
  132049. declare module BABYLON {
  132050. /**
  132051. * Block used to get a random number
  132052. */
  132053. export class RandomNumberBlock extends NodeMaterialBlock {
  132054. /**
  132055. * Creates a new RandomNumberBlock
  132056. * @param name defines the block name
  132057. */
  132058. constructor(name: string);
  132059. /**
  132060. * Gets the current class name
  132061. * @returns the class name
  132062. */
  132063. getClassName(): string;
  132064. /**
  132065. * Gets the seed input component
  132066. */
  132067. get seed(): NodeMaterialConnectionPoint;
  132068. /**
  132069. * Gets the output component
  132070. */
  132071. get output(): NodeMaterialConnectionPoint;
  132072. protected _buildBlock(state: NodeMaterialBuildState): this;
  132073. }
  132074. }
  132075. declare module BABYLON {
  132076. /**
  132077. * Block used to compute arc tangent of 2 values
  132078. */
  132079. export class ArcTan2Block extends NodeMaterialBlock {
  132080. /**
  132081. * Creates a new ArcTan2Block
  132082. * @param name defines the block name
  132083. */
  132084. constructor(name: string);
  132085. /**
  132086. * Gets the current class name
  132087. * @returns the class name
  132088. */
  132089. getClassName(): string;
  132090. /**
  132091. * Gets the x operand input component
  132092. */
  132093. get x(): NodeMaterialConnectionPoint;
  132094. /**
  132095. * Gets the y operand input component
  132096. */
  132097. get y(): NodeMaterialConnectionPoint;
  132098. /**
  132099. * Gets the output component
  132100. */
  132101. get output(): NodeMaterialConnectionPoint;
  132102. protected _buildBlock(state: NodeMaterialBuildState): this;
  132103. }
  132104. }
  132105. declare module BABYLON {
  132106. /**
  132107. * Block used to smooth step a value
  132108. */
  132109. export class SmoothStepBlock extends NodeMaterialBlock {
  132110. /**
  132111. * Creates a new SmoothStepBlock
  132112. * @param name defines the block name
  132113. */
  132114. constructor(name: string);
  132115. /**
  132116. * Gets the current class name
  132117. * @returns the class name
  132118. */
  132119. getClassName(): string;
  132120. /**
  132121. * Gets the value operand input component
  132122. */
  132123. get value(): NodeMaterialConnectionPoint;
  132124. /**
  132125. * Gets the first edge operand input component
  132126. */
  132127. get edge0(): NodeMaterialConnectionPoint;
  132128. /**
  132129. * Gets the second edge operand input component
  132130. */
  132131. get edge1(): NodeMaterialConnectionPoint;
  132132. /**
  132133. * Gets the output component
  132134. */
  132135. get output(): NodeMaterialConnectionPoint;
  132136. protected _buildBlock(state: NodeMaterialBuildState): this;
  132137. }
  132138. }
  132139. declare module BABYLON {
  132140. /**
  132141. * Block used to get the reciprocal (1 / x) of a value
  132142. */
  132143. export class ReciprocalBlock extends NodeMaterialBlock {
  132144. /**
  132145. * Creates a new ReciprocalBlock
  132146. * @param name defines the block name
  132147. */
  132148. constructor(name: string);
  132149. /**
  132150. * Gets the current class name
  132151. * @returns the class name
  132152. */
  132153. getClassName(): string;
  132154. /**
  132155. * Gets the input component
  132156. */
  132157. get input(): NodeMaterialConnectionPoint;
  132158. /**
  132159. * Gets the output component
  132160. */
  132161. get output(): NodeMaterialConnectionPoint;
  132162. protected _buildBlock(state: NodeMaterialBuildState): this;
  132163. }
  132164. }
  132165. declare module BABYLON {
  132166. /**
  132167. * Block used to replace a color by another one
  132168. */
  132169. export class ReplaceColorBlock extends NodeMaterialBlock {
  132170. /**
  132171. * Creates a new ReplaceColorBlock
  132172. * @param name defines the block name
  132173. */
  132174. constructor(name: string);
  132175. /**
  132176. * Gets the current class name
  132177. * @returns the class name
  132178. */
  132179. getClassName(): string;
  132180. /**
  132181. * Gets the value input component
  132182. */
  132183. get value(): NodeMaterialConnectionPoint;
  132184. /**
  132185. * Gets the reference input component
  132186. */
  132187. get reference(): NodeMaterialConnectionPoint;
  132188. /**
  132189. * Gets the distance input component
  132190. */
  132191. get distance(): NodeMaterialConnectionPoint;
  132192. /**
  132193. * Gets the replacement input component
  132194. */
  132195. get replacement(): NodeMaterialConnectionPoint;
  132196. /**
  132197. * Gets the output component
  132198. */
  132199. get output(): NodeMaterialConnectionPoint;
  132200. protected _buildBlock(state: NodeMaterialBuildState): this;
  132201. }
  132202. }
  132203. declare module BABYLON {
  132204. /**
  132205. * Block used to posterize a value
  132206. * @see https://en.wikipedia.org/wiki/Posterization
  132207. */
  132208. export class PosterizeBlock extends NodeMaterialBlock {
  132209. /**
  132210. * Creates a new PosterizeBlock
  132211. * @param name defines the block name
  132212. */
  132213. constructor(name: string);
  132214. /**
  132215. * Gets the current class name
  132216. * @returns the class name
  132217. */
  132218. getClassName(): string;
  132219. /**
  132220. * Gets the value input component
  132221. */
  132222. get value(): NodeMaterialConnectionPoint;
  132223. /**
  132224. * Gets the steps input component
  132225. */
  132226. get steps(): NodeMaterialConnectionPoint;
  132227. /**
  132228. * Gets the output component
  132229. */
  132230. get output(): NodeMaterialConnectionPoint;
  132231. protected _buildBlock(state: NodeMaterialBuildState): this;
  132232. }
  132233. }
  132234. declare module BABYLON {
  132235. /**
  132236. * Operations supported by the Wave block
  132237. */
  132238. export enum WaveBlockKind {
  132239. /** SawTooth */
  132240. SawTooth = 0,
  132241. /** Square */
  132242. Square = 1,
  132243. /** Triangle */
  132244. Triangle = 2
  132245. }
  132246. /**
  132247. * Block used to apply wave operation to floats
  132248. */
  132249. export class WaveBlock extends NodeMaterialBlock {
  132250. /**
  132251. * Gets or sets the kibnd of wave to be applied by the block
  132252. */
  132253. kind: WaveBlockKind;
  132254. /**
  132255. * Creates a new WaveBlock
  132256. * @param name defines the block name
  132257. */
  132258. constructor(name: string);
  132259. /**
  132260. * Gets the current class name
  132261. * @returns the class name
  132262. */
  132263. getClassName(): string;
  132264. /**
  132265. * Gets the input component
  132266. */
  132267. get input(): NodeMaterialConnectionPoint;
  132268. /**
  132269. * Gets the output component
  132270. */
  132271. get output(): NodeMaterialConnectionPoint;
  132272. protected _buildBlock(state: NodeMaterialBuildState): this;
  132273. serialize(): any;
  132274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132275. }
  132276. }
  132277. declare module BABYLON {
  132278. /**
  132279. * Class used to store a color step for the GradientBlock
  132280. */
  132281. export class GradientBlockColorStep {
  132282. /**
  132283. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132284. */
  132285. step: number;
  132286. /**
  132287. * Gets or sets the color associated with this step
  132288. */
  132289. color: Color3;
  132290. /**
  132291. * Creates a new GradientBlockColorStep
  132292. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132293. * @param color defines the color associated with this step
  132294. */
  132295. constructor(
  132296. /**
  132297. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132298. */
  132299. step: number,
  132300. /**
  132301. * Gets or sets the color associated with this step
  132302. */
  132303. color: Color3);
  132304. }
  132305. /**
  132306. * Block used to return a color from a gradient based on an input value between 0 and 1
  132307. */
  132308. export class GradientBlock extends NodeMaterialBlock {
  132309. /**
  132310. * Gets or sets the list of color steps
  132311. */
  132312. colorSteps: GradientBlockColorStep[];
  132313. /**
  132314. * Creates a new GradientBlock
  132315. * @param name defines the block name
  132316. */
  132317. constructor(name: string);
  132318. /**
  132319. * Gets the current class name
  132320. * @returns the class name
  132321. */
  132322. getClassName(): string;
  132323. /**
  132324. * Gets the gradient input component
  132325. */
  132326. get gradient(): NodeMaterialConnectionPoint;
  132327. /**
  132328. * Gets the output component
  132329. */
  132330. get output(): NodeMaterialConnectionPoint;
  132331. private _writeColorConstant;
  132332. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132333. serialize(): any;
  132334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132335. protected _dumpPropertiesCode(): string;
  132336. }
  132337. }
  132338. declare module BABYLON {
  132339. /**
  132340. * Block used to normalize lerp between 2 values
  132341. */
  132342. export class NLerpBlock extends NodeMaterialBlock {
  132343. /**
  132344. * Creates a new NLerpBlock
  132345. * @param name defines the block name
  132346. */
  132347. constructor(name: string);
  132348. /**
  132349. * Gets the current class name
  132350. * @returns the class name
  132351. */
  132352. getClassName(): string;
  132353. /**
  132354. * Gets the left operand input component
  132355. */
  132356. get left(): NodeMaterialConnectionPoint;
  132357. /**
  132358. * Gets the right operand input component
  132359. */
  132360. get right(): NodeMaterialConnectionPoint;
  132361. /**
  132362. * Gets the gradient operand input component
  132363. */
  132364. get gradient(): NodeMaterialConnectionPoint;
  132365. /**
  132366. * Gets the output component
  132367. */
  132368. get output(): NodeMaterialConnectionPoint;
  132369. protected _buildBlock(state: NodeMaterialBuildState): this;
  132370. }
  132371. }
  132372. declare module BABYLON {
  132373. /**
  132374. * block used to Generate a Worley Noise 3D Noise Pattern
  132375. */
  132376. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  132377. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132378. manhattanDistance: boolean;
  132379. /**
  132380. * Creates a new WorleyNoise3DBlock
  132381. * @param name defines the block name
  132382. */
  132383. constructor(name: string);
  132384. /**
  132385. * Gets the current class name
  132386. * @returns the class name
  132387. */
  132388. getClassName(): string;
  132389. /**
  132390. * Gets the seed input component
  132391. */
  132392. get seed(): NodeMaterialConnectionPoint;
  132393. /**
  132394. * Gets the jitter input component
  132395. */
  132396. get jitter(): NodeMaterialConnectionPoint;
  132397. /**
  132398. * Gets the output component
  132399. */
  132400. get output(): NodeMaterialConnectionPoint;
  132401. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132402. /**
  132403. * Exposes the properties to the UI?
  132404. */
  132405. protected _dumpPropertiesCode(): string;
  132406. /**
  132407. * Exposes the properties to the Seralize?
  132408. */
  132409. serialize(): any;
  132410. /**
  132411. * Exposes the properties to the deseralize?
  132412. */
  132413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132414. }
  132415. }
  132416. declare module BABYLON {
  132417. /**
  132418. * block used to Generate a Simplex Perlin 3d Noise Pattern
  132419. */
  132420. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  132421. /**
  132422. * Creates a new SimplexPerlin3DBlock
  132423. * @param name defines the block name
  132424. */
  132425. constructor(name: string);
  132426. /**
  132427. * Gets the current class name
  132428. * @returns the class name
  132429. */
  132430. getClassName(): string;
  132431. /**
  132432. * Gets the seed operand input component
  132433. */
  132434. get seed(): NodeMaterialConnectionPoint;
  132435. /**
  132436. * Gets the output component
  132437. */
  132438. get output(): NodeMaterialConnectionPoint;
  132439. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132440. }
  132441. }
  132442. declare module BABYLON {
  132443. /**
  132444. * Block used to blend normals
  132445. */
  132446. export class NormalBlendBlock extends NodeMaterialBlock {
  132447. /**
  132448. * Creates a new NormalBlendBlock
  132449. * @param name defines the block name
  132450. */
  132451. constructor(name: string);
  132452. /**
  132453. * Gets the current class name
  132454. * @returns the class name
  132455. */
  132456. getClassName(): string;
  132457. /**
  132458. * Gets the first input component
  132459. */
  132460. get normalMap0(): NodeMaterialConnectionPoint;
  132461. /**
  132462. * Gets the second input component
  132463. */
  132464. get normalMap1(): NodeMaterialConnectionPoint;
  132465. /**
  132466. * Gets the output component
  132467. */
  132468. get output(): NodeMaterialConnectionPoint;
  132469. protected _buildBlock(state: NodeMaterialBuildState): this;
  132470. }
  132471. }
  132472. declare module BABYLON {
  132473. /**
  132474. * Block used to rotate a 2d vector by a given angle
  132475. */
  132476. export class Rotate2dBlock extends NodeMaterialBlock {
  132477. /**
  132478. * Creates a new Rotate2dBlock
  132479. * @param name defines the block name
  132480. */
  132481. constructor(name: string);
  132482. /**
  132483. * Gets the current class name
  132484. * @returns the class name
  132485. */
  132486. getClassName(): string;
  132487. /**
  132488. * Gets the input vector
  132489. */
  132490. get input(): NodeMaterialConnectionPoint;
  132491. /**
  132492. * Gets the input angle
  132493. */
  132494. get angle(): NodeMaterialConnectionPoint;
  132495. /**
  132496. * Gets the output component
  132497. */
  132498. get output(): NodeMaterialConnectionPoint;
  132499. autoConfigure(material: NodeMaterial): void;
  132500. protected _buildBlock(state: NodeMaterialBuildState): this;
  132501. }
  132502. }
  132503. declare module BABYLON {
  132504. /**
  132505. * Block used to get the reflected vector from a direction and a normal
  132506. */
  132507. export class ReflectBlock extends NodeMaterialBlock {
  132508. /**
  132509. * Creates a new ReflectBlock
  132510. * @param name defines the block name
  132511. */
  132512. constructor(name: string);
  132513. /**
  132514. * Gets the current class name
  132515. * @returns the class name
  132516. */
  132517. getClassName(): string;
  132518. /**
  132519. * Gets the incident component
  132520. */
  132521. get incident(): NodeMaterialConnectionPoint;
  132522. /**
  132523. * Gets the normal component
  132524. */
  132525. get normal(): NodeMaterialConnectionPoint;
  132526. /**
  132527. * Gets the output component
  132528. */
  132529. get output(): NodeMaterialConnectionPoint;
  132530. protected _buildBlock(state: NodeMaterialBuildState): this;
  132531. }
  132532. }
  132533. declare module BABYLON {
  132534. /**
  132535. * Block used to get the refracted vector from a direction and a normal
  132536. */
  132537. export class RefractBlock extends NodeMaterialBlock {
  132538. /**
  132539. * Creates a new RefractBlock
  132540. * @param name defines the block name
  132541. */
  132542. constructor(name: string);
  132543. /**
  132544. * Gets the current class name
  132545. * @returns the class name
  132546. */
  132547. getClassName(): string;
  132548. /**
  132549. * Gets the incident component
  132550. */
  132551. get incident(): NodeMaterialConnectionPoint;
  132552. /**
  132553. * Gets the normal component
  132554. */
  132555. get normal(): NodeMaterialConnectionPoint;
  132556. /**
  132557. * Gets the index of refraction component
  132558. */
  132559. get ior(): NodeMaterialConnectionPoint;
  132560. /**
  132561. * Gets the output component
  132562. */
  132563. get output(): NodeMaterialConnectionPoint;
  132564. protected _buildBlock(state: NodeMaterialBuildState): this;
  132565. }
  132566. }
  132567. declare module BABYLON {
  132568. /**
  132569. * Block used to desaturate a color
  132570. */
  132571. export class DesaturateBlock extends NodeMaterialBlock {
  132572. /**
  132573. * Creates a new DesaturateBlock
  132574. * @param name defines the block name
  132575. */
  132576. constructor(name: string);
  132577. /**
  132578. * Gets the current class name
  132579. * @returns the class name
  132580. */
  132581. getClassName(): string;
  132582. /**
  132583. * Gets the color operand input component
  132584. */
  132585. get color(): NodeMaterialConnectionPoint;
  132586. /**
  132587. * Gets the level operand input component
  132588. */
  132589. get level(): NodeMaterialConnectionPoint;
  132590. /**
  132591. * Gets the output component
  132592. */
  132593. get output(): NodeMaterialConnectionPoint;
  132594. protected _buildBlock(state: NodeMaterialBuildState): this;
  132595. }
  132596. }
  132597. declare module BABYLON {
  132598. /**
  132599. * Effect Render Options
  132600. */
  132601. export interface IEffectRendererOptions {
  132602. /**
  132603. * Defines the vertices positions.
  132604. */
  132605. positions?: number[];
  132606. /**
  132607. * Defines the indices.
  132608. */
  132609. indices?: number[];
  132610. }
  132611. /**
  132612. * Helper class to render one or more effects
  132613. */
  132614. export class EffectRenderer {
  132615. private engine;
  132616. private static _DefaultOptions;
  132617. private _vertexBuffers;
  132618. private _indexBuffer;
  132619. private _ringBufferIndex;
  132620. private _ringScreenBuffer;
  132621. private _fullscreenViewport;
  132622. private _getNextFrameBuffer;
  132623. /**
  132624. * Creates an effect renderer
  132625. * @param engine the engine to use for rendering
  132626. * @param options defines the options of the effect renderer
  132627. */
  132628. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  132629. /**
  132630. * Sets the current viewport in normalized coordinates 0-1
  132631. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  132632. */
  132633. setViewport(viewport?: Viewport): void;
  132634. /**
  132635. * Binds the embedded attributes buffer to the effect.
  132636. * @param effect Defines the effect to bind the attributes for
  132637. */
  132638. bindBuffers(effect: Effect): void;
  132639. /**
  132640. * Sets the current effect wrapper to use during draw.
  132641. * The effect needs to be ready before calling this api.
  132642. * This also sets the default full screen position attribute.
  132643. * @param effectWrapper Defines the effect to draw with
  132644. */
  132645. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  132646. /**
  132647. * Draws a full screen quad.
  132648. */
  132649. draw(): void;
  132650. /**
  132651. * renders one or more effects to a specified texture
  132652. * @param effectWrappers list of effects to renderer
  132653. * @param outputTexture texture to draw to, if null it will render to the screen
  132654. */
  132655. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  132656. /**
  132657. * Disposes of the effect renderer
  132658. */
  132659. dispose(): void;
  132660. }
  132661. /**
  132662. * Options to create an EffectWrapper
  132663. */
  132664. interface EffectWrapperCreationOptions {
  132665. /**
  132666. * Engine to use to create the effect
  132667. */
  132668. engine: ThinEngine;
  132669. /**
  132670. * Fragment shader for the effect
  132671. */
  132672. fragmentShader: string;
  132673. /**
  132674. * Vertex shader for the effect
  132675. */
  132676. vertexShader?: string;
  132677. /**
  132678. * Attributes to use in the shader
  132679. */
  132680. attributeNames?: Array<string>;
  132681. /**
  132682. * Uniforms to use in the shader
  132683. */
  132684. uniformNames?: Array<string>;
  132685. /**
  132686. * Texture sampler names to use in the shader
  132687. */
  132688. samplerNames?: Array<string>;
  132689. /**
  132690. * The friendly name of the effect displayed in Spector.
  132691. */
  132692. name?: string;
  132693. }
  132694. /**
  132695. * Wraps an effect to be used for rendering
  132696. */
  132697. export class EffectWrapper {
  132698. /**
  132699. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  132700. */
  132701. onApplyObservable: Observable<{}>;
  132702. /**
  132703. * The underlying effect
  132704. */
  132705. effect: Effect;
  132706. /**
  132707. * Creates an effect to be renderer
  132708. * @param creationOptions options to create the effect
  132709. */
  132710. constructor(creationOptions: EffectWrapperCreationOptions);
  132711. /**
  132712. * Disposes of the effect wrapper
  132713. */
  132714. dispose(): void;
  132715. }
  132716. }
  132717. declare module BABYLON {
  132718. /**
  132719. * Helper class to push actions to a pool of workers.
  132720. */
  132721. export class WorkerPool implements IDisposable {
  132722. private _workerInfos;
  132723. private _pendingActions;
  132724. /**
  132725. * Constructor
  132726. * @param workers Array of workers to use for actions
  132727. */
  132728. constructor(workers: Array<Worker>);
  132729. /**
  132730. * Terminates all workers and clears any pending actions.
  132731. */
  132732. dispose(): void;
  132733. /**
  132734. * Pushes an action to the worker pool. If all the workers are active, the action will be
  132735. * pended until a worker has completed its action.
  132736. * @param action The action to perform. Call onComplete when the action is complete.
  132737. */
  132738. push(action: (worker: Worker, onComplete: () => void) => void): void;
  132739. private _execute;
  132740. }
  132741. }
  132742. declare module BABYLON {
  132743. /**
  132744. * Configuration for Draco compression
  132745. */
  132746. export interface IDracoCompressionConfiguration {
  132747. /**
  132748. * Configuration for the decoder.
  132749. */
  132750. decoder: {
  132751. /**
  132752. * The url to the WebAssembly module.
  132753. */
  132754. wasmUrl?: string;
  132755. /**
  132756. * The url to the WebAssembly binary.
  132757. */
  132758. wasmBinaryUrl?: string;
  132759. /**
  132760. * The url to the fallback JavaScript module.
  132761. */
  132762. fallbackUrl?: string;
  132763. };
  132764. }
  132765. /**
  132766. * Draco compression (https://google.github.io/draco/)
  132767. *
  132768. * This class wraps the Draco module.
  132769. *
  132770. * **Encoder**
  132771. *
  132772. * The encoder is not currently implemented.
  132773. *
  132774. * **Decoder**
  132775. *
  132776. * 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.
  132777. *
  132778. * To update the configuration, use the following code:
  132779. * ```javascript
  132780. * DracoCompression.Configuration = {
  132781. * decoder: {
  132782. * wasmUrl: "<url to the WebAssembly library>",
  132783. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  132784. * fallbackUrl: "<url to the fallback JavaScript library>",
  132785. * }
  132786. * };
  132787. * ```
  132788. *
  132789. * 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.
  132790. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  132791. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  132792. *
  132793. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  132794. * ```javascript
  132795. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  132796. * ```
  132797. *
  132798. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  132799. */
  132800. export class DracoCompression implements IDisposable {
  132801. private _workerPoolPromise?;
  132802. private _decoderModulePromise?;
  132803. /**
  132804. * The configuration. Defaults to the following urls:
  132805. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  132806. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  132807. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  132808. */
  132809. static Configuration: IDracoCompressionConfiguration;
  132810. /**
  132811. * Returns true if the decoder configuration is available.
  132812. */
  132813. static get DecoderAvailable(): boolean;
  132814. /**
  132815. * Default number of workers to create when creating the draco compression object.
  132816. */
  132817. static DefaultNumWorkers: number;
  132818. private static GetDefaultNumWorkers;
  132819. private static _Default;
  132820. /**
  132821. * Default instance for the draco compression object.
  132822. */
  132823. static get Default(): DracoCompression;
  132824. /**
  132825. * Constructor
  132826. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  132827. */
  132828. constructor(numWorkers?: number);
  132829. /**
  132830. * Stop all async operations and release resources.
  132831. */
  132832. dispose(): void;
  132833. /**
  132834. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  132835. * @returns a promise that resolves when ready
  132836. */
  132837. whenReadyAsync(): Promise<void>;
  132838. /**
  132839. * Decode Draco compressed mesh data to vertex data.
  132840. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  132841. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  132842. * @returns A promise that resolves with the decoded vertex data
  132843. */
  132844. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  132845. [kind: string]: number;
  132846. }): Promise<VertexData>;
  132847. }
  132848. }
  132849. declare module BABYLON {
  132850. /**
  132851. * Class for building Constructive Solid Geometry
  132852. */
  132853. export class CSG {
  132854. private polygons;
  132855. /**
  132856. * The world matrix
  132857. */
  132858. matrix: Matrix;
  132859. /**
  132860. * Stores the position
  132861. */
  132862. position: Vector3;
  132863. /**
  132864. * Stores the rotation
  132865. */
  132866. rotation: Vector3;
  132867. /**
  132868. * Stores the rotation quaternion
  132869. */
  132870. rotationQuaternion: Nullable<Quaternion>;
  132871. /**
  132872. * Stores the scaling vector
  132873. */
  132874. scaling: Vector3;
  132875. /**
  132876. * Convert the Mesh to CSG
  132877. * @param mesh The Mesh to convert to CSG
  132878. * @returns A new CSG from the Mesh
  132879. */
  132880. static FromMesh(mesh: Mesh): CSG;
  132881. /**
  132882. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  132883. * @param polygons Polygons used to construct a CSG solid
  132884. */
  132885. private static FromPolygons;
  132886. /**
  132887. * Clones, or makes a deep copy, of the CSG
  132888. * @returns A new CSG
  132889. */
  132890. clone(): CSG;
  132891. /**
  132892. * Unions this CSG with another CSG
  132893. * @param csg The CSG to union against this CSG
  132894. * @returns The unioned CSG
  132895. */
  132896. union(csg: CSG): CSG;
  132897. /**
  132898. * Unions this CSG with another CSG in place
  132899. * @param csg The CSG to union against this CSG
  132900. */
  132901. unionInPlace(csg: CSG): void;
  132902. /**
  132903. * Subtracts this CSG with another CSG
  132904. * @param csg The CSG to subtract against this CSG
  132905. * @returns A new CSG
  132906. */
  132907. subtract(csg: CSG): CSG;
  132908. /**
  132909. * Subtracts this CSG with another CSG in place
  132910. * @param csg The CSG to subtact against this CSG
  132911. */
  132912. subtractInPlace(csg: CSG): void;
  132913. /**
  132914. * Intersect this CSG with another CSG
  132915. * @param csg The CSG to intersect against this CSG
  132916. * @returns A new CSG
  132917. */
  132918. intersect(csg: CSG): CSG;
  132919. /**
  132920. * Intersects this CSG with another CSG in place
  132921. * @param csg The CSG to intersect against this CSG
  132922. */
  132923. intersectInPlace(csg: CSG): void;
  132924. /**
  132925. * Return a new CSG solid with solid and empty space switched. This solid is
  132926. * not modified.
  132927. * @returns A new CSG solid with solid and empty space switched
  132928. */
  132929. inverse(): CSG;
  132930. /**
  132931. * Inverses the CSG in place
  132932. */
  132933. inverseInPlace(): void;
  132934. /**
  132935. * This is used to keep meshes transformations so they can be restored
  132936. * when we build back a Babylon Mesh
  132937. * NB : All CSG operations are performed in world coordinates
  132938. * @param csg The CSG to copy the transform attributes from
  132939. * @returns This CSG
  132940. */
  132941. copyTransformAttributes(csg: CSG): CSG;
  132942. /**
  132943. * Build Raw mesh from CSG
  132944. * Coordinates here are in world space
  132945. * @param name The name of the mesh geometry
  132946. * @param scene The Scene
  132947. * @param keepSubMeshes Specifies if the submeshes should be kept
  132948. * @returns A new Mesh
  132949. */
  132950. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132951. /**
  132952. * Build Mesh from CSG taking material and transforms into account
  132953. * @param name The name of the Mesh
  132954. * @param material The material of the Mesh
  132955. * @param scene The Scene
  132956. * @param keepSubMeshes Specifies if submeshes should be kept
  132957. * @returns The new Mesh
  132958. */
  132959. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132960. }
  132961. }
  132962. declare module BABYLON {
  132963. /**
  132964. * Class used to create a trail following a mesh
  132965. */
  132966. export class TrailMesh extends Mesh {
  132967. private _generator;
  132968. private _autoStart;
  132969. private _running;
  132970. private _diameter;
  132971. private _length;
  132972. private _sectionPolygonPointsCount;
  132973. private _sectionVectors;
  132974. private _sectionNormalVectors;
  132975. private _beforeRenderObserver;
  132976. /**
  132977. * @constructor
  132978. * @param name The value used by scene.getMeshByName() to do a lookup.
  132979. * @param generator The mesh or transform node to generate a trail.
  132980. * @param scene The scene to add this mesh to.
  132981. * @param diameter Diameter of trailing mesh. Default is 1.
  132982. * @param length Length of trailing mesh. Default is 60.
  132983. * @param autoStart Automatically start trailing mesh. Default true.
  132984. */
  132985. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  132986. /**
  132987. * "TrailMesh"
  132988. * @returns "TrailMesh"
  132989. */
  132990. getClassName(): string;
  132991. private _createMesh;
  132992. /**
  132993. * Start trailing mesh.
  132994. */
  132995. start(): void;
  132996. /**
  132997. * Stop trailing mesh.
  132998. */
  132999. stop(): void;
  133000. /**
  133001. * Update trailing mesh geometry.
  133002. */
  133003. update(): void;
  133004. /**
  133005. * Returns a new TrailMesh object.
  133006. * @param name is a string, the name given to the new mesh
  133007. * @param newGenerator use new generator object for cloned trail mesh
  133008. * @returns a new mesh
  133009. */
  133010. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133011. /**
  133012. * Serializes this trail mesh
  133013. * @param serializationObject object to write serialization to
  133014. */
  133015. serialize(serializationObject: any): void;
  133016. /**
  133017. * Parses a serialized trail mesh
  133018. * @param parsedMesh the serialized mesh
  133019. * @param scene the scene to create the trail mesh in
  133020. * @returns the created trail mesh
  133021. */
  133022. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133023. }
  133024. }
  133025. declare module BABYLON {
  133026. /**
  133027. * Class containing static functions to help procedurally build meshes
  133028. */
  133029. export class TiledBoxBuilder {
  133030. /**
  133031. * Creates a box mesh
  133032. * 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)
  133033. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133037. * @param name defines the name of the mesh
  133038. * @param options defines the options used to create the mesh
  133039. * @param scene defines the hosting scene
  133040. * @returns the box mesh
  133041. */
  133042. static CreateTiledBox(name: string, options: {
  133043. pattern?: number;
  133044. width?: number;
  133045. height?: number;
  133046. depth?: number;
  133047. tileSize?: number;
  133048. tileWidth?: number;
  133049. tileHeight?: number;
  133050. alignHorizontal?: number;
  133051. alignVertical?: number;
  133052. faceUV?: Vector4[];
  133053. faceColors?: Color4[];
  133054. sideOrientation?: number;
  133055. updatable?: boolean;
  133056. }, scene?: Nullable<Scene>): Mesh;
  133057. }
  133058. }
  133059. declare module BABYLON {
  133060. /**
  133061. * Class containing static functions to help procedurally build meshes
  133062. */
  133063. export class TorusKnotBuilder {
  133064. /**
  133065. * Creates a torus knot mesh
  133066. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133067. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133068. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133069. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133073. * @param name defines the name of the mesh
  133074. * @param options defines the options used to create the mesh
  133075. * @param scene defines the hosting scene
  133076. * @returns the torus knot mesh
  133077. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133078. */
  133079. static CreateTorusKnot(name: string, options: {
  133080. radius?: number;
  133081. tube?: number;
  133082. radialSegments?: number;
  133083. tubularSegments?: number;
  133084. p?: number;
  133085. q?: number;
  133086. updatable?: boolean;
  133087. sideOrientation?: number;
  133088. frontUVs?: Vector4;
  133089. backUVs?: Vector4;
  133090. }, scene: any): Mesh;
  133091. }
  133092. }
  133093. declare module BABYLON {
  133094. /**
  133095. * Polygon
  133096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133097. */
  133098. export class Polygon {
  133099. /**
  133100. * Creates a rectangle
  133101. * @param xmin bottom X coord
  133102. * @param ymin bottom Y coord
  133103. * @param xmax top X coord
  133104. * @param ymax top Y coord
  133105. * @returns points that make the resulting rectation
  133106. */
  133107. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133108. /**
  133109. * Creates a circle
  133110. * @param radius radius of circle
  133111. * @param cx scale in x
  133112. * @param cy scale in y
  133113. * @param numberOfSides number of sides that make up the circle
  133114. * @returns points that make the resulting circle
  133115. */
  133116. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133117. /**
  133118. * Creates a polygon from input string
  133119. * @param input Input polygon data
  133120. * @returns the parsed points
  133121. */
  133122. static Parse(input: string): Vector2[];
  133123. /**
  133124. * Starts building a polygon from x and y coordinates
  133125. * @param x x coordinate
  133126. * @param y y coordinate
  133127. * @returns the started path2
  133128. */
  133129. static StartingAt(x: number, y: number): Path2;
  133130. }
  133131. /**
  133132. * Builds a polygon
  133133. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133134. */
  133135. export class PolygonMeshBuilder {
  133136. private _points;
  133137. private _outlinepoints;
  133138. private _holes;
  133139. private _name;
  133140. private _scene;
  133141. private _epoints;
  133142. private _eholes;
  133143. private _addToepoint;
  133144. /**
  133145. * Babylon reference to the earcut plugin.
  133146. */
  133147. bjsEarcut: any;
  133148. /**
  133149. * Creates a PolygonMeshBuilder
  133150. * @param name name of the builder
  133151. * @param contours Path of the polygon
  133152. * @param scene scene to add to when creating the mesh
  133153. * @param earcutInjection can be used to inject your own earcut reference
  133154. */
  133155. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133156. /**
  133157. * Adds a whole within the polygon
  133158. * @param hole Array of points defining the hole
  133159. * @returns this
  133160. */
  133161. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133162. /**
  133163. * Creates the polygon
  133164. * @param updatable If the mesh should be updatable
  133165. * @param depth The depth of the mesh created
  133166. * @returns the created mesh
  133167. */
  133168. build(updatable?: boolean, depth?: number): Mesh;
  133169. /**
  133170. * Creates the polygon
  133171. * @param depth The depth of the mesh created
  133172. * @returns the created VertexData
  133173. */
  133174. buildVertexData(depth?: number): VertexData;
  133175. /**
  133176. * Adds a side to the polygon
  133177. * @param positions points that make the polygon
  133178. * @param normals normals of the polygon
  133179. * @param uvs uvs of the polygon
  133180. * @param indices indices of the polygon
  133181. * @param bounds bounds of the polygon
  133182. * @param points points of the polygon
  133183. * @param depth depth of the polygon
  133184. * @param flip flip of the polygon
  133185. */
  133186. private addSide;
  133187. }
  133188. }
  133189. declare module BABYLON {
  133190. /**
  133191. * Class containing static functions to help procedurally build meshes
  133192. */
  133193. export class PolygonBuilder {
  133194. /**
  133195. * Creates a polygon mesh
  133196. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133197. * * 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
  133198. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133201. * * Remember you can only change the shape positions, not their number when updating a polygon
  133202. * @param name defines the name of the mesh
  133203. * @param options defines the options used to create the mesh
  133204. * @param scene defines the hosting scene
  133205. * @param earcutInjection can be used to inject your own earcut reference
  133206. * @returns the polygon mesh
  133207. */
  133208. static CreatePolygon(name: string, options: {
  133209. shape: Vector3[];
  133210. holes?: Vector3[][];
  133211. depth?: number;
  133212. faceUV?: Vector4[];
  133213. faceColors?: Color4[];
  133214. updatable?: boolean;
  133215. sideOrientation?: number;
  133216. frontUVs?: Vector4;
  133217. backUVs?: Vector4;
  133218. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133219. /**
  133220. * Creates an extruded polygon mesh, with depth in the Y direction.
  133221. * * 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)
  133222. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133223. * @param name defines the name of the mesh
  133224. * @param options defines the options used to create the mesh
  133225. * @param scene defines the hosting scene
  133226. * @param earcutInjection can be used to inject your own earcut reference
  133227. * @returns the polygon mesh
  133228. */
  133229. static ExtrudePolygon(name: string, options: {
  133230. shape: Vector3[];
  133231. holes?: Vector3[][];
  133232. depth?: number;
  133233. faceUV?: Vector4[];
  133234. faceColors?: Color4[];
  133235. updatable?: boolean;
  133236. sideOrientation?: number;
  133237. frontUVs?: Vector4;
  133238. backUVs?: Vector4;
  133239. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133240. }
  133241. }
  133242. declare module BABYLON {
  133243. /**
  133244. * Class containing static functions to help procedurally build meshes
  133245. */
  133246. export class LatheBuilder {
  133247. /**
  133248. * Creates lathe mesh.
  133249. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133250. * * 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
  133251. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133252. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133253. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133254. * * 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
  133255. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133256. * * 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
  133257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133261. * @param name defines the name of the mesh
  133262. * @param options defines the options used to create the mesh
  133263. * @param scene defines the hosting scene
  133264. * @returns the lathe mesh
  133265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133266. */
  133267. static CreateLathe(name: string, options: {
  133268. shape: Vector3[];
  133269. radius?: number;
  133270. tessellation?: number;
  133271. clip?: number;
  133272. arc?: number;
  133273. closed?: boolean;
  133274. updatable?: boolean;
  133275. sideOrientation?: number;
  133276. frontUVs?: Vector4;
  133277. backUVs?: Vector4;
  133278. cap?: number;
  133279. invertUV?: boolean;
  133280. }, scene?: Nullable<Scene>): Mesh;
  133281. }
  133282. }
  133283. declare module BABYLON {
  133284. /**
  133285. * Class containing static functions to help procedurally build meshes
  133286. */
  133287. export class TiledPlaneBuilder {
  133288. /**
  133289. * Creates a tiled plane mesh
  133290. * * The parameter `pattern` will, depending on value, do nothing or
  133291. * * * flip (reflect about central vertical) alternate tiles across and up
  133292. * * * flip every tile on alternate rows
  133293. * * * rotate (180 degs) alternate tiles across and up
  133294. * * * rotate every tile on alternate rows
  133295. * * * flip and rotate alternate tiles across and up
  133296. * * * flip and rotate every tile on alternate rows
  133297. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133298. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133301. * * 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)
  133302. * * 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)
  133303. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133304. * @param name defines the name of the mesh
  133305. * @param options defines the options used to create the mesh
  133306. * @param scene defines the hosting scene
  133307. * @returns the box mesh
  133308. */
  133309. static CreateTiledPlane(name: string, options: {
  133310. pattern?: number;
  133311. tileSize?: number;
  133312. tileWidth?: number;
  133313. tileHeight?: number;
  133314. size?: number;
  133315. width?: number;
  133316. height?: number;
  133317. alignHorizontal?: number;
  133318. alignVertical?: number;
  133319. sideOrientation?: number;
  133320. frontUVs?: Vector4;
  133321. backUVs?: Vector4;
  133322. updatable?: boolean;
  133323. }, scene?: Nullable<Scene>): Mesh;
  133324. }
  133325. }
  133326. declare module BABYLON {
  133327. /**
  133328. * Class containing static functions to help procedurally build meshes
  133329. */
  133330. export class TubeBuilder {
  133331. /**
  133332. * Creates a tube mesh.
  133333. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133334. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  133335. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  133336. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  133337. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  133338. * * 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)
  133339. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  133340. * * 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
  133341. * * 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
  133342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133344. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133346. * @param name defines the name of the mesh
  133347. * @param options defines the options used to create the mesh
  133348. * @param scene defines the hosting scene
  133349. * @returns the tube mesh
  133350. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133351. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  133352. */
  133353. static CreateTube(name: string, options: {
  133354. path: Vector3[];
  133355. radius?: number;
  133356. tessellation?: number;
  133357. radiusFunction?: {
  133358. (i: number, distance: number): number;
  133359. };
  133360. cap?: number;
  133361. arc?: number;
  133362. updatable?: boolean;
  133363. sideOrientation?: number;
  133364. frontUVs?: Vector4;
  133365. backUVs?: Vector4;
  133366. instance?: Mesh;
  133367. invertUV?: boolean;
  133368. }, scene?: Nullable<Scene>): Mesh;
  133369. }
  133370. }
  133371. declare module BABYLON {
  133372. /**
  133373. * Class containing static functions to help procedurally build meshes
  133374. */
  133375. export class IcoSphereBuilder {
  133376. /**
  133377. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133378. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133379. * * 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`)
  133380. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133381. * * 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
  133382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133385. * @param name defines the name of the mesh
  133386. * @param options defines the options used to create the mesh
  133387. * @param scene defines the hosting scene
  133388. * @returns the icosahedron mesh
  133389. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133390. */
  133391. static CreateIcoSphere(name: string, options: {
  133392. radius?: number;
  133393. radiusX?: number;
  133394. radiusY?: number;
  133395. radiusZ?: number;
  133396. flat?: boolean;
  133397. subdivisions?: number;
  133398. sideOrientation?: number;
  133399. frontUVs?: Vector4;
  133400. backUVs?: Vector4;
  133401. updatable?: boolean;
  133402. }, scene?: Nullable<Scene>): Mesh;
  133403. }
  133404. }
  133405. declare module BABYLON {
  133406. /**
  133407. * Class containing static functions to help procedurally build meshes
  133408. */
  133409. export class DecalBuilder {
  133410. /**
  133411. * Creates a decal mesh.
  133412. * 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
  133413. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  133414. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  133415. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  133416. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  133417. * @param name defines the name of the mesh
  133418. * @param sourceMesh defines the mesh where the decal must be applied
  133419. * @param options defines the options used to create the mesh
  133420. * @param scene defines the hosting scene
  133421. * @returns the decal mesh
  133422. * @see https://doc.babylonjs.com/how_to/decals
  133423. */
  133424. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  133425. position?: Vector3;
  133426. normal?: Vector3;
  133427. size?: Vector3;
  133428. angle?: number;
  133429. }): Mesh;
  133430. }
  133431. }
  133432. declare module BABYLON {
  133433. /**
  133434. * Class containing static functions to help procedurally build meshes
  133435. */
  133436. export class MeshBuilder {
  133437. /**
  133438. * Creates a box mesh
  133439. * * The parameter `size` sets the size (float) of each box side (default 1)
  133440. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  133441. * * 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)
  133442. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133446. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133447. * @param name defines the name of the mesh
  133448. * @param options defines the options used to create the mesh
  133449. * @param scene defines the hosting scene
  133450. * @returns the box mesh
  133451. */
  133452. static CreateBox(name: string, options: {
  133453. size?: number;
  133454. width?: number;
  133455. height?: number;
  133456. depth?: number;
  133457. faceUV?: Vector4[];
  133458. faceColors?: Color4[];
  133459. sideOrientation?: number;
  133460. frontUVs?: Vector4;
  133461. backUVs?: Vector4;
  133462. updatable?: boolean;
  133463. }, scene?: Nullable<Scene>): Mesh;
  133464. /**
  133465. * Creates a tiled box mesh
  133466. * * faceTiles sets the pattern, tile size and number of tiles for a face
  133467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133468. * @param name defines the name of the mesh
  133469. * @param options defines the options used to create the mesh
  133470. * @param scene defines the hosting scene
  133471. * @returns the tiled box mesh
  133472. */
  133473. static CreateTiledBox(name: string, options: {
  133474. pattern?: number;
  133475. size?: number;
  133476. width?: number;
  133477. height?: number;
  133478. depth: number;
  133479. tileSize?: number;
  133480. tileWidth?: number;
  133481. tileHeight?: number;
  133482. faceUV?: Vector4[];
  133483. faceColors?: Color4[];
  133484. alignHorizontal?: number;
  133485. alignVertical?: number;
  133486. sideOrientation?: number;
  133487. updatable?: boolean;
  133488. }, scene?: Nullable<Scene>): Mesh;
  133489. /**
  133490. * Creates a sphere mesh
  133491. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133492. * * 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`)
  133493. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133494. * * 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
  133495. * * 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)
  133496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133499. * @param name defines the name of the mesh
  133500. * @param options defines the options used to create the mesh
  133501. * @param scene defines the hosting scene
  133502. * @returns the sphere mesh
  133503. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133504. */
  133505. static CreateSphere(name: string, options: {
  133506. segments?: number;
  133507. diameter?: number;
  133508. diameterX?: number;
  133509. diameterY?: number;
  133510. diameterZ?: number;
  133511. arc?: number;
  133512. slice?: number;
  133513. sideOrientation?: number;
  133514. frontUVs?: Vector4;
  133515. backUVs?: Vector4;
  133516. updatable?: boolean;
  133517. }, scene?: Nullable<Scene>): Mesh;
  133518. /**
  133519. * Creates a plane polygonal mesh. By default, this is a disc
  133520. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  133521. * * 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
  133522. * * 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
  133523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133526. * @param name defines the name of the mesh
  133527. * @param options defines the options used to create the mesh
  133528. * @param scene defines the hosting scene
  133529. * @returns the plane polygonal mesh
  133530. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  133531. */
  133532. static CreateDisc(name: string, options: {
  133533. radius?: number;
  133534. tessellation?: number;
  133535. arc?: number;
  133536. updatable?: boolean;
  133537. sideOrientation?: number;
  133538. frontUVs?: Vector4;
  133539. backUVs?: Vector4;
  133540. }, scene?: Nullable<Scene>): Mesh;
  133541. /**
  133542. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133543. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133544. * * 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`)
  133545. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133546. * * 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
  133547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133550. * @param name defines the name of the mesh
  133551. * @param options defines the options used to create the mesh
  133552. * @param scene defines the hosting scene
  133553. * @returns the icosahedron mesh
  133554. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133555. */
  133556. static CreateIcoSphere(name: string, options: {
  133557. radius?: number;
  133558. radiusX?: number;
  133559. radiusY?: number;
  133560. radiusZ?: number;
  133561. flat?: boolean;
  133562. subdivisions?: number;
  133563. sideOrientation?: number;
  133564. frontUVs?: Vector4;
  133565. backUVs?: Vector4;
  133566. updatable?: boolean;
  133567. }, scene?: Nullable<Scene>): Mesh;
  133568. /**
  133569. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133570. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  133571. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  133572. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  133573. * * 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
  133574. * * 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
  133575. * * 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
  133576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133578. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133579. * * 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
  133580. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  133581. * * 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
  133582. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  133583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133584. * @param name defines the name of the mesh
  133585. * @param options defines the options used to create the mesh
  133586. * @param scene defines the hosting scene
  133587. * @returns the ribbon mesh
  133588. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  133589. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133590. */
  133591. static CreateRibbon(name: string, options: {
  133592. pathArray: Vector3[][];
  133593. closeArray?: boolean;
  133594. closePath?: boolean;
  133595. offset?: number;
  133596. updatable?: boolean;
  133597. sideOrientation?: number;
  133598. frontUVs?: Vector4;
  133599. backUVs?: Vector4;
  133600. instance?: Mesh;
  133601. invertUV?: boolean;
  133602. uvs?: Vector2[];
  133603. colors?: Color4[];
  133604. }, scene?: Nullable<Scene>): Mesh;
  133605. /**
  133606. * Creates a cylinder or a cone mesh
  133607. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  133608. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  133609. * * 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.
  133610. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  133611. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  133612. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  133613. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  133614. * * 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).
  133615. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  133616. * * 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).
  133617. * * 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
  133618. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  133619. * * 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
  133620. * * 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.
  133621. * * If `enclose` is false, a ring surface is one element.
  133622. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  133623. * * 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
  133624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133627. * @param name defines the name of the mesh
  133628. * @param options defines the options used to create the mesh
  133629. * @param scene defines the hosting scene
  133630. * @returns the cylinder mesh
  133631. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  133632. */
  133633. static CreateCylinder(name: string, options: {
  133634. height?: number;
  133635. diameterTop?: number;
  133636. diameterBottom?: number;
  133637. diameter?: number;
  133638. tessellation?: number;
  133639. subdivisions?: number;
  133640. arc?: number;
  133641. faceColors?: Color4[];
  133642. faceUV?: Vector4[];
  133643. updatable?: boolean;
  133644. hasRings?: boolean;
  133645. enclose?: boolean;
  133646. cap?: number;
  133647. sideOrientation?: number;
  133648. frontUVs?: Vector4;
  133649. backUVs?: Vector4;
  133650. }, scene?: Nullable<Scene>): Mesh;
  133651. /**
  133652. * Creates a torus mesh
  133653. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  133654. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  133655. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  133656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133659. * @param name defines the name of the mesh
  133660. * @param options defines the options used to create the mesh
  133661. * @param scene defines the hosting scene
  133662. * @returns the torus mesh
  133663. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  133664. */
  133665. static CreateTorus(name: string, options: {
  133666. diameter?: number;
  133667. thickness?: number;
  133668. tessellation?: number;
  133669. updatable?: boolean;
  133670. sideOrientation?: number;
  133671. frontUVs?: Vector4;
  133672. backUVs?: Vector4;
  133673. }, scene?: Nullable<Scene>): Mesh;
  133674. /**
  133675. * Creates a torus knot mesh
  133676. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133677. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133678. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133679. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133683. * @param name defines the name of the mesh
  133684. * @param options defines the options used to create the mesh
  133685. * @param scene defines the hosting scene
  133686. * @returns the torus knot mesh
  133687. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133688. */
  133689. static CreateTorusKnot(name: string, options: {
  133690. radius?: number;
  133691. tube?: number;
  133692. radialSegments?: number;
  133693. tubularSegments?: number;
  133694. p?: number;
  133695. q?: number;
  133696. updatable?: boolean;
  133697. sideOrientation?: number;
  133698. frontUVs?: Vector4;
  133699. backUVs?: Vector4;
  133700. }, scene?: Nullable<Scene>): Mesh;
  133701. /**
  133702. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133703. * * 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
  133704. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133705. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133706. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133707. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133708. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133709. * * 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
  133710. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133713. * @param name defines the name of the new line system
  133714. * @param options defines the options used to create the line system
  133715. * @param scene defines the hosting scene
  133716. * @returns a new line system mesh
  133717. */
  133718. static CreateLineSystem(name: string, options: {
  133719. lines: Vector3[][];
  133720. updatable?: boolean;
  133721. instance?: Nullable<LinesMesh>;
  133722. colors?: Nullable<Color4[][]>;
  133723. useVertexAlpha?: boolean;
  133724. }, scene: Nullable<Scene>): LinesMesh;
  133725. /**
  133726. * Creates a line mesh
  133727. * 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
  133728. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133729. * * The parameter `points` is an array successive Vector3
  133730. * * 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
  133731. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133732. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133733. * * When updating an instance, remember that only point positions can change, not the number of points
  133734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133736. * @param name defines the name of the new line system
  133737. * @param options defines the options used to create the line system
  133738. * @param scene defines the hosting scene
  133739. * @returns a new line mesh
  133740. */
  133741. static CreateLines(name: string, options: {
  133742. points: Vector3[];
  133743. updatable?: boolean;
  133744. instance?: Nullable<LinesMesh>;
  133745. colors?: Color4[];
  133746. useVertexAlpha?: boolean;
  133747. }, scene?: Nullable<Scene>): LinesMesh;
  133748. /**
  133749. * Creates a dashed line mesh
  133750. * * 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
  133751. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133752. * * The parameter `points` is an array successive Vector3
  133753. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133754. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133755. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133756. * * 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
  133757. * * When updating an instance, remember that only point positions can change, not the number of points
  133758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133759. * @param name defines the name of the mesh
  133760. * @param options defines the options used to create the mesh
  133761. * @param scene defines the hosting scene
  133762. * @returns the dashed line mesh
  133763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133764. */
  133765. static CreateDashedLines(name: string, options: {
  133766. points: Vector3[];
  133767. dashSize?: number;
  133768. gapSize?: number;
  133769. dashNb?: number;
  133770. updatable?: boolean;
  133771. instance?: LinesMesh;
  133772. }, scene?: Nullable<Scene>): LinesMesh;
  133773. /**
  133774. * 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.
  133775. * * 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.
  133776. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133777. * * 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.
  133778. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  133779. * * 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
  133780. * * 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
  133781. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  133782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  133785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133786. * @param name defines the name of the mesh
  133787. * @param options defines the options used to create the mesh
  133788. * @param scene defines the hosting scene
  133789. * @returns the extruded shape mesh
  133790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133792. */
  133793. static ExtrudeShape(name: string, options: {
  133794. shape: Vector3[];
  133795. path: Vector3[];
  133796. scale?: number;
  133797. rotation?: number;
  133798. cap?: number;
  133799. updatable?: boolean;
  133800. sideOrientation?: number;
  133801. frontUVs?: Vector4;
  133802. backUVs?: Vector4;
  133803. instance?: Mesh;
  133804. invertUV?: boolean;
  133805. }, scene?: Nullable<Scene>): Mesh;
  133806. /**
  133807. * Creates an custom extruded shape mesh.
  133808. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  133809. * * 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.
  133810. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133811. * * 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
  133812. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  133813. * * 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
  133814. * * It must returns a float value that will be the scale value applied to the shape on each path point
  133815. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  133816. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  133817. * * 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
  133818. * * 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
  133819. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  133820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133824. * @param name defines the name of the mesh
  133825. * @param options defines the options used to create the mesh
  133826. * @param scene defines the hosting scene
  133827. * @returns the custom extruded shape mesh
  133828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  133829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133831. */
  133832. static ExtrudeShapeCustom(name: string, options: {
  133833. shape: Vector3[];
  133834. path: Vector3[];
  133835. scaleFunction?: any;
  133836. rotationFunction?: any;
  133837. ribbonCloseArray?: boolean;
  133838. ribbonClosePath?: boolean;
  133839. cap?: number;
  133840. updatable?: boolean;
  133841. sideOrientation?: number;
  133842. frontUVs?: Vector4;
  133843. backUVs?: Vector4;
  133844. instance?: Mesh;
  133845. invertUV?: boolean;
  133846. }, scene?: Nullable<Scene>): Mesh;
  133847. /**
  133848. * Creates lathe mesh.
  133849. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133850. * * 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
  133851. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133852. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133853. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133854. * * 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
  133855. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133856. * * 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
  133857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133859. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133861. * @param name defines the name of the mesh
  133862. * @param options defines the options used to create the mesh
  133863. * @param scene defines the hosting scene
  133864. * @returns the lathe mesh
  133865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133866. */
  133867. static CreateLathe(name: string, options: {
  133868. shape: Vector3[];
  133869. radius?: number;
  133870. tessellation?: number;
  133871. clip?: number;
  133872. arc?: number;
  133873. closed?: boolean;
  133874. updatable?: boolean;
  133875. sideOrientation?: number;
  133876. frontUVs?: Vector4;
  133877. backUVs?: Vector4;
  133878. cap?: number;
  133879. invertUV?: boolean;
  133880. }, scene?: Nullable<Scene>): Mesh;
  133881. /**
  133882. * Creates a tiled plane mesh
  133883. * * You can set a limited pattern arrangement with the tiles
  133884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133887. * @param name defines the name of the mesh
  133888. * @param options defines the options used to create the mesh
  133889. * @param scene defines the hosting scene
  133890. * @returns the plane mesh
  133891. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133892. */
  133893. static CreateTiledPlane(name: string, options: {
  133894. pattern?: number;
  133895. tileSize?: number;
  133896. tileWidth?: number;
  133897. tileHeight?: number;
  133898. size?: number;
  133899. width?: number;
  133900. height?: number;
  133901. alignHorizontal?: number;
  133902. alignVertical?: number;
  133903. sideOrientation?: number;
  133904. frontUVs?: Vector4;
  133905. backUVs?: Vector4;
  133906. updatable?: boolean;
  133907. }, scene?: Nullable<Scene>): Mesh;
  133908. /**
  133909. * Creates a plane mesh
  133910. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  133911. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  133912. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  133913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133916. * @param name defines the name of the mesh
  133917. * @param options defines the options used to create the mesh
  133918. * @param scene defines the hosting scene
  133919. * @returns the plane mesh
  133920. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133921. */
  133922. static CreatePlane(name: string, options: {
  133923. size?: number;
  133924. width?: number;
  133925. height?: number;
  133926. sideOrientation?: number;
  133927. frontUVs?: Vector4;
  133928. backUVs?: Vector4;
  133929. updatable?: boolean;
  133930. sourcePlane?: Plane;
  133931. }, scene?: Nullable<Scene>): Mesh;
  133932. /**
  133933. * Creates a ground mesh
  133934. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  133935. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  133936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133937. * @param name defines the name of the mesh
  133938. * @param options defines the options used to create the mesh
  133939. * @param scene defines the hosting scene
  133940. * @returns the ground mesh
  133941. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  133942. */
  133943. static CreateGround(name: string, options: {
  133944. width?: number;
  133945. height?: number;
  133946. subdivisions?: number;
  133947. subdivisionsX?: number;
  133948. subdivisionsY?: number;
  133949. updatable?: boolean;
  133950. }, scene?: Nullable<Scene>): Mesh;
  133951. /**
  133952. * Creates a tiled ground mesh
  133953. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  133954. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  133955. * * 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
  133956. * * 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
  133957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133958. * @param name defines the name of the mesh
  133959. * @param options defines the options used to create the mesh
  133960. * @param scene defines the hosting scene
  133961. * @returns the tiled ground mesh
  133962. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  133963. */
  133964. static CreateTiledGround(name: string, options: {
  133965. xmin: number;
  133966. zmin: number;
  133967. xmax: number;
  133968. zmax: number;
  133969. subdivisions?: {
  133970. w: number;
  133971. h: number;
  133972. };
  133973. precision?: {
  133974. w: number;
  133975. h: number;
  133976. };
  133977. updatable?: boolean;
  133978. }, scene?: Nullable<Scene>): Mesh;
  133979. /**
  133980. * Creates a ground mesh from a height map
  133981. * * The parameter `url` sets the URL of the height map image resource.
  133982. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  133983. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  133984. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  133985. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  133986. * * 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.
  133987. * * 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).
  133988. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  133989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133990. * @param name defines the name of the mesh
  133991. * @param url defines the url to the height map
  133992. * @param options defines the options used to create the mesh
  133993. * @param scene defines the hosting scene
  133994. * @returns the ground mesh
  133995. * @see https://doc.babylonjs.com/babylon101/height_map
  133996. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  133997. */
  133998. static CreateGroundFromHeightMap(name: string, url: string, options: {
  133999. width?: number;
  134000. height?: number;
  134001. subdivisions?: number;
  134002. minHeight?: number;
  134003. maxHeight?: number;
  134004. colorFilter?: Color3;
  134005. alphaFilter?: number;
  134006. updatable?: boolean;
  134007. onReady?: (mesh: GroundMesh) => void;
  134008. }, scene?: Nullable<Scene>): GroundMesh;
  134009. /**
  134010. * Creates a polygon mesh
  134011. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134012. * * 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
  134013. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134016. * * Remember you can only change the shape positions, not their number when updating a polygon
  134017. * @param name defines the name of the mesh
  134018. * @param options defines the options used to create the mesh
  134019. * @param scene defines the hosting scene
  134020. * @param earcutInjection can be used to inject your own earcut reference
  134021. * @returns the polygon mesh
  134022. */
  134023. static CreatePolygon(name: string, options: {
  134024. shape: Vector3[];
  134025. holes?: Vector3[][];
  134026. depth?: number;
  134027. faceUV?: Vector4[];
  134028. faceColors?: Color4[];
  134029. updatable?: boolean;
  134030. sideOrientation?: number;
  134031. frontUVs?: Vector4;
  134032. backUVs?: Vector4;
  134033. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134034. /**
  134035. * Creates an extruded polygon mesh, with depth in the Y direction.
  134036. * * 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)
  134037. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134038. * @param name defines the name of the mesh
  134039. * @param options defines the options used to create the mesh
  134040. * @param scene defines the hosting scene
  134041. * @param earcutInjection can be used to inject your own earcut reference
  134042. * @returns the polygon mesh
  134043. */
  134044. static ExtrudePolygon(name: string, options: {
  134045. shape: Vector3[];
  134046. holes?: Vector3[][];
  134047. depth?: number;
  134048. faceUV?: Vector4[];
  134049. faceColors?: Color4[];
  134050. updatable?: boolean;
  134051. sideOrientation?: number;
  134052. frontUVs?: Vector4;
  134053. backUVs?: Vector4;
  134054. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134055. /**
  134056. * Creates a tube mesh.
  134057. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134058. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134059. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134060. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134061. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134062. * * 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)
  134063. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134064. * * 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
  134065. * * 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
  134066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134070. * @param name defines the name of the mesh
  134071. * @param options defines the options used to create the mesh
  134072. * @param scene defines the hosting scene
  134073. * @returns the tube mesh
  134074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134075. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134076. */
  134077. static CreateTube(name: string, options: {
  134078. path: Vector3[];
  134079. radius?: number;
  134080. tessellation?: number;
  134081. radiusFunction?: {
  134082. (i: number, distance: number): number;
  134083. };
  134084. cap?: number;
  134085. arc?: number;
  134086. updatable?: boolean;
  134087. sideOrientation?: number;
  134088. frontUVs?: Vector4;
  134089. backUVs?: Vector4;
  134090. instance?: Mesh;
  134091. invertUV?: boolean;
  134092. }, scene?: Nullable<Scene>): Mesh;
  134093. /**
  134094. * Creates a polyhedron mesh
  134095. * * 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
  134096. * * The parameter `size` (positive float, default 1) sets the polygon size
  134097. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134098. * * 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`
  134099. * * 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
  134100. * * 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)`)
  134101. * * 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
  134102. * * 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
  134103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134106. * @param name defines the name of the mesh
  134107. * @param options defines the options used to create the mesh
  134108. * @param scene defines the hosting scene
  134109. * @returns the polyhedron mesh
  134110. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134111. */
  134112. static CreatePolyhedron(name: string, options: {
  134113. type?: number;
  134114. size?: number;
  134115. sizeX?: number;
  134116. sizeY?: number;
  134117. sizeZ?: number;
  134118. custom?: any;
  134119. faceUV?: Vector4[];
  134120. faceColors?: Color4[];
  134121. flat?: boolean;
  134122. updatable?: boolean;
  134123. sideOrientation?: number;
  134124. frontUVs?: Vector4;
  134125. backUVs?: Vector4;
  134126. }, scene?: Nullable<Scene>): Mesh;
  134127. /**
  134128. * Creates a decal mesh.
  134129. * 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
  134130. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134131. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134132. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134133. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134134. * @param name defines the name of the mesh
  134135. * @param sourceMesh defines the mesh where the decal must be applied
  134136. * @param options defines the options used to create the mesh
  134137. * @param scene defines the hosting scene
  134138. * @returns the decal mesh
  134139. * @see https://doc.babylonjs.com/how_to/decals
  134140. */
  134141. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134142. position?: Vector3;
  134143. normal?: Vector3;
  134144. size?: Vector3;
  134145. angle?: number;
  134146. }): Mesh;
  134147. }
  134148. }
  134149. declare module BABYLON {
  134150. /**
  134151. * A simplifier interface for future simplification implementations
  134152. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134153. */
  134154. export interface ISimplifier {
  134155. /**
  134156. * Simplification of a given mesh according to the given settings.
  134157. * Since this requires computation, it is assumed that the function runs async.
  134158. * @param settings The settings of the simplification, including quality and distance
  134159. * @param successCallback A callback that will be called after the mesh was simplified.
  134160. * @param errorCallback in case of an error, this callback will be called. optional.
  134161. */
  134162. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134163. }
  134164. /**
  134165. * Expected simplification settings.
  134166. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134167. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134168. */
  134169. export interface ISimplificationSettings {
  134170. /**
  134171. * Gets or sets the expected quality
  134172. */
  134173. quality: number;
  134174. /**
  134175. * Gets or sets the distance when this optimized version should be used
  134176. */
  134177. distance: number;
  134178. /**
  134179. * Gets an already optimized mesh
  134180. */
  134181. optimizeMesh?: boolean;
  134182. }
  134183. /**
  134184. * Class used to specify simplification options
  134185. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134186. */
  134187. export class SimplificationSettings implements ISimplificationSettings {
  134188. /** expected quality */
  134189. quality: number;
  134190. /** distance when this optimized version should be used */
  134191. distance: number;
  134192. /** already optimized mesh */
  134193. optimizeMesh?: boolean | undefined;
  134194. /**
  134195. * Creates a SimplificationSettings
  134196. * @param quality expected quality
  134197. * @param distance distance when this optimized version should be used
  134198. * @param optimizeMesh already optimized mesh
  134199. */
  134200. constructor(
  134201. /** expected quality */
  134202. quality: number,
  134203. /** distance when this optimized version should be used */
  134204. distance: number,
  134205. /** already optimized mesh */
  134206. optimizeMesh?: boolean | undefined);
  134207. }
  134208. /**
  134209. * Interface used to define a simplification task
  134210. */
  134211. export interface ISimplificationTask {
  134212. /**
  134213. * Array of settings
  134214. */
  134215. settings: Array<ISimplificationSettings>;
  134216. /**
  134217. * Simplification type
  134218. */
  134219. simplificationType: SimplificationType;
  134220. /**
  134221. * Mesh to simplify
  134222. */
  134223. mesh: Mesh;
  134224. /**
  134225. * Callback called on success
  134226. */
  134227. successCallback?: () => void;
  134228. /**
  134229. * Defines if parallel processing can be used
  134230. */
  134231. parallelProcessing: boolean;
  134232. }
  134233. /**
  134234. * Queue used to order the simplification tasks
  134235. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134236. */
  134237. export class SimplificationQueue {
  134238. private _simplificationArray;
  134239. /**
  134240. * Gets a boolean indicating that the process is still running
  134241. */
  134242. running: boolean;
  134243. /**
  134244. * Creates a new queue
  134245. */
  134246. constructor();
  134247. /**
  134248. * Adds a new simplification task
  134249. * @param task defines a task to add
  134250. */
  134251. addTask(task: ISimplificationTask): void;
  134252. /**
  134253. * Execute next task
  134254. */
  134255. executeNext(): void;
  134256. /**
  134257. * Execute a simplification task
  134258. * @param task defines the task to run
  134259. */
  134260. runSimplification(task: ISimplificationTask): void;
  134261. private getSimplifier;
  134262. }
  134263. /**
  134264. * The implemented types of simplification
  134265. * At the moment only Quadratic Error Decimation is implemented
  134266. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134267. */
  134268. export enum SimplificationType {
  134269. /** Quadratic error decimation */
  134270. QUADRATIC = 0
  134271. }
  134272. }
  134273. declare module BABYLON {
  134274. interface Scene {
  134275. /** @hidden (Backing field) */
  134276. _simplificationQueue: SimplificationQueue;
  134277. /**
  134278. * Gets or sets the simplification queue attached to the scene
  134279. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134280. */
  134281. simplificationQueue: SimplificationQueue;
  134282. }
  134283. interface Mesh {
  134284. /**
  134285. * Simplify the mesh according to the given array of settings.
  134286. * Function will return immediately and will simplify async
  134287. * @param settings a collection of simplification settings
  134288. * @param parallelProcessing should all levels calculate parallel or one after the other
  134289. * @param simplificationType the type of simplification to run
  134290. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134291. * @returns the current mesh
  134292. */
  134293. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134294. }
  134295. /**
  134296. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134297. * created in a scene
  134298. */
  134299. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134300. /**
  134301. * The component name helpfull to identify the component in the list of scene components.
  134302. */
  134303. readonly name: string;
  134304. /**
  134305. * The scene the component belongs to.
  134306. */
  134307. scene: Scene;
  134308. /**
  134309. * Creates a new instance of the component for the given scene
  134310. * @param scene Defines the scene to register the component in
  134311. */
  134312. constructor(scene: Scene);
  134313. /**
  134314. * Registers the component in a given scene
  134315. */
  134316. register(): void;
  134317. /**
  134318. * Rebuilds the elements related to this component in case of
  134319. * context lost for instance.
  134320. */
  134321. rebuild(): void;
  134322. /**
  134323. * Disposes the component and the associated ressources
  134324. */
  134325. dispose(): void;
  134326. private _beforeCameraUpdate;
  134327. }
  134328. }
  134329. declare module BABYLON {
  134330. /**
  134331. * Navigation plugin interface to add navigation constrained by a navigation mesh
  134332. */
  134333. export interface INavigationEnginePlugin {
  134334. /**
  134335. * plugin name
  134336. */
  134337. name: string;
  134338. /**
  134339. * Creates a navigation mesh
  134340. * @param meshes array of all the geometry used to compute the navigatio mesh
  134341. * @param parameters bunch of parameters used to filter geometry
  134342. */
  134343. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134344. /**
  134345. * Create a navigation mesh debug mesh
  134346. * @param scene is where the mesh will be added
  134347. * @returns debug display mesh
  134348. */
  134349. createDebugNavMesh(scene: Scene): Mesh;
  134350. /**
  134351. * Get a navigation mesh constrained position, closest to the parameter position
  134352. * @param position world position
  134353. * @returns the closest point to position constrained by the navigation mesh
  134354. */
  134355. getClosestPoint(position: Vector3): Vector3;
  134356. /**
  134357. * Get a navigation mesh constrained position, within a particular radius
  134358. * @param position world position
  134359. * @param maxRadius the maximum distance to the constrained world position
  134360. * @returns the closest point to position constrained by the navigation mesh
  134361. */
  134362. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134363. /**
  134364. * Compute the final position from a segment made of destination-position
  134365. * @param position world position
  134366. * @param destination world position
  134367. * @returns the resulting point along the navmesh
  134368. */
  134369. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134370. /**
  134371. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134372. * @param start world position
  134373. * @param end world position
  134374. * @returns array containing world position composing the path
  134375. */
  134376. computePath(start: Vector3, end: Vector3): Vector3[];
  134377. /**
  134378. * If this plugin is supported
  134379. * @returns true if plugin is supported
  134380. */
  134381. isSupported(): boolean;
  134382. /**
  134383. * Create a new Crowd so you can add agents
  134384. * @param maxAgents the maximum agent count in the crowd
  134385. * @param maxAgentRadius the maximum radius an agent can have
  134386. * @param scene to attach the crowd to
  134387. * @returns the crowd you can add agents to
  134388. */
  134389. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134390. /**
  134391. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134392. * The queries will try to find a solution within those bounds
  134393. * default is (1,1,1)
  134394. * @param extent x,y,z value that define the extent around the queries point of reference
  134395. */
  134396. setDefaultQueryExtent(extent: Vector3): void;
  134397. /**
  134398. * Get the Bounding box extent specified by setDefaultQueryExtent
  134399. * @returns the box extent values
  134400. */
  134401. getDefaultQueryExtent(): Vector3;
  134402. /**
  134403. * Release all resources
  134404. */
  134405. dispose(): void;
  134406. }
  134407. /**
  134408. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  134409. */
  134410. export interface ICrowd {
  134411. /**
  134412. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134413. * You can attach anything to that node. The node position is updated in the scene update tick.
  134414. * @param pos world position that will be constrained by the navigation mesh
  134415. * @param parameters agent parameters
  134416. * @param transform hooked to the agent that will be update by the scene
  134417. * @returns agent index
  134418. */
  134419. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134420. /**
  134421. * Returns the agent position in world space
  134422. * @param index agent index returned by addAgent
  134423. * @returns world space position
  134424. */
  134425. getAgentPosition(index: number): Vector3;
  134426. /**
  134427. * Gets the agent velocity in world space
  134428. * @param index agent index returned by addAgent
  134429. * @returns world space velocity
  134430. */
  134431. getAgentVelocity(index: number): Vector3;
  134432. /**
  134433. * remove a particular agent previously created
  134434. * @param index agent index returned by addAgent
  134435. */
  134436. removeAgent(index: number): void;
  134437. /**
  134438. * get the list of all agents attached to this crowd
  134439. * @returns list of agent indices
  134440. */
  134441. getAgents(): number[];
  134442. /**
  134443. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134444. * @param deltaTime in seconds
  134445. */
  134446. update(deltaTime: number): void;
  134447. /**
  134448. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134449. * @param index agent index returned by addAgent
  134450. * @param destination targeted world position
  134451. */
  134452. agentGoto(index: number, destination: Vector3): void;
  134453. /**
  134454. * Teleport the agent to a new position
  134455. * @param index agent index returned by addAgent
  134456. * @param destination targeted world position
  134457. */
  134458. agentTeleport(index: number, destination: Vector3): void;
  134459. /**
  134460. * Update agent parameters
  134461. * @param index agent index returned by addAgent
  134462. * @param parameters agent parameters
  134463. */
  134464. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134465. /**
  134466. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134467. * The queries will try to find a solution within those bounds
  134468. * default is (1,1,1)
  134469. * @param extent x,y,z value that define the extent around the queries point of reference
  134470. */
  134471. setDefaultQueryExtent(extent: Vector3): void;
  134472. /**
  134473. * Get the Bounding box extent specified by setDefaultQueryExtent
  134474. * @returns the box extent values
  134475. */
  134476. getDefaultQueryExtent(): Vector3;
  134477. /**
  134478. * Release all resources
  134479. */
  134480. dispose(): void;
  134481. }
  134482. /**
  134483. * Configures an agent
  134484. */
  134485. export interface IAgentParameters {
  134486. /**
  134487. * Agent radius. [Limit: >= 0]
  134488. */
  134489. radius: number;
  134490. /**
  134491. * Agent height. [Limit: > 0]
  134492. */
  134493. height: number;
  134494. /**
  134495. * Maximum allowed acceleration. [Limit: >= 0]
  134496. */
  134497. maxAcceleration: number;
  134498. /**
  134499. * Maximum allowed speed. [Limit: >= 0]
  134500. */
  134501. maxSpeed: number;
  134502. /**
  134503. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  134504. */
  134505. collisionQueryRange: number;
  134506. /**
  134507. * The path visibility optimization range. [Limit: > 0]
  134508. */
  134509. pathOptimizationRange: number;
  134510. /**
  134511. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  134512. */
  134513. separationWeight: number;
  134514. }
  134515. /**
  134516. * Configures the navigation mesh creation
  134517. */
  134518. export interface INavMeshParameters {
  134519. /**
  134520. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  134521. */
  134522. cs: number;
  134523. /**
  134524. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  134525. */
  134526. ch: number;
  134527. /**
  134528. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  134529. */
  134530. walkableSlopeAngle: number;
  134531. /**
  134532. * Minimum floor to 'ceiling' height that will still allow the floor area to
  134533. * be considered walkable. [Limit: >= 3] [Units: vx]
  134534. */
  134535. walkableHeight: number;
  134536. /**
  134537. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  134538. */
  134539. walkableClimb: number;
  134540. /**
  134541. * The distance to erode/shrink the walkable area of the heightfield away from
  134542. * obstructions. [Limit: >=0] [Units: vx]
  134543. */
  134544. walkableRadius: number;
  134545. /**
  134546. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  134547. */
  134548. maxEdgeLen: number;
  134549. /**
  134550. * The maximum distance a simplfied contour's border edges should deviate
  134551. * the original raw contour. [Limit: >=0] [Units: vx]
  134552. */
  134553. maxSimplificationError: number;
  134554. /**
  134555. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  134556. */
  134557. minRegionArea: number;
  134558. /**
  134559. * Any regions with a span count smaller than this value will, if possible,
  134560. * be merged with larger regions. [Limit: >=0] [Units: vx]
  134561. */
  134562. mergeRegionArea: number;
  134563. /**
  134564. * The maximum number of vertices allowed for polygons generated during the
  134565. * contour to polygon conversion process. [Limit: >= 3]
  134566. */
  134567. maxVertsPerPoly: number;
  134568. /**
  134569. * Sets the sampling distance to use when generating the detail mesh.
  134570. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  134571. */
  134572. detailSampleDist: number;
  134573. /**
  134574. * The maximum distance the detail mesh surface should deviate from heightfield
  134575. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  134576. */
  134577. detailSampleMaxError: number;
  134578. }
  134579. }
  134580. declare module BABYLON {
  134581. /**
  134582. * RecastJS navigation plugin
  134583. */
  134584. export class RecastJSPlugin implements INavigationEnginePlugin {
  134585. /**
  134586. * Reference to the Recast library
  134587. */
  134588. bjsRECAST: any;
  134589. /**
  134590. * plugin name
  134591. */
  134592. name: string;
  134593. /**
  134594. * the first navmesh created. We might extend this to support multiple navmeshes
  134595. */
  134596. navMesh: any;
  134597. /**
  134598. * Initializes the recastJS plugin
  134599. * @param recastInjection can be used to inject your own recast reference
  134600. */
  134601. constructor(recastInjection?: any);
  134602. /**
  134603. * Creates a navigation mesh
  134604. * @param meshes array of all the geometry used to compute the navigatio mesh
  134605. * @param parameters bunch of parameters used to filter geometry
  134606. */
  134607. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134608. /**
  134609. * Create a navigation mesh debug mesh
  134610. * @param scene is where the mesh will be added
  134611. * @returns debug display mesh
  134612. */
  134613. createDebugNavMesh(scene: Scene): Mesh;
  134614. /**
  134615. * Get a navigation mesh constrained position, closest to the parameter position
  134616. * @param position world position
  134617. * @returns the closest point to position constrained by the navigation mesh
  134618. */
  134619. getClosestPoint(position: Vector3): Vector3;
  134620. /**
  134621. * Get a navigation mesh constrained position, within a particular radius
  134622. * @param position world position
  134623. * @param maxRadius the maximum distance to the constrained world position
  134624. * @returns the closest point to position constrained by the navigation mesh
  134625. */
  134626. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134627. /**
  134628. * Compute the final position from a segment made of destination-position
  134629. * @param position world position
  134630. * @param destination world position
  134631. * @returns the resulting point along the navmesh
  134632. */
  134633. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134634. /**
  134635. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134636. * @param start world position
  134637. * @param end world position
  134638. * @returns array containing world position composing the path
  134639. */
  134640. computePath(start: Vector3, end: Vector3): Vector3[];
  134641. /**
  134642. * Create a new Crowd so you can add agents
  134643. * @param maxAgents the maximum agent count in the crowd
  134644. * @param maxAgentRadius the maximum radius an agent can have
  134645. * @param scene to attach the crowd to
  134646. * @returns the crowd you can add agents to
  134647. */
  134648. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134649. /**
  134650. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134651. * The queries will try to find a solution within those bounds
  134652. * default is (1,1,1)
  134653. * @param extent x,y,z value that define the extent around the queries point of reference
  134654. */
  134655. setDefaultQueryExtent(extent: Vector3): void;
  134656. /**
  134657. * Get the Bounding box extent specified by setDefaultQueryExtent
  134658. * @returns the box extent values
  134659. */
  134660. getDefaultQueryExtent(): Vector3;
  134661. /**
  134662. * Disposes
  134663. */
  134664. dispose(): void;
  134665. /**
  134666. * If this plugin is supported
  134667. * @returns true if plugin is supported
  134668. */
  134669. isSupported(): boolean;
  134670. }
  134671. /**
  134672. * Recast detour crowd implementation
  134673. */
  134674. export class RecastJSCrowd implements ICrowd {
  134675. /**
  134676. * Recast/detour plugin
  134677. */
  134678. bjsRECASTPlugin: RecastJSPlugin;
  134679. /**
  134680. * Link to the detour crowd
  134681. */
  134682. recastCrowd: any;
  134683. /**
  134684. * One transform per agent
  134685. */
  134686. transforms: TransformNode[];
  134687. /**
  134688. * All agents created
  134689. */
  134690. agents: number[];
  134691. /**
  134692. * Link to the scene is kept to unregister the crowd from the scene
  134693. */
  134694. private _scene;
  134695. /**
  134696. * Observer for crowd updates
  134697. */
  134698. private _onBeforeAnimationsObserver;
  134699. /**
  134700. * Constructor
  134701. * @param plugin recastJS plugin
  134702. * @param maxAgents the maximum agent count in the crowd
  134703. * @param maxAgentRadius the maximum radius an agent can have
  134704. * @param scene to attach the crowd to
  134705. * @returns the crowd you can add agents to
  134706. */
  134707. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  134708. /**
  134709. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134710. * You can attach anything to that node. The node position is updated in the scene update tick.
  134711. * @param pos world position that will be constrained by the navigation mesh
  134712. * @param parameters agent parameters
  134713. * @param transform hooked to the agent that will be update by the scene
  134714. * @returns agent index
  134715. */
  134716. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134717. /**
  134718. * Returns the agent position in world space
  134719. * @param index agent index returned by addAgent
  134720. * @returns world space position
  134721. */
  134722. getAgentPosition(index: number): Vector3;
  134723. /**
  134724. * Returns the agent velocity in world space
  134725. * @param index agent index returned by addAgent
  134726. * @returns world space velocity
  134727. */
  134728. getAgentVelocity(index: number): Vector3;
  134729. /**
  134730. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134731. * @param index agent index returned by addAgent
  134732. * @param destination targeted world position
  134733. */
  134734. agentGoto(index: number, destination: Vector3): void;
  134735. /**
  134736. * Teleport the agent to a new position
  134737. * @param index agent index returned by addAgent
  134738. * @param destination targeted world position
  134739. */
  134740. agentTeleport(index: number, destination: Vector3): void;
  134741. /**
  134742. * Update agent parameters
  134743. * @param index agent index returned by addAgent
  134744. * @param parameters agent parameters
  134745. */
  134746. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134747. /**
  134748. * remove a particular agent previously created
  134749. * @param index agent index returned by addAgent
  134750. */
  134751. removeAgent(index: number): void;
  134752. /**
  134753. * get the list of all agents attached to this crowd
  134754. * @returns list of agent indices
  134755. */
  134756. getAgents(): number[];
  134757. /**
  134758. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134759. * @param deltaTime in seconds
  134760. */
  134761. update(deltaTime: number): void;
  134762. /**
  134763. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134764. * The queries will try to find a solution within those bounds
  134765. * default is (1,1,1)
  134766. * @param extent x,y,z value that define the extent around the queries point of reference
  134767. */
  134768. setDefaultQueryExtent(extent: Vector3): void;
  134769. /**
  134770. * Get the Bounding box extent specified by setDefaultQueryExtent
  134771. * @returns the box extent values
  134772. */
  134773. getDefaultQueryExtent(): Vector3;
  134774. /**
  134775. * Release all resources
  134776. */
  134777. dispose(): void;
  134778. }
  134779. }
  134780. declare module BABYLON {
  134781. /**
  134782. * Class used to enable access to IndexedDB
  134783. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  134784. */
  134785. export class Database implements IOfflineProvider {
  134786. private _callbackManifestChecked;
  134787. private _currentSceneUrl;
  134788. private _db;
  134789. private _enableSceneOffline;
  134790. private _enableTexturesOffline;
  134791. private _manifestVersionFound;
  134792. private _mustUpdateRessources;
  134793. private _hasReachedQuota;
  134794. private _isSupported;
  134795. private _idbFactory;
  134796. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  134797. private static IsUASupportingBlobStorage;
  134798. /**
  134799. * Gets a boolean indicating if Database storate is enabled (off by default)
  134800. */
  134801. static IDBStorageEnabled: boolean;
  134802. /**
  134803. * Gets a boolean indicating if scene must be saved in the database
  134804. */
  134805. get enableSceneOffline(): boolean;
  134806. /**
  134807. * Gets a boolean indicating if textures must be saved in the database
  134808. */
  134809. get enableTexturesOffline(): boolean;
  134810. /**
  134811. * Creates a new Database
  134812. * @param urlToScene defines the url to load the scene
  134813. * @param callbackManifestChecked defines the callback to use when manifest is checked
  134814. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  134815. */
  134816. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  134817. private static _ParseURL;
  134818. private static _ReturnFullUrlLocation;
  134819. private _checkManifestFile;
  134820. /**
  134821. * Open the database and make it available
  134822. * @param successCallback defines the callback to call on success
  134823. * @param errorCallback defines the callback to call on error
  134824. */
  134825. open(successCallback: () => void, errorCallback: () => void): void;
  134826. /**
  134827. * Loads an image from the database
  134828. * @param url defines the url to load from
  134829. * @param image defines the target DOM image
  134830. */
  134831. loadImage(url: string, image: HTMLImageElement): void;
  134832. private _loadImageFromDBAsync;
  134833. private _saveImageIntoDBAsync;
  134834. private _checkVersionFromDB;
  134835. private _loadVersionFromDBAsync;
  134836. private _saveVersionIntoDBAsync;
  134837. /**
  134838. * Loads a file from database
  134839. * @param url defines the URL to load from
  134840. * @param sceneLoaded defines a callback to call on success
  134841. * @param progressCallBack defines a callback to call when progress changed
  134842. * @param errorCallback defines a callback to call on error
  134843. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  134844. */
  134845. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  134846. private _loadFileAsync;
  134847. private _saveFileAsync;
  134848. /**
  134849. * Validates if xhr data is correct
  134850. * @param xhr defines the request to validate
  134851. * @param dataType defines the expected data type
  134852. * @returns true if data is correct
  134853. */
  134854. private static _ValidateXHRData;
  134855. }
  134856. }
  134857. declare module BABYLON {
  134858. /** @hidden */
  134859. export var gpuUpdateParticlesPixelShader: {
  134860. name: string;
  134861. shader: string;
  134862. };
  134863. }
  134864. declare module BABYLON {
  134865. /** @hidden */
  134866. export var gpuUpdateParticlesVertexShader: {
  134867. name: string;
  134868. shader: string;
  134869. };
  134870. }
  134871. declare module BABYLON {
  134872. /** @hidden */
  134873. export var clipPlaneFragmentDeclaration2: {
  134874. name: string;
  134875. shader: string;
  134876. };
  134877. }
  134878. declare module BABYLON {
  134879. /** @hidden */
  134880. export var gpuRenderParticlesPixelShader: {
  134881. name: string;
  134882. shader: string;
  134883. };
  134884. }
  134885. declare module BABYLON {
  134886. /** @hidden */
  134887. export var clipPlaneVertexDeclaration2: {
  134888. name: string;
  134889. shader: string;
  134890. };
  134891. }
  134892. declare module BABYLON {
  134893. /** @hidden */
  134894. export var gpuRenderParticlesVertexShader: {
  134895. name: string;
  134896. shader: string;
  134897. };
  134898. }
  134899. declare module BABYLON {
  134900. /**
  134901. * This represents a GPU particle system in Babylon
  134902. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  134903. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  134904. */
  134905. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  134906. /**
  134907. * The layer mask we are rendering the particles through.
  134908. */
  134909. layerMask: number;
  134910. private _capacity;
  134911. private _activeCount;
  134912. private _currentActiveCount;
  134913. private _accumulatedCount;
  134914. private _renderEffect;
  134915. private _updateEffect;
  134916. private _buffer0;
  134917. private _buffer1;
  134918. private _spriteBuffer;
  134919. private _updateVAO;
  134920. private _renderVAO;
  134921. private _targetIndex;
  134922. private _sourceBuffer;
  134923. private _targetBuffer;
  134924. private _engine;
  134925. private _currentRenderId;
  134926. private _started;
  134927. private _stopped;
  134928. private _timeDelta;
  134929. private _randomTexture;
  134930. private _randomTexture2;
  134931. private _attributesStrideSize;
  134932. private _updateEffectOptions;
  134933. private _randomTextureSize;
  134934. private _actualFrame;
  134935. private readonly _rawTextureWidth;
  134936. /**
  134937. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  134938. */
  134939. static get IsSupported(): boolean;
  134940. /**
  134941. * An event triggered when the system is disposed.
  134942. */
  134943. onDisposeObservable: Observable<GPUParticleSystem>;
  134944. /**
  134945. * Gets the maximum number of particles active at the same time.
  134946. * @returns The max number of active particles.
  134947. */
  134948. getCapacity(): number;
  134949. /**
  134950. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  134951. * to override the particles.
  134952. */
  134953. forceDepthWrite: boolean;
  134954. /**
  134955. * Gets or set the number of active particles
  134956. */
  134957. get activeParticleCount(): number;
  134958. set activeParticleCount(value: number);
  134959. private _preWarmDone;
  134960. /**
  134961. * Is this system ready to be used/rendered
  134962. * @return true if the system is ready
  134963. */
  134964. isReady(): boolean;
  134965. /**
  134966. * Gets if the system has been started. (Note: this will still be true after stop is called)
  134967. * @returns True if it has been started, otherwise false.
  134968. */
  134969. isStarted(): boolean;
  134970. /**
  134971. * Starts the particle system and begins to emit
  134972. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  134973. */
  134974. start(delay?: number): void;
  134975. /**
  134976. * Stops the particle system.
  134977. */
  134978. stop(): void;
  134979. /**
  134980. * Remove all active particles
  134981. */
  134982. reset(): void;
  134983. /**
  134984. * Returns the string "GPUParticleSystem"
  134985. * @returns a string containing the class name
  134986. */
  134987. getClassName(): string;
  134988. private _colorGradientsTexture;
  134989. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  134990. /**
  134991. * Adds a new color gradient
  134992. * @param gradient defines the gradient to use (between 0 and 1)
  134993. * @param color1 defines the color to affect to the specified gradient
  134994. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  134995. * @returns the current particle system
  134996. */
  134997. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  134998. /**
  134999. * Remove a specific color gradient
  135000. * @param gradient defines the gradient to remove
  135001. * @returns the current particle system
  135002. */
  135003. removeColorGradient(gradient: number): GPUParticleSystem;
  135004. private _angularSpeedGradientsTexture;
  135005. private _sizeGradientsTexture;
  135006. private _velocityGradientsTexture;
  135007. private _limitVelocityGradientsTexture;
  135008. private _dragGradientsTexture;
  135009. private _addFactorGradient;
  135010. /**
  135011. * Adds a new size gradient
  135012. * @param gradient defines the gradient to use (between 0 and 1)
  135013. * @param factor defines the size factor to affect to the specified gradient
  135014. * @returns the current particle system
  135015. */
  135016. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135017. /**
  135018. * Remove a specific size gradient
  135019. * @param gradient defines the gradient to remove
  135020. * @returns the current particle system
  135021. */
  135022. removeSizeGradient(gradient: number): GPUParticleSystem;
  135023. /**
  135024. * Adds a new angular speed gradient
  135025. * @param gradient defines the gradient to use (between 0 and 1)
  135026. * @param factor defines the angular speed to affect to the specified gradient
  135027. * @returns the current particle system
  135028. */
  135029. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135030. /**
  135031. * Remove a specific angular speed gradient
  135032. * @param gradient defines the gradient to remove
  135033. * @returns the current particle system
  135034. */
  135035. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135036. /**
  135037. * Adds a new velocity gradient
  135038. * @param gradient defines the gradient to use (between 0 and 1)
  135039. * @param factor defines the velocity to affect to the specified gradient
  135040. * @returns the current particle system
  135041. */
  135042. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135043. /**
  135044. * Remove a specific velocity gradient
  135045. * @param gradient defines the gradient to remove
  135046. * @returns the current particle system
  135047. */
  135048. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135049. /**
  135050. * Adds a new limit velocity gradient
  135051. * @param gradient defines the gradient to use (between 0 and 1)
  135052. * @param factor defines the limit velocity value to affect to the specified gradient
  135053. * @returns the current particle system
  135054. */
  135055. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135056. /**
  135057. * Remove a specific limit velocity gradient
  135058. * @param gradient defines the gradient to remove
  135059. * @returns the current particle system
  135060. */
  135061. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135062. /**
  135063. * Adds a new drag gradient
  135064. * @param gradient defines the gradient to use (between 0 and 1)
  135065. * @param factor defines the drag value to affect to the specified gradient
  135066. * @returns the current particle system
  135067. */
  135068. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135069. /**
  135070. * Remove a specific drag gradient
  135071. * @param gradient defines the gradient to remove
  135072. * @returns the current particle system
  135073. */
  135074. removeDragGradient(gradient: number): GPUParticleSystem;
  135075. /**
  135076. * Not supported by GPUParticleSystem
  135077. * @param gradient defines the gradient to use (between 0 and 1)
  135078. * @param factor defines the emit rate value to affect to the specified gradient
  135079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135080. * @returns the current particle system
  135081. */
  135082. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135083. /**
  135084. * Not supported by GPUParticleSystem
  135085. * @param gradient defines the gradient to remove
  135086. * @returns the current particle system
  135087. */
  135088. removeEmitRateGradient(gradient: number): IParticleSystem;
  135089. /**
  135090. * Not supported by GPUParticleSystem
  135091. * @param gradient defines the gradient to use (between 0 and 1)
  135092. * @param factor defines the start size value to affect to the specified gradient
  135093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135094. * @returns the current particle system
  135095. */
  135096. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135097. /**
  135098. * Not supported by GPUParticleSystem
  135099. * @param gradient defines the gradient to remove
  135100. * @returns the current particle system
  135101. */
  135102. removeStartSizeGradient(gradient: number): IParticleSystem;
  135103. /**
  135104. * Not supported by GPUParticleSystem
  135105. * @param gradient defines the gradient to use (between 0 and 1)
  135106. * @param min defines the color remap minimal range
  135107. * @param max defines the color remap maximal range
  135108. * @returns the current particle system
  135109. */
  135110. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135111. /**
  135112. * Not supported by GPUParticleSystem
  135113. * @param gradient defines the gradient to remove
  135114. * @returns the current particle system
  135115. */
  135116. removeColorRemapGradient(): IParticleSystem;
  135117. /**
  135118. * Not supported by GPUParticleSystem
  135119. * @param gradient defines the gradient to use (between 0 and 1)
  135120. * @param min defines the alpha remap minimal range
  135121. * @param max defines the alpha remap maximal range
  135122. * @returns the current particle system
  135123. */
  135124. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135125. /**
  135126. * Not supported by GPUParticleSystem
  135127. * @param gradient defines the gradient to remove
  135128. * @returns the current particle system
  135129. */
  135130. removeAlphaRemapGradient(): IParticleSystem;
  135131. /**
  135132. * Not supported by GPUParticleSystem
  135133. * @param gradient defines the gradient to use (between 0 and 1)
  135134. * @param color defines the color to affect to the specified gradient
  135135. * @returns the current particle system
  135136. */
  135137. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135138. /**
  135139. * Not supported by GPUParticleSystem
  135140. * @param gradient defines the gradient to remove
  135141. * @returns the current particle system
  135142. */
  135143. removeRampGradient(): IParticleSystem;
  135144. /**
  135145. * Not supported by GPUParticleSystem
  135146. * @returns the list of ramp gradients
  135147. */
  135148. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135149. /**
  135150. * Not supported by GPUParticleSystem
  135151. * Gets or sets a boolean indicating that ramp gradients must be used
  135152. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135153. */
  135154. get useRampGradients(): boolean;
  135155. set useRampGradients(value: boolean);
  135156. /**
  135157. * Not supported by GPUParticleSystem
  135158. * @param gradient defines the gradient to use (between 0 and 1)
  135159. * @param factor defines the life time factor to affect to the specified gradient
  135160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135161. * @returns the current particle system
  135162. */
  135163. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135164. /**
  135165. * Not supported by GPUParticleSystem
  135166. * @param gradient defines the gradient to remove
  135167. * @returns the current particle system
  135168. */
  135169. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135170. /**
  135171. * Instantiates a GPU particle system.
  135172. * 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.
  135173. * @param name The name of the particle system
  135174. * @param options The options used to create the system
  135175. * @param scene The scene the particle system belongs to
  135176. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135177. */
  135178. constructor(name: string, options: Partial<{
  135179. capacity: number;
  135180. randomTextureSize: number;
  135181. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135182. protected _reset(): void;
  135183. private _createUpdateVAO;
  135184. private _createRenderVAO;
  135185. private _initialize;
  135186. /** @hidden */
  135187. _recreateUpdateEffect(): void;
  135188. /** @hidden */
  135189. _recreateRenderEffect(): void;
  135190. /**
  135191. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135192. * @param preWarm defines if we are in the pre-warmimg phase
  135193. */
  135194. animate(preWarm?: boolean): void;
  135195. private _createFactorGradientTexture;
  135196. private _createSizeGradientTexture;
  135197. private _createAngularSpeedGradientTexture;
  135198. private _createVelocityGradientTexture;
  135199. private _createLimitVelocityGradientTexture;
  135200. private _createDragGradientTexture;
  135201. private _createColorGradientTexture;
  135202. /**
  135203. * Renders the particle system in its current state
  135204. * @param preWarm defines if the system should only update the particles but not render them
  135205. * @returns the current number of particles
  135206. */
  135207. render(preWarm?: boolean): number;
  135208. /**
  135209. * Rebuilds the particle system
  135210. */
  135211. rebuild(): void;
  135212. private _releaseBuffers;
  135213. private _releaseVAOs;
  135214. /**
  135215. * Disposes the particle system and free the associated resources
  135216. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135217. */
  135218. dispose(disposeTexture?: boolean): void;
  135219. /**
  135220. * Clones the particle system.
  135221. * @param name The name of the cloned object
  135222. * @param newEmitter The new emitter to use
  135223. * @returns the cloned particle system
  135224. */
  135225. clone(name: string, newEmitter: any): GPUParticleSystem;
  135226. /**
  135227. * Serializes the particle system to a JSON object.
  135228. * @returns the JSON object
  135229. */
  135230. serialize(): any;
  135231. /**
  135232. * Parses a JSON object to create a GPU particle system.
  135233. * @param parsedParticleSystem The JSON object to parse
  135234. * @param scene The scene to create the particle system in
  135235. * @param rootUrl The root url to use to load external dependencies like texture
  135236. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135237. * @returns the parsed GPU particle system
  135238. */
  135239. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135240. }
  135241. }
  135242. declare module BABYLON {
  135243. /**
  135244. * Represents a set of particle systems working together to create a specific effect
  135245. */
  135246. export class ParticleSystemSet implements IDisposable {
  135247. /**
  135248. * Gets or sets base Assets URL
  135249. */
  135250. static BaseAssetsUrl: string;
  135251. private _emitterCreationOptions;
  135252. private _emitterNode;
  135253. /**
  135254. * Gets the particle system list
  135255. */
  135256. systems: IParticleSystem[];
  135257. /**
  135258. * Gets the emitter node used with this set
  135259. */
  135260. get emitterNode(): Nullable<TransformNode>;
  135261. /**
  135262. * Creates a new emitter mesh as a sphere
  135263. * @param options defines the options used to create the sphere
  135264. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135265. * @param scene defines the hosting scene
  135266. */
  135267. setEmitterAsSphere(options: {
  135268. diameter: number;
  135269. segments: number;
  135270. color: Color3;
  135271. }, renderingGroupId: number, scene: Scene): void;
  135272. /**
  135273. * Starts all particle systems of the set
  135274. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135275. */
  135276. start(emitter?: AbstractMesh): void;
  135277. /**
  135278. * Release all associated resources
  135279. */
  135280. dispose(): void;
  135281. /**
  135282. * Serialize the set into a JSON compatible object
  135283. * @returns a JSON compatible representation of the set
  135284. */
  135285. serialize(): any;
  135286. /**
  135287. * Parse a new ParticleSystemSet from a serialized source
  135288. * @param data defines a JSON compatible representation of the set
  135289. * @param scene defines the hosting scene
  135290. * @param gpu defines if we want GPU particles or CPU particles
  135291. * @returns a new ParticleSystemSet
  135292. */
  135293. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135294. }
  135295. }
  135296. declare module BABYLON {
  135297. /**
  135298. * This class is made for on one-liner static method to help creating particle system set.
  135299. */
  135300. export class ParticleHelper {
  135301. /**
  135302. * Gets or sets base Assets URL
  135303. */
  135304. static BaseAssetsUrl: string;
  135305. /**
  135306. * Create a default particle system that you can tweak
  135307. * @param emitter defines the emitter to use
  135308. * @param capacity defines the system capacity (default is 500 particles)
  135309. * @param scene defines the hosting scene
  135310. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135311. * @returns the new Particle system
  135312. */
  135313. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135314. /**
  135315. * This is the main static method (one-liner) of this helper to create different particle systems
  135316. * @param type This string represents the type to the particle system to create
  135317. * @param scene The scene where the particle system should live
  135318. * @param gpu If the system will use gpu
  135319. * @returns the ParticleSystemSet created
  135320. */
  135321. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  135322. /**
  135323. * Static function used to export a particle system to a ParticleSystemSet variable.
  135324. * Please note that the emitter shape is not exported
  135325. * @param systems defines the particle systems to export
  135326. * @returns the created particle system set
  135327. */
  135328. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  135329. }
  135330. }
  135331. declare module BABYLON {
  135332. interface Engine {
  135333. /**
  135334. * Create an effect to use with particle systems.
  135335. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  135336. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  135337. * @param uniformsNames defines a list of attribute names
  135338. * @param samplers defines an array of string used to represent textures
  135339. * @param defines defines the string containing the defines to use to compile the shaders
  135340. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  135341. * @param onCompiled defines a function to call when the effect creation is successful
  135342. * @param onError defines a function to call when the effect creation has failed
  135343. * @returns the new Effect
  135344. */
  135345. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  135346. }
  135347. interface Mesh {
  135348. /**
  135349. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  135350. * @returns an array of IParticleSystem
  135351. */
  135352. getEmittedParticleSystems(): IParticleSystem[];
  135353. /**
  135354. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  135355. * @returns an array of IParticleSystem
  135356. */
  135357. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  135358. }
  135359. /**
  135360. * @hidden
  135361. */
  135362. export var _IDoNeedToBeInTheBuild: number;
  135363. }
  135364. declare module BABYLON {
  135365. /** Defines the 4 color options */
  135366. export enum PointColor {
  135367. /** color value */
  135368. Color = 2,
  135369. /** uv value */
  135370. UV = 1,
  135371. /** random value */
  135372. Random = 0,
  135373. /** stated value */
  135374. Stated = 3
  135375. }
  135376. /**
  135377. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  135378. * 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.
  135379. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  135380. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  135381. *
  135382. * Full documentation here : TO BE ENTERED
  135383. */
  135384. export class PointsCloudSystem implements IDisposable {
  135385. /**
  135386. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  135387. * Example : var p = SPS.particles[i];
  135388. */
  135389. particles: CloudPoint[];
  135390. /**
  135391. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  135392. */
  135393. nbParticles: number;
  135394. /**
  135395. * This a counter for your own usage. It's not set by any SPS functions.
  135396. */
  135397. counter: number;
  135398. /**
  135399. * The PCS name. This name is also given to the underlying mesh.
  135400. */
  135401. name: string;
  135402. /**
  135403. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  135404. */
  135405. mesh: Mesh;
  135406. /**
  135407. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  135408. * Please read :
  135409. */
  135410. vars: any;
  135411. /**
  135412. * @hidden
  135413. */
  135414. _size: number;
  135415. private _scene;
  135416. private _promises;
  135417. private _positions;
  135418. private _indices;
  135419. private _normals;
  135420. private _colors;
  135421. private _uvs;
  135422. private _indices32;
  135423. private _positions32;
  135424. private _colors32;
  135425. private _uvs32;
  135426. private _updatable;
  135427. private _isVisibilityBoxLocked;
  135428. private _alwaysVisible;
  135429. private _groups;
  135430. private _groupCounter;
  135431. private _computeParticleColor;
  135432. private _computeParticleTexture;
  135433. private _computeParticleRotation;
  135434. private _computeBoundingBox;
  135435. private _isReady;
  135436. /**
  135437. * Creates a PCS (Points Cloud System) object
  135438. * @param name (String) is the PCS name, this will be the underlying mesh name
  135439. * @param pointSize (number) is the size for each point
  135440. * @param scene (Scene) is the scene in which the PCS is added
  135441. * @param options defines the options of the PCS e.g.
  135442. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  135443. */
  135444. constructor(name: string, pointSize: number, scene: Scene, options?: {
  135445. updatable?: boolean;
  135446. });
  135447. /**
  135448. * Builds the PCS underlying mesh. Returns a standard Mesh.
  135449. * If no points were added to the PCS, the returned mesh is just a single point.
  135450. * @returns a promise for the created mesh
  135451. */
  135452. buildMeshAsync(): Promise<Mesh>;
  135453. /**
  135454. * @hidden
  135455. */
  135456. private _buildMesh;
  135457. private _addParticle;
  135458. private _randomUnitVector;
  135459. private _getColorIndicesForCoord;
  135460. private _setPointsColorOrUV;
  135461. private _colorFromTexture;
  135462. private _calculateDensity;
  135463. /**
  135464. * Adds points to the PCS in random positions within a unit sphere
  135465. * @param nb (positive integer) the number of particles to be created from this model
  135466. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  135467. * @returns the number of groups in the system
  135468. */
  135469. addPoints(nb: number, pointFunction?: any): number;
  135470. /**
  135471. * Adds points to the PCS from the surface of the model shape
  135472. * @param mesh is any Mesh object that will be used as a surface model for the points
  135473. * @param nb (positive integer) the number of particles to be created from this model
  135474. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135475. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135476. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135477. * @returns the number of groups in the system
  135478. */
  135479. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135480. /**
  135481. * Adds points to the PCS inside the model shape
  135482. * @param mesh is any Mesh object that will be used as a surface model for the points
  135483. * @param nb (positive integer) the number of particles to be created from this model
  135484. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135485. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135486. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135487. * @returns the number of groups in the system
  135488. */
  135489. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135490. /**
  135491. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  135492. * This method calls `updateParticle()` for each particle of the SPS.
  135493. * For an animated SPS, it is usually called within the render loop.
  135494. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  135495. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  135496. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  135497. * @returns the PCS.
  135498. */
  135499. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  135500. /**
  135501. * Disposes the PCS.
  135502. */
  135503. dispose(): void;
  135504. /**
  135505. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  135506. * doc :
  135507. * @returns the PCS.
  135508. */
  135509. refreshVisibleSize(): PointsCloudSystem;
  135510. /**
  135511. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  135512. * @param size the size (float) of the visibility box
  135513. * note : this doesn't lock the PCS mesh bounding box.
  135514. * doc :
  135515. */
  135516. setVisibilityBox(size: number): void;
  135517. /**
  135518. * Gets whether the PCS is always visible or not
  135519. * doc :
  135520. */
  135521. get isAlwaysVisible(): boolean;
  135522. /**
  135523. * Sets the PCS as always visible or not
  135524. * doc :
  135525. */
  135526. set isAlwaysVisible(val: boolean);
  135527. /**
  135528. * Tells to `setParticles()` to compute the particle rotations or not
  135529. * Default value : false. The PCS is faster when it's set to false
  135530. * Note : particle rotations are only applied to parent particles
  135531. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  135532. */
  135533. set computeParticleRotation(val: boolean);
  135534. /**
  135535. * Tells to `setParticles()` to compute the particle colors or not.
  135536. * Default value : true. The PCS is faster when it's set to false.
  135537. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135538. */
  135539. set computeParticleColor(val: boolean);
  135540. set computeParticleTexture(val: boolean);
  135541. /**
  135542. * Gets if `setParticles()` computes the particle colors or not.
  135543. * Default value : false. The PCS is faster when it's set to false.
  135544. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135545. */
  135546. get computeParticleColor(): boolean;
  135547. /**
  135548. * Gets if `setParticles()` computes the particle textures or not.
  135549. * Default value : false. The PCS is faster when it's set to false.
  135550. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  135551. */
  135552. get computeParticleTexture(): boolean;
  135553. /**
  135554. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  135555. */
  135556. set computeBoundingBox(val: boolean);
  135557. /**
  135558. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  135559. */
  135560. get computeBoundingBox(): boolean;
  135561. /**
  135562. * This function does nothing. It may be overwritten to set all the particle first values.
  135563. * The PCS doesn't call this function, you may have to call it by your own.
  135564. * doc :
  135565. */
  135566. initParticles(): void;
  135567. /**
  135568. * This function does nothing. It may be overwritten to recycle a particle
  135569. * The PCS doesn't call this function, you can to call it
  135570. * doc :
  135571. * @param particle The particle to recycle
  135572. * @returns the recycled particle
  135573. */
  135574. recycleParticle(particle: CloudPoint): CloudPoint;
  135575. /**
  135576. * Updates a particle : this function should be overwritten by the user.
  135577. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  135578. * doc :
  135579. * @example : just set a particle position or velocity and recycle conditions
  135580. * @param particle The particle to update
  135581. * @returns the updated particle
  135582. */
  135583. updateParticle(particle: CloudPoint): CloudPoint;
  135584. /**
  135585. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  135586. * This does nothing and may be overwritten by the user.
  135587. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135588. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135589. * @param update the boolean update value actually passed to setParticles()
  135590. */
  135591. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135592. /**
  135593. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  135594. * This will be passed three parameters.
  135595. * This does nothing and may be overwritten by the user.
  135596. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135597. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135598. * @param update the boolean update value actually passed to setParticles()
  135599. */
  135600. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135601. }
  135602. }
  135603. declare module BABYLON {
  135604. /**
  135605. * Represents one particle of a points cloud system.
  135606. */
  135607. export class CloudPoint {
  135608. /**
  135609. * particle global index
  135610. */
  135611. idx: number;
  135612. /**
  135613. * The color of the particle
  135614. */
  135615. color: Nullable<Color4>;
  135616. /**
  135617. * The world space position of the particle.
  135618. */
  135619. position: Vector3;
  135620. /**
  135621. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  135622. */
  135623. rotation: Vector3;
  135624. /**
  135625. * The world space rotation quaternion of the particle.
  135626. */
  135627. rotationQuaternion: Nullable<Quaternion>;
  135628. /**
  135629. * The uv of the particle.
  135630. */
  135631. uv: Nullable<Vector2>;
  135632. /**
  135633. * The current speed of the particle.
  135634. */
  135635. velocity: Vector3;
  135636. /**
  135637. * The pivot point in the particle local space.
  135638. */
  135639. pivot: Vector3;
  135640. /**
  135641. * Must the particle be translated from its pivot point in its local space ?
  135642. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  135643. * Default : false
  135644. */
  135645. translateFromPivot: boolean;
  135646. /**
  135647. * Index of this particle in the global "positions" array (Internal use)
  135648. * @hidden
  135649. */
  135650. _pos: number;
  135651. /**
  135652. * @hidden Index of this particle in the global "indices" array (Internal use)
  135653. */
  135654. _ind: number;
  135655. /**
  135656. * Group this particle belongs to
  135657. */
  135658. _group: PointsGroup;
  135659. /**
  135660. * Group id of this particle
  135661. */
  135662. groupId: number;
  135663. /**
  135664. * Index of the particle in its group id (Internal use)
  135665. */
  135666. idxInGroup: number;
  135667. /**
  135668. * @hidden Particle BoundingInfo object (Internal use)
  135669. */
  135670. _boundingInfo: BoundingInfo;
  135671. /**
  135672. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  135673. */
  135674. _pcs: PointsCloudSystem;
  135675. /**
  135676. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  135677. */
  135678. _stillInvisible: boolean;
  135679. /**
  135680. * @hidden Last computed particle rotation matrix
  135681. */
  135682. _rotationMatrix: number[];
  135683. /**
  135684. * Parent particle Id, if any.
  135685. * Default null.
  135686. */
  135687. parentId: Nullable<number>;
  135688. /**
  135689. * @hidden Internal global position in the PCS.
  135690. */
  135691. _globalPosition: Vector3;
  135692. /**
  135693. * Creates a Point Cloud object.
  135694. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  135695. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  135696. * @param group (PointsGroup) is the group the particle belongs to
  135697. * @param groupId (integer) is the group identifier in the PCS.
  135698. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  135699. * @param pcs defines the PCS it is associated to
  135700. */
  135701. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  135702. /**
  135703. * get point size
  135704. */
  135705. get size(): Vector3;
  135706. /**
  135707. * Set point size
  135708. */
  135709. set size(scale: Vector3);
  135710. /**
  135711. * Legacy support, changed quaternion to rotationQuaternion
  135712. */
  135713. get quaternion(): Nullable<Quaternion>;
  135714. /**
  135715. * Legacy support, changed quaternion to rotationQuaternion
  135716. */
  135717. set quaternion(q: Nullable<Quaternion>);
  135718. /**
  135719. * Returns a boolean. True if the particle intersects a mesh, else false
  135720. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  135721. * @param target is the object (point or mesh) what the intersection is computed against
  135722. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  135723. * @returns true if it intersects
  135724. */
  135725. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  135726. /**
  135727. * get the rotation matrix of the particle
  135728. * @hidden
  135729. */
  135730. getRotationMatrix(m: Matrix): void;
  135731. }
  135732. /**
  135733. * Represents a group of points in a points cloud system
  135734. * * PCS internal tool, don't use it manually.
  135735. */
  135736. export class PointsGroup {
  135737. /**
  135738. * The group id
  135739. * @hidden
  135740. */
  135741. groupID: number;
  135742. /**
  135743. * image data for group (internal use)
  135744. * @hidden
  135745. */
  135746. _groupImageData: Nullable<ArrayBufferView>;
  135747. /**
  135748. * Image Width (internal use)
  135749. * @hidden
  135750. */
  135751. _groupImgWidth: number;
  135752. /**
  135753. * Image Height (internal use)
  135754. * @hidden
  135755. */
  135756. _groupImgHeight: number;
  135757. /**
  135758. * Custom position function (internal use)
  135759. * @hidden
  135760. */
  135761. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  135762. /**
  135763. * density per facet for surface points
  135764. * @hidden
  135765. */
  135766. _groupDensity: number[];
  135767. /**
  135768. * Only when points are colored by texture carries pointer to texture list array
  135769. * @hidden
  135770. */
  135771. _textureNb: number;
  135772. /**
  135773. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  135774. * PCS internal tool, don't use it manually.
  135775. * @hidden
  135776. */
  135777. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  135778. }
  135779. }
  135780. declare module BABYLON {
  135781. interface Scene {
  135782. /** @hidden (Backing field) */
  135783. _physicsEngine: Nullable<IPhysicsEngine>;
  135784. /** @hidden */
  135785. _physicsTimeAccumulator: number;
  135786. /**
  135787. * Gets the current physics engine
  135788. * @returns a IPhysicsEngine or null if none attached
  135789. */
  135790. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  135791. /**
  135792. * Enables physics to the current scene
  135793. * @param gravity defines the scene's gravity for the physics engine
  135794. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  135795. * @return a boolean indicating if the physics engine was initialized
  135796. */
  135797. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  135798. /**
  135799. * Disables and disposes the physics engine associated with the scene
  135800. */
  135801. disablePhysicsEngine(): void;
  135802. /**
  135803. * Gets a boolean indicating if there is an active physics engine
  135804. * @returns a boolean indicating if there is an active physics engine
  135805. */
  135806. isPhysicsEnabled(): boolean;
  135807. /**
  135808. * Deletes a physics compound impostor
  135809. * @param compound defines the compound to delete
  135810. */
  135811. deleteCompoundImpostor(compound: any): void;
  135812. /**
  135813. * An event triggered when physic simulation is about to be run
  135814. */
  135815. onBeforePhysicsObservable: Observable<Scene>;
  135816. /**
  135817. * An event triggered when physic simulation has been done
  135818. */
  135819. onAfterPhysicsObservable: Observable<Scene>;
  135820. }
  135821. interface AbstractMesh {
  135822. /** @hidden */
  135823. _physicsImpostor: Nullable<PhysicsImpostor>;
  135824. /**
  135825. * Gets or sets impostor used for physic simulation
  135826. * @see http://doc.babylonjs.com/features/physics_engine
  135827. */
  135828. physicsImpostor: Nullable<PhysicsImpostor>;
  135829. /**
  135830. * Gets the current physics impostor
  135831. * @see http://doc.babylonjs.com/features/physics_engine
  135832. * @returns a physics impostor or null
  135833. */
  135834. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  135835. /** Apply a physic impulse to the mesh
  135836. * @param force defines the force to apply
  135837. * @param contactPoint defines where to apply the force
  135838. * @returns the current mesh
  135839. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135840. */
  135841. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  135842. /**
  135843. * Creates a physic joint between two meshes
  135844. * @param otherMesh defines the other mesh to use
  135845. * @param pivot1 defines the pivot to use on this mesh
  135846. * @param pivot2 defines the pivot to use on the other mesh
  135847. * @param options defines additional options (can be plugin dependent)
  135848. * @returns the current mesh
  135849. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  135850. */
  135851. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  135852. /** @hidden */
  135853. _disposePhysicsObserver: Nullable<Observer<Node>>;
  135854. }
  135855. /**
  135856. * Defines the physics engine scene component responsible to manage a physics engine
  135857. */
  135858. export class PhysicsEngineSceneComponent implements ISceneComponent {
  135859. /**
  135860. * The component name helpful to identify the component in the list of scene components.
  135861. */
  135862. readonly name: string;
  135863. /**
  135864. * The scene the component belongs to.
  135865. */
  135866. scene: Scene;
  135867. /**
  135868. * Creates a new instance of the component for the given scene
  135869. * @param scene Defines the scene to register the component in
  135870. */
  135871. constructor(scene: Scene);
  135872. /**
  135873. * Registers the component in a given scene
  135874. */
  135875. register(): void;
  135876. /**
  135877. * Rebuilds the elements related to this component in case of
  135878. * context lost for instance.
  135879. */
  135880. rebuild(): void;
  135881. /**
  135882. * Disposes the component and the associated ressources
  135883. */
  135884. dispose(): void;
  135885. }
  135886. }
  135887. declare module BABYLON {
  135888. /**
  135889. * A helper for physics simulations
  135890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  135891. */
  135892. export class PhysicsHelper {
  135893. private _scene;
  135894. private _physicsEngine;
  135895. /**
  135896. * Initializes the Physics helper
  135897. * @param scene Babylon.js scene
  135898. */
  135899. constructor(scene: Scene);
  135900. /**
  135901. * Applies a radial explosion impulse
  135902. * @param origin the origin of the explosion
  135903. * @param radiusOrEventOptions the radius or the options of radial explosion
  135904. * @param strength the explosion strength
  135905. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135906. * @returns A physics radial explosion event, or null
  135907. */
  135908. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135909. /**
  135910. * Applies a radial explosion force
  135911. * @param origin the origin of the explosion
  135912. * @param radiusOrEventOptions the radius or the options of radial explosion
  135913. * @param strength the explosion strength
  135914. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135915. * @returns A physics radial explosion event, or null
  135916. */
  135917. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135918. /**
  135919. * Creates a gravitational field
  135920. * @param origin the origin of the explosion
  135921. * @param radiusOrEventOptions the radius or the options of radial explosion
  135922. * @param strength the explosion strength
  135923. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135924. * @returns A physics gravitational field event, or null
  135925. */
  135926. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  135927. /**
  135928. * Creates a physics updraft event
  135929. * @param origin the origin of the updraft
  135930. * @param radiusOrEventOptions the radius or the options of the updraft
  135931. * @param strength the strength of the updraft
  135932. * @param height the height of the updraft
  135933. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  135934. * @returns A physics updraft event, or null
  135935. */
  135936. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  135937. /**
  135938. * Creates a physics vortex event
  135939. * @param origin the of the vortex
  135940. * @param radiusOrEventOptions the radius or the options of the vortex
  135941. * @param strength the strength of the vortex
  135942. * @param height the height of the vortex
  135943. * @returns a Physics vortex event, or null
  135944. * A physics vortex event or null
  135945. */
  135946. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  135947. }
  135948. /**
  135949. * Represents a physics radial explosion event
  135950. */
  135951. class PhysicsRadialExplosionEvent {
  135952. private _scene;
  135953. private _options;
  135954. private _sphere;
  135955. private _dataFetched;
  135956. /**
  135957. * Initializes a radial explosioin event
  135958. * @param _scene BabylonJS scene
  135959. * @param _options The options for the vortex event
  135960. */
  135961. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  135962. /**
  135963. * Returns the data related to the radial explosion event (sphere).
  135964. * @returns The radial explosion event data
  135965. */
  135966. getData(): PhysicsRadialExplosionEventData;
  135967. /**
  135968. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  135969. * @param impostor A physics imposter
  135970. * @param origin the origin of the explosion
  135971. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  135972. */
  135973. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  135974. /**
  135975. * Triggers affecterd impostors callbacks
  135976. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  135977. */
  135978. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  135979. /**
  135980. * Disposes the sphere.
  135981. * @param force Specifies if the sphere should be disposed by force
  135982. */
  135983. dispose(force?: boolean): void;
  135984. /*** Helpers ***/
  135985. private _prepareSphere;
  135986. private _intersectsWithSphere;
  135987. }
  135988. /**
  135989. * Represents a gravitational field event
  135990. */
  135991. class PhysicsGravitationalFieldEvent {
  135992. private _physicsHelper;
  135993. private _scene;
  135994. private _origin;
  135995. private _options;
  135996. private _tickCallback;
  135997. private _sphere;
  135998. private _dataFetched;
  135999. /**
  136000. * Initializes the physics gravitational field event
  136001. * @param _physicsHelper A physics helper
  136002. * @param _scene BabylonJS scene
  136003. * @param _origin The origin position of the gravitational field event
  136004. * @param _options The options for the vortex event
  136005. */
  136006. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136007. /**
  136008. * Returns the data related to the gravitational field event (sphere).
  136009. * @returns A gravitational field event
  136010. */
  136011. getData(): PhysicsGravitationalFieldEventData;
  136012. /**
  136013. * Enables the gravitational field.
  136014. */
  136015. enable(): void;
  136016. /**
  136017. * Disables the gravitational field.
  136018. */
  136019. disable(): void;
  136020. /**
  136021. * Disposes the sphere.
  136022. * @param force The force to dispose from the gravitational field event
  136023. */
  136024. dispose(force?: boolean): void;
  136025. private _tick;
  136026. }
  136027. /**
  136028. * Represents a physics updraft event
  136029. */
  136030. class PhysicsUpdraftEvent {
  136031. private _scene;
  136032. private _origin;
  136033. private _options;
  136034. private _physicsEngine;
  136035. private _originTop;
  136036. private _originDirection;
  136037. private _tickCallback;
  136038. private _cylinder;
  136039. private _cylinderPosition;
  136040. private _dataFetched;
  136041. /**
  136042. * Initializes the physics updraft event
  136043. * @param _scene BabylonJS scene
  136044. * @param _origin The origin position of the updraft
  136045. * @param _options The options for the updraft event
  136046. */
  136047. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136048. /**
  136049. * Returns the data related to the updraft event (cylinder).
  136050. * @returns A physics updraft event
  136051. */
  136052. getData(): PhysicsUpdraftEventData;
  136053. /**
  136054. * Enables the updraft.
  136055. */
  136056. enable(): void;
  136057. /**
  136058. * Disables the updraft.
  136059. */
  136060. disable(): void;
  136061. /**
  136062. * Disposes the cylinder.
  136063. * @param force Specifies if the updraft should be disposed by force
  136064. */
  136065. dispose(force?: boolean): void;
  136066. private getImpostorHitData;
  136067. private _tick;
  136068. /*** Helpers ***/
  136069. private _prepareCylinder;
  136070. private _intersectsWithCylinder;
  136071. }
  136072. /**
  136073. * Represents a physics vortex event
  136074. */
  136075. class PhysicsVortexEvent {
  136076. private _scene;
  136077. private _origin;
  136078. private _options;
  136079. private _physicsEngine;
  136080. private _originTop;
  136081. private _tickCallback;
  136082. private _cylinder;
  136083. private _cylinderPosition;
  136084. private _dataFetched;
  136085. /**
  136086. * Initializes the physics vortex event
  136087. * @param _scene The BabylonJS scene
  136088. * @param _origin The origin position of the vortex
  136089. * @param _options The options for the vortex event
  136090. */
  136091. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136092. /**
  136093. * Returns the data related to the vortex event (cylinder).
  136094. * @returns The physics vortex event data
  136095. */
  136096. getData(): PhysicsVortexEventData;
  136097. /**
  136098. * Enables the vortex.
  136099. */
  136100. enable(): void;
  136101. /**
  136102. * Disables the cortex.
  136103. */
  136104. disable(): void;
  136105. /**
  136106. * Disposes the sphere.
  136107. * @param force
  136108. */
  136109. dispose(force?: boolean): void;
  136110. private getImpostorHitData;
  136111. private _tick;
  136112. /*** Helpers ***/
  136113. private _prepareCylinder;
  136114. private _intersectsWithCylinder;
  136115. }
  136116. /**
  136117. * Options fot the radial explosion event
  136118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136119. */
  136120. export class PhysicsRadialExplosionEventOptions {
  136121. /**
  136122. * The radius of the sphere for the radial explosion.
  136123. */
  136124. radius: number;
  136125. /**
  136126. * The strenth of the explosion.
  136127. */
  136128. strength: number;
  136129. /**
  136130. * The strenght of the force in correspondence to the distance of the affected object
  136131. */
  136132. falloff: PhysicsRadialImpulseFalloff;
  136133. /**
  136134. * Sphere options for the radial explosion.
  136135. */
  136136. sphere: {
  136137. segments: number;
  136138. diameter: number;
  136139. };
  136140. /**
  136141. * Sphere options for the radial explosion.
  136142. */
  136143. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136144. }
  136145. /**
  136146. * Options fot the updraft event
  136147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136148. */
  136149. export class PhysicsUpdraftEventOptions {
  136150. /**
  136151. * The radius of the cylinder for the vortex
  136152. */
  136153. radius: number;
  136154. /**
  136155. * The strenth of the updraft.
  136156. */
  136157. strength: number;
  136158. /**
  136159. * The height of the cylinder for the updraft.
  136160. */
  136161. height: number;
  136162. /**
  136163. * The mode for the the updraft.
  136164. */
  136165. updraftMode: PhysicsUpdraftMode;
  136166. }
  136167. /**
  136168. * Options fot the vortex event
  136169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136170. */
  136171. export class PhysicsVortexEventOptions {
  136172. /**
  136173. * The radius of the cylinder for the vortex
  136174. */
  136175. radius: number;
  136176. /**
  136177. * The strenth of the vortex.
  136178. */
  136179. strength: number;
  136180. /**
  136181. * The height of the cylinder for the vortex.
  136182. */
  136183. height: number;
  136184. /**
  136185. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136186. */
  136187. centripetalForceThreshold: number;
  136188. /**
  136189. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136190. */
  136191. centripetalForceMultiplier: number;
  136192. /**
  136193. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136194. */
  136195. centrifugalForceMultiplier: number;
  136196. /**
  136197. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136198. */
  136199. updraftForceMultiplier: number;
  136200. }
  136201. /**
  136202. * The strenght of the force in correspondence to the distance of the affected object
  136203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136204. */
  136205. export enum PhysicsRadialImpulseFalloff {
  136206. /** Defines that impulse is constant in strength across it's whole radius */
  136207. Constant = 0,
  136208. /** Defines that impulse gets weaker if it's further from the origin */
  136209. Linear = 1
  136210. }
  136211. /**
  136212. * The strength of the force in correspondence to the distance of the affected object
  136213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136214. */
  136215. export enum PhysicsUpdraftMode {
  136216. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136217. Center = 0,
  136218. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136219. Perpendicular = 1
  136220. }
  136221. /**
  136222. * Interface for a physics hit data
  136223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136224. */
  136225. export interface PhysicsHitData {
  136226. /**
  136227. * The force applied at the contact point
  136228. */
  136229. force: Vector3;
  136230. /**
  136231. * The contact point
  136232. */
  136233. contactPoint: Vector3;
  136234. /**
  136235. * The distance from the origin to the contact point
  136236. */
  136237. distanceFromOrigin: number;
  136238. }
  136239. /**
  136240. * Interface for radial explosion event data
  136241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136242. */
  136243. export interface PhysicsRadialExplosionEventData {
  136244. /**
  136245. * A sphere used for the radial explosion event
  136246. */
  136247. sphere: Mesh;
  136248. }
  136249. /**
  136250. * Interface for gravitational field event data
  136251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136252. */
  136253. export interface PhysicsGravitationalFieldEventData {
  136254. /**
  136255. * A sphere mesh used for the gravitational field event
  136256. */
  136257. sphere: Mesh;
  136258. }
  136259. /**
  136260. * Interface for updraft event data
  136261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136262. */
  136263. export interface PhysicsUpdraftEventData {
  136264. /**
  136265. * A cylinder used for the updraft event
  136266. */
  136267. cylinder: Mesh;
  136268. }
  136269. /**
  136270. * Interface for vortex event data
  136271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136272. */
  136273. export interface PhysicsVortexEventData {
  136274. /**
  136275. * A cylinder used for the vortex event
  136276. */
  136277. cylinder: Mesh;
  136278. }
  136279. /**
  136280. * Interface for an affected physics impostor
  136281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136282. */
  136283. export interface PhysicsAffectedImpostorWithData {
  136284. /**
  136285. * The impostor affected by the effect
  136286. */
  136287. impostor: PhysicsImpostor;
  136288. /**
  136289. * The data about the hit/horce from the explosion
  136290. */
  136291. hitData: PhysicsHitData;
  136292. }
  136293. }
  136294. declare module BABYLON {
  136295. /** @hidden */
  136296. export var blackAndWhitePixelShader: {
  136297. name: string;
  136298. shader: string;
  136299. };
  136300. }
  136301. declare module BABYLON {
  136302. /**
  136303. * Post process used to render in black and white
  136304. */
  136305. export class BlackAndWhitePostProcess extends PostProcess {
  136306. /**
  136307. * Linear about to convert he result to black and white (default: 1)
  136308. */
  136309. degree: number;
  136310. /**
  136311. * Creates a black and white post process
  136312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136313. * @param name The name of the effect.
  136314. * @param options The required width/height ratio to downsize to before computing the render pass.
  136315. * @param camera The camera to apply the render pass to.
  136316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136317. * @param engine The engine which the post process will be applied. (default: current engine)
  136318. * @param reusable If the post process can be reused on the same frame. (default: false)
  136319. */
  136320. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136321. }
  136322. }
  136323. declare module BABYLON {
  136324. /**
  136325. * This represents a set of one or more post processes in Babylon.
  136326. * A post process can be used to apply a shader to a texture after it is rendered.
  136327. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  136328. */
  136329. export class PostProcessRenderEffect {
  136330. private _postProcesses;
  136331. private _getPostProcesses;
  136332. private _singleInstance;
  136333. private _cameras;
  136334. private _indicesForCamera;
  136335. /**
  136336. * Name of the effect
  136337. * @hidden
  136338. */
  136339. _name: string;
  136340. /**
  136341. * Instantiates a post process render effect.
  136342. * A post process can be used to apply a shader to a texture after it is rendered.
  136343. * @param engine The engine the effect is tied to
  136344. * @param name The name of the effect
  136345. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  136346. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  136347. */
  136348. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  136349. /**
  136350. * Checks if all the post processes in the effect are supported.
  136351. */
  136352. get isSupported(): boolean;
  136353. /**
  136354. * Updates the current state of the effect
  136355. * @hidden
  136356. */
  136357. _update(): void;
  136358. /**
  136359. * Attaches the effect on cameras
  136360. * @param cameras The camera to attach to.
  136361. * @hidden
  136362. */
  136363. _attachCameras(cameras: Camera): void;
  136364. /**
  136365. * Attaches the effect on cameras
  136366. * @param cameras The camera to attach to.
  136367. * @hidden
  136368. */
  136369. _attachCameras(cameras: Camera[]): void;
  136370. /**
  136371. * Detaches the effect on cameras
  136372. * @param cameras The camera to detatch from.
  136373. * @hidden
  136374. */
  136375. _detachCameras(cameras: Camera): void;
  136376. /**
  136377. * Detatches the effect on cameras
  136378. * @param cameras The camera to detatch from.
  136379. * @hidden
  136380. */
  136381. _detachCameras(cameras: Camera[]): void;
  136382. /**
  136383. * Enables the effect on given cameras
  136384. * @param cameras The camera to enable.
  136385. * @hidden
  136386. */
  136387. _enable(cameras: Camera): void;
  136388. /**
  136389. * Enables the effect on given cameras
  136390. * @param cameras The camera to enable.
  136391. * @hidden
  136392. */
  136393. _enable(cameras: Nullable<Camera[]>): void;
  136394. /**
  136395. * Disables the effect on the given cameras
  136396. * @param cameras The camera to disable.
  136397. * @hidden
  136398. */
  136399. _disable(cameras: Camera): void;
  136400. /**
  136401. * Disables the effect on the given cameras
  136402. * @param cameras The camera to disable.
  136403. * @hidden
  136404. */
  136405. _disable(cameras: Nullable<Camera[]>): void;
  136406. /**
  136407. * Gets a list of the post processes contained in the effect.
  136408. * @param camera The camera to get the post processes on.
  136409. * @returns The list of the post processes in the effect.
  136410. */
  136411. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  136412. }
  136413. }
  136414. declare module BABYLON {
  136415. /** @hidden */
  136416. export var extractHighlightsPixelShader: {
  136417. name: string;
  136418. shader: string;
  136419. };
  136420. }
  136421. declare module BABYLON {
  136422. /**
  136423. * 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.
  136424. */
  136425. export class ExtractHighlightsPostProcess extends PostProcess {
  136426. /**
  136427. * The luminance threshold, pixels below this value will be set to black.
  136428. */
  136429. threshold: number;
  136430. /** @hidden */
  136431. _exposure: number;
  136432. /**
  136433. * Post process which has the input texture to be used when performing highlight extraction
  136434. * @hidden
  136435. */
  136436. _inputPostProcess: Nullable<PostProcess>;
  136437. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136438. }
  136439. }
  136440. declare module BABYLON {
  136441. /** @hidden */
  136442. export var bloomMergePixelShader: {
  136443. name: string;
  136444. shader: string;
  136445. };
  136446. }
  136447. declare module BABYLON {
  136448. /**
  136449. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136450. */
  136451. export class BloomMergePostProcess extends PostProcess {
  136452. /** Weight of the bloom to be added to the original input. */
  136453. weight: number;
  136454. /**
  136455. * Creates a new instance of @see BloomMergePostProcess
  136456. * @param name The name of the effect.
  136457. * @param originalFromInput Post process which's input will be used for the merge.
  136458. * @param blurred Blurred highlights post process which's output will be used.
  136459. * @param weight Weight of the bloom to be added to the original input.
  136460. * @param options The required width/height ratio to downsize to before computing the render pass.
  136461. * @param camera The camera to apply the render pass to.
  136462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136463. * @param engine The engine which the post process will be applied. (default: current engine)
  136464. * @param reusable If the post process can be reused on the same frame. (default: false)
  136465. * @param textureType Type of textures used when performing the post process. (default: 0)
  136466. * @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)
  136467. */
  136468. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  136469. /** Weight of the bloom to be added to the original input. */
  136470. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136471. }
  136472. }
  136473. declare module BABYLON {
  136474. /**
  136475. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  136476. */
  136477. export class BloomEffect extends PostProcessRenderEffect {
  136478. private bloomScale;
  136479. /**
  136480. * @hidden Internal
  136481. */
  136482. _effects: Array<PostProcess>;
  136483. /**
  136484. * @hidden Internal
  136485. */
  136486. _downscale: ExtractHighlightsPostProcess;
  136487. private _blurX;
  136488. private _blurY;
  136489. private _merge;
  136490. /**
  136491. * The luminance threshold to find bright areas of the image to bloom.
  136492. */
  136493. get threshold(): number;
  136494. set threshold(value: number);
  136495. /**
  136496. * The strength of the bloom.
  136497. */
  136498. get weight(): number;
  136499. set weight(value: number);
  136500. /**
  136501. * Specifies the size of the bloom blur kernel, relative to the final output size
  136502. */
  136503. get kernel(): number;
  136504. set kernel(value: number);
  136505. /**
  136506. * Creates a new instance of @see BloomEffect
  136507. * @param scene The scene the effect belongs to.
  136508. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  136509. * @param bloomKernel The size of the kernel to be used when applying the blur.
  136510. * @param bloomWeight The the strength of bloom.
  136511. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136512. * @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)
  136513. */
  136514. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  136515. /**
  136516. * Disposes each of the internal effects for a given camera.
  136517. * @param camera The camera to dispose the effect on.
  136518. */
  136519. disposeEffects(camera: Camera): void;
  136520. /**
  136521. * @hidden Internal
  136522. */
  136523. _updateEffects(): void;
  136524. /**
  136525. * Internal
  136526. * @returns if all the contained post processes are ready.
  136527. * @hidden
  136528. */
  136529. _isReady(): boolean;
  136530. }
  136531. }
  136532. declare module BABYLON {
  136533. /** @hidden */
  136534. export var chromaticAberrationPixelShader: {
  136535. name: string;
  136536. shader: string;
  136537. };
  136538. }
  136539. declare module BABYLON {
  136540. /**
  136541. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  136542. */
  136543. export class ChromaticAberrationPostProcess extends PostProcess {
  136544. /**
  136545. * The amount of seperation of rgb channels (default: 30)
  136546. */
  136547. aberrationAmount: number;
  136548. /**
  136549. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  136550. */
  136551. radialIntensity: number;
  136552. /**
  136553. * 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))
  136554. */
  136555. direction: Vector2;
  136556. /**
  136557. * 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))
  136558. */
  136559. centerPosition: Vector2;
  136560. /**
  136561. * Creates a new instance ChromaticAberrationPostProcess
  136562. * @param name The name of the effect.
  136563. * @param screenWidth The width of the screen to apply the effect on.
  136564. * @param screenHeight The height of the screen to apply the effect on.
  136565. * @param options The required width/height ratio to downsize to before computing the render pass.
  136566. * @param camera The camera to apply the render pass to.
  136567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136568. * @param engine The engine which the post process will be applied. (default: current engine)
  136569. * @param reusable If the post process can be reused on the same frame. (default: false)
  136570. * @param textureType Type of textures used when performing the post process. (default: 0)
  136571. * @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)
  136572. */
  136573. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136574. }
  136575. }
  136576. declare module BABYLON {
  136577. /** @hidden */
  136578. export var circleOfConfusionPixelShader: {
  136579. name: string;
  136580. shader: string;
  136581. };
  136582. }
  136583. declare module BABYLON {
  136584. /**
  136585. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  136586. */
  136587. export class CircleOfConfusionPostProcess extends PostProcess {
  136588. /**
  136589. * 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.
  136590. */
  136591. lensSize: number;
  136592. /**
  136593. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136594. */
  136595. fStop: number;
  136596. /**
  136597. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136598. */
  136599. focusDistance: number;
  136600. /**
  136601. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  136602. */
  136603. focalLength: number;
  136604. private _depthTexture;
  136605. /**
  136606. * Creates a new instance CircleOfConfusionPostProcess
  136607. * @param name The name of the effect.
  136608. * @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.
  136609. * @param options The required width/height ratio to downsize to before computing the render pass.
  136610. * @param camera The camera to apply the render pass to.
  136611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136612. * @param engine The engine which the post process will be applied. (default: current engine)
  136613. * @param reusable If the post process can be reused on the same frame. (default: false)
  136614. * @param textureType Type of textures used when performing the post process. (default: 0)
  136615. * @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)
  136616. */
  136617. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136618. /**
  136619. * 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.
  136620. */
  136621. set depthTexture(value: RenderTargetTexture);
  136622. }
  136623. }
  136624. declare module BABYLON {
  136625. /** @hidden */
  136626. export var colorCorrectionPixelShader: {
  136627. name: string;
  136628. shader: string;
  136629. };
  136630. }
  136631. declare module BABYLON {
  136632. /**
  136633. *
  136634. * This post-process allows the modification of rendered colors by using
  136635. * a 'look-up table' (LUT). This effect is also called Color Grading.
  136636. *
  136637. * The object needs to be provided an url to a texture containing the color
  136638. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  136639. * Use an image editing software to tweak the LUT to match your needs.
  136640. *
  136641. * For an example of a color LUT, see here:
  136642. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  136643. * For explanations on color grading, see here:
  136644. * @see http://udn.epicgames.com/Three/ColorGrading.html
  136645. *
  136646. */
  136647. export class ColorCorrectionPostProcess extends PostProcess {
  136648. private _colorTableTexture;
  136649. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136650. }
  136651. }
  136652. declare module BABYLON {
  136653. /** @hidden */
  136654. export var convolutionPixelShader: {
  136655. name: string;
  136656. shader: string;
  136657. };
  136658. }
  136659. declare module BABYLON {
  136660. /**
  136661. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  136662. * input texture to perform effects such as edge detection or sharpening
  136663. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  136664. */
  136665. export class ConvolutionPostProcess extends PostProcess {
  136666. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136667. kernel: number[];
  136668. /**
  136669. * Creates a new instance ConvolutionPostProcess
  136670. * @param name The name of the effect.
  136671. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  136672. * @param options The required width/height ratio to downsize to before computing the render pass.
  136673. * @param camera The camera to apply the render pass to.
  136674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136675. * @param engine The engine which the post process will be applied. (default: current engine)
  136676. * @param reusable If the post process can be reused on the same frame. (default: false)
  136677. * @param textureType Type of textures used when performing the post process. (default: 0)
  136678. */
  136679. constructor(name: string,
  136680. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136681. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136682. /**
  136683. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136684. */
  136685. static EdgeDetect0Kernel: number[];
  136686. /**
  136687. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136688. */
  136689. static EdgeDetect1Kernel: number[];
  136690. /**
  136691. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136692. */
  136693. static EdgeDetect2Kernel: number[];
  136694. /**
  136695. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136696. */
  136697. static SharpenKernel: number[];
  136698. /**
  136699. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136700. */
  136701. static EmbossKernel: number[];
  136702. /**
  136703. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136704. */
  136705. static GaussianKernel: number[];
  136706. }
  136707. }
  136708. declare module BABYLON {
  136709. /**
  136710. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  136711. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  136712. * based on samples that have a large difference in distance than the center pixel.
  136713. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  136714. */
  136715. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  136716. direction: Vector2;
  136717. /**
  136718. * Creates a new instance CircleOfConfusionPostProcess
  136719. * @param name The name of the effect.
  136720. * @param scene The scene the effect belongs to.
  136721. * @param direction The direction the blur should be applied.
  136722. * @param kernel The size of the kernel used to blur.
  136723. * @param options The required width/height ratio to downsize to before computing the render pass.
  136724. * @param camera The camera to apply the render pass to.
  136725. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  136726. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  136727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136728. * @param engine The engine which the post process will be applied. (default: current engine)
  136729. * @param reusable If the post process can be reused on the same frame. (default: false)
  136730. * @param textureType Type of textures used when performing the post process. (default: 0)
  136731. * @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)
  136732. */
  136733. 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);
  136734. }
  136735. }
  136736. declare module BABYLON {
  136737. /** @hidden */
  136738. export var depthOfFieldMergePixelShader: {
  136739. name: string;
  136740. shader: string;
  136741. };
  136742. }
  136743. declare module BABYLON {
  136744. /**
  136745. * Options to be set when merging outputs from the default pipeline.
  136746. */
  136747. export class DepthOfFieldMergePostProcessOptions {
  136748. /**
  136749. * The original image to merge on top of
  136750. */
  136751. originalFromInput: PostProcess;
  136752. /**
  136753. * Parameters to perform the merge of the depth of field effect
  136754. */
  136755. depthOfField?: {
  136756. circleOfConfusion: PostProcess;
  136757. blurSteps: Array<PostProcess>;
  136758. };
  136759. /**
  136760. * Parameters to perform the merge of bloom effect
  136761. */
  136762. bloom?: {
  136763. blurred: PostProcess;
  136764. weight: number;
  136765. };
  136766. }
  136767. /**
  136768. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136769. */
  136770. export class DepthOfFieldMergePostProcess extends PostProcess {
  136771. private blurSteps;
  136772. /**
  136773. * Creates a new instance of DepthOfFieldMergePostProcess
  136774. * @param name The name of the effect.
  136775. * @param originalFromInput Post process which's input will be used for the merge.
  136776. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  136777. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  136778. * @param options The required width/height ratio to downsize to before computing the render pass.
  136779. * @param camera The camera to apply the render pass to.
  136780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136781. * @param engine The engine which the post process will be applied. (default: current engine)
  136782. * @param reusable If the post process can be reused on the same frame. (default: false)
  136783. * @param textureType Type of textures used when performing the post process. (default: 0)
  136784. * @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)
  136785. */
  136786. 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);
  136787. /**
  136788. * Updates the effect with the current post process compile time values and recompiles the shader.
  136789. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  136790. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  136791. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  136792. * @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
  136793. * @param onCompiled Called when the shader has been compiled.
  136794. * @param onError Called if there is an error when compiling a shader.
  136795. */
  136796. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  136797. }
  136798. }
  136799. declare module BABYLON {
  136800. /**
  136801. * Specifies the level of max blur that should be applied when using the depth of field effect
  136802. */
  136803. export enum DepthOfFieldEffectBlurLevel {
  136804. /**
  136805. * Subtle blur
  136806. */
  136807. Low = 0,
  136808. /**
  136809. * Medium blur
  136810. */
  136811. Medium = 1,
  136812. /**
  136813. * Large blur
  136814. */
  136815. High = 2
  136816. }
  136817. /**
  136818. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  136819. */
  136820. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  136821. private _circleOfConfusion;
  136822. /**
  136823. * @hidden Internal, blurs from high to low
  136824. */
  136825. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  136826. private _depthOfFieldBlurY;
  136827. private _dofMerge;
  136828. /**
  136829. * @hidden Internal post processes in depth of field effect
  136830. */
  136831. _effects: Array<PostProcess>;
  136832. /**
  136833. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  136834. */
  136835. set focalLength(value: number);
  136836. get focalLength(): number;
  136837. /**
  136838. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136839. */
  136840. set fStop(value: number);
  136841. get fStop(): number;
  136842. /**
  136843. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136844. */
  136845. set focusDistance(value: number);
  136846. get focusDistance(): number;
  136847. /**
  136848. * 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.
  136849. */
  136850. set lensSize(value: number);
  136851. get lensSize(): number;
  136852. /**
  136853. * Creates a new instance DepthOfFieldEffect
  136854. * @param scene The scene the effect belongs to.
  136855. * @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.
  136856. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136857. * @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)
  136858. */
  136859. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  136860. /**
  136861. * Get the current class name of the current effet
  136862. * @returns "DepthOfFieldEffect"
  136863. */
  136864. getClassName(): string;
  136865. /**
  136866. * 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.
  136867. */
  136868. set depthTexture(value: RenderTargetTexture);
  136869. /**
  136870. * Disposes each of the internal effects for a given camera.
  136871. * @param camera The camera to dispose the effect on.
  136872. */
  136873. disposeEffects(camera: Camera): void;
  136874. /**
  136875. * @hidden Internal
  136876. */
  136877. _updateEffects(): void;
  136878. /**
  136879. * Internal
  136880. * @returns if all the contained post processes are ready.
  136881. * @hidden
  136882. */
  136883. _isReady(): boolean;
  136884. }
  136885. }
  136886. declare module BABYLON {
  136887. /** @hidden */
  136888. export var displayPassPixelShader: {
  136889. name: string;
  136890. shader: string;
  136891. };
  136892. }
  136893. declare module BABYLON {
  136894. /**
  136895. * DisplayPassPostProcess which produces an output the same as it's input
  136896. */
  136897. export class DisplayPassPostProcess extends PostProcess {
  136898. /**
  136899. * Creates the DisplayPassPostProcess
  136900. * @param name The name of the effect.
  136901. * @param options The required width/height ratio to downsize to before computing the render pass.
  136902. * @param camera The camera to apply the render pass to.
  136903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136904. * @param engine The engine which the post process will be applied. (default: current engine)
  136905. * @param reusable If the post process can be reused on the same frame. (default: false)
  136906. */
  136907. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136908. }
  136909. }
  136910. declare module BABYLON {
  136911. /** @hidden */
  136912. export var filterPixelShader: {
  136913. name: string;
  136914. shader: string;
  136915. };
  136916. }
  136917. declare module BABYLON {
  136918. /**
  136919. * Applies a kernel filter to the image
  136920. */
  136921. export class FilterPostProcess extends PostProcess {
  136922. /** The matrix to be applied to the image */
  136923. kernelMatrix: Matrix;
  136924. /**
  136925. *
  136926. * @param name The name of the effect.
  136927. * @param kernelMatrix The matrix to be applied to the image
  136928. * @param options The required width/height ratio to downsize to before computing the render pass.
  136929. * @param camera The camera to apply the render pass to.
  136930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136931. * @param engine The engine which the post process will be applied. (default: current engine)
  136932. * @param reusable If the post process can be reused on the same frame. (default: false)
  136933. */
  136934. constructor(name: string,
  136935. /** The matrix to be applied to the image */
  136936. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136937. }
  136938. }
  136939. declare module BABYLON {
  136940. /** @hidden */
  136941. export var fxaaPixelShader: {
  136942. name: string;
  136943. shader: string;
  136944. };
  136945. }
  136946. declare module BABYLON {
  136947. /** @hidden */
  136948. export var fxaaVertexShader: {
  136949. name: string;
  136950. shader: string;
  136951. };
  136952. }
  136953. declare module BABYLON {
  136954. /**
  136955. * Fxaa post process
  136956. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  136957. */
  136958. export class FxaaPostProcess extends PostProcess {
  136959. /** @hidden */
  136960. texelWidth: number;
  136961. /** @hidden */
  136962. texelHeight: number;
  136963. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136964. private _getDefines;
  136965. }
  136966. }
  136967. declare module BABYLON {
  136968. /** @hidden */
  136969. export var grainPixelShader: {
  136970. name: string;
  136971. shader: string;
  136972. };
  136973. }
  136974. declare module BABYLON {
  136975. /**
  136976. * The GrainPostProcess adds noise to the image at mid luminance levels
  136977. */
  136978. export class GrainPostProcess extends PostProcess {
  136979. /**
  136980. * The intensity of the grain added (default: 30)
  136981. */
  136982. intensity: number;
  136983. /**
  136984. * If the grain should be randomized on every frame
  136985. */
  136986. animated: boolean;
  136987. /**
  136988. * Creates a new instance of @see GrainPostProcess
  136989. * @param name The name of the effect.
  136990. * @param options The required width/height ratio to downsize to before computing the render pass.
  136991. * @param camera The camera to apply the render pass to.
  136992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136993. * @param engine The engine which the post process will be applied. (default: current engine)
  136994. * @param reusable If the post process can be reused on the same frame. (default: false)
  136995. * @param textureType Type of textures used when performing the post process. (default: 0)
  136996. * @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)
  136997. */
  136998. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136999. }
  137000. }
  137001. declare module BABYLON {
  137002. /** @hidden */
  137003. export var highlightsPixelShader: {
  137004. name: string;
  137005. shader: string;
  137006. };
  137007. }
  137008. declare module BABYLON {
  137009. /**
  137010. * Extracts highlights from the image
  137011. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137012. */
  137013. export class HighlightsPostProcess extends PostProcess {
  137014. /**
  137015. * Extracts highlights from the image
  137016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137017. * @param name The name of the effect.
  137018. * @param options The required width/height ratio to downsize to before computing the render pass.
  137019. * @param camera The camera to apply the render pass to.
  137020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137021. * @param engine The engine which the post process will be applied. (default: current engine)
  137022. * @param reusable If the post process can be reused on the same frame. (default: false)
  137023. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137024. */
  137025. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137026. }
  137027. }
  137028. declare module BABYLON {
  137029. /** @hidden */
  137030. export var mrtFragmentDeclaration: {
  137031. name: string;
  137032. shader: string;
  137033. };
  137034. }
  137035. declare module BABYLON {
  137036. /** @hidden */
  137037. export var geometryPixelShader: {
  137038. name: string;
  137039. shader: string;
  137040. };
  137041. }
  137042. declare module BABYLON {
  137043. /** @hidden */
  137044. export var geometryVertexShader: {
  137045. name: string;
  137046. shader: string;
  137047. };
  137048. }
  137049. declare module BABYLON {
  137050. /** @hidden */
  137051. interface ISavedTransformationMatrix {
  137052. world: Matrix;
  137053. viewProjection: Matrix;
  137054. }
  137055. /**
  137056. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137057. */
  137058. export class GeometryBufferRenderer {
  137059. /**
  137060. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137061. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137062. */
  137063. static readonly POSITION_TEXTURE_TYPE: number;
  137064. /**
  137065. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137066. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137067. */
  137068. static readonly VELOCITY_TEXTURE_TYPE: number;
  137069. /**
  137070. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137071. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137072. */
  137073. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137074. /**
  137075. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137076. * in order to compute objects velocities when enableVelocity is set to "true"
  137077. * @hidden
  137078. */
  137079. _previousTransformationMatrices: {
  137080. [index: number]: ISavedTransformationMatrix;
  137081. };
  137082. /**
  137083. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137084. * in order to compute objects velocities when enableVelocity is set to "true"
  137085. * @hidden
  137086. */
  137087. _previousBonesTransformationMatrices: {
  137088. [index: number]: Float32Array;
  137089. };
  137090. /**
  137091. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137092. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137093. */
  137094. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137095. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137096. renderTransparentMeshes: boolean;
  137097. private _scene;
  137098. private _multiRenderTarget;
  137099. private _ratio;
  137100. private _enablePosition;
  137101. private _enableVelocity;
  137102. private _enableReflectivity;
  137103. private _positionIndex;
  137104. private _velocityIndex;
  137105. private _reflectivityIndex;
  137106. protected _effect: Effect;
  137107. protected _cachedDefines: string;
  137108. /**
  137109. * Set the render list (meshes to be rendered) used in the G buffer.
  137110. */
  137111. set renderList(meshes: Mesh[]);
  137112. /**
  137113. * Gets wether or not G buffer are supported by the running hardware.
  137114. * This requires draw buffer supports
  137115. */
  137116. get isSupported(): boolean;
  137117. /**
  137118. * Returns the index of the given texture type in the G-Buffer textures array
  137119. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137120. * @returns the index of the given texture type in the G-Buffer textures array
  137121. */
  137122. getTextureIndex(textureType: number): number;
  137123. /**
  137124. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137125. */
  137126. get enablePosition(): boolean;
  137127. /**
  137128. * Sets whether or not objects positions are enabled for the G buffer.
  137129. */
  137130. set enablePosition(enable: boolean);
  137131. /**
  137132. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137133. */
  137134. get enableVelocity(): boolean;
  137135. /**
  137136. * Sets wether or not objects velocities are enabled for the G buffer.
  137137. */
  137138. set enableVelocity(enable: boolean);
  137139. /**
  137140. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137141. */
  137142. get enableReflectivity(): boolean;
  137143. /**
  137144. * Sets wether or not objects roughness are enabled for the G buffer.
  137145. */
  137146. set enableReflectivity(enable: boolean);
  137147. /**
  137148. * Gets the scene associated with the buffer.
  137149. */
  137150. get scene(): Scene;
  137151. /**
  137152. * Gets the ratio used by the buffer during its creation.
  137153. * How big is the buffer related to the main canvas.
  137154. */
  137155. get ratio(): number;
  137156. /** @hidden */
  137157. static _SceneComponentInitialization: (scene: Scene) => void;
  137158. /**
  137159. * Creates a new G Buffer for the scene
  137160. * @param scene The scene the buffer belongs to
  137161. * @param ratio How big is the buffer related to the main canvas.
  137162. */
  137163. constructor(scene: Scene, ratio?: number);
  137164. /**
  137165. * Checks wether everything is ready to render a submesh to the G buffer.
  137166. * @param subMesh the submesh to check readiness for
  137167. * @param useInstances is the mesh drawn using instance or not
  137168. * @returns true if ready otherwise false
  137169. */
  137170. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137171. /**
  137172. * Gets the current underlying G Buffer.
  137173. * @returns the buffer
  137174. */
  137175. getGBuffer(): MultiRenderTarget;
  137176. /**
  137177. * Gets the number of samples used to render the buffer (anti aliasing).
  137178. */
  137179. get samples(): number;
  137180. /**
  137181. * Sets the number of samples used to render the buffer (anti aliasing).
  137182. */
  137183. set samples(value: number);
  137184. /**
  137185. * Disposes the renderer and frees up associated resources.
  137186. */
  137187. dispose(): void;
  137188. protected _createRenderTargets(): void;
  137189. private _copyBonesTransformationMatrices;
  137190. }
  137191. }
  137192. declare module BABYLON {
  137193. interface Scene {
  137194. /** @hidden (Backing field) */
  137195. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137196. /**
  137197. * Gets or Sets the current geometry buffer associated to the scene.
  137198. */
  137199. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137200. /**
  137201. * Enables a GeometryBufferRender and associates it with the scene
  137202. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137203. * @returns the GeometryBufferRenderer
  137204. */
  137205. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137206. /**
  137207. * Disables the GeometryBufferRender associated with the scene
  137208. */
  137209. disableGeometryBufferRenderer(): void;
  137210. }
  137211. /**
  137212. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137213. * in several rendering techniques.
  137214. */
  137215. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137216. /**
  137217. * The component name helpful to identify the component in the list of scene components.
  137218. */
  137219. readonly name: string;
  137220. /**
  137221. * The scene the component belongs to.
  137222. */
  137223. scene: Scene;
  137224. /**
  137225. * Creates a new instance of the component for the given scene
  137226. * @param scene Defines the scene to register the component in
  137227. */
  137228. constructor(scene: Scene);
  137229. /**
  137230. * Registers the component in a given scene
  137231. */
  137232. register(): void;
  137233. /**
  137234. * Rebuilds the elements related to this component in case of
  137235. * context lost for instance.
  137236. */
  137237. rebuild(): void;
  137238. /**
  137239. * Disposes the component and the associated ressources
  137240. */
  137241. dispose(): void;
  137242. private _gatherRenderTargets;
  137243. }
  137244. }
  137245. declare module BABYLON {
  137246. /** @hidden */
  137247. export var motionBlurPixelShader: {
  137248. name: string;
  137249. shader: string;
  137250. };
  137251. }
  137252. declare module BABYLON {
  137253. /**
  137254. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137255. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137256. * As an example, all you have to do is to create the post-process:
  137257. * var mb = new BABYLON.MotionBlurPostProcess(
  137258. * 'mb', // The name of the effect.
  137259. * scene, // The scene containing the objects to blur according to their velocity.
  137260. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137261. * camera // The camera to apply the render pass to.
  137262. * );
  137263. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137264. */
  137265. export class MotionBlurPostProcess extends PostProcess {
  137266. /**
  137267. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137268. */
  137269. motionStrength: number;
  137270. /**
  137271. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137272. */
  137273. get motionBlurSamples(): number;
  137274. /**
  137275. * Sets the number of iterations to be used for motion blur quality
  137276. */
  137277. set motionBlurSamples(samples: number);
  137278. private _motionBlurSamples;
  137279. private _geometryBufferRenderer;
  137280. /**
  137281. * Creates a new instance MotionBlurPostProcess
  137282. * @param name The name of the effect.
  137283. * @param scene The scene containing the objects to blur according to their velocity.
  137284. * @param options The required width/height ratio to downsize to before computing the render pass.
  137285. * @param camera The camera to apply the render pass to.
  137286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137287. * @param engine The engine which the post process will be applied. (default: current engine)
  137288. * @param reusable If the post process can be reused on the same frame. (default: false)
  137289. * @param textureType Type of textures used when performing the post process. (default: 0)
  137290. * @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)
  137291. */
  137292. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137293. /**
  137294. * Excludes the given skinned mesh from computing bones velocities.
  137295. * 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.
  137296. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137297. */
  137298. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137299. /**
  137300. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137301. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137302. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137303. */
  137304. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137305. /**
  137306. * Disposes the post process.
  137307. * @param camera The camera to dispose the post process on.
  137308. */
  137309. dispose(camera?: Camera): void;
  137310. }
  137311. }
  137312. declare module BABYLON {
  137313. /** @hidden */
  137314. export var refractionPixelShader: {
  137315. name: string;
  137316. shader: string;
  137317. };
  137318. }
  137319. declare module BABYLON {
  137320. /**
  137321. * Post process which applies a refractin texture
  137322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137323. */
  137324. export class RefractionPostProcess extends PostProcess {
  137325. /** the base color of the refraction (used to taint the rendering) */
  137326. color: Color3;
  137327. /** simulated refraction depth */
  137328. depth: number;
  137329. /** the coefficient of the base color (0 to remove base color tainting) */
  137330. colorLevel: number;
  137331. private _refTexture;
  137332. private _ownRefractionTexture;
  137333. /**
  137334. * Gets or sets the refraction texture
  137335. * Please note that you are responsible for disposing the texture if you set it manually
  137336. */
  137337. get refractionTexture(): Texture;
  137338. set refractionTexture(value: Texture);
  137339. /**
  137340. * Initializes the RefractionPostProcess
  137341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137342. * @param name The name of the effect.
  137343. * @param refractionTextureUrl Url of the refraction texture to use
  137344. * @param color the base color of the refraction (used to taint the rendering)
  137345. * @param depth simulated refraction depth
  137346. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  137347. * @param camera The camera to apply the render pass to.
  137348. * @param options The required width/height ratio to downsize to before computing the render pass.
  137349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137350. * @param engine The engine which the post process will be applied. (default: current engine)
  137351. * @param reusable If the post process can be reused on the same frame. (default: false)
  137352. */
  137353. constructor(name: string, refractionTextureUrl: string,
  137354. /** the base color of the refraction (used to taint the rendering) */
  137355. color: Color3,
  137356. /** simulated refraction depth */
  137357. depth: number,
  137358. /** the coefficient of the base color (0 to remove base color tainting) */
  137359. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137360. /**
  137361. * Disposes of the post process
  137362. * @param camera Camera to dispose post process on
  137363. */
  137364. dispose(camera: Camera): void;
  137365. }
  137366. }
  137367. declare module BABYLON {
  137368. /** @hidden */
  137369. export var sharpenPixelShader: {
  137370. name: string;
  137371. shader: string;
  137372. };
  137373. }
  137374. declare module BABYLON {
  137375. /**
  137376. * The SharpenPostProcess applies a sharpen kernel to every pixel
  137377. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137378. */
  137379. export class SharpenPostProcess extends PostProcess {
  137380. /**
  137381. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  137382. */
  137383. colorAmount: number;
  137384. /**
  137385. * How much sharpness should be applied (default: 0.3)
  137386. */
  137387. edgeAmount: number;
  137388. /**
  137389. * Creates a new instance ConvolutionPostProcess
  137390. * @param name The name of the effect.
  137391. * @param options The required width/height ratio to downsize to before computing the render pass.
  137392. * @param camera The camera to apply the render pass to.
  137393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137394. * @param engine The engine which the post process will be applied. (default: current engine)
  137395. * @param reusable If the post process can be reused on the same frame. (default: false)
  137396. * @param textureType Type of textures used when performing the post process. (default: 0)
  137397. * @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)
  137398. */
  137399. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137400. }
  137401. }
  137402. declare module BABYLON {
  137403. /**
  137404. * PostProcessRenderPipeline
  137405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137406. */
  137407. export class PostProcessRenderPipeline {
  137408. private engine;
  137409. private _renderEffects;
  137410. private _renderEffectsForIsolatedPass;
  137411. /**
  137412. * List of inspectable custom properties (used by the Inspector)
  137413. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  137414. */
  137415. inspectableCustomProperties: IInspectable[];
  137416. /**
  137417. * @hidden
  137418. */
  137419. protected _cameras: Camera[];
  137420. /** @hidden */
  137421. _name: string;
  137422. /**
  137423. * Gets pipeline name
  137424. */
  137425. get name(): string;
  137426. /** Gets the list of attached cameras */
  137427. get cameras(): Camera[];
  137428. /**
  137429. * Initializes a PostProcessRenderPipeline
  137430. * @param engine engine to add the pipeline to
  137431. * @param name name of the pipeline
  137432. */
  137433. constructor(engine: Engine, name: string);
  137434. /**
  137435. * Gets the class name
  137436. * @returns "PostProcessRenderPipeline"
  137437. */
  137438. getClassName(): string;
  137439. /**
  137440. * If all the render effects in the pipeline are supported
  137441. */
  137442. get isSupported(): boolean;
  137443. /**
  137444. * Adds an effect to the pipeline
  137445. * @param renderEffect the effect to add
  137446. */
  137447. addEffect(renderEffect: PostProcessRenderEffect): void;
  137448. /** @hidden */
  137449. _rebuild(): void;
  137450. /** @hidden */
  137451. _enableEffect(renderEffectName: string, cameras: Camera): void;
  137452. /** @hidden */
  137453. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  137454. /** @hidden */
  137455. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137456. /** @hidden */
  137457. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137458. /** @hidden */
  137459. _attachCameras(cameras: Camera, unique: boolean): void;
  137460. /** @hidden */
  137461. _attachCameras(cameras: Camera[], unique: boolean): void;
  137462. /** @hidden */
  137463. _detachCameras(cameras: Camera): void;
  137464. /** @hidden */
  137465. _detachCameras(cameras: Nullable<Camera[]>): void;
  137466. /** @hidden */
  137467. _update(): void;
  137468. /** @hidden */
  137469. _reset(): void;
  137470. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  137471. /**
  137472. * Disposes of the pipeline
  137473. */
  137474. dispose(): void;
  137475. }
  137476. }
  137477. declare module BABYLON {
  137478. /**
  137479. * PostProcessRenderPipelineManager class
  137480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137481. */
  137482. export class PostProcessRenderPipelineManager {
  137483. private _renderPipelines;
  137484. /**
  137485. * Initializes a PostProcessRenderPipelineManager
  137486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137487. */
  137488. constructor();
  137489. /**
  137490. * Gets the list of supported render pipelines
  137491. */
  137492. get supportedPipelines(): PostProcessRenderPipeline[];
  137493. /**
  137494. * Adds a pipeline to the manager
  137495. * @param renderPipeline The pipeline to add
  137496. */
  137497. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  137498. /**
  137499. * Attaches a camera to the pipeline
  137500. * @param renderPipelineName The name of the pipeline to attach to
  137501. * @param cameras the camera to attach
  137502. * @param unique if the camera can be attached multiple times to the pipeline
  137503. */
  137504. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  137505. /**
  137506. * Detaches a camera from the pipeline
  137507. * @param renderPipelineName The name of the pipeline to detach from
  137508. * @param cameras the camera to detach
  137509. */
  137510. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  137511. /**
  137512. * Enables an effect by name on a pipeline
  137513. * @param renderPipelineName the name of the pipeline to enable the effect in
  137514. * @param renderEffectName the name of the effect to enable
  137515. * @param cameras the cameras that the effect should be enabled on
  137516. */
  137517. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137518. /**
  137519. * Disables an effect by name on a pipeline
  137520. * @param renderPipelineName the name of the pipeline to disable the effect in
  137521. * @param renderEffectName the name of the effect to disable
  137522. * @param cameras the cameras that the effect should be disabled on
  137523. */
  137524. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137525. /**
  137526. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  137527. */
  137528. update(): void;
  137529. /** @hidden */
  137530. _rebuild(): void;
  137531. /**
  137532. * Disposes of the manager and pipelines
  137533. */
  137534. dispose(): void;
  137535. }
  137536. }
  137537. declare module BABYLON {
  137538. interface Scene {
  137539. /** @hidden (Backing field) */
  137540. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137541. /**
  137542. * Gets the postprocess render pipeline manager
  137543. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137544. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137545. */
  137546. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137547. }
  137548. /**
  137549. * Defines the Render Pipeline scene component responsible to rendering pipelines
  137550. */
  137551. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  137552. /**
  137553. * The component name helpfull to identify the component in the list of scene components.
  137554. */
  137555. readonly name: string;
  137556. /**
  137557. * The scene the component belongs to.
  137558. */
  137559. scene: Scene;
  137560. /**
  137561. * Creates a new instance of the component for the given scene
  137562. * @param scene Defines the scene to register the component in
  137563. */
  137564. constructor(scene: Scene);
  137565. /**
  137566. * Registers the component in a given scene
  137567. */
  137568. register(): void;
  137569. /**
  137570. * Rebuilds the elements related to this component in case of
  137571. * context lost for instance.
  137572. */
  137573. rebuild(): void;
  137574. /**
  137575. * Disposes the component and the associated ressources
  137576. */
  137577. dispose(): void;
  137578. private _gatherRenderTargets;
  137579. }
  137580. }
  137581. declare module BABYLON {
  137582. /**
  137583. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  137584. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137585. */
  137586. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  137587. private _scene;
  137588. private _camerasToBeAttached;
  137589. /**
  137590. * ID of the sharpen post process,
  137591. */
  137592. private readonly SharpenPostProcessId;
  137593. /**
  137594. * @ignore
  137595. * ID of the image processing post process;
  137596. */
  137597. readonly ImageProcessingPostProcessId: string;
  137598. /**
  137599. * @ignore
  137600. * ID of the Fast Approximate Anti-Aliasing post process;
  137601. */
  137602. readonly FxaaPostProcessId: string;
  137603. /**
  137604. * ID of the chromatic aberration post process,
  137605. */
  137606. private readonly ChromaticAberrationPostProcessId;
  137607. /**
  137608. * ID of the grain post process
  137609. */
  137610. private readonly GrainPostProcessId;
  137611. /**
  137612. * Sharpen post process which will apply a sharpen convolution to enhance edges
  137613. */
  137614. sharpen: SharpenPostProcess;
  137615. private _sharpenEffect;
  137616. private bloom;
  137617. /**
  137618. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  137619. */
  137620. depthOfField: DepthOfFieldEffect;
  137621. /**
  137622. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  137623. */
  137624. fxaa: FxaaPostProcess;
  137625. /**
  137626. * Image post processing pass used to perform operations such as tone mapping or color grading.
  137627. */
  137628. imageProcessing: ImageProcessingPostProcess;
  137629. /**
  137630. * Chromatic aberration post process which will shift rgb colors in the image
  137631. */
  137632. chromaticAberration: ChromaticAberrationPostProcess;
  137633. private _chromaticAberrationEffect;
  137634. /**
  137635. * Grain post process which add noise to the image
  137636. */
  137637. grain: GrainPostProcess;
  137638. private _grainEffect;
  137639. /**
  137640. * Glow post process which adds a glow to emissive areas of the image
  137641. */
  137642. private _glowLayer;
  137643. /**
  137644. * Animations which can be used to tweak settings over a period of time
  137645. */
  137646. animations: Animation[];
  137647. private _imageProcessingConfigurationObserver;
  137648. private _sharpenEnabled;
  137649. private _bloomEnabled;
  137650. private _depthOfFieldEnabled;
  137651. private _depthOfFieldBlurLevel;
  137652. private _fxaaEnabled;
  137653. private _imageProcessingEnabled;
  137654. private _defaultPipelineTextureType;
  137655. private _bloomScale;
  137656. private _chromaticAberrationEnabled;
  137657. private _grainEnabled;
  137658. private _buildAllowed;
  137659. /**
  137660. * Gets active scene
  137661. */
  137662. get scene(): Scene;
  137663. /**
  137664. * Enable or disable the sharpen process from the pipeline
  137665. */
  137666. set sharpenEnabled(enabled: boolean);
  137667. get sharpenEnabled(): boolean;
  137668. private _resizeObserver;
  137669. private _hardwareScaleLevel;
  137670. private _bloomKernel;
  137671. /**
  137672. * Specifies the size of the bloom blur kernel, relative to the final output size
  137673. */
  137674. get bloomKernel(): number;
  137675. set bloomKernel(value: number);
  137676. /**
  137677. * Specifies the weight of the bloom in the final rendering
  137678. */
  137679. private _bloomWeight;
  137680. /**
  137681. * Specifies the luma threshold for the area that will be blurred by the bloom
  137682. */
  137683. private _bloomThreshold;
  137684. private _hdr;
  137685. /**
  137686. * The strength of the bloom.
  137687. */
  137688. set bloomWeight(value: number);
  137689. get bloomWeight(): number;
  137690. /**
  137691. * The strength of the bloom.
  137692. */
  137693. set bloomThreshold(value: number);
  137694. get bloomThreshold(): number;
  137695. /**
  137696. * The scale of the bloom, lower value will provide better performance.
  137697. */
  137698. set bloomScale(value: number);
  137699. get bloomScale(): number;
  137700. /**
  137701. * Enable or disable the bloom from the pipeline
  137702. */
  137703. set bloomEnabled(enabled: boolean);
  137704. get bloomEnabled(): boolean;
  137705. private _rebuildBloom;
  137706. /**
  137707. * If the depth of field is enabled.
  137708. */
  137709. get depthOfFieldEnabled(): boolean;
  137710. set depthOfFieldEnabled(enabled: boolean);
  137711. /**
  137712. * Blur level of the depth of field effect. (Higher blur will effect performance)
  137713. */
  137714. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  137715. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  137716. /**
  137717. * If the anti aliasing is enabled.
  137718. */
  137719. set fxaaEnabled(enabled: boolean);
  137720. get fxaaEnabled(): boolean;
  137721. private _samples;
  137722. /**
  137723. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  137724. */
  137725. set samples(sampleCount: number);
  137726. get samples(): number;
  137727. /**
  137728. * If image processing is enabled.
  137729. */
  137730. set imageProcessingEnabled(enabled: boolean);
  137731. get imageProcessingEnabled(): boolean;
  137732. /**
  137733. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  137734. */
  137735. set glowLayerEnabled(enabled: boolean);
  137736. get glowLayerEnabled(): boolean;
  137737. /**
  137738. * Gets the glow layer (or null if not defined)
  137739. */
  137740. get glowLayer(): Nullable<GlowLayer>;
  137741. /**
  137742. * Enable or disable the chromaticAberration process from the pipeline
  137743. */
  137744. set chromaticAberrationEnabled(enabled: boolean);
  137745. get chromaticAberrationEnabled(): boolean;
  137746. /**
  137747. * Enable or disable the grain process from the pipeline
  137748. */
  137749. set grainEnabled(enabled: boolean);
  137750. get grainEnabled(): boolean;
  137751. /**
  137752. * @constructor
  137753. * @param name - The rendering pipeline name (default: "")
  137754. * @param hdr - If high dynamic range textures should be used (default: true)
  137755. * @param scene - The scene linked to this pipeline (default: the last created scene)
  137756. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  137757. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  137758. */
  137759. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  137760. /**
  137761. * Get the class name
  137762. * @returns "DefaultRenderingPipeline"
  137763. */
  137764. getClassName(): string;
  137765. /**
  137766. * Force the compilation of the entire pipeline.
  137767. */
  137768. prepare(): void;
  137769. private _hasCleared;
  137770. private _prevPostProcess;
  137771. private _prevPrevPostProcess;
  137772. private _setAutoClearAndTextureSharing;
  137773. private _depthOfFieldSceneObserver;
  137774. private _buildPipeline;
  137775. private _disposePostProcesses;
  137776. /**
  137777. * Adds a camera to the pipeline
  137778. * @param camera the camera to be added
  137779. */
  137780. addCamera(camera: Camera): void;
  137781. /**
  137782. * Removes a camera from the pipeline
  137783. * @param camera the camera to remove
  137784. */
  137785. removeCamera(camera: Camera): void;
  137786. /**
  137787. * Dispose of the pipeline and stop all post processes
  137788. */
  137789. dispose(): void;
  137790. /**
  137791. * Serialize the rendering pipeline (Used when exporting)
  137792. * @returns the serialized object
  137793. */
  137794. serialize(): any;
  137795. /**
  137796. * Parse the serialized pipeline
  137797. * @param source Source pipeline.
  137798. * @param scene The scene to load the pipeline to.
  137799. * @param rootUrl The URL of the serialized pipeline.
  137800. * @returns An instantiated pipeline from the serialized object.
  137801. */
  137802. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  137803. }
  137804. }
  137805. declare module BABYLON {
  137806. /** @hidden */
  137807. export var lensHighlightsPixelShader: {
  137808. name: string;
  137809. shader: string;
  137810. };
  137811. }
  137812. declare module BABYLON {
  137813. /** @hidden */
  137814. export var depthOfFieldPixelShader: {
  137815. name: string;
  137816. shader: string;
  137817. };
  137818. }
  137819. declare module BABYLON {
  137820. /**
  137821. * BABYLON.JS Chromatic Aberration GLSL Shader
  137822. * Author: Olivier Guyot
  137823. * Separates very slightly R, G and B colors on the edges of the screen
  137824. * Inspired by Francois Tarlier & Martins Upitis
  137825. */
  137826. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  137827. /**
  137828. * @ignore
  137829. * The chromatic aberration PostProcess id in the pipeline
  137830. */
  137831. LensChromaticAberrationEffect: string;
  137832. /**
  137833. * @ignore
  137834. * The highlights enhancing PostProcess id in the pipeline
  137835. */
  137836. HighlightsEnhancingEffect: string;
  137837. /**
  137838. * @ignore
  137839. * The depth-of-field PostProcess id in the pipeline
  137840. */
  137841. LensDepthOfFieldEffect: string;
  137842. private _scene;
  137843. private _depthTexture;
  137844. private _grainTexture;
  137845. private _chromaticAberrationPostProcess;
  137846. private _highlightsPostProcess;
  137847. private _depthOfFieldPostProcess;
  137848. private _edgeBlur;
  137849. private _grainAmount;
  137850. private _chromaticAberration;
  137851. private _distortion;
  137852. private _highlightsGain;
  137853. private _highlightsThreshold;
  137854. private _dofDistance;
  137855. private _dofAperture;
  137856. private _dofDarken;
  137857. private _dofPentagon;
  137858. private _blurNoise;
  137859. /**
  137860. * @constructor
  137861. *
  137862. * Effect parameters are as follow:
  137863. * {
  137864. * chromatic_aberration: number; // from 0 to x (1 for realism)
  137865. * edge_blur: number; // from 0 to x (1 for realism)
  137866. * distortion: number; // from 0 to x (1 for realism)
  137867. * grain_amount: number; // from 0 to 1
  137868. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  137869. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  137870. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  137871. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  137872. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  137873. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  137874. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  137875. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  137876. * }
  137877. * Note: if an effect parameter is unset, effect is disabled
  137878. *
  137879. * @param name The rendering pipeline name
  137880. * @param parameters - An object containing all parameters (see above)
  137881. * @param scene The scene linked to this pipeline
  137882. * @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)
  137883. * @param cameras The array of cameras that the rendering pipeline will be attached to
  137884. */
  137885. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  137886. /**
  137887. * Get the class name
  137888. * @returns "LensRenderingPipeline"
  137889. */
  137890. getClassName(): string;
  137891. /**
  137892. * Gets associated scene
  137893. */
  137894. get scene(): Scene;
  137895. /**
  137896. * Gets or sets the edge blur
  137897. */
  137898. get edgeBlur(): number;
  137899. set edgeBlur(value: number);
  137900. /**
  137901. * Gets or sets the grain amount
  137902. */
  137903. get grainAmount(): number;
  137904. set grainAmount(value: number);
  137905. /**
  137906. * Gets or sets the chromatic aberration amount
  137907. */
  137908. get chromaticAberration(): number;
  137909. set chromaticAberration(value: number);
  137910. /**
  137911. * Gets or sets the depth of field aperture
  137912. */
  137913. get dofAperture(): number;
  137914. set dofAperture(value: number);
  137915. /**
  137916. * Gets or sets the edge distortion
  137917. */
  137918. get edgeDistortion(): number;
  137919. set edgeDistortion(value: number);
  137920. /**
  137921. * Gets or sets the depth of field distortion
  137922. */
  137923. get dofDistortion(): number;
  137924. set dofDistortion(value: number);
  137925. /**
  137926. * Gets or sets the darken out of focus amount
  137927. */
  137928. get darkenOutOfFocus(): number;
  137929. set darkenOutOfFocus(value: number);
  137930. /**
  137931. * Gets or sets a boolean indicating if blur noise is enabled
  137932. */
  137933. get blurNoise(): boolean;
  137934. set blurNoise(value: boolean);
  137935. /**
  137936. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  137937. */
  137938. get pentagonBokeh(): boolean;
  137939. set pentagonBokeh(value: boolean);
  137940. /**
  137941. * Gets or sets the highlight grain amount
  137942. */
  137943. get highlightsGain(): number;
  137944. set highlightsGain(value: number);
  137945. /**
  137946. * Gets or sets the highlight threshold
  137947. */
  137948. get highlightsThreshold(): number;
  137949. set highlightsThreshold(value: number);
  137950. /**
  137951. * Sets the amount of blur at the edges
  137952. * @param amount blur amount
  137953. */
  137954. setEdgeBlur(amount: number): void;
  137955. /**
  137956. * Sets edge blur to 0
  137957. */
  137958. disableEdgeBlur(): void;
  137959. /**
  137960. * Sets the amout of grain
  137961. * @param amount Amount of grain
  137962. */
  137963. setGrainAmount(amount: number): void;
  137964. /**
  137965. * Set grain amount to 0
  137966. */
  137967. disableGrain(): void;
  137968. /**
  137969. * Sets the chromatic aberration amount
  137970. * @param amount amount of chromatic aberration
  137971. */
  137972. setChromaticAberration(amount: number): void;
  137973. /**
  137974. * Sets chromatic aberration amount to 0
  137975. */
  137976. disableChromaticAberration(): void;
  137977. /**
  137978. * Sets the EdgeDistortion amount
  137979. * @param amount amount of EdgeDistortion
  137980. */
  137981. setEdgeDistortion(amount: number): void;
  137982. /**
  137983. * Sets edge distortion to 0
  137984. */
  137985. disableEdgeDistortion(): void;
  137986. /**
  137987. * Sets the FocusDistance amount
  137988. * @param amount amount of FocusDistance
  137989. */
  137990. setFocusDistance(amount: number): void;
  137991. /**
  137992. * Disables depth of field
  137993. */
  137994. disableDepthOfField(): void;
  137995. /**
  137996. * Sets the Aperture amount
  137997. * @param amount amount of Aperture
  137998. */
  137999. setAperture(amount: number): void;
  138000. /**
  138001. * Sets the DarkenOutOfFocus amount
  138002. * @param amount amount of DarkenOutOfFocus
  138003. */
  138004. setDarkenOutOfFocus(amount: number): void;
  138005. private _pentagonBokehIsEnabled;
  138006. /**
  138007. * Creates a pentagon bokeh effect
  138008. */
  138009. enablePentagonBokeh(): void;
  138010. /**
  138011. * Disables the pentagon bokeh effect
  138012. */
  138013. disablePentagonBokeh(): void;
  138014. /**
  138015. * Enables noise blur
  138016. */
  138017. enableNoiseBlur(): void;
  138018. /**
  138019. * Disables noise blur
  138020. */
  138021. disableNoiseBlur(): void;
  138022. /**
  138023. * Sets the HighlightsGain amount
  138024. * @param amount amount of HighlightsGain
  138025. */
  138026. setHighlightsGain(amount: number): void;
  138027. /**
  138028. * Sets the HighlightsThreshold amount
  138029. * @param amount amount of HighlightsThreshold
  138030. */
  138031. setHighlightsThreshold(amount: number): void;
  138032. /**
  138033. * Disables highlights
  138034. */
  138035. disableHighlights(): void;
  138036. /**
  138037. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138038. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138039. */
  138040. dispose(disableDepthRender?: boolean): void;
  138041. private _createChromaticAberrationPostProcess;
  138042. private _createHighlightsPostProcess;
  138043. private _createDepthOfFieldPostProcess;
  138044. private _createGrainTexture;
  138045. }
  138046. }
  138047. declare module BABYLON {
  138048. /** @hidden */
  138049. export var ssao2PixelShader: {
  138050. name: string;
  138051. shader: string;
  138052. };
  138053. }
  138054. declare module BABYLON {
  138055. /** @hidden */
  138056. export var ssaoCombinePixelShader: {
  138057. name: string;
  138058. shader: string;
  138059. };
  138060. }
  138061. declare module BABYLON {
  138062. /**
  138063. * Render pipeline to produce ssao effect
  138064. */
  138065. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138066. /**
  138067. * @ignore
  138068. * The PassPostProcess id in the pipeline that contains the original scene color
  138069. */
  138070. SSAOOriginalSceneColorEffect: string;
  138071. /**
  138072. * @ignore
  138073. * The SSAO PostProcess id in the pipeline
  138074. */
  138075. SSAORenderEffect: string;
  138076. /**
  138077. * @ignore
  138078. * The horizontal blur PostProcess id in the pipeline
  138079. */
  138080. SSAOBlurHRenderEffect: string;
  138081. /**
  138082. * @ignore
  138083. * The vertical blur PostProcess id in the pipeline
  138084. */
  138085. SSAOBlurVRenderEffect: string;
  138086. /**
  138087. * @ignore
  138088. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138089. */
  138090. SSAOCombineRenderEffect: string;
  138091. /**
  138092. * The output strength of the SSAO post-process. Default value is 1.0.
  138093. */
  138094. totalStrength: number;
  138095. /**
  138096. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138097. */
  138098. maxZ: number;
  138099. /**
  138100. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138101. */
  138102. minZAspect: number;
  138103. private _samples;
  138104. /**
  138105. * Number of samples used for the SSAO calculations. Default value is 8
  138106. */
  138107. set samples(n: number);
  138108. get samples(): number;
  138109. private _textureSamples;
  138110. /**
  138111. * Number of samples to use for antialiasing
  138112. */
  138113. set textureSamples(n: number);
  138114. get textureSamples(): number;
  138115. /**
  138116. * Ratio object used for SSAO ratio and blur ratio
  138117. */
  138118. private _ratio;
  138119. /**
  138120. * Dynamically generated sphere sampler.
  138121. */
  138122. private _sampleSphere;
  138123. /**
  138124. * Blur filter offsets
  138125. */
  138126. private _samplerOffsets;
  138127. private _expensiveBlur;
  138128. /**
  138129. * If bilateral blur should be used
  138130. */
  138131. set expensiveBlur(b: boolean);
  138132. get expensiveBlur(): boolean;
  138133. /**
  138134. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138135. */
  138136. radius: number;
  138137. /**
  138138. * The base color of the SSAO post-process
  138139. * The final result is "base + ssao" between [0, 1]
  138140. */
  138141. base: number;
  138142. /**
  138143. * Support test.
  138144. */
  138145. static get IsSupported(): boolean;
  138146. private _scene;
  138147. private _depthTexture;
  138148. private _normalTexture;
  138149. private _randomTexture;
  138150. private _originalColorPostProcess;
  138151. private _ssaoPostProcess;
  138152. private _blurHPostProcess;
  138153. private _blurVPostProcess;
  138154. private _ssaoCombinePostProcess;
  138155. /**
  138156. * Gets active scene
  138157. */
  138158. get scene(): Scene;
  138159. /**
  138160. * @constructor
  138161. * @param name The rendering pipeline name
  138162. * @param scene The scene linked to this pipeline
  138163. * @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 }
  138164. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138165. */
  138166. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138167. /**
  138168. * Get the class name
  138169. * @returns "SSAO2RenderingPipeline"
  138170. */
  138171. getClassName(): string;
  138172. /**
  138173. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138174. */
  138175. dispose(disableGeometryBufferRenderer?: boolean): void;
  138176. private _createBlurPostProcess;
  138177. /** @hidden */
  138178. _rebuild(): void;
  138179. private _bits;
  138180. private _radicalInverse_VdC;
  138181. private _hammersley;
  138182. private _hemisphereSample_uniform;
  138183. private _generateHemisphere;
  138184. private _createSSAOPostProcess;
  138185. private _createSSAOCombinePostProcess;
  138186. private _createRandomTexture;
  138187. /**
  138188. * Serialize the rendering pipeline (Used when exporting)
  138189. * @returns the serialized object
  138190. */
  138191. serialize(): any;
  138192. /**
  138193. * Parse the serialized pipeline
  138194. * @param source Source pipeline.
  138195. * @param scene The scene to load the pipeline to.
  138196. * @param rootUrl The URL of the serialized pipeline.
  138197. * @returns An instantiated pipeline from the serialized object.
  138198. */
  138199. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138200. }
  138201. }
  138202. declare module BABYLON {
  138203. /** @hidden */
  138204. export var ssaoPixelShader: {
  138205. name: string;
  138206. shader: string;
  138207. };
  138208. }
  138209. declare module BABYLON {
  138210. /**
  138211. * Render pipeline to produce ssao effect
  138212. */
  138213. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138214. /**
  138215. * @ignore
  138216. * The PassPostProcess id in the pipeline that contains the original scene color
  138217. */
  138218. SSAOOriginalSceneColorEffect: string;
  138219. /**
  138220. * @ignore
  138221. * The SSAO PostProcess id in the pipeline
  138222. */
  138223. SSAORenderEffect: string;
  138224. /**
  138225. * @ignore
  138226. * The horizontal blur PostProcess id in the pipeline
  138227. */
  138228. SSAOBlurHRenderEffect: string;
  138229. /**
  138230. * @ignore
  138231. * The vertical blur PostProcess id in the pipeline
  138232. */
  138233. SSAOBlurVRenderEffect: string;
  138234. /**
  138235. * @ignore
  138236. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138237. */
  138238. SSAOCombineRenderEffect: string;
  138239. /**
  138240. * The output strength of the SSAO post-process. Default value is 1.0.
  138241. */
  138242. totalStrength: number;
  138243. /**
  138244. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138245. */
  138246. radius: number;
  138247. /**
  138248. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138249. * Must not be equal to fallOff and superior to fallOff.
  138250. * Default value is 0.0075
  138251. */
  138252. area: number;
  138253. /**
  138254. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138255. * Must not be equal to area and inferior to area.
  138256. * Default value is 0.000001
  138257. */
  138258. fallOff: number;
  138259. /**
  138260. * The base color of the SSAO post-process
  138261. * The final result is "base + ssao" between [0, 1]
  138262. */
  138263. base: number;
  138264. private _scene;
  138265. private _depthTexture;
  138266. private _randomTexture;
  138267. private _originalColorPostProcess;
  138268. private _ssaoPostProcess;
  138269. private _blurHPostProcess;
  138270. private _blurVPostProcess;
  138271. private _ssaoCombinePostProcess;
  138272. private _firstUpdate;
  138273. /**
  138274. * Gets active scene
  138275. */
  138276. get scene(): Scene;
  138277. /**
  138278. * @constructor
  138279. * @param name - The rendering pipeline name
  138280. * @param scene - The scene linked to this pipeline
  138281. * @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 }
  138282. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138283. */
  138284. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138285. /**
  138286. * Get the class name
  138287. * @returns "SSAORenderingPipeline"
  138288. */
  138289. getClassName(): string;
  138290. /**
  138291. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138292. */
  138293. dispose(disableDepthRender?: boolean): void;
  138294. private _createBlurPostProcess;
  138295. /** @hidden */
  138296. _rebuild(): void;
  138297. private _createSSAOPostProcess;
  138298. private _createSSAOCombinePostProcess;
  138299. private _createRandomTexture;
  138300. }
  138301. }
  138302. declare module BABYLON {
  138303. /** @hidden */
  138304. export var screenSpaceReflectionPixelShader: {
  138305. name: string;
  138306. shader: string;
  138307. };
  138308. }
  138309. declare module BABYLON {
  138310. /**
  138311. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  138312. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  138313. */
  138314. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  138315. /**
  138316. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  138317. */
  138318. threshold: number;
  138319. /**
  138320. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  138321. */
  138322. strength: number;
  138323. /**
  138324. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  138325. */
  138326. reflectionSpecularFalloffExponent: number;
  138327. /**
  138328. * 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]
  138329. */
  138330. step: number;
  138331. /**
  138332. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  138333. */
  138334. roughnessFactor: number;
  138335. private _geometryBufferRenderer;
  138336. private _enableSmoothReflections;
  138337. private _reflectionSamples;
  138338. private _smoothSteps;
  138339. /**
  138340. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  138341. * @param name The name of the effect.
  138342. * @param scene The scene containing the objects to calculate reflections.
  138343. * @param options The required width/height ratio to downsize to before computing the render pass.
  138344. * @param camera The camera to apply the render pass to.
  138345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138346. * @param engine The engine which the post process will be applied. (default: current engine)
  138347. * @param reusable If the post process can be reused on the same frame. (default: false)
  138348. * @param textureType Type of textures used when performing the post process. (default: 0)
  138349. * @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)
  138350. */
  138351. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138352. /**
  138353. * Gets wether or not smoothing reflections is enabled.
  138354. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138355. */
  138356. get enableSmoothReflections(): boolean;
  138357. /**
  138358. * Sets wether or not smoothing reflections is enabled.
  138359. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138360. */
  138361. set enableSmoothReflections(enabled: boolean);
  138362. /**
  138363. * Gets the number of samples taken while computing reflections. More samples count is high,
  138364. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138365. */
  138366. get reflectionSamples(): number;
  138367. /**
  138368. * Sets the number of samples taken while computing reflections. More samples count is high,
  138369. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138370. */
  138371. set reflectionSamples(samples: number);
  138372. /**
  138373. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  138374. * more the post-process will require GPU power and can generate a drop in FPS.
  138375. * Default value (5.0) work pretty well in all cases but can be adjusted.
  138376. */
  138377. get smoothSteps(): number;
  138378. set smoothSteps(steps: number);
  138379. private _updateEffectDefines;
  138380. }
  138381. }
  138382. declare module BABYLON {
  138383. /** @hidden */
  138384. export var standardPixelShader: {
  138385. name: string;
  138386. shader: string;
  138387. };
  138388. }
  138389. declare module BABYLON {
  138390. /**
  138391. * Standard rendering pipeline
  138392. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138393. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  138394. */
  138395. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138396. /**
  138397. * Public members
  138398. */
  138399. /**
  138400. * Post-process which contains the original scene color before the pipeline applies all the effects
  138401. */
  138402. originalPostProcess: Nullable<PostProcess>;
  138403. /**
  138404. * Post-process used to down scale an image x4
  138405. */
  138406. downSampleX4PostProcess: Nullable<PostProcess>;
  138407. /**
  138408. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  138409. */
  138410. brightPassPostProcess: Nullable<PostProcess>;
  138411. /**
  138412. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  138413. */
  138414. blurHPostProcesses: PostProcess[];
  138415. /**
  138416. * Post-process array storing all the vertical blur post-processes used by the pipeline
  138417. */
  138418. blurVPostProcesses: PostProcess[];
  138419. /**
  138420. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  138421. */
  138422. textureAdderPostProcess: Nullable<PostProcess>;
  138423. /**
  138424. * Post-process used to create volumetric lighting effect
  138425. */
  138426. volumetricLightPostProcess: Nullable<PostProcess>;
  138427. /**
  138428. * Post-process used to smooth the previous volumetric light post-process on the X axis
  138429. */
  138430. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  138431. /**
  138432. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  138433. */
  138434. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  138435. /**
  138436. * Post-process used to merge the volumetric light effect and the real scene color
  138437. */
  138438. volumetricLightMergePostProces: Nullable<PostProcess>;
  138439. /**
  138440. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  138441. */
  138442. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  138443. /**
  138444. * Base post-process used to calculate the average luminance of the final image for HDR
  138445. */
  138446. luminancePostProcess: Nullable<PostProcess>;
  138447. /**
  138448. * Post-processes used to create down sample post-processes in order to get
  138449. * the average luminance of the final image for HDR
  138450. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  138451. */
  138452. luminanceDownSamplePostProcesses: PostProcess[];
  138453. /**
  138454. * Post-process used to create a HDR effect (light adaptation)
  138455. */
  138456. hdrPostProcess: Nullable<PostProcess>;
  138457. /**
  138458. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  138459. */
  138460. textureAdderFinalPostProcess: Nullable<PostProcess>;
  138461. /**
  138462. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  138463. */
  138464. lensFlareFinalPostProcess: Nullable<PostProcess>;
  138465. /**
  138466. * Post-process used to merge the final HDR post-process and the real scene color
  138467. */
  138468. hdrFinalPostProcess: Nullable<PostProcess>;
  138469. /**
  138470. * Post-process used to create a lens flare effect
  138471. */
  138472. lensFlarePostProcess: Nullable<PostProcess>;
  138473. /**
  138474. * Post-process that merges the result of the lens flare post-process and the real scene color
  138475. */
  138476. lensFlareComposePostProcess: Nullable<PostProcess>;
  138477. /**
  138478. * Post-process used to create a motion blur effect
  138479. */
  138480. motionBlurPostProcess: Nullable<PostProcess>;
  138481. /**
  138482. * Post-process used to create a depth of field effect
  138483. */
  138484. depthOfFieldPostProcess: Nullable<PostProcess>;
  138485. /**
  138486. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138487. */
  138488. fxaaPostProcess: Nullable<FxaaPostProcess>;
  138489. /**
  138490. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  138491. */
  138492. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  138493. /**
  138494. * Represents the brightness threshold in order to configure the illuminated surfaces
  138495. */
  138496. brightThreshold: number;
  138497. /**
  138498. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  138499. */
  138500. blurWidth: number;
  138501. /**
  138502. * Sets if the blur for highlighted surfaces must be only horizontal
  138503. */
  138504. horizontalBlur: boolean;
  138505. /**
  138506. * Gets the overall exposure used by the pipeline
  138507. */
  138508. get exposure(): number;
  138509. /**
  138510. * Sets the overall exposure used by the pipeline
  138511. */
  138512. set exposure(value: number);
  138513. /**
  138514. * Texture used typically to simulate "dirty" on camera lens
  138515. */
  138516. lensTexture: Nullable<Texture>;
  138517. /**
  138518. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  138519. */
  138520. volumetricLightCoefficient: number;
  138521. /**
  138522. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  138523. */
  138524. volumetricLightPower: number;
  138525. /**
  138526. * Used the set the blur intensity to smooth the volumetric lights
  138527. */
  138528. volumetricLightBlurScale: number;
  138529. /**
  138530. * Light (spot or directional) used to generate the volumetric lights rays
  138531. * The source light must have a shadow generate so the pipeline can get its
  138532. * depth map
  138533. */
  138534. sourceLight: Nullable<SpotLight | DirectionalLight>;
  138535. /**
  138536. * For eye adaptation, represents the minimum luminance the eye can see
  138537. */
  138538. hdrMinimumLuminance: number;
  138539. /**
  138540. * For eye adaptation, represents the decrease luminance speed
  138541. */
  138542. hdrDecreaseRate: number;
  138543. /**
  138544. * For eye adaptation, represents the increase luminance speed
  138545. */
  138546. hdrIncreaseRate: number;
  138547. /**
  138548. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138549. */
  138550. get hdrAutoExposure(): boolean;
  138551. /**
  138552. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138553. */
  138554. set hdrAutoExposure(value: boolean);
  138555. /**
  138556. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  138557. */
  138558. lensColorTexture: Nullable<Texture>;
  138559. /**
  138560. * The overall strengh for the lens flare effect
  138561. */
  138562. lensFlareStrength: number;
  138563. /**
  138564. * Dispersion coefficient for lens flare ghosts
  138565. */
  138566. lensFlareGhostDispersal: number;
  138567. /**
  138568. * Main lens flare halo width
  138569. */
  138570. lensFlareHaloWidth: number;
  138571. /**
  138572. * Based on the lens distortion effect, defines how much the lens flare result
  138573. * is distorted
  138574. */
  138575. lensFlareDistortionStrength: number;
  138576. /**
  138577. * Configures the blur intensity used for for lens flare (halo)
  138578. */
  138579. lensFlareBlurWidth: number;
  138580. /**
  138581. * Lens star texture must be used to simulate rays on the flares and is available
  138582. * in the documentation
  138583. */
  138584. lensStarTexture: Nullable<Texture>;
  138585. /**
  138586. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  138587. * flare effect by taking account of the dirt texture
  138588. */
  138589. lensFlareDirtTexture: Nullable<Texture>;
  138590. /**
  138591. * Represents the focal length for the depth of field effect
  138592. */
  138593. depthOfFieldDistance: number;
  138594. /**
  138595. * Represents the blur intensity for the blurred part of the depth of field effect
  138596. */
  138597. depthOfFieldBlurWidth: number;
  138598. /**
  138599. * Gets how much the image is blurred by the movement while using the motion blur post-process
  138600. */
  138601. get motionStrength(): number;
  138602. /**
  138603. * Sets how much the image is blurred by the movement while using the motion blur post-process
  138604. */
  138605. set motionStrength(strength: number);
  138606. /**
  138607. * Gets wether or not the motion blur post-process is object based or screen based.
  138608. */
  138609. get objectBasedMotionBlur(): boolean;
  138610. /**
  138611. * Sets wether or not the motion blur post-process should be object based or screen based
  138612. */
  138613. set objectBasedMotionBlur(value: boolean);
  138614. /**
  138615. * List of animations for the pipeline (IAnimatable implementation)
  138616. */
  138617. animations: Animation[];
  138618. /**
  138619. * Private members
  138620. */
  138621. private _scene;
  138622. private _currentDepthOfFieldSource;
  138623. private _basePostProcess;
  138624. private _fixedExposure;
  138625. private _currentExposure;
  138626. private _hdrAutoExposure;
  138627. private _hdrCurrentLuminance;
  138628. private _motionStrength;
  138629. private _isObjectBasedMotionBlur;
  138630. private _floatTextureType;
  138631. private _camerasToBeAttached;
  138632. private _ratio;
  138633. private _bloomEnabled;
  138634. private _depthOfFieldEnabled;
  138635. private _vlsEnabled;
  138636. private _lensFlareEnabled;
  138637. private _hdrEnabled;
  138638. private _motionBlurEnabled;
  138639. private _fxaaEnabled;
  138640. private _screenSpaceReflectionsEnabled;
  138641. private _motionBlurSamples;
  138642. private _volumetricLightStepsCount;
  138643. private _samples;
  138644. /**
  138645. * @ignore
  138646. * Specifies if the bloom pipeline is enabled
  138647. */
  138648. get BloomEnabled(): boolean;
  138649. set BloomEnabled(enabled: boolean);
  138650. /**
  138651. * @ignore
  138652. * Specifies if the depth of field pipeline is enabed
  138653. */
  138654. get DepthOfFieldEnabled(): boolean;
  138655. set DepthOfFieldEnabled(enabled: boolean);
  138656. /**
  138657. * @ignore
  138658. * Specifies if the lens flare pipeline is enabed
  138659. */
  138660. get LensFlareEnabled(): boolean;
  138661. set LensFlareEnabled(enabled: boolean);
  138662. /**
  138663. * @ignore
  138664. * Specifies if the HDR pipeline is enabled
  138665. */
  138666. get HDREnabled(): boolean;
  138667. set HDREnabled(enabled: boolean);
  138668. /**
  138669. * @ignore
  138670. * Specifies if the volumetric lights scattering effect is enabled
  138671. */
  138672. get VLSEnabled(): boolean;
  138673. set VLSEnabled(enabled: boolean);
  138674. /**
  138675. * @ignore
  138676. * Specifies if the motion blur effect is enabled
  138677. */
  138678. get MotionBlurEnabled(): boolean;
  138679. set MotionBlurEnabled(enabled: boolean);
  138680. /**
  138681. * Specifies if anti-aliasing is enabled
  138682. */
  138683. get fxaaEnabled(): boolean;
  138684. set fxaaEnabled(enabled: boolean);
  138685. /**
  138686. * Specifies if screen space reflections are enabled.
  138687. */
  138688. get screenSpaceReflectionsEnabled(): boolean;
  138689. set screenSpaceReflectionsEnabled(enabled: boolean);
  138690. /**
  138691. * Specifies the number of steps used to calculate the volumetric lights
  138692. * Typically in interval [50, 200]
  138693. */
  138694. get volumetricLightStepsCount(): number;
  138695. set volumetricLightStepsCount(count: number);
  138696. /**
  138697. * Specifies the number of samples used for the motion blur effect
  138698. * Typically in interval [16, 64]
  138699. */
  138700. get motionBlurSamples(): number;
  138701. set motionBlurSamples(samples: number);
  138702. /**
  138703. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138704. */
  138705. get samples(): number;
  138706. set samples(sampleCount: number);
  138707. /**
  138708. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138709. * @constructor
  138710. * @param name The rendering pipeline name
  138711. * @param scene The scene linked to this pipeline
  138712. * @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)
  138713. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  138714. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138715. */
  138716. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  138717. private _buildPipeline;
  138718. private _createDownSampleX4PostProcess;
  138719. private _createBrightPassPostProcess;
  138720. private _createBlurPostProcesses;
  138721. private _createTextureAdderPostProcess;
  138722. private _createVolumetricLightPostProcess;
  138723. private _createLuminancePostProcesses;
  138724. private _createHdrPostProcess;
  138725. private _createLensFlarePostProcess;
  138726. private _createDepthOfFieldPostProcess;
  138727. private _createMotionBlurPostProcess;
  138728. private _getDepthTexture;
  138729. private _disposePostProcesses;
  138730. /**
  138731. * Dispose of the pipeline and stop all post processes
  138732. */
  138733. dispose(): void;
  138734. /**
  138735. * Serialize the rendering pipeline (Used when exporting)
  138736. * @returns the serialized object
  138737. */
  138738. serialize(): any;
  138739. /**
  138740. * Parse the serialized pipeline
  138741. * @param source Source pipeline.
  138742. * @param scene The scene to load the pipeline to.
  138743. * @param rootUrl The URL of the serialized pipeline.
  138744. * @returns An instantiated pipeline from the serialized object.
  138745. */
  138746. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  138747. /**
  138748. * Luminance steps
  138749. */
  138750. static LuminanceSteps: number;
  138751. }
  138752. }
  138753. declare module BABYLON {
  138754. /** @hidden */
  138755. export var tonemapPixelShader: {
  138756. name: string;
  138757. shader: string;
  138758. };
  138759. }
  138760. declare module BABYLON {
  138761. /** Defines operator used for tonemapping */
  138762. export enum TonemappingOperator {
  138763. /** Hable */
  138764. Hable = 0,
  138765. /** Reinhard */
  138766. Reinhard = 1,
  138767. /** HejiDawson */
  138768. HejiDawson = 2,
  138769. /** Photographic */
  138770. Photographic = 3
  138771. }
  138772. /**
  138773. * Defines a post process to apply tone mapping
  138774. */
  138775. export class TonemapPostProcess extends PostProcess {
  138776. private _operator;
  138777. /** Defines the required exposure adjustement */
  138778. exposureAdjustment: number;
  138779. /**
  138780. * Creates a new TonemapPostProcess
  138781. * @param name defines the name of the postprocess
  138782. * @param _operator defines the operator to use
  138783. * @param exposureAdjustment defines the required exposure adjustement
  138784. * @param camera defines the camera to use (can be null)
  138785. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  138786. * @param engine defines the hosting engine (can be ignore if camera is set)
  138787. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138788. */
  138789. constructor(name: string, _operator: TonemappingOperator,
  138790. /** Defines the required exposure adjustement */
  138791. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  138792. }
  138793. }
  138794. declare module BABYLON {
  138795. /** @hidden */
  138796. export var volumetricLightScatteringPixelShader: {
  138797. name: string;
  138798. shader: string;
  138799. };
  138800. }
  138801. declare module BABYLON {
  138802. /** @hidden */
  138803. export var volumetricLightScatteringPassVertexShader: {
  138804. name: string;
  138805. shader: string;
  138806. };
  138807. }
  138808. declare module BABYLON {
  138809. /** @hidden */
  138810. export var volumetricLightScatteringPassPixelShader: {
  138811. name: string;
  138812. shader: string;
  138813. };
  138814. }
  138815. declare module BABYLON {
  138816. /**
  138817. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  138818. */
  138819. export class VolumetricLightScatteringPostProcess extends PostProcess {
  138820. private _volumetricLightScatteringPass;
  138821. private _volumetricLightScatteringRTT;
  138822. private _viewPort;
  138823. private _screenCoordinates;
  138824. private _cachedDefines;
  138825. /**
  138826. * If not undefined, the mesh position is computed from the attached node position
  138827. */
  138828. attachedNode: {
  138829. position: Vector3;
  138830. };
  138831. /**
  138832. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  138833. */
  138834. customMeshPosition: Vector3;
  138835. /**
  138836. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  138837. */
  138838. useCustomMeshPosition: boolean;
  138839. /**
  138840. * If the post-process should inverse the light scattering direction
  138841. */
  138842. invert: boolean;
  138843. /**
  138844. * The internal mesh used by the post-process
  138845. */
  138846. mesh: Mesh;
  138847. /**
  138848. * @hidden
  138849. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  138850. */
  138851. get useDiffuseColor(): boolean;
  138852. set useDiffuseColor(useDiffuseColor: boolean);
  138853. /**
  138854. * Array containing the excluded meshes not rendered in the internal pass
  138855. */
  138856. excludedMeshes: AbstractMesh[];
  138857. /**
  138858. * Controls the overall intensity of the post-process
  138859. */
  138860. exposure: number;
  138861. /**
  138862. * Dissipates each sample's contribution in range [0, 1]
  138863. */
  138864. decay: number;
  138865. /**
  138866. * Controls the overall intensity of each sample
  138867. */
  138868. weight: number;
  138869. /**
  138870. * Controls the density of each sample
  138871. */
  138872. density: number;
  138873. /**
  138874. * @constructor
  138875. * @param name The post-process name
  138876. * @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)
  138877. * @param camera The camera that the post-process will be attached to
  138878. * @param mesh The mesh used to create the light scattering
  138879. * @param samples The post-process quality, default 100
  138880. * @param samplingModeThe post-process filtering mode
  138881. * @param engine The babylon engine
  138882. * @param reusable If the post-process is reusable
  138883. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  138884. */
  138885. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  138886. /**
  138887. * Returns the string "VolumetricLightScatteringPostProcess"
  138888. * @returns "VolumetricLightScatteringPostProcess"
  138889. */
  138890. getClassName(): string;
  138891. private _isReady;
  138892. /**
  138893. * Sets the new light position for light scattering effect
  138894. * @param position The new custom light position
  138895. */
  138896. setCustomMeshPosition(position: Vector3): void;
  138897. /**
  138898. * Returns the light position for light scattering effect
  138899. * @return Vector3 The custom light position
  138900. */
  138901. getCustomMeshPosition(): Vector3;
  138902. /**
  138903. * Disposes the internal assets and detaches the post-process from the camera
  138904. */
  138905. dispose(camera: Camera): void;
  138906. /**
  138907. * Returns the render target texture used by the post-process
  138908. * @return the render target texture used by the post-process
  138909. */
  138910. getPass(): RenderTargetTexture;
  138911. private _meshExcluded;
  138912. private _createPass;
  138913. private _updateMeshScreenCoordinates;
  138914. /**
  138915. * Creates a default mesh for the Volumeric Light Scattering post-process
  138916. * @param name The mesh name
  138917. * @param scene The scene where to create the mesh
  138918. * @return the default mesh
  138919. */
  138920. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  138921. }
  138922. }
  138923. declare module BABYLON {
  138924. interface Scene {
  138925. /** @hidden (Backing field) */
  138926. _boundingBoxRenderer: BoundingBoxRenderer;
  138927. /** @hidden (Backing field) */
  138928. _forceShowBoundingBoxes: boolean;
  138929. /**
  138930. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  138931. */
  138932. forceShowBoundingBoxes: boolean;
  138933. /**
  138934. * Gets the bounding box renderer associated with the scene
  138935. * @returns a BoundingBoxRenderer
  138936. */
  138937. getBoundingBoxRenderer(): BoundingBoxRenderer;
  138938. }
  138939. interface AbstractMesh {
  138940. /** @hidden (Backing field) */
  138941. _showBoundingBox: boolean;
  138942. /**
  138943. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  138944. */
  138945. showBoundingBox: boolean;
  138946. }
  138947. /**
  138948. * Component responsible of rendering the bounding box of the meshes in a scene.
  138949. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  138950. */
  138951. export class BoundingBoxRenderer implements ISceneComponent {
  138952. /**
  138953. * The component name helpfull to identify the component in the list of scene components.
  138954. */
  138955. readonly name: string;
  138956. /**
  138957. * The scene the component belongs to.
  138958. */
  138959. scene: Scene;
  138960. /**
  138961. * Color of the bounding box lines placed in front of an object
  138962. */
  138963. frontColor: Color3;
  138964. /**
  138965. * Color of the bounding box lines placed behind an object
  138966. */
  138967. backColor: Color3;
  138968. /**
  138969. * Defines if the renderer should show the back lines or not
  138970. */
  138971. showBackLines: boolean;
  138972. /**
  138973. * @hidden
  138974. */
  138975. renderList: SmartArray<BoundingBox>;
  138976. private _colorShader;
  138977. private _vertexBuffers;
  138978. private _indexBuffer;
  138979. private _fillIndexBuffer;
  138980. private _fillIndexData;
  138981. /**
  138982. * Instantiates a new bounding box renderer in a scene.
  138983. * @param scene the scene the renderer renders in
  138984. */
  138985. constructor(scene: Scene);
  138986. /**
  138987. * Registers the component in a given scene
  138988. */
  138989. register(): void;
  138990. private _evaluateSubMesh;
  138991. private _activeMesh;
  138992. private _prepareRessources;
  138993. private _createIndexBuffer;
  138994. /**
  138995. * Rebuilds the elements related to this component in case of
  138996. * context lost for instance.
  138997. */
  138998. rebuild(): void;
  138999. /**
  139000. * @hidden
  139001. */
  139002. reset(): void;
  139003. /**
  139004. * Render the bounding boxes of a specific rendering group
  139005. * @param renderingGroupId defines the rendering group to render
  139006. */
  139007. render(renderingGroupId: number): void;
  139008. /**
  139009. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139010. * @param mesh Define the mesh to render the occlusion bounding box for
  139011. */
  139012. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139013. /**
  139014. * Dispose and release the resources attached to this renderer.
  139015. */
  139016. dispose(): void;
  139017. }
  139018. }
  139019. declare module BABYLON {
  139020. interface Scene {
  139021. /** @hidden (Backing field) */
  139022. _depthRenderer: {
  139023. [id: string]: DepthRenderer;
  139024. };
  139025. /**
  139026. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139027. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139028. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139029. * @returns the created depth renderer
  139030. */
  139031. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139032. /**
  139033. * Disables a depth renderer for a given camera
  139034. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139035. */
  139036. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139037. }
  139038. /**
  139039. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139040. * in several rendering techniques.
  139041. */
  139042. export class DepthRendererSceneComponent implements ISceneComponent {
  139043. /**
  139044. * The component name helpfull to identify the component in the list of scene components.
  139045. */
  139046. readonly name: string;
  139047. /**
  139048. * The scene the component belongs to.
  139049. */
  139050. scene: Scene;
  139051. /**
  139052. * Creates a new instance of the component for the given scene
  139053. * @param scene Defines the scene to register the component in
  139054. */
  139055. constructor(scene: Scene);
  139056. /**
  139057. * Registers the component in a given scene
  139058. */
  139059. register(): void;
  139060. /**
  139061. * Rebuilds the elements related to this component in case of
  139062. * context lost for instance.
  139063. */
  139064. rebuild(): void;
  139065. /**
  139066. * Disposes the component and the associated ressources
  139067. */
  139068. dispose(): void;
  139069. private _gatherRenderTargets;
  139070. private _gatherActiveCameraRenderTargets;
  139071. }
  139072. }
  139073. declare module BABYLON {
  139074. /** @hidden */
  139075. export var outlinePixelShader: {
  139076. name: string;
  139077. shader: string;
  139078. };
  139079. }
  139080. declare module BABYLON {
  139081. /** @hidden */
  139082. export var outlineVertexShader: {
  139083. name: string;
  139084. shader: string;
  139085. };
  139086. }
  139087. declare module BABYLON {
  139088. interface Scene {
  139089. /** @hidden */
  139090. _outlineRenderer: OutlineRenderer;
  139091. /**
  139092. * Gets the outline renderer associated with the scene
  139093. * @returns a OutlineRenderer
  139094. */
  139095. getOutlineRenderer(): OutlineRenderer;
  139096. }
  139097. interface AbstractMesh {
  139098. /** @hidden (Backing field) */
  139099. _renderOutline: boolean;
  139100. /**
  139101. * Gets or sets a boolean indicating if the outline must be rendered as well
  139102. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139103. */
  139104. renderOutline: boolean;
  139105. /** @hidden (Backing field) */
  139106. _renderOverlay: boolean;
  139107. /**
  139108. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139109. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139110. */
  139111. renderOverlay: boolean;
  139112. }
  139113. /**
  139114. * This class is responsible to draw bothe outline/overlay of meshes.
  139115. * It should not be used directly but through the available method on mesh.
  139116. */
  139117. export class OutlineRenderer implements ISceneComponent {
  139118. /**
  139119. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139120. */
  139121. private static _StencilReference;
  139122. /**
  139123. * The name of the component. Each component must have a unique name.
  139124. */
  139125. name: string;
  139126. /**
  139127. * The scene the component belongs to.
  139128. */
  139129. scene: Scene;
  139130. /**
  139131. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139132. */
  139133. zOffset: number;
  139134. private _engine;
  139135. private _effect;
  139136. private _cachedDefines;
  139137. private _savedDepthWrite;
  139138. /**
  139139. * Instantiates a new outline renderer. (There could be only one per scene).
  139140. * @param scene Defines the scene it belongs to
  139141. */
  139142. constructor(scene: Scene);
  139143. /**
  139144. * Register the component to one instance of a scene.
  139145. */
  139146. register(): void;
  139147. /**
  139148. * Rebuilds the elements related to this component in case of
  139149. * context lost for instance.
  139150. */
  139151. rebuild(): void;
  139152. /**
  139153. * Disposes the component and the associated ressources.
  139154. */
  139155. dispose(): void;
  139156. /**
  139157. * Renders the outline in the canvas.
  139158. * @param subMesh Defines the sumesh to render
  139159. * @param batch Defines the batch of meshes in case of instances
  139160. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139161. */
  139162. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139163. /**
  139164. * Returns whether or not the outline renderer is ready for a given submesh.
  139165. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139166. * @param subMesh Defines the submesh to check readyness for
  139167. * @param useInstances Defines wheter wee are trying to render instances or not
  139168. * @returns true if ready otherwise false
  139169. */
  139170. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139171. private _beforeRenderingMesh;
  139172. private _afterRenderingMesh;
  139173. }
  139174. }
  139175. declare module BABYLON {
  139176. /**
  139177. * Defines the basic options interface of a Sprite Frame Source Size.
  139178. */
  139179. export interface ISpriteJSONSpriteSourceSize {
  139180. /**
  139181. * number of the original width of the Frame
  139182. */
  139183. w: number;
  139184. /**
  139185. * number of the original height of the Frame
  139186. */
  139187. h: number;
  139188. }
  139189. /**
  139190. * Defines the basic options interface of a Sprite Frame Data.
  139191. */
  139192. export interface ISpriteJSONSpriteFrameData {
  139193. /**
  139194. * number of the x offset of the Frame
  139195. */
  139196. x: number;
  139197. /**
  139198. * number of the y offset of the Frame
  139199. */
  139200. y: number;
  139201. /**
  139202. * number of the width of the Frame
  139203. */
  139204. w: number;
  139205. /**
  139206. * number of the height of the Frame
  139207. */
  139208. h: number;
  139209. }
  139210. /**
  139211. * Defines the basic options interface of a JSON Sprite.
  139212. */
  139213. export interface ISpriteJSONSprite {
  139214. /**
  139215. * string name of the Frame
  139216. */
  139217. filename: string;
  139218. /**
  139219. * ISpriteJSONSpriteFrame basic object of the frame data
  139220. */
  139221. frame: ISpriteJSONSpriteFrameData;
  139222. /**
  139223. * boolean to flag is the frame was rotated.
  139224. */
  139225. rotated: boolean;
  139226. /**
  139227. * boolean to flag is the frame was trimmed.
  139228. */
  139229. trimmed: boolean;
  139230. /**
  139231. * ISpriteJSONSpriteFrame basic object of the source data
  139232. */
  139233. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139234. /**
  139235. * ISpriteJSONSpriteFrame basic object of the source data
  139236. */
  139237. sourceSize: ISpriteJSONSpriteSourceSize;
  139238. }
  139239. /**
  139240. * Defines the basic options interface of a JSON atlas.
  139241. */
  139242. export interface ISpriteJSONAtlas {
  139243. /**
  139244. * Array of objects that contain the frame data.
  139245. */
  139246. frames: Array<ISpriteJSONSprite>;
  139247. /**
  139248. * object basic object containing the sprite meta data.
  139249. */
  139250. meta?: object;
  139251. }
  139252. }
  139253. declare module BABYLON {
  139254. /** @hidden */
  139255. export var spriteMapPixelShader: {
  139256. name: string;
  139257. shader: string;
  139258. };
  139259. }
  139260. declare module BABYLON {
  139261. /** @hidden */
  139262. export var spriteMapVertexShader: {
  139263. name: string;
  139264. shader: string;
  139265. };
  139266. }
  139267. declare module BABYLON {
  139268. /**
  139269. * Defines the basic options interface of a SpriteMap
  139270. */
  139271. export interface ISpriteMapOptions {
  139272. /**
  139273. * Vector2 of the number of cells in the grid.
  139274. */
  139275. stageSize?: Vector2;
  139276. /**
  139277. * Vector2 of the size of the output plane in World Units.
  139278. */
  139279. outputSize?: Vector2;
  139280. /**
  139281. * Vector3 of the position of the output plane in World Units.
  139282. */
  139283. outputPosition?: Vector3;
  139284. /**
  139285. * Vector3 of the rotation of the output plane.
  139286. */
  139287. outputRotation?: Vector3;
  139288. /**
  139289. * number of layers that the system will reserve in resources.
  139290. */
  139291. layerCount?: number;
  139292. /**
  139293. * number of max animation frames a single cell will reserve in resources.
  139294. */
  139295. maxAnimationFrames?: number;
  139296. /**
  139297. * number cell index of the base tile when the system compiles.
  139298. */
  139299. baseTile?: number;
  139300. /**
  139301. * boolean flip the sprite after its been repositioned by the framing data.
  139302. */
  139303. flipU?: boolean;
  139304. /**
  139305. * Vector3 scalar of the global RGB values of the SpriteMap.
  139306. */
  139307. colorMultiply?: Vector3;
  139308. }
  139309. /**
  139310. * Defines the IDisposable interface in order to be cleanable from resources.
  139311. */
  139312. export interface ISpriteMap extends IDisposable {
  139313. /**
  139314. * String name of the SpriteMap.
  139315. */
  139316. name: string;
  139317. /**
  139318. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139319. */
  139320. atlasJSON: ISpriteJSONAtlas;
  139321. /**
  139322. * Texture of the SpriteMap.
  139323. */
  139324. spriteSheet: Texture;
  139325. /**
  139326. * The parameters to initialize the SpriteMap with.
  139327. */
  139328. options: ISpriteMapOptions;
  139329. }
  139330. /**
  139331. * Class used to manage a grid restricted sprite deployment on an Output plane.
  139332. */
  139333. export class SpriteMap implements ISpriteMap {
  139334. /** The Name of the spriteMap */
  139335. name: string;
  139336. /** The JSON file with the frame and meta data */
  139337. atlasJSON: ISpriteJSONAtlas;
  139338. /** The systems Sprite Sheet Texture */
  139339. spriteSheet: Texture;
  139340. /** Arguments passed with the Constructor */
  139341. options: ISpriteMapOptions;
  139342. /** Public Sprite Storage array, parsed from atlasJSON */
  139343. sprites: Array<ISpriteJSONSprite>;
  139344. /** Returns the Number of Sprites in the System */
  139345. get spriteCount(): number;
  139346. /** Returns the Position of Output Plane*/
  139347. get position(): Vector3;
  139348. /** Returns the Position of Output Plane*/
  139349. set position(v: Vector3);
  139350. /** Returns the Rotation of Output Plane*/
  139351. get rotation(): Vector3;
  139352. /** Returns the Rotation of Output Plane*/
  139353. set rotation(v: Vector3);
  139354. /** Sets the AnimationMap*/
  139355. get animationMap(): RawTexture;
  139356. /** Sets the AnimationMap*/
  139357. set animationMap(v: RawTexture);
  139358. /** Scene that the SpriteMap was created in */
  139359. private _scene;
  139360. /** Texture Buffer of Float32 that holds tile frame data*/
  139361. private _frameMap;
  139362. /** Texture Buffers of Float32 that holds tileMap data*/
  139363. private _tileMaps;
  139364. /** Texture Buffer of Float32 that holds Animation Data*/
  139365. private _animationMap;
  139366. /** Custom ShaderMaterial Central to the System*/
  139367. private _material;
  139368. /** Custom ShaderMaterial Central to the System*/
  139369. private _output;
  139370. /** Systems Time Ticker*/
  139371. private _time;
  139372. /**
  139373. * Creates a new SpriteMap
  139374. * @param name defines the SpriteMaps Name
  139375. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  139376. * @param spriteSheet is the Texture that the Sprites are on.
  139377. * @param options a basic deployment configuration
  139378. * @param scene The Scene that the map is deployed on
  139379. */
  139380. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  139381. /**
  139382. * Returns tileID location
  139383. * @returns Vector2 the cell position ID
  139384. */
  139385. getTileID(): Vector2;
  139386. /**
  139387. * Gets the UV location of the mouse over the SpriteMap.
  139388. * @returns Vector2 the UV position of the mouse interaction
  139389. */
  139390. getMousePosition(): Vector2;
  139391. /**
  139392. * Creates the "frame" texture Buffer
  139393. * -------------------------------------
  139394. * Structure of frames
  139395. * "filename": "Falling-Water-2.png",
  139396. * "frame": {"x":69,"y":103,"w":24,"h":32},
  139397. * "rotated": true,
  139398. * "trimmed": true,
  139399. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  139400. * "sourceSize": {"w":32,"h":32}
  139401. * @returns RawTexture of the frameMap
  139402. */
  139403. private _createFrameBuffer;
  139404. /**
  139405. * Creates the tileMap texture Buffer
  139406. * @param buffer normally and array of numbers, or a false to generate from scratch
  139407. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  139408. * @returns RawTexture of the tileMap
  139409. */
  139410. private _createTileBuffer;
  139411. /**
  139412. * Modifies the data of the tileMaps
  139413. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  139414. * @param pos is the iVector2 Coordinates of the Tile
  139415. * @param tile The SpriteIndex of the new Tile
  139416. */
  139417. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  139418. /**
  139419. * Creates the animationMap texture Buffer
  139420. * @param buffer normally and array of numbers, or a false to generate from scratch
  139421. * @returns RawTexture of the animationMap
  139422. */
  139423. private _createTileAnimationBuffer;
  139424. /**
  139425. * Modifies the data of the animationMap
  139426. * @param cellID is the Index of the Sprite
  139427. * @param _frame is the target Animation frame
  139428. * @param toCell is the Target Index of the next frame of the animation
  139429. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  139430. * @param speed is a global scalar of the time variable on the map.
  139431. */
  139432. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  139433. /**
  139434. * Exports the .tilemaps file
  139435. */
  139436. saveTileMaps(): void;
  139437. /**
  139438. * Imports the .tilemaps file
  139439. * @param url of the .tilemaps file
  139440. */
  139441. loadTileMaps(url: string): void;
  139442. /**
  139443. * Release associated resources
  139444. */
  139445. dispose(): void;
  139446. }
  139447. }
  139448. declare module BABYLON {
  139449. /**
  139450. * Class used to manage multiple sprites of different sizes on the same spritesheet
  139451. * @see http://doc.babylonjs.com/babylon101/sprites
  139452. */
  139453. export class SpritePackedManager extends SpriteManager {
  139454. /** defines the packed manager's name */
  139455. name: string;
  139456. /**
  139457. * Creates a new sprite manager from a packed sprite sheet
  139458. * @param name defines the manager's name
  139459. * @param imgUrl defines the sprite sheet url
  139460. * @param capacity defines the maximum allowed number of sprites
  139461. * @param scene defines the hosting scene
  139462. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  139463. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  139464. * @param samplingMode defines the smapling mode to use with spritesheet
  139465. * @param fromPacked set to true; do not alter
  139466. */
  139467. constructor(
  139468. /** defines the packed manager's name */
  139469. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  139470. }
  139471. }
  139472. declare module BABYLON {
  139473. /**
  139474. * Defines the list of states available for a task inside a AssetsManager
  139475. */
  139476. export enum AssetTaskState {
  139477. /**
  139478. * Initialization
  139479. */
  139480. INIT = 0,
  139481. /**
  139482. * Running
  139483. */
  139484. RUNNING = 1,
  139485. /**
  139486. * Done
  139487. */
  139488. DONE = 2,
  139489. /**
  139490. * Error
  139491. */
  139492. ERROR = 3
  139493. }
  139494. /**
  139495. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  139496. */
  139497. export abstract class AbstractAssetTask {
  139498. /**
  139499. * Task name
  139500. */ name: string;
  139501. /**
  139502. * Callback called when the task is successful
  139503. */
  139504. onSuccess: (task: any) => void;
  139505. /**
  139506. * Callback called when the task is not successful
  139507. */
  139508. onError: (task: any, message?: string, exception?: any) => void;
  139509. /**
  139510. * Creates a new AssetsManager
  139511. * @param name defines the name of the task
  139512. */
  139513. constructor(
  139514. /**
  139515. * Task name
  139516. */ name: string);
  139517. private _isCompleted;
  139518. private _taskState;
  139519. private _errorObject;
  139520. /**
  139521. * Get if the task is completed
  139522. */
  139523. get isCompleted(): boolean;
  139524. /**
  139525. * Gets the current state of the task
  139526. */
  139527. get taskState(): AssetTaskState;
  139528. /**
  139529. * Gets the current error object (if task is in error)
  139530. */
  139531. get errorObject(): {
  139532. message?: string;
  139533. exception?: any;
  139534. };
  139535. /**
  139536. * Internal only
  139537. * @hidden
  139538. */
  139539. _setErrorObject(message?: string, exception?: any): void;
  139540. /**
  139541. * Execute the current task
  139542. * @param scene defines the scene where you want your assets to be loaded
  139543. * @param onSuccess is a callback called when the task is successfully executed
  139544. * @param onError is a callback called if an error occurs
  139545. */
  139546. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139547. /**
  139548. * Execute the current task
  139549. * @param scene defines the scene where you want your assets to be loaded
  139550. * @param onSuccess is a callback called when the task is successfully executed
  139551. * @param onError is a callback called if an error occurs
  139552. */
  139553. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139554. /**
  139555. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  139556. * This can be used with failed tasks that have the reason for failure fixed.
  139557. */
  139558. reset(): void;
  139559. private onErrorCallback;
  139560. private onDoneCallback;
  139561. }
  139562. /**
  139563. * Define the interface used by progress events raised during assets loading
  139564. */
  139565. export interface IAssetsProgressEvent {
  139566. /**
  139567. * Defines the number of remaining tasks to process
  139568. */
  139569. remainingCount: number;
  139570. /**
  139571. * Defines the total number of tasks
  139572. */
  139573. totalCount: number;
  139574. /**
  139575. * Defines the task that was just processed
  139576. */
  139577. task: AbstractAssetTask;
  139578. }
  139579. /**
  139580. * Class used to share progress information about assets loading
  139581. */
  139582. export class AssetsProgressEvent implements IAssetsProgressEvent {
  139583. /**
  139584. * Defines the number of remaining tasks to process
  139585. */
  139586. remainingCount: number;
  139587. /**
  139588. * Defines the total number of tasks
  139589. */
  139590. totalCount: number;
  139591. /**
  139592. * Defines the task that was just processed
  139593. */
  139594. task: AbstractAssetTask;
  139595. /**
  139596. * Creates a AssetsProgressEvent
  139597. * @param remainingCount defines the number of remaining tasks to process
  139598. * @param totalCount defines the total number of tasks
  139599. * @param task defines the task that was just processed
  139600. */
  139601. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  139602. }
  139603. /**
  139604. * Define a task used by AssetsManager to load meshes
  139605. */
  139606. export class MeshAssetTask extends AbstractAssetTask {
  139607. /**
  139608. * Defines the name of the task
  139609. */
  139610. name: string;
  139611. /**
  139612. * Defines the list of mesh's names you want to load
  139613. */
  139614. meshesNames: any;
  139615. /**
  139616. * Defines the root url to use as a base to load your meshes and associated resources
  139617. */
  139618. rootUrl: string;
  139619. /**
  139620. * Defines the filename of the scene to load from
  139621. */
  139622. sceneFilename: string;
  139623. /**
  139624. * Gets the list of loaded meshes
  139625. */
  139626. loadedMeshes: Array<AbstractMesh>;
  139627. /**
  139628. * Gets the list of loaded particle systems
  139629. */
  139630. loadedParticleSystems: Array<IParticleSystem>;
  139631. /**
  139632. * Gets the list of loaded skeletons
  139633. */
  139634. loadedSkeletons: Array<Skeleton>;
  139635. /**
  139636. * Gets the list of loaded animation groups
  139637. */
  139638. loadedAnimationGroups: Array<AnimationGroup>;
  139639. /**
  139640. * Callback called when the task is successful
  139641. */
  139642. onSuccess: (task: MeshAssetTask) => void;
  139643. /**
  139644. * Callback called when the task is successful
  139645. */
  139646. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  139647. /**
  139648. * Creates a new MeshAssetTask
  139649. * @param name defines the name of the task
  139650. * @param meshesNames defines the list of mesh's names you want to load
  139651. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  139652. * @param sceneFilename defines the filename of the scene to load from
  139653. */
  139654. constructor(
  139655. /**
  139656. * Defines the name of the task
  139657. */
  139658. name: string,
  139659. /**
  139660. * Defines the list of mesh's names you want to load
  139661. */
  139662. meshesNames: any,
  139663. /**
  139664. * Defines the root url to use as a base to load your meshes and associated resources
  139665. */
  139666. rootUrl: string,
  139667. /**
  139668. * Defines the filename of the scene to load from
  139669. */
  139670. sceneFilename: string);
  139671. /**
  139672. * Execute the current task
  139673. * @param scene defines the scene where you want your assets to be loaded
  139674. * @param onSuccess is a callback called when the task is successfully executed
  139675. * @param onError is a callback called if an error occurs
  139676. */
  139677. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139678. }
  139679. /**
  139680. * Define a task used by AssetsManager to load text content
  139681. */
  139682. export class TextFileAssetTask extends AbstractAssetTask {
  139683. /**
  139684. * Defines the name of the task
  139685. */
  139686. name: string;
  139687. /**
  139688. * Defines the location of the file to load
  139689. */
  139690. url: string;
  139691. /**
  139692. * Gets the loaded text string
  139693. */
  139694. text: string;
  139695. /**
  139696. * Callback called when the task is successful
  139697. */
  139698. onSuccess: (task: TextFileAssetTask) => void;
  139699. /**
  139700. * Callback called when the task is successful
  139701. */
  139702. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  139703. /**
  139704. * Creates a new TextFileAssetTask object
  139705. * @param name defines the name of the task
  139706. * @param url defines the location of the file to load
  139707. */
  139708. constructor(
  139709. /**
  139710. * Defines the name of the task
  139711. */
  139712. name: string,
  139713. /**
  139714. * Defines the location of the file to load
  139715. */
  139716. url: string);
  139717. /**
  139718. * Execute the current task
  139719. * @param scene defines the scene where you want your assets to be loaded
  139720. * @param onSuccess is a callback called when the task is successfully executed
  139721. * @param onError is a callback called if an error occurs
  139722. */
  139723. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139724. }
  139725. /**
  139726. * Define a task used by AssetsManager to load binary data
  139727. */
  139728. export class BinaryFileAssetTask extends AbstractAssetTask {
  139729. /**
  139730. * Defines the name of the task
  139731. */
  139732. name: string;
  139733. /**
  139734. * Defines the location of the file to load
  139735. */
  139736. url: string;
  139737. /**
  139738. * Gets the lodaded data (as an array buffer)
  139739. */
  139740. data: ArrayBuffer;
  139741. /**
  139742. * Callback called when the task is successful
  139743. */
  139744. onSuccess: (task: BinaryFileAssetTask) => void;
  139745. /**
  139746. * Callback called when the task is successful
  139747. */
  139748. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  139749. /**
  139750. * Creates a new BinaryFileAssetTask object
  139751. * @param name defines the name of the new task
  139752. * @param url defines the location of the file to load
  139753. */
  139754. constructor(
  139755. /**
  139756. * Defines the name of the task
  139757. */
  139758. name: string,
  139759. /**
  139760. * Defines the location of the file to load
  139761. */
  139762. url: string);
  139763. /**
  139764. * Execute the current task
  139765. * @param scene defines the scene where you want your assets to be loaded
  139766. * @param onSuccess is a callback called when the task is successfully executed
  139767. * @param onError is a callback called if an error occurs
  139768. */
  139769. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139770. }
  139771. /**
  139772. * Define a task used by AssetsManager to load images
  139773. */
  139774. export class ImageAssetTask extends AbstractAssetTask {
  139775. /**
  139776. * Defines the name of the task
  139777. */
  139778. name: string;
  139779. /**
  139780. * Defines the location of the image to load
  139781. */
  139782. url: string;
  139783. /**
  139784. * Gets the loaded images
  139785. */
  139786. image: HTMLImageElement;
  139787. /**
  139788. * Callback called when the task is successful
  139789. */
  139790. onSuccess: (task: ImageAssetTask) => void;
  139791. /**
  139792. * Callback called when the task is successful
  139793. */
  139794. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  139795. /**
  139796. * Creates a new ImageAssetTask
  139797. * @param name defines the name of the task
  139798. * @param url defines the location of the image to load
  139799. */
  139800. constructor(
  139801. /**
  139802. * Defines the name of the task
  139803. */
  139804. name: string,
  139805. /**
  139806. * Defines the location of the image to load
  139807. */
  139808. url: string);
  139809. /**
  139810. * Execute the current task
  139811. * @param scene defines the scene where you want your assets to be loaded
  139812. * @param onSuccess is a callback called when the task is successfully executed
  139813. * @param onError is a callback called if an error occurs
  139814. */
  139815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139816. }
  139817. /**
  139818. * Defines the interface used by texture loading tasks
  139819. */
  139820. export interface ITextureAssetTask<TEX extends BaseTexture> {
  139821. /**
  139822. * Gets the loaded texture
  139823. */
  139824. texture: TEX;
  139825. }
  139826. /**
  139827. * Define a task used by AssetsManager to load 2D textures
  139828. */
  139829. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  139830. /**
  139831. * Defines the name of the task
  139832. */
  139833. name: string;
  139834. /**
  139835. * Defines the location of the file to load
  139836. */
  139837. url: string;
  139838. /**
  139839. * Defines if mipmap should not be generated (default is false)
  139840. */
  139841. noMipmap?: boolean | undefined;
  139842. /**
  139843. * Defines if texture must be inverted on Y axis (default is false)
  139844. */
  139845. invertY?: boolean | undefined;
  139846. /**
  139847. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139848. */
  139849. samplingMode: number;
  139850. /**
  139851. * Gets the loaded texture
  139852. */
  139853. texture: Texture;
  139854. /**
  139855. * Callback called when the task is successful
  139856. */
  139857. onSuccess: (task: TextureAssetTask) => void;
  139858. /**
  139859. * Callback called when the task is successful
  139860. */
  139861. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  139862. /**
  139863. * Creates a new TextureAssetTask object
  139864. * @param name defines the name of the task
  139865. * @param url defines the location of the file to load
  139866. * @param noMipmap defines if mipmap should not be generated (default is false)
  139867. * @param invertY defines if texture must be inverted on Y axis (default is false)
  139868. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139869. */
  139870. constructor(
  139871. /**
  139872. * Defines the name of the task
  139873. */
  139874. name: string,
  139875. /**
  139876. * Defines the location of the file to load
  139877. */
  139878. url: string,
  139879. /**
  139880. * Defines if mipmap should not be generated (default is false)
  139881. */
  139882. noMipmap?: boolean | undefined,
  139883. /**
  139884. * Defines if texture must be inverted on Y axis (default is false)
  139885. */
  139886. invertY?: boolean | undefined,
  139887. /**
  139888. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139889. */
  139890. samplingMode?: number);
  139891. /**
  139892. * Execute the current task
  139893. * @param scene defines the scene where you want your assets to be loaded
  139894. * @param onSuccess is a callback called when the task is successfully executed
  139895. * @param onError is a callback called if an error occurs
  139896. */
  139897. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139898. }
  139899. /**
  139900. * Define a task used by AssetsManager to load cube textures
  139901. */
  139902. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  139903. /**
  139904. * Defines the name of the task
  139905. */
  139906. name: string;
  139907. /**
  139908. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139909. */
  139910. url: string;
  139911. /**
  139912. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139913. */
  139914. extensions?: string[] | undefined;
  139915. /**
  139916. * Defines if mipmaps should not be generated (default is false)
  139917. */
  139918. noMipmap?: boolean | undefined;
  139919. /**
  139920. * Defines the explicit list of files (undefined by default)
  139921. */
  139922. files?: string[] | undefined;
  139923. /**
  139924. * Gets the loaded texture
  139925. */
  139926. texture: CubeTexture;
  139927. /**
  139928. * Callback called when the task is successful
  139929. */
  139930. onSuccess: (task: CubeTextureAssetTask) => void;
  139931. /**
  139932. * Callback called when the task is successful
  139933. */
  139934. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  139935. /**
  139936. * Creates a new CubeTextureAssetTask
  139937. * @param name defines the name of the task
  139938. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139939. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139940. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139941. * @param files defines the explicit list of files (undefined by default)
  139942. */
  139943. constructor(
  139944. /**
  139945. * Defines the name of the task
  139946. */
  139947. name: string,
  139948. /**
  139949. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139950. */
  139951. url: string,
  139952. /**
  139953. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139954. */
  139955. extensions?: string[] | undefined,
  139956. /**
  139957. * Defines if mipmaps should not be generated (default is false)
  139958. */
  139959. noMipmap?: boolean | undefined,
  139960. /**
  139961. * Defines the explicit list of files (undefined by default)
  139962. */
  139963. files?: string[] | undefined);
  139964. /**
  139965. * Execute the current task
  139966. * @param scene defines the scene where you want your assets to be loaded
  139967. * @param onSuccess is a callback called when the task is successfully executed
  139968. * @param onError is a callback called if an error occurs
  139969. */
  139970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139971. }
  139972. /**
  139973. * Define a task used by AssetsManager to load HDR cube textures
  139974. */
  139975. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  139976. /**
  139977. * Defines the name of the task
  139978. */
  139979. name: string;
  139980. /**
  139981. * Defines the location of the file to load
  139982. */
  139983. url: string;
  139984. /**
  139985. * Defines the desired size (the more it increases the longer the generation will be)
  139986. */
  139987. size: number;
  139988. /**
  139989. * Defines if mipmaps should not be generated (default is false)
  139990. */
  139991. noMipmap: boolean;
  139992. /**
  139993. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139994. */
  139995. generateHarmonics: boolean;
  139996. /**
  139997. * 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)
  139998. */
  139999. gammaSpace: boolean;
  140000. /**
  140001. * Internal Use Only
  140002. */
  140003. reserved: boolean;
  140004. /**
  140005. * Gets the loaded texture
  140006. */
  140007. texture: HDRCubeTexture;
  140008. /**
  140009. * Callback called when the task is successful
  140010. */
  140011. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140012. /**
  140013. * Callback called when the task is successful
  140014. */
  140015. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140016. /**
  140017. * Creates a new HDRCubeTextureAssetTask object
  140018. * @param name defines the name of the task
  140019. * @param url defines the location of the file to load
  140020. * @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.
  140021. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140022. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140023. * @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)
  140024. * @param reserved Internal use only
  140025. */
  140026. constructor(
  140027. /**
  140028. * Defines the name of the task
  140029. */
  140030. name: string,
  140031. /**
  140032. * Defines the location of the file to load
  140033. */
  140034. url: string,
  140035. /**
  140036. * Defines the desired size (the more it increases the longer the generation will be)
  140037. */
  140038. size: number,
  140039. /**
  140040. * Defines if mipmaps should not be generated (default is false)
  140041. */
  140042. noMipmap?: boolean,
  140043. /**
  140044. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140045. */
  140046. generateHarmonics?: boolean,
  140047. /**
  140048. * 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)
  140049. */
  140050. gammaSpace?: boolean,
  140051. /**
  140052. * Internal Use Only
  140053. */
  140054. reserved?: boolean);
  140055. /**
  140056. * Execute the current task
  140057. * @param scene defines the scene where you want your assets to be loaded
  140058. * @param onSuccess is a callback called when the task is successfully executed
  140059. * @param onError is a callback called if an error occurs
  140060. */
  140061. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140062. }
  140063. /**
  140064. * Define a task used by AssetsManager to load Equirectangular cube textures
  140065. */
  140066. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140067. /**
  140068. * Defines the name of the task
  140069. */
  140070. name: string;
  140071. /**
  140072. * Defines the location of the file to load
  140073. */
  140074. url: string;
  140075. /**
  140076. * Defines the desired size (the more it increases the longer the generation will be)
  140077. */
  140078. size: number;
  140079. /**
  140080. * Defines if mipmaps should not be generated (default is false)
  140081. */
  140082. noMipmap: boolean;
  140083. /**
  140084. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140085. * but the standard material would require them in Gamma space) (default is true)
  140086. */
  140087. gammaSpace: boolean;
  140088. /**
  140089. * Gets the loaded texture
  140090. */
  140091. texture: EquiRectangularCubeTexture;
  140092. /**
  140093. * Callback called when the task is successful
  140094. */
  140095. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140096. /**
  140097. * Callback called when the task is successful
  140098. */
  140099. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140100. /**
  140101. * Creates a new EquiRectangularCubeTextureAssetTask object
  140102. * @param name defines the name of the task
  140103. * @param url defines the location of the file to load
  140104. * @param size defines the desired size (the more it increases the longer the generation will be)
  140105. * If the size is omitted this implies you are using a preprocessed cubemap.
  140106. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140107. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140108. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140109. * (default is true)
  140110. */
  140111. constructor(
  140112. /**
  140113. * Defines the name of the task
  140114. */
  140115. name: string,
  140116. /**
  140117. * Defines the location of the file to load
  140118. */
  140119. url: string,
  140120. /**
  140121. * Defines the desired size (the more it increases the longer the generation will be)
  140122. */
  140123. size: number,
  140124. /**
  140125. * Defines if mipmaps should not be generated (default is false)
  140126. */
  140127. noMipmap?: boolean,
  140128. /**
  140129. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140130. * but the standard material would require them in Gamma space) (default is true)
  140131. */
  140132. gammaSpace?: boolean);
  140133. /**
  140134. * Execute the current task
  140135. * @param scene defines the scene where you want your assets to be loaded
  140136. * @param onSuccess is a callback called when the task is successfully executed
  140137. * @param onError is a callback called if an error occurs
  140138. */
  140139. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140140. }
  140141. /**
  140142. * This class can be used to easily import assets into a scene
  140143. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140144. */
  140145. export class AssetsManager {
  140146. private _scene;
  140147. private _isLoading;
  140148. protected _tasks: AbstractAssetTask[];
  140149. protected _waitingTasksCount: number;
  140150. protected _totalTasksCount: number;
  140151. /**
  140152. * Callback called when all tasks are processed
  140153. */
  140154. onFinish: (tasks: AbstractAssetTask[]) => void;
  140155. /**
  140156. * Callback called when a task is successful
  140157. */
  140158. onTaskSuccess: (task: AbstractAssetTask) => void;
  140159. /**
  140160. * Callback called when a task had an error
  140161. */
  140162. onTaskError: (task: AbstractAssetTask) => void;
  140163. /**
  140164. * Callback called when a task is done (whatever the result is)
  140165. */
  140166. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140167. /**
  140168. * Observable called when all tasks are processed
  140169. */
  140170. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140171. /**
  140172. * Observable called when a task had an error
  140173. */
  140174. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140175. /**
  140176. * Observable called when all tasks were executed
  140177. */
  140178. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140179. /**
  140180. * Observable called when a task is done (whatever the result is)
  140181. */
  140182. onProgressObservable: Observable<IAssetsProgressEvent>;
  140183. /**
  140184. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140185. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140186. */
  140187. useDefaultLoadingScreen: boolean;
  140188. /**
  140189. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140190. * when all assets have been downloaded.
  140191. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140192. */
  140193. autoHideLoadingUI: boolean;
  140194. /**
  140195. * Creates a new AssetsManager
  140196. * @param scene defines the scene to work on
  140197. */
  140198. constructor(scene: Scene);
  140199. /**
  140200. * Add a MeshAssetTask to the list of active tasks
  140201. * @param taskName defines the name of the new task
  140202. * @param meshesNames defines the name of meshes to load
  140203. * @param rootUrl defines the root url to use to locate files
  140204. * @param sceneFilename defines the filename of the scene file
  140205. * @returns a new MeshAssetTask object
  140206. */
  140207. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140208. /**
  140209. * Add a TextFileAssetTask to the list of active tasks
  140210. * @param taskName defines the name of the new task
  140211. * @param url defines the url of the file to load
  140212. * @returns a new TextFileAssetTask object
  140213. */
  140214. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140215. /**
  140216. * Add a BinaryFileAssetTask to the list of active tasks
  140217. * @param taskName defines the name of the new task
  140218. * @param url defines the url of the file to load
  140219. * @returns a new BinaryFileAssetTask object
  140220. */
  140221. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140222. /**
  140223. * Add a ImageAssetTask to the list of active tasks
  140224. * @param taskName defines the name of the new task
  140225. * @param url defines the url of the file to load
  140226. * @returns a new ImageAssetTask object
  140227. */
  140228. addImageTask(taskName: string, url: string): ImageAssetTask;
  140229. /**
  140230. * Add a TextureAssetTask to the list of active tasks
  140231. * @param taskName defines the name of the new task
  140232. * @param url defines the url of the file to load
  140233. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140234. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140235. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140236. * @returns a new TextureAssetTask object
  140237. */
  140238. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140239. /**
  140240. * Add a CubeTextureAssetTask to the list of active tasks
  140241. * @param taskName defines the name of the new task
  140242. * @param url defines the url of the file to load
  140243. * @param extensions defines the extension to use to load the cube map (can be null)
  140244. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140245. * @param files defines the list of files to load (can be null)
  140246. * @returns a new CubeTextureAssetTask object
  140247. */
  140248. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140249. /**
  140250. *
  140251. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140252. * @param taskName defines the name of the new task
  140253. * @param url defines the url of the file to load
  140254. * @param size defines the size you want for the cubemap (can be null)
  140255. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140256. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140257. * @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)
  140258. * @param reserved Internal use only
  140259. * @returns a new HDRCubeTextureAssetTask object
  140260. */
  140261. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140262. /**
  140263. *
  140264. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140265. * @param taskName defines the name of the new task
  140266. * @param url defines the url of the file to load
  140267. * @param size defines the size you want for the cubemap (can be null)
  140268. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140269. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140270. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140271. * @returns a new EquiRectangularCubeTextureAssetTask object
  140272. */
  140273. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140274. /**
  140275. * Remove a task from the assets manager.
  140276. * @param task the task to remove
  140277. */
  140278. removeTask(task: AbstractAssetTask): void;
  140279. private _decreaseWaitingTasksCount;
  140280. private _runTask;
  140281. /**
  140282. * Reset the AssetsManager and remove all tasks
  140283. * @return the current instance of the AssetsManager
  140284. */
  140285. reset(): AssetsManager;
  140286. /**
  140287. * Start the loading process
  140288. * @return the current instance of the AssetsManager
  140289. */
  140290. load(): AssetsManager;
  140291. /**
  140292. * Start the loading process as an async operation
  140293. * @return a promise returning the list of failed tasks
  140294. */
  140295. loadAsync(): Promise<void>;
  140296. }
  140297. }
  140298. declare module BABYLON {
  140299. /**
  140300. * Wrapper class for promise with external resolve and reject.
  140301. */
  140302. export class Deferred<T> {
  140303. /**
  140304. * The promise associated with this deferred object.
  140305. */
  140306. readonly promise: Promise<T>;
  140307. private _resolve;
  140308. private _reject;
  140309. /**
  140310. * The resolve method of the promise associated with this deferred object.
  140311. */
  140312. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140313. /**
  140314. * The reject method of the promise associated with this deferred object.
  140315. */
  140316. get reject(): (reason?: any) => void;
  140317. /**
  140318. * Constructor for this deferred object.
  140319. */
  140320. constructor();
  140321. }
  140322. }
  140323. declare module BABYLON {
  140324. /**
  140325. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  140326. */
  140327. export class MeshExploder {
  140328. private _centerMesh;
  140329. private _meshes;
  140330. private _meshesOrigins;
  140331. private _toCenterVectors;
  140332. private _scaledDirection;
  140333. private _newPosition;
  140334. private _centerPosition;
  140335. /**
  140336. * Explodes meshes from a center mesh.
  140337. * @param meshes The meshes to explode.
  140338. * @param centerMesh The mesh to be center of explosion.
  140339. */
  140340. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  140341. private _setCenterMesh;
  140342. /**
  140343. * Get class name
  140344. * @returns "MeshExploder"
  140345. */
  140346. getClassName(): string;
  140347. /**
  140348. * "Exploded meshes"
  140349. * @returns Array of meshes with the centerMesh at index 0.
  140350. */
  140351. getMeshes(): Array<Mesh>;
  140352. /**
  140353. * Explodes meshes giving a specific direction
  140354. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  140355. */
  140356. explode(direction?: number): void;
  140357. }
  140358. }
  140359. declare module BABYLON {
  140360. /**
  140361. * Class used to help managing file picking and drag'n'drop
  140362. */
  140363. export class FilesInput {
  140364. /**
  140365. * List of files ready to be loaded
  140366. */
  140367. static get FilesToLoad(): {
  140368. [key: string]: File;
  140369. };
  140370. /**
  140371. * Callback called when a file is processed
  140372. */
  140373. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  140374. private _engine;
  140375. private _currentScene;
  140376. private _sceneLoadedCallback;
  140377. private _progressCallback;
  140378. private _additionalRenderLoopLogicCallback;
  140379. private _textureLoadingCallback;
  140380. private _startingProcessingFilesCallback;
  140381. private _onReloadCallback;
  140382. private _errorCallback;
  140383. private _elementToMonitor;
  140384. private _sceneFileToLoad;
  140385. private _filesToLoad;
  140386. /**
  140387. * Creates a new FilesInput
  140388. * @param engine defines the rendering engine
  140389. * @param scene defines the hosting scene
  140390. * @param sceneLoadedCallback callback called when scene is loaded
  140391. * @param progressCallback callback called to track progress
  140392. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  140393. * @param textureLoadingCallback callback called when a texture is loading
  140394. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  140395. * @param onReloadCallback callback called when a reload is requested
  140396. * @param errorCallback callback call if an error occurs
  140397. */
  140398. 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);
  140399. private _dragEnterHandler;
  140400. private _dragOverHandler;
  140401. private _dropHandler;
  140402. /**
  140403. * Calls this function to listen to drag'n'drop events on a specific DOM element
  140404. * @param elementToMonitor defines the DOM element to track
  140405. */
  140406. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  140407. /**
  140408. * Release all associated resources
  140409. */
  140410. dispose(): void;
  140411. private renderFunction;
  140412. private drag;
  140413. private drop;
  140414. private _traverseFolder;
  140415. private _processFiles;
  140416. /**
  140417. * Load files from a drop event
  140418. * @param event defines the drop event to use as source
  140419. */
  140420. loadFiles(event: any): void;
  140421. private _processReload;
  140422. /**
  140423. * Reload the current scene from the loaded files
  140424. */
  140425. reload(): void;
  140426. }
  140427. }
  140428. declare module BABYLON {
  140429. /**
  140430. * Defines the root class used to create scene optimization to use with SceneOptimizer
  140431. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140432. */
  140433. export class SceneOptimization {
  140434. /**
  140435. * Defines the priority of this optimization (0 by default which means first in the list)
  140436. */
  140437. priority: number;
  140438. /**
  140439. * Gets a string describing the action executed by the current optimization
  140440. * @returns description string
  140441. */
  140442. getDescription(): string;
  140443. /**
  140444. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140445. * @param scene defines the current scene where to apply this optimization
  140446. * @param optimizer defines the current optimizer
  140447. * @returns true if everything that can be done was applied
  140448. */
  140449. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140450. /**
  140451. * Creates the SceneOptimization object
  140452. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140453. * @param desc defines the description associated with the optimization
  140454. */
  140455. constructor(
  140456. /**
  140457. * Defines the priority of this optimization (0 by default which means first in the list)
  140458. */
  140459. priority?: number);
  140460. }
  140461. /**
  140462. * Defines an optimization used to reduce the size of render target textures
  140463. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140464. */
  140465. export class TextureOptimization extends SceneOptimization {
  140466. /**
  140467. * Defines the priority of this optimization (0 by default which means first in the list)
  140468. */
  140469. priority: number;
  140470. /**
  140471. * 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
  140472. */
  140473. maximumSize: number;
  140474. /**
  140475. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140476. */
  140477. step: number;
  140478. /**
  140479. * Gets a string describing the action executed by the current optimization
  140480. * @returns description string
  140481. */
  140482. getDescription(): string;
  140483. /**
  140484. * Creates the TextureOptimization object
  140485. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140486. * @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
  140487. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140488. */
  140489. constructor(
  140490. /**
  140491. * Defines the priority of this optimization (0 by default which means first in the list)
  140492. */
  140493. priority?: number,
  140494. /**
  140495. * 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
  140496. */
  140497. maximumSize?: number,
  140498. /**
  140499. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140500. */
  140501. step?: number);
  140502. /**
  140503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140504. * @param scene defines the current scene where to apply this optimization
  140505. * @param optimizer defines the current optimizer
  140506. * @returns true if everything that can be done was applied
  140507. */
  140508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140509. }
  140510. /**
  140511. * Defines an optimization used to increase or decrease the rendering resolution
  140512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140513. */
  140514. export class HardwareScalingOptimization extends SceneOptimization {
  140515. /**
  140516. * Defines the priority of this optimization (0 by default which means first in the list)
  140517. */
  140518. priority: number;
  140519. /**
  140520. * Defines the maximum scale to use (2 by default)
  140521. */
  140522. maximumScale: number;
  140523. /**
  140524. * Defines the step to use between two passes (0.5 by default)
  140525. */
  140526. step: number;
  140527. private _currentScale;
  140528. private _directionOffset;
  140529. /**
  140530. * Gets a string describing the action executed by the current optimization
  140531. * @return description string
  140532. */
  140533. getDescription(): string;
  140534. /**
  140535. * Creates the HardwareScalingOptimization object
  140536. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140537. * @param maximumScale defines the maximum scale to use (2 by default)
  140538. * @param step defines the step to use between two passes (0.5 by default)
  140539. */
  140540. constructor(
  140541. /**
  140542. * Defines the priority of this optimization (0 by default which means first in the list)
  140543. */
  140544. priority?: number,
  140545. /**
  140546. * Defines the maximum scale to use (2 by default)
  140547. */
  140548. maximumScale?: number,
  140549. /**
  140550. * Defines the step to use between two passes (0.5 by default)
  140551. */
  140552. step?: number);
  140553. /**
  140554. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140555. * @param scene defines the current scene where to apply this optimization
  140556. * @param optimizer defines the current optimizer
  140557. * @returns true if everything that can be done was applied
  140558. */
  140559. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140560. }
  140561. /**
  140562. * Defines an optimization used to remove shadows
  140563. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140564. */
  140565. export class ShadowsOptimization extends SceneOptimization {
  140566. /**
  140567. * Gets a string describing the action executed by the current optimization
  140568. * @return description string
  140569. */
  140570. getDescription(): string;
  140571. /**
  140572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140573. * @param scene defines the current scene where to apply this optimization
  140574. * @param optimizer defines the current optimizer
  140575. * @returns true if everything that can be done was applied
  140576. */
  140577. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140578. }
  140579. /**
  140580. * Defines an optimization used to turn post-processes off
  140581. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140582. */
  140583. export class PostProcessesOptimization extends SceneOptimization {
  140584. /**
  140585. * Gets a string describing the action executed by the current optimization
  140586. * @return description string
  140587. */
  140588. getDescription(): string;
  140589. /**
  140590. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140591. * @param scene defines the current scene where to apply this optimization
  140592. * @param optimizer defines the current optimizer
  140593. * @returns true if everything that can be done was applied
  140594. */
  140595. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140596. }
  140597. /**
  140598. * Defines an optimization used to turn lens flares off
  140599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140600. */
  140601. export class LensFlaresOptimization extends SceneOptimization {
  140602. /**
  140603. * Gets a string describing the action executed by the current optimization
  140604. * @return description string
  140605. */
  140606. getDescription(): string;
  140607. /**
  140608. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140609. * @param scene defines the current scene where to apply this optimization
  140610. * @param optimizer defines the current optimizer
  140611. * @returns true if everything that can be done was applied
  140612. */
  140613. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140614. }
  140615. /**
  140616. * Defines an optimization based on user defined callback.
  140617. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140618. */
  140619. export class CustomOptimization extends SceneOptimization {
  140620. /**
  140621. * Callback called to apply the custom optimization.
  140622. */
  140623. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  140624. /**
  140625. * Callback called to get custom description
  140626. */
  140627. onGetDescription: () => string;
  140628. /**
  140629. * Gets a string describing the action executed by the current optimization
  140630. * @returns description string
  140631. */
  140632. getDescription(): string;
  140633. /**
  140634. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140635. * @param scene defines the current scene where to apply this optimization
  140636. * @param optimizer defines the current optimizer
  140637. * @returns true if everything that can be done was applied
  140638. */
  140639. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140640. }
  140641. /**
  140642. * Defines an optimization used to turn particles off
  140643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140644. */
  140645. export class ParticlesOptimization extends SceneOptimization {
  140646. /**
  140647. * Gets a string describing the action executed by the current optimization
  140648. * @return description string
  140649. */
  140650. getDescription(): string;
  140651. /**
  140652. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140653. * @param scene defines the current scene where to apply this optimization
  140654. * @param optimizer defines the current optimizer
  140655. * @returns true if everything that can be done was applied
  140656. */
  140657. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140658. }
  140659. /**
  140660. * Defines an optimization used to turn render targets off
  140661. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140662. */
  140663. export class RenderTargetsOptimization extends SceneOptimization {
  140664. /**
  140665. * Gets a string describing the action executed by the current optimization
  140666. * @return description string
  140667. */
  140668. getDescription(): string;
  140669. /**
  140670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140671. * @param scene defines the current scene where to apply this optimization
  140672. * @param optimizer defines the current optimizer
  140673. * @returns true if everything that can be done was applied
  140674. */
  140675. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140676. }
  140677. /**
  140678. * Defines an optimization used to merge meshes with compatible materials
  140679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140680. */
  140681. export class MergeMeshesOptimization extends SceneOptimization {
  140682. private static _UpdateSelectionTree;
  140683. /**
  140684. * Gets or sets a boolean which defines if optimization octree has to be updated
  140685. */
  140686. static get UpdateSelectionTree(): boolean;
  140687. /**
  140688. * Gets or sets a boolean which defines if optimization octree has to be updated
  140689. */
  140690. static set UpdateSelectionTree(value: boolean);
  140691. /**
  140692. * Gets a string describing the action executed by the current optimization
  140693. * @return description string
  140694. */
  140695. getDescription(): string;
  140696. private _canBeMerged;
  140697. /**
  140698. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140699. * @param scene defines the current scene where to apply this optimization
  140700. * @param optimizer defines the current optimizer
  140701. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  140702. * @returns true if everything that can be done was applied
  140703. */
  140704. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  140705. }
  140706. /**
  140707. * Defines a list of options used by SceneOptimizer
  140708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140709. */
  140710. export class SceneOptimizerOptions {
  140711. /**
  140712. * Defines the target frame rate to reach (60 by default)
  140713. */
  140714. targetFrameRate: number;
  140715. /**
  140716. * Defines the interval between two checkes (2000ms by default)
  140717. */
  140718. trackerDuration: number;
  140719. /**
  140720. * Gets the list of optimizations to apply
  140721. */
  140722. optimizations: SceneOptimization[];
  140723. /**
  140724. * Creates a new list of options used by SceneOptimizer
  140725. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  140726. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  140727. */
  140728. constructor(
  140729. /**
  140730. * Defines the target frame rate to reach (60 by default)
  140731. */
  140732. targetFrameRate?: number,
  140733. /**
  140734. * Defines the interval between two checkes (2000ms by default)
  140735. */
  140736. trackerDuration?: number);
  140737. /**
  140738. * Add a new optimization
  140739. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  140740. * @returns the current SceneOptimizerOptions
  140741. */
  140742. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  140743. /**
  140744. * Add a new custom optimization
  140745. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  140746. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  140747. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140748. * @returns the current SceneOptimizerOptions
  140749. */
  140750. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  140751. /**
  140752. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  140753. * @param targetFrameRate defines the target frame rate (60 by default)
  140754. * @returns a SceneOptimizerOptions object
  140755. */
  140756. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140757. /**
  140758. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  140759. * @param targetFrameRate defines the target frame rate (60 by default)
  140760. * @returns a SceneOptimizerOptions object
  140761. */
  140762. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140763. /**
  140764. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  140765. * @param targetFrameRate defines the target frame rate (60 by default)
  140766. * @returns a SceneOptimizerOptions object
  140767. */
  140768. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140769. }
  140770. /**
  140771. * Class used to run optimizations in order to reach a target frame rate
  140772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140773. */
  140774. export class SceneOptimizer implements IDisposable {
  140775. private _isRunning;
  140776. private _options;
  140777. private _scene;
  140778. private _currentPriorityLevel;
  140779. private _targetFrameRate;
  140780. private _trackerDuration;
  140781. private _currentFrameRate;
  140782. private _sceneDisposeObserver;
  140783. private _improvementMode;
  140784. /**
  140785. * Defines an observable called when the optimizer reaches the target frame rate
  140786. */
  140787. onSuccessObservable: Observable<SceneOptimizer>;
  140788. /**
  140789. * Defines an observable called when the optimizer enables an optimization
  140790. */
  140791. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  140792. /**
  140793. * Defines an observable called when the optimizer is not able to reach the target frame rate
  140794. */
  140795. onFailureObservable: Observable<SceneOptimizer>;
  140796. /**
  140797. * Gets a boolean indicating if the optimizer is in improvement mode
  140798. */
  140799. get isInImprovementMode(): boolean;
  140800. /**
  140801. * Gets the current priority level (0 at start)
  140802. */
  140803. get currentPriorityLevel(): number;
  140804. /**
  140805. * Gets the current frame rate checked by the SceneOptimizer
  140806. */
  140807. get currentFrameRate(): number;
  140808. /**
  140809. * Gets or sets the current target frame rate (60 by default)
  140810. */
  140811. get targetFrameRate(): number;
  140812. /**
  140813. * Gets or sets the current target frame rate (60 by default)
  140814. */
  140815. set targetFrameRate(value: number);
  140816. /**
  140817. * Gets or sets the current interval between two checks (every 2000ms by default)
  140818. */
  140819. get trackerDuration(): number;
  140820. /**
  140821. * Gets or sets the current interval between two checks (every 2000ms by default)
  140822. */
  140823. set trackerDuration(value: number);
  140824. /**
  140825. * Gets the list of active optimizations
  140826. */
  140827. get optimizations(): SceneOptimization[];
  140828. /**
  140829. * Creates a new SceneOptimizer
  140830. * @param scene defines the scene to work on
  140831. * @param options defines the options to use with the SceneOptimizer
  140832. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  140833. * @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)
  140834. */
  140835. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  140836. /**
  140837. * Stops the current optimizer
  140838. */
  140839. stop(): void;
  140840. /**
  140841. * Reset the optimizer to initial step (current priority level = 0)
  140842. */
  140843. reset(): void;
  140844. /**
  140845. * Start the optimizer. By default it will try to reach a specific framerate
  140846. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  140847. */
  140848. start(): void;
  140849. private _checkCurrentState;
  140850. /**
  140851. * Release all resources
  140852. */
  140853. dispose(): void;
  140854. /**
  140855. * Helper function to create a SceneOptimizer with one single line of code
  140856. * @param scene defines the scene to work on
  140857. * @param options defines the options to use with the SceneOptimizer
  140858. * @param onSuccess defines a callback to call on success
  140859. * @param onFailure defines a callback to call on failure
  140860. * @returns the new SceneOptimizer object
  140861. */
  140862. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  140863. }
  140864. }
  140865. declare module BABYLON {
  140866. /**
  140867. * Class used to serialize a scene into a string
  140868. */
  140869. export class SceneSerializer {
  140870. /**
  140871. * Clear cache used by a previous serialization
  140872. */
  140873. static ClearCache(): void;
  140874. /**
  140875. * Serialize a scene into a JSON compatible object
  140876. * @param scene defines the scene to serialize
  140877. * @returns a JSON compatible object
  140878. */
  140879. static Serialize(scene: Scene): any;
  140880. /**
  140881. * Serialize a mesh into a JSON compatible object
  140882. * @param toSerialize defines the mesh to serialize
  140883. * @param withParents defines if parents must be serialized as well
  140884. * @param withChildren defines if children must be serialized as well
  140885. * @returns a JSON compatible object
  140886. */
  140887. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  140888. }
  140889. }
  140890. declare module BABYLON {
  140891. /**
  140892. * Class used to host texture specific utilities
  140893. */
  140894. export class TextureTools {
  140895. /**
  140896. * Uses the GPU to create a copy texture rescaled at a given size
  140897. * @param texture Texture to copy from
  140898. * @param width defines the desired width
  140899. * @param height defines the desired height
  140900. * @param useBilinearMode defines if bilinear mode has to be used
  140901. * @return the generated texture
  140902. */
  140903. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  140904. }
  140905. }
  140906. declare module BABYLON {
  140907. /**
  140908. * This represents the different options available for the video capture.
  140909. */
  140910. export interface VideoRecorderOptions {
  140911. /** Defines the mime type of the video. */
  140912. mimeType: string;
  140913. /** Defines the FPS the video should be recorded at. */
  140914. fps: number;
  140915. /** Defines the chunk size for the recording data. */
  140916. recordChunckSize: number;
  140917. /** The audio tracks to attach to the recording. */
  140918. audioTracks?: MediaStreamTrack[];
  140919. }
  140920. /**
  140921. * This can help with recording videos from BabylonJS.
  140922. * This is based on the available WebRTC functionalities of the browser.
  140923. *
  140924. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  140925. */
  140926. export class VideoRecorder {
  140927. private static readonly _defaultOptions;
  140928. /**
  140929. * Returns whether or not the VideoRecorder is available in your browser.
  140930. * @param engine Defines the Babylon Engine.
  140931. * @returns true if supported otherwise false.
  140932. */
  140933. static IsSupported(engine: Engine): boolean;
  140934. private readonly _options;
  140935. private _canvas;
  140936. private _mediaRecorder;
  140937. private _recordedChunks;
  140938. private _fileName;
  140939. private _resolve;
  140940. private _reject;
  140941. /**
  140942. * True when a recording is already in progress.
  140943. */
  140944. get isRecording(): boolean;
  140945. /**
  140946. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  140947. * @param engine Defines the BabylonJS Engine you wish to record.
  140948. * @param options Defines options that can be used to customize the capture.
  140949. */
  140950. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  140951. /**
  140952. * Stops the current recording before the default capture timeout passed in the startRecording function.
  140953. */
  140954. stopRecording(): void;
  140955. /**
  140956. * Starts recording the canvas for a max duration specified in parameters.
  140957. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  140958. * If null no automatic download will start and you can rely on the promise to get the data back.
  140959. * @param maxDuration Defines the maximum recording time in seconds.
  140960. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  140961. * @return A promise callback at the end of the recording with the video data in Blob.
  140962. */
  140963. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  140964. /**
  140965. * Releases internal resources used during the recording.
  140966. */
  140967. dispose(): void;
  140968. private _handleDataAvailable;
  140969. private _handleError;
  140970. private _handleStop;
  140971. }
  140972. }
  140973. declare module BABYLON {
  140974. /**
  140975. * Class containing a set of static utilities functions for screenshots
  140976. */
  140977. export class ScreenshotTools {
  140978. /**
  140979. * Captures a screenshot of the current rendering
  140980. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140981. * @param engine defines the rendering engine
  140982. * @param camera defines the source camera
  140983. * @param size This parameter can be set to a single number or to an object with the
  140984. * following (optional) properties: precision, width, height. If a single number is passed,
  140985. * it will be used for both width and height. If an object is passed, the screenshot size
  140986. * will be derived from the parameters. The precision property is a multiplier allowing
  140987. * rendering at a higher or lower resolution
  140988. * @param successCallback defines the callback receives a single parameter which contains the
  140989. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  140990. * src parameter of an <img> to display it
  140991. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  140992. * Check your browser for supported MIME types
  140993. */
  140994. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  140995. /**
  140996. * Captures a screenshot of the current rendering
  140997. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140998. * @param engine defines the rendering engine
  140999. * @param camera defines the source camera
  141000. * @param size This parameter can be set to a single number or to an object with the
  141001. * following (optional) properties: precision, width, height. If a single number is passed,
  141002. * it will be used for both width and height. If an object is passed, the screenshot size
  141003. * will be derived from the parameters. The precision property is a multiplier allowing
  141004. * rendering at a higher or lower resolution
  141005. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141006. * Check your browser for supported MIME types
  141007. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141008. * to the src parameter of an <img> to display it
  141009. */
  141010. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141011. /**
  141012. * Generates an image screenshot from the specified camera.
  141013. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141014. * @param engine The engine to use for rendering
  141015. * @param camera The camera to use for rendering
  141016. * @param size This parameter can be set to a single number or to an object with the
  141017. * following (optional) properties: precision, width, height. If a single number is passed,
  141018. * it will be used for both width and height. If an object is passed, the screenshot size
  141019. * will be derived from the parameters. The precision property is a multiplier allowing
  141020. * rendering at a higher or lower resolution
  141021. * @param successCallback The callback receives a single parameter which contains the
  141022. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141023. * src parameter of an <img> to display it
  141024. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141025. * Check your browser for supported MIME types
  141026. * @param samples Texture samples (default: 1)
  141027. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141028. * @param fileName A name for for the downloaded file.
  141029. */
  141030. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  141031. /**
  141032. * Generates an image screenshot from the specified camera.
  141033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141034. * @param engine The engine to use for rendering
  141035. * @param camera The camera to use for rendering
  141036. * @param size This parameter can be set to a single number or to an object with the
  141037. * following (optional) properties: precision, width, height. If a single number is passed,
  141038. * it will be used for both width and height. If an object is passed, the screenshot size
  141039. * will be derived from the parameters. The precision property is a multiplier allowing
  141040. * rendering at a higher or lower resolution
  141041. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141042. * Check your browser for supported MIME types
  141043. * @param samples Texture samples (default: 1)
  141044. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141045. * @param fileName A name for for the downloaded file.
  141046. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141047. * to the src parameter of an <img> to display it
  141048. */
  141049. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  141050. /**
  141051. * Gets height and width for screenshot size
  141052. * @private
  141053. */
  141054. private static _getScreenshotSize;
  141055. }
  141056. }
  141057. declare module BABYLON {
  141058. /**
  141059. * Interface for a data buffer
  141060. */
  141061. export interface IDataBuffer {
  141062. /**
  141063. * Reads bytes from the data buffer.
  141064. * @param byteOffset The byte offset to read
  141065. * @param byteLength The byte length to read
  141066. * @returns A promise that resolves when the bytes are read
  141067. */
  141068. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141069. /**
  141070. * The byte length of the buffer.
  141071. */
  141072. readonly byteLength: number;
  141073. }
  141074. /**
  141075. * Utility class for reading from a data buffer
  141076. */
  141077. export class DataReader {
  141078. /**
  141079. * The data buffer associated with this data reader.
  141080. */
  141081. readonly buffer: IDataBuffer;
  141082. /**
  141083. * The current byte offset from the beginning of the data buffer.
  141084. */
  141085. byteOffset: number;
  141086. private _dataView;
  141087. private _dataByteOffset;
  141088. /**
  141089. * Constructor
  141090. * @param buffer The buffer to read
  141091. */
  141092. constructor(buffer: IDataBuffer);
  141093. /**
  141094. * Loads the given byte length.
  141095. * @param byteLength The byte length to load
  141096. * @returns A promise that resolves when the load is complete
  141097. */
  141098. loadAsync(byteLength: number): Promise<void>;
  141099. /**
  141100. * Read a unsigned 32-bit integer from the currently loaded data range.
  141101. * @returns The 32-bit integer read
  141102. */
  141103. readUint32(): number;
  141104. /**
  141105. * Read a byte array from the currently loaded data range.
  141106. * @param byteLength The byte length to read
  141107. * @returns The byte array read
  141108. */
  141109. readUint8Array(byteLength: number): Uint8Array;
  141110. /**
  141111. * Read a string from the currently loaded data range.
  141112. * @param byteLength The byte length to read
  141113. * @returns The string read
  141114. */
  141115. readString(byteLength: number): string;
  141116. /**
  141117. * Skips the given byte length the currently loaded data range.
  141118. * @param byteLength The byte length to skip
  141119. */
  141120. skipBytes(byteLength: number): void;
  141121. }
  141122. }
  141123. declare module BABYLON {
  141124. /**
  141125. * Options used for hit testing
  141126. */
  141127. export interface IWebXRHitTestOptions {
  141128. /**
  141129. * Only test when user interacted with the scene. Default - hit test every frame
  141130. */
  141131. testOnPointerDownOnly?: boolean;
  141132. /**
  141133. * The node to use to transform the local results to world coordinates
  141134. */
  141135. worldParentNode?: TransformNode;
  141136. }
  141137. /**
  141138. * Interface defining the babylon result of raycasting/hit-test
  141139. */
  141140. export interface IWebXRHitResult {
  141141. /**
  141142. * The native hit test result
  141143. */
  141144. xrHitResult: XRHitResult;
  141145. /**
  141146. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141147. */
  141148. transformationMatrix: Matrix;
  141149. }
  141150. /**
  141151. * The currently-working hit-test module.
  141152. * Hit test (or raycasting) is used to interact with the real world.
  141153. * For further information read here - https://github.com/immersive-web/hit-test
  141154. */
  141155. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141156. /**
  141157. * options to use when constructing this feature
  141158. */
  141159. readonly options: IWebXRHitTestOptions;
  141160. /**
  141161. * The module's name
  141162. */
  141163. static readonly Name: string;
  141164. /**
  141165. * The (Babylon) version of this module.
  141166. * This is an integer representing the implementation version.
  141167. * This number does not correspond to the webxr specs version
  141168. */
  141169. static readonly Version: number;
  141170. /**
  141171. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141172. * @param event the (select) event to use to select with
  141173. * @param referenceSpace the reference space to use for this hit test
  141174. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141175. */
  141176. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141177. /**
  141178. * execute a hit test with an XR Ray
  141179. *
  141180. * @param xrSession a native xrSession that will execute this hit test
  141181. * @param xrRay the ray (position and direction) to use for raycasting
  141182. * @param referenceSpace native XR reference space to use for the hit-test
  141183. * @param filter filter function that will filter the results
  141184. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141185. */
  141186. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141187. /**
  141188. * Triggered when new babylon (transformed) hit test results are available
  141189. */
  141190. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141191. private _onSelectEnabled;
  141192. /**
  141193. * Creates a new instance of the (legacy version) hit test feature
  141194. * @param _xrSessionManager an instance of WebXRSessionManager
  141195. * @param options options to use when constructing this feature
  141196. */
  141197. constructor(_xrSessionManager: WebXRSessionManager,
  141198. /**
  141199. * options to use when constructing this feature
  141200. */
  141201. options?: IWebXRHitTestOptions);
  141202. /**
  141203. * Populated with the last native XR Hit Results
  141204. */
  141205. lastNativeXRHitResults: XRHitResult[];
  141206. /**
  141207. * attach this feature
  141208. * Will usually be called by the features manager
  141209. *
  141210. * @returns true if successful.
  141211. */
  141212. attach(): boolean;
  141213. /**
  141214. * detach this feature.
  141215. * Will usually be called by the features manager
  141216. *
  141217. * @returns true if successful.
  141218. */
  141219. detach(): boolean;
  141220. private _onHitTestResults;
  141221. private _origin;
  141222. private _direction;
  141223. private _mat;
  141224. protected _onXRFrame(frame: XRFrame): void;
  141225. private _onSelect;
  141226. /**
  141227. * Dispose this feature and all of the resources attached
  141228. */
  141229. dispose(): void;
  141230. }
  141231. }
  141232. declare module BABYLON {
  141233. /**
  141234. * Options used in the plane detector module
  141235. */
  141236. export interface IWebXRPlaneDetectorOptions {
  141237. /**
  141238. * The node to use to transform the local results to world coordinates
  141239. */
  141240. worldParentNode?: TransformNode;
  141241. }
  141242. /**
  141243. * A babylon interface for a webxr plane.
  141244. * A Plane is actually a polygon, built from N points in space
  141245. *
  141246. * Supported in chrome 79, not supported in canary 81 ATM
  141247. */
  141248. export interface IWebXRPlane {
  141249. /**
  141250. * a babylon-assigned ID for this polygon
  141251. */
  141252. id: number;
  141253. /**
  141254. * the native xr-plane object
  141255. */
  141256. xrPlane: XRPlane;
  141257. /**
  141258. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  141259. */
  141260. polygonDefinition: Array<Vector3>;
  141261. /**
  141262. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  141263. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  141264. */
  141265. transformationMatrix: Matrix;
  141266. }
  141267. /**
  141268. * The plane detector is used to detect planes in the real world when in AR
  141269. * For more information see https://github.com/immersive-web/real-world-geometry/
  141270. */
  141271. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  141272. private _options;
  141273. /**
  141274. * The module's name
  141275. */
  141276. static readonly Name: string;
  141277. /**
  141278. * The (Babylon) version of this module.
  141279. * This is an integer representing the implementation version.
  141280. * This number does not correspond to the webxr specs version
  141281. */
  141282. static readonly Version: number;
  141283. /**
  141284. * Observers registered here will be executed when a new plane was added to the session
  141285. */
  141286. onPlaneAddedObservable: Observable<IWebXRPlane>;
  141287. /**
  141288. * Observers registered here will be executed when a plane is no longer detected in the session
  141289. */
  141290. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  141291. /**
  141292. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  141293. * This can execute N times every frame
  141294. */
  141295. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  141296. private _enabled;
  141297. private _detectedPlanes;
  141298. private _lastFrameDetected;
  141299. /**
  141300. * construct a new Plane Detector
  141301. * @param _xrSessionManager an instance of xr Session manager
  141302. * @param _options configuration to use when constructing this feature
  141303. */
  141304. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  141305. private _init;
  141306. protected _onXRFrame(frame: XRFrame): void;
  141307. /**
  141308. * Dispose this feature and all of the resources attached
  141309. */
  141310. dispose(): void;
  141311. private _updatePlaneWithXRPlane;
  141312. /**
  141313. * avoiding using Array.find for global support.
  141314. * @param xrPlane the plane to find in the array
  141315. */
  141316. private findIndexInPlaneArray;
  141317. }
  141318. }
  141319. declare module BABYLON {
  141320. /**
  141321. * Configuration options of the anchor system
  141322. */
  141323. export interface IWebXRAnchorSystemOptions {
  141324. /**
  141325. * a node that will be used to convert local to world coordinates
  141326. */
  141327. worldParentNode?: TransformNode;
  141328. /**
  141329. * should the anchor system use plane detection.
  141330. * If set to true, the plane-detection feature should be set using setPlaneDetector
  141331. */
  141332. usePlaneDetection?: boolean;
  141333. /**
  141334. * Should a new anchor be added every time a select event is triggered
  141335. */
  141336. addAnchorOnSelect?: boolean;
  141337. }
  141338. /**
  141339. * A babylon container for an XR Anchor
  141340. */
  141341. export interface IWebXRAnchor {
  141342. /**
  141343. * A babylon-assigned ID for this anchor
  141344. */
  141345. id: number;
  141346. /**
  141347. * The native anchor object
  141348. */
  141349. xrAnchor: XRAnchor;
  141350. /**
  141351. * Transformation matrix to apply to an object attached to this anchor
  141352. */
  141353. transformationMatrix: Matrix;
  141354. }
  141355. /**
  141356. * An implementation of the anchor system of WebXR.
  141357. * Note that the current documented implementation is not available in any browser. Future implementations
  141358. * will use the frame to create an anchor and not the session or a detected plane
  141359. * For further information see https://github.com/immersive-web/anchors/
  141360. */
  141361. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  141362. private _options;
  141363. /**
  141364. * The module's name
  141365. */
  141366. static readonly Name: string;
  141367. /**
  141368. * The (Babylon) version of this module.
  141369. * This is an integer representing the implementation version.
  141370. * This number does not correspond to the webxr specs version
  141371. */
  141372. static readonly Version: number;
  141373. /**
  141374. * Observers registered here will be executed when a new anchor was added to the session
  141375. */
  141376. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  141377. /**
  141378. * Observers registered here will be executed when an existing anchor updates
  141379. * This can execute N times every frame
  141380. */
  141381. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  141382. /**
  141383. * Observers registered here will be executed when an anchor was removed from the session
  141384. */
  141385. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  141386. private _planeDetector;
  141387. private _hitTestModule;
  141388. private _enabled;
  141389. private _trackedAnchors;
  141390. private _lastFrameDetected;
  141391. /**
  141392. * constructs a new anchor system
  141393. * @param _xrSessionManager an instance of WebXRSessionManager
  141394. * @param _options configuration object for this feature
  141395. */
  141396. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  141397. /**
  141398. * set the plane detector to use in order to create anchors from frames
  141399. * @param planeDetector the plane-detector module to use
  141400. * @param enable enable plane-anchors. default is true
  141401. */
  141402. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  141403. /**
  141404. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  141405. * @param hitTestModule the hit-test module to use.
  141406. */
  141407. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  141408. /**
  141409. * attach this feature
  141410. * Will usually be called by the features manager
  141411. *
  141412. * @returns true if successful.
  141413. */
  141414. attach(): boolean;
  141415. /**
  141416. * detach this feature.
  141417. * Will usually be called by the features manager
  141418. *
  141419. * @returns true if successful.
  141420. */
  141421. detach(): boolean;
  141422. /**
  141423. * Dispose this feature and all of the resources attached
  141424. */
  141425. dispose(): void;
  141426. protected _onXRFrame(frame: XRFrame): void;
  141427. private _onSelect;
  141428. /**
  141429. * Add anchor at a specific XR point.
  141430. *
  141431. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  141432. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  141433. * @returns a promise the fulfills when the anchor was created
  141434. */
  141435. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  141436. private _updateAnchorWithXRFrame;
  141437. /**
  141438. * avoiding using Array.find for global support.
  141439. * @param xrAnchor the plane to find in the array
  141440. */
  141441. private _findIndexInAnchorArray;
  141442. }
  141443. }
  141444. declare module BABYLON {
  141445. /**
  141446. * Options interface for the background remover plugin
  141447. */
  141448. export interface IWebXRBackgroundRemoverOptions {
  141449. /**
  141450. * don't disable the environment helper
  141451. */
  141452. ignoreEnvironmentHelper?: boolean;
  141453. /**
  141454. * flags to configure the removal of the environment helper.
  141455. * If not set, the entire background will be removed. If set, flags should be set as well.
  141456. */
  141457. environmentHelperRemovalFlags?: {
  141458. /**
  141459. * Should the skybox be removed (default false)
  141460. */
  141461. skyBox?: boolean;
  141462. /**
  141463. * Should the ground be removed (default false)
  141464. */
  141465. ground?: boolean;
  141466. };
  141467. /**
  141468. * Further background meshes to disable when entering AR
  141469. */
  141470. backgroundMeshes?: AbstractMesh[];
  141471. }
  141472. /**
  141473. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  141474. */
  141475. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  141476. /**
  141477. * read-only options to be used in this module
  141478. */
  141479. readonly options: IWebXRBackgroundRemoverOptions;
  141480. /**
  141481. * The module's name
  141482. */
  141483. static readonly Name: string;
  141484. /**
  141485. * The (Babylon) version of this module.
  141486. * This is an integer representing the implementation version.
  141487. * This number does not correspond to the webxr specs version
  141488. */
  141489. static readonly Version: number;
  141490. /**
  141491. * registered observers will be triggered when the background state changes
  141492. */
  141493. onBackgroundStateChangedObservable: Observable<boolean>;
  141494. /**
  141495. * constructs a new background remover module
  141496. * @param _xrSessionManager the session manager for this module
  141497. * @param options read-only options to be used in this module
  141498. */
  141499. constructor(_xrSessionManager: WebXRSessionManager,
  141500. /**
  141501. * read-only options to be used in this module
  141502. */
  141503. options?: IWebXRBackgroundRemoverOptions);
  141504. /**
  141505. * attach this feature
  141506. * Will usually be called by the features manager
  141507. *
  141508. * @returns true if successful.
  141509. */
  141510. attach(): boolean;
  141511. /**
  141512. * detach this feature.
  141513. * Will usually be called by the features manager
  141514. *
  141515. * @returns true if successful.
  141516. */
  141517. detach(): boolean;
  141518. private _setBackgroundState;
  141519. /**
  141520. * Dispose this feature and all of the resources attached
  141521. */
  141522. dispose(): void;
  141523. protected _onXRFrame(_xrFrame: XRFrame): void;
  141524. }
  141525. }
  141526. declare module BABYLON {
  141527. /**
  141528. * Options for the controller physics feature
  141529. */
  141530. export class IWebXRControllerPhysicsOptions {
  141531. /**
  141532. * the xr input to use with this pointer selection
  141533. */
  141534. xrInput: WebXRInput;
  141535. /**
  141536. * The physics properties of the future impostors
  141537. */
  141538. physicsProperties?: {
  141539. /**
  141540. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  141541. * Note that this requires a physics engine that supports mesh impostors!
  141542. */
  141543. useControllerMesh?: boolean;
  141544. /**
  141545. * The type of impostor to create. Default is sphere
  141546. */
  141547. impostorType?: number;
  141548. /**
  141549. * the size of the impostor. Defaults to 10cm
  141550. */
  141551. impostorSize?: number | {
  141552. width: number;
  141553. height: number;
  141554. depth: number;
  141555. };
  141556. /**
  141557. * Friction definitions
  141558. */
  141559. friction?: number;
  141560. /**
  141561. * Restitution
  141562. */
  141563. restitution?: number;
  141564. };
  141565. }
  141566. /**
  141567. * Add physics impostor to your webxr controllers,
  141568. * including naive calculation of their linear and angular velocity
  141569. */
  141570. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  141571. private readonly _options;
  141572. /**
  141573. * The module's name
  141574. */
  141575. static readonly Name: string;
  141576. /**
  141577. * The (Babylon) version of this module.
  141578. * This is an integer representing the implementation version.
  141579. * This number does not correspond to the webxr specs version
  141580. */
  141581. static readonly Version: number;
  141582. private _lastTimestamp;
  141583. private _delta;
  141584. private _controllers;
  141585. private _tmpVector;
  141586. private _tmpQuaternion;
  141587. /**
  141588. * Construct a new Controller Physics Feature
  141589. * @param _xrSessionManager the corresponding xr session manager
  141590. * @param _options options to create this feature with
  141591. */
  141592. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  141593. /**
  141594. * Update the physics properties provided in the constructor
  141595. * @param newProperties the new properties object
  141596. */
  141597. setPhysicsProperties(newProperties: {
  141598. impostorType?: number;
  141599. impostorSize?: number | {
  141600. width: number;
  141601. height: number;
  141602. depth: number;
  141603. };
  141604. friction?: number;
  141605. restitution?: number;
  141606. }): void;
  141607. /**
  141608. * attach this feature
  141609. * Will usually be called by the features manager
  141610. *
  141611. * @returns true if successful.
  141612. */
  141613. attach(): boolean;
  141614. /**
  141615. * detach this feature.
  141616. * Will usually be called by the features manager
  141617. *
  141618. * @returns true if successful.
  141619. */
  141620. detach(): boolean;
  141621. /**
  141622. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  141623. * @param xrController the controller to add
  141624. */
  141625. addController(xrController: WebXRController): void;
  141626. private _debugMode;
  141627. /**
  141628. * @hidden
  141629. * enable debugging - will show console outputs and the impostor mesh
  141630. */
  141631. _enablePhysicsDebug(): void;
  141632. private _attachController;
  141633. private _detachController;
  141634. protected _onXRFrame(_xrFrame: any): void;
  141635. }
  141636. }
  141637. declare module BABYLON {
  141638. /**
  141639. * The motion controller class for all microsoft mixed reality controllers
  141640. */
  141641. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  141642. /**
  141643. * The base url used to load the left and right controller models
  141644. */
  141645. static MODEL_BASE_URL: string;
  141646. /**
  141647. * The name of the left controller model file
  141648. */
  141649. static MODEL_LEFT_FILENAME: string;
  141650. /**
  141651. * The name of the right controller model file
  141652. */
  141653. static MODEL_RIGHT_FILENAME: string;
  141654. profileId: string;
  141655. protected readonly _mapping: {
  141656. defaultButton: {
  141657. "valueNodeName": string;
  141658. "unpressedNodeName": string;
  141659. "pressedNodeName": string;
  141660. };
  141661. defaultAxis: {
  141662. "valueNodeName": string;
  141663. "minNodeName": string;
  141664. "maxNodeName": string;
  141665. };
  141666. buttons: {
  141667. "xr-standard-trigger": {
  141668. "rootNodeName": string;
  141669. "componentProperty": string;
  141670. "states": string[];
  141671. };
  141672. "xr-standard-squeeze": {
  141673. "rootNodeName": string;
  141674. "componentProperty": string;
  141675. "states": string[];
  141676. };
  141677. "xr-standard-touchpad": {
  141678. "rootNodeName": string;
  141679. "labelAnchorNodeName": string;
  141680. "touchPointNodeName": string;
  141681. };
  141682. "xr-standard-thumbstick": {
  141683. "rootNodeName": string;
  141684. "componentProperty": string;
  141685. "states": string[];
  141686. };
  141687. };
  141688. axes: {
  141689. "xr-standard-touchpad": {
  141690. "x-axis": {
  141691. "rootNodeName": string;
  141692. };
  141693. "y-axis": {
  141694. "rootNodeName": string;
  141695. };
  141696. };
  141697. "xr-standard-thumbstick": {
  141698. "x-axis": {
  141699. "rootNodeName": string;
  141700. };
  141701. "y-axis": {
  141702. "rootNodeName": string;
  141703. };
  141704. };
  141705. };
  141706. };
  141707. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  141708. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  141709. protected _getFilenameAndPath(): {
  141710. filename: string;
  141711. path: string;
  141712. };
  141713. protected _updateModel(): void;
  141714. protected _getModelLoadingConstraints(): boolean;
  141715. protected _setRootMesh(meshes: AbstractMesh[]): void;
  141716. }
  141717. }
  141718. declare module BABYLON {
  141719. /**
  141720. * The motion controller class for oculus touch (quest, rift).
  141721. * This class supports legacy mapping as well the standard xr mapping
  141722. */
  141723. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  141724. private _forceLegacyControllers;
  141725. /**
  141726. * The base url used to load the left and right controller models
  141727. */
  141728. static MODEL_BASE_URL: string;
  141729. /**
  141730. * The name of the left controller model file
  141731. */
  141732. static MODEL_LEFT_FILENAME: string;
  141733. /**
  141734. * The name of the right controller model file
  141735. */
  141736. static MODEL_RIGHT_FILENAME: string;
  141737. /**
  141738. * Base Url for the Quest controller model.
  141739. */
  141740. static QUEST_MODEL_BASE_URL: string;
  141741. profileId: string;
  141742. private _modelRootNode;
  141743. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  141744. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  141745. protected _getFilenameAndPath(): {
  141746. filename: string;
  141747. path: string;
  141748. };
  141749. /**
  141750. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  141751. * between the touch and touch 2.
  141752. */
  141753. private _isQuest;
  141754. protected _updateModel(): void;
  141755. protected _getModelLoadingConstraints(): boolean;
  141756. protected _setRootMesh(meshes: AbstractMesh[]): void;
  141757. }
  141758. }
  141759. declare module BABYLON {
  141760. /**
  141761. * The motion controller class for the standard HTC-Vive controllers
  141762. */
  141763. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  141764. /**
  141765. * The base url used to load the left and right controller models
  141766. */
  141767. static MODEL_BASE_URL: string;
  141768. /**
  141769. * File name for the controller model.
  141770. */
  141771. static MODEL_FILENAME: string;
  141772. profileId: string;
  141773. private _modelRootNode;
  141774. /**
  141775. * Create a new Vive motion controller object
  141776. * @param scene the scene to use to create this controller
  141777. * @param gamepadObject the corresponding gamepad object
  141778. * @param handness the handness of the controller
  141779. */
  141780. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  141781. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  141782. protected _getFilenameAndPath(): {
  141783. filename: string;
  141784. path: string;
  141785. };
  141786. protected _updateModel(): void;
  141787. protected _getModelLoadingConstraints(): boolean;
  141788. protected _setRootMesh(meshes: AbstractMesh[]): void;
  141789. }
  141790. }
  141791. declare module BABYLON {
  141792. /**
  141793. * A cursor which tracks a point on a path
  141794. */
  141795. export class PathCursor {
  141796. private path;
  141797. /**
  141798. * Stores path cursor callbacks for when an onchange event is triggered
  141799. */
  141800. private _onchange;
  141801. /**
  141802. * The value of the path cursor
  141803. */
  141804. value: number;
  141805. /**
  141806. * The animation array of the path cursor
  141807. */
  141808. animations: Animation[];
  141809. /**
  141810. * Initializes the path cursor
  141811. * @param path The path to track
  141812. */
  141813. constructor(path: Path2);
  141814. /**
  141815. * Gets the cursor point on the path
  141816. * @returns A point on the path cursor at the cursor location
  141817. */
  141818. getPoint(): Vector3;
  141819. /**
  141820. * Moves the cursor ahead by the step amount
  141821. * @param step The amount to move the cursor forward
  141822. * @returns This path cursor
  141823. */
  141824. moveAhead(step?: number): PathCursor;
  141825. /**
  141826. * Moves the cursor behind by the step amount
  141827. * @param step The amount to move the cursor back
  141828. * @returns This path cursor
  141829. */
  141830. moveBack(step?: number): PathCursor;
  141831. /**
  141832. * Moves the cursor by the step amount
  141833. * If the step amount is greater than one, an exception is thrown
  141834. * @param step The amount to move the cursor
  141835. * @returns This path cursor
  141836. */
  141837. move(step: number): PathCursor;
  141838. /**
  141839. * Ensures that the value is limited between zero and one
  141840. * @returns This path cursor
  141841. */
  141842. private ensureLimits;
  141843. /**
  141844. * Runs onchange callbacks on change (used by the animation engine)
  141845. * @returns This path cursor
  141846. */
  141847. private raiseOnChange;
  141848. /**
  141849. * Executes a function on change
  141850. * @param f A path cursor onchange callback
  141851. * @returns This path cursor
  141852. */
  141853. onchange(f: (cursor: PathCursor) => void): PathCursor;
  141854. }
  141855. }
  141856. declare module BABYLON {
  141857. /** @hidden */
  141858. export var blurPixelShader: {
  141859. name: string;
  141860. shader: string;
  141861. };
  141862. }
  141863. declare module BABYLON {
  141864. /** @hidden */
  141865. export var pointCloudVertexDeclaration: {
  141866. name: string;
  141867. shader: string;
  141868. };
  141869. }
  141870. // Mixins
  141871. interface Window {
  141872. mozIndexedDB: IDBFactory;
  141873. webkitIndexedDB: IDBFactory;
  141874. msIndexedDB: IDBFactory;
  141875. webkitURL: typeof URL;
  141876. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  141877. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  141878. WebGLRenderingContext: WebGLRenderingContext;
  141879. MSGesture: MSGesture;
  141880. CANNON: any;
  141881. AudioContext: AudioContext;
  141882. webkitAudioContext: AudioContext;
  141883. PointerEvent: any;
  141884. Math: Math;
  141885. Uint8Array: Uint8ArrayConstructor;
  141886. Float32Array: Float32ArrayConstructor;
  141887. mozURL: typeof URL;
  141888. msURL: typeof URL;
  141889. VRFrameData: any; // WebVR, from specs 1.1
  141890. DracoDecoderModule: any;
  141891. setImmediate(handler: (...args: any[]) => void): number;
  141892. }
  141893. interface HTMLCanvasElement {
  141894. requestPointerLock(): void;
  141895. msRequestPointerLock?(): void;
  141896. mozRequestPointerLock?(): void;
  141897. webkitRequestPointerLock?(): void;
  141898. /** Track wether a record is in progress */
  141899. isRecording: boolean;
  141900. /** Capture Stream method defined by some browsers */
  141901. captureStream(fps?: number): MediaStream;
  141902. }
  141903. interface CanvasRenderingContext2D {
  141904. msImageSmoothingEnabled: boolean;
  141905. }
  141906. interface MouseEvent {
  141907. mozMovementX: number;
  141908. mozMovementY: number;
  141909. webkitMovementX: number;
  141910. webkitMovementY: number;
  141911. msMovementX: number;
  141912. msMovementY: number;
  141913. }
  141914. interface Navigator {
  141915. mozGetVRDevices: (any: any) => any;
  141916. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141917. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141918. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141919. webkitGetGamepads(): Gamepad[];
  141920. msGetGamepads(): Gamepad[];
  141921. webkitGamepads(): Gamepad[];
  141922. }
  141923. interface HTMLVideoElement {
  141924. mozSrcObject: any;
  141925. }
  141926. interface Math {
  141927. fround(x: number): number;
  141928. imul(a: number, b: number): number;
  141929. }
  141930. interface WebGLRenderingContext {
  141931. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  141932. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  141933. vertexAttribDivisor(index: number, divisor: number): void;
  141934. createVertexArray(): any;
  141935. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  141936. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  141937. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  141938. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  141939. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  141940. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  141941. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  141942. // Queries
  141943. createQuery(): WebGLQuery;
  141944. deleteQuery(query: WebGLQuery): void;
  141945. beginQuery(target: number, query: WebGLQuery): void;
  141946. endQuery(target: number): void;
  141947. getQueryParameter(query: WebGLQuery, pname: number): any;
  141948. getQuery(target: number, pname: number): any;
  141949. MAX_SAMPLES: number;
  141950. RGBA8: number;
  141951. READ_FRAMEBUFFER: number;
  141952. DRAW_FRAMEBUFFER: number;
  141953. UNIFORM_BUFFER: number;
  141954. HALF_FLOAT_OES: number;
  141955. RGBA16F: number;
  141956. RGBA32F: number;
  141957. R32F: number;
  141958. RG32F: number;
  141959. RGB32F: number;
  141960. R16F: number;
  141961. RG16F: number;
  141962. RGB16F: number;
  141963. RED: number;
  141964. RG: number;
  141965. R8: number;
  141966. RG8: number;
  141967. UNSIGNED_INT_24_8: number;
  141968. DEPTH24_STENCIL8: number;
  141969. MIN: number;
  141970. MAX: number;
  141971. /* Multiple Render Targets */
  141972. drawBuffers(buffers: number[]): void;
  141973. readBuffer(src: number): void;
  141974. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  141975. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  141976. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  141977. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  141978. // Occlusion Query
  141979. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  141980. ANY_SAMPLES_PASSED: number;
  141981. QUERY_RESULT_AVAILABLE: number;
  141982. QUERY_RESULT: number;
  141983. }
  141984. interface WebGLProgram {
  141985. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  141986. }
  141987. interface EXT_disjoint_timer_query {
  141988. QUERY_COUNTER_BITS_EXT: number;
  141989. TIME_ELAPSED_EXT: number;
  141990. TIMESTAMP_EXT: number;
  141991. GPU_DISJOINT_EXT: number;
  141992. QUERY_RESULT_EXT: number;
  141993. QUERY_RESULT_AVAILABLE_EXT: number;
  141994. queryCounterEXT(query: WebGLQuery, target: number): void;
  141995. createQueryEXT(): WebGLQuery;
  141996. beginQueryEXT(target: number, query: WebGLQuery): void;
  141997. endQueryEXT(target: number): void;
  141998. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  141999. deleteQueryEXT(query: WebGLQuery): void;
  142000. }
  142001. interface WebGLUniformLocation {
  142002. _currentState: any;
  142003. }
  142004. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142005. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142006. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142007. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142008. interface WebGLRenderingContext {
  142009. readonly RASTERIZER_DISCARD: number;
  142010. readonly DEPTH_COMPONENT24: number;
  142011. readonly TEXTURE_3D: number;
  142012. readonly TEXTURE_2D_ARRAY: number;
  142013. readonly TEXTURE_COMPARE_FUNC: number;
  142014. readonly TEXTURE_COMPARE_MODE: number;
  142015. readonly COMPARE_REF_TO_TEXTURE: number;
  142016. readonly TEXTURE_WRAP_R: number;
  142017. readonly HALF_FLOAT: number;
  142018. readonly RGB8: number;
  142019. readonly RED_INTEGER: number;
  142020. readonly RG_INTEGER: number;
  142021. readonly RGB_INTEGER: number;
  142022. readonly RGBA_INTEGER: number;
  142023. readonly R8_SNORM: number;
  142024. readonly RG8_SNORM: number;
  142025. readonly RGB8_SNORM: number;
  142026. readonly RGBA8_SNORM: number;
  142027. readonly R8I: number;
  142028. readonly RG8I: number;
  142029. readonly RGB8I: number;
  142030. readonly RGBA8I: number;
  142031. readonly R8UI: number;
  142032. readonly RG8UI: number;
  142033. readonly RGB8UI: number;
  142034. readonly RGBA8UI: number;
  142035. readonly R16I: number;
  142036. readonly RG16I: number;
  142037. readonly RGB16I: number;
  142038. readonly RGBA16I: number;
  142039. readonly R16UI: number;
  142040. readonly RG16UI: number;
  142041. readonly RGB16UI: number;
  142042. readonly RGBA16UI: number;
  142043. readonly R32I: number;
  142044. readonly RG32I: number;
  142045. readonly RGB32I: number;
  142046. readonly RGBA32I: number;
  142047. readonly R32UI: number;
  142048. readonly RG32UI: number;
  142049. readonly RGB32UI: number;
  142050. readonly RGBA32UI: number;
  142051. readonly RGB10_A2UI: number;
  142052. readonly R11F_G11F_B10F: number;
  142053. readonly RGB9_E5: number;
  142054. readonly RGB10_A2: number;
  142055. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142056. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142057. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142058. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142059. readonly DEPTH_COMPONENT32F: number;
  142060. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142061. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142062. 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;
  142063. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142064. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142065. readonly TRANSFORM_FEEDBACK: number;
  142066. readonly INTERLEAVED_ATTRIBS: number;
  142067. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142068. createTransformFeedback(): WebGLTransformFeedback;
  142069. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142070. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142071. beginTransformFeedback(primitiveMode: number): void;
  142072. endTransformFeedback(): void;
  142073. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142074. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142075. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142076. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142077. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142078. }
  142079. interface ImageBitmap {
  142080. readonly width: number;
  142081. readonly height: number;
  142082. close(): void;
  142083. }
  142084. interface WebGLQuery extends WebGLObject {
  142085. }
  142086. declare var WebGLQuery: {
  142087. prototype: WebGLQuery;
  142088. new(): WebGLQuery;
  142089. };
  142090. interface WebGLSampler extends WebGLObject {
  142091. }
  142092. declare var WebGLSampler: {
  142093. prototype: WebGLSampler;
  142094. new(): WebGLSampler;
  142095. };
  142096. interface WebGLSync extends WebGLObject {
  142097. }
  142098. declare var WebGLSync: {
  142099. prototype: WebGLSync;
  142100. new(): WebGLSync;
  142101. };
  142102. interface WebGLTransformFeedback extends WebGLObject {
  142103. }
  142104. declare var WebGLTransformFeedback: {
  142105. prototype: WebGLTransformFeedback;
  142106. new(): WebGLTransformFeedback;
  142107. };
  142108. interface WebGLVertexArrayObject extends WebGLObject {
  142109. }
  142110. declare var WebGLVertexArrayObject: {
  142111. prototype: WebGLVertexArrayObject;
  142112. new(): WebGLVertexArrayObject;
  142113. };
  142114. // Type definitions for WebVR API
  142115. // Project: https://w3c.github.io/webvr/
  142116. // Definitions by: six a <https://github.com/lostfictions>
  142117. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142118. interface VRDisplay extends EventTarget {
  142119. /**
  142120. * Dictionary of capabilities describing the VRDisplay.
  142121. */
  142122. readonly capabilities: VRDisplayCapabilities;
  142123. /**
  142124. * z-depth defining the far plane of the eye view frustum
  142125. * enables mapping of values in the render target depth
  142126. * attachment to scene coordinates. Initially set to 10000.0.
  142127. */
  142128. depthFar: number;
  142129. /**
  142130. * z-depth defining the near plane of the eye view frustum
  142131. * enables mapping of values in the render target depth
  142132. * attachment to scene coordinates. Initially set to 0.01.
  142133. */
  142134. depthNear: number;
  142135. /**
  142136. * An identifier for this distinct VRDisplay. Used as an
  142137. * association point in the Gamepad API.
  142138. */
  142139. readonly displayId: number;
  142140. /**
  142141. * A display name, a user-readable name identifying it.
  142142. */
  142143. readonly displayName: string;
  142144. readonly isConnected: boolean;
  142145. readonly isPresenting: boolean;
  142146. /**
  142147. * If this VRDisplay supports room-scale experiences, the optional
  142148. * stage attribute contains details on the room-scale parameters.
  142149. */
  142150. readonly stageParameters: VRStageParameters | null;
  142151. /**
  142152. * Passing the value returned by `requestAnimationFrame` to
  142153. * `cancelAnimationFrame` will unregister the callback.
  142154. * @param handle Define the hanle of the request to cancel
  142155. */
  142156. cancelAnimationFrame(handle: number): void;
  142157. /**
  142158. * Stops presenting to the VRDisplay.
  142159. * @returns a promise to know when it stopped
  142160. */
  142161. exitPresent(): Promise<void>;
  142162. /**
  142163. * Return the current VREyeParameters for the given eye.
  142164. * @param whichEye Define the eye we want the parameter for
  142165. * @returns the eye parameters
  142166. */
  142167. getEyeParameters(whichEye: string): VREyeParameters;
  142168. /**
  142169. * Populates the passed VRFrameData with the information required to render
  142170. * the current frame.
  142171. * @param frameData Define the data structure to populate
  142172. * @returns true if ok otherwise false
  142173. */
  142174. getFrameData(frameData: VRFrameData): boolean;
  142175. /**
  142176. * Get the layers currently being presented.
  142177. * @returns the list of VR layers
  142178. */
  142179. getLayers(): VRLayer[];
  142180. /**
  142181. * Return a VRPose containing the future predicted pose of the VRDisplay
  142182. * when the current frame will be presented. The value returned will not
  142183. * change until JavaScript has returned control to the browser.
  142184. *
  142185. * The VRPose will contain the position, orientation, velocity,
  142186. * and acceleration of each of these properties.
  142187. * @returns the pose object
  142188. */
  142189. getPose(): VRPose;
  142190. /**
  142191. * Return the current instantaneous pose of the VRDisplay, with no
  142192. * prediction applied.
  142193. * @returns the current instantaneous pose
  142194. */
  142195. getImmediatePose(): VRPose;
  142196. /**
  142197. * The callback passed to `requestAnimationFrame` will be called
  142198. * any time a new frame should be rendered. When the VRDisplay is
  142199. * presenting the callback will be called at the native refresh
  142200. * rate of the HMD. When not presenting this function acts
  142201. * identically to how window.requestAnimationFrame acts. Content should
  142202. * make no assumptions of frame rate or vsync behavior as the HMD runs
  142203. * asynchronously from other displays and at differing refresh rates.
  142204. * @param callback Define the eaction to run next frame
  142205. * @returns the request handle it
  142206. */
  142207. requestAnimationFrame(callback: FrameRequestCallback): number;
  142208. /**
  142209. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  142210. * Repeat calls while already presenting will update the VRLayers being displayed.
  142211. * @param layers Define the list of layer to present
  142212. * @returns a promise to know when the request has been fulfilled
  142213. */
  142214. requestPresent(layers: VRLayer[]): Promise<void>;
  142215. /**
  142216. * Reset the pose for this display, treating its current position and
  142217. * orientation as the "origin/zero" values. VRPose.position,
  142218. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  142219. * updated when calling resetPose(). This should be called in only
  142220. * sitting-space experiences.
  142221. */
  142222. resetPose(): void;
  142223. /**
  142224. * The VRLayer provided to the VRDisplay will be captured and presented
  142225. * in the HMD. Calling this function has the same effect on the source
  142226. * canvas as any other operation that uses its source image, and canvases
  142227. * created without preserveDrawingBuffer set to true will be cleared.
  142228. * @param pose Define the pose to submit
  142229. */
  142230. submitFrame(pose?: VRPose): void;
  142231. }
  142232. declare var VRDisplay: {
  142233. prototype: VRDisplay;
  142234. new(): VRDisplay;
  142235. };
  142236. interface VRLayer {
  142237. leftBounds?: number[] | Float32Array | null;
  142238. rightBounds?: number[] | Float32Array | null;
  142239. source?: HTMLCanvasElement | null;
  142240. }
  142241. interface VRDisplayCapabilities {
  142242. readonly canPresent: boolean;
  142243. readonly hasExternalDisplay: boolean;
  142244. readonly hasOrientation: boolean;
  142245. readonly hasPosition: boolean;
  142246. readonly maxLayers: number;
  142247. }
  142248. interface VREyeParameters {
  142249. /** @deprecated */
  142250. readonly fieldOfView: VRFieldOfView;
  142251. readonly offset: Float32Array;
  142252. readonly renderHeight: number;
  142253. readonly renderWidth: number;
  142254. }
  142255. interface VRFieldOfView {
  142256. readonly downDegrees: number;
  142257. readonly leftDegrees: number;
  142258. readonly rightDegrees: number;
  142259. readonly upDegrees: number;
  142260. }
  142261. interface VRFrameData {
  142262. readonly leftProjectionMatrix: Float32Array;
  142263. readonly leftViewMatrix: Float32Array;
  142264. readonly pose: VRPose;
  142265. readonly rightProjectionMatrix: Float32Array;
  142266. readonly rightViewMatrix: Float32Array;
  142267. readonly timestamp: number;
  142268. }
  142269. interface VRPose {
  142270. readonly angularAcceleration: Float32Array | null;
  142271. readonly angularVelocity: Float32Array | null;
  142272. readonly linearAcceleration: Float32Array | null;
  142273. readonly linearVelocity: Float32Array | null;
  142274. readonly orientation: Float32Array | null;
  142275. readonly position: Float32Array | null;
  142276. readonly timestamp: number;
  142277. }
  142278. interface VRStageParameters {
  142279. sittingToStandingTransform?: Float32Array;
  142280. sizeX?: number;
  142281. sizeY?: number;
  142282. }
  142283. interface Navigator {
  142284. getVRDisplays(): Promise<VRDisplay[]>;
  142285. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  142286. }
  142287. interface Window {
  142288. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  142289. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  142290. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  142291. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  142292. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  142293. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  142294. }
  142295. interface Gamepad {
  142296. readonly displayId: number;
  142297. }
  142298. type XRSessionMode =
  142299. | "inline"
  142300. | "immersive-vr"
  142301. | "immersive-ar";
  142302. type XRReferenceSpaceType =
  142303. | "viewer"
  142304. | "local"
  142305. | "local-floor"
  142306. | "bounded-floor"
  142307. | "unbounded";
  142308. type XREnvironmentBlendMode =
  142309. | "opaque"
  142310. | "additive"
  142311. | "alpha-blend";
  142312. type XRVisibilityState =
  142313. | "visible"
  142314. | "visible-blurred"
  142315. | "hidden";
  142316. type XRHandedness =
  142317. | "none"
  142318. | "left"
  142319. | "right";
  142320. type XRTargetRayMode =
  142321. | "gaze"
  142322. | "tracked-pointer"
  142323. | "screen";
  142324. type XREye =
  142325. | "none"
  142326. | "left"
  142327. | "right";
  142328. interface XRSpace extends EventTarget {
  142329. }
  142330. interface XRRenderState {
  142331. depthNear?: number;
  142332. depthFar?: number;
  142333. inlineVerticalFieldOfView?: number;
  142334. baseLayer?: XRWebGLLayer;
  142335. }
  142336. interface XRInputSource {
  142337. handedness: XRHandedness;
  142338. targetRayMode: XRTargetRayMode;
  142339. targetRaySpace: XRSpace;
  142340. gripSpace: XRSpace | undefined;
  142341. gamepad: Gamepad | undefined;
  142342. profiles: Array<string>;
  142343. }
  142344. interface XRSessionInit {
  142345. optionalFeatures?: XRReferenceSpaceType[];
  142346. requiredFeatures?: XRReferenceSpaceType[];
  142347. }
  142348. interface XRSession extends XRAnchorCreator {
  142349. addEventListener: Function;
  142350. removeEventListener: Function;
  142351. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  142352. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  142353. requestAnimationFrame: Function;
  142354. end(): Promise<void>;
  142355. renderState: XRRenderState;
  142356. inputSources: Array<XRInputSource>;
  142357. // AR hit test
  142358. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142359. updateWorldTrackingState(options: {
  142360. planeDetectionState?: { enabled: boolean; }
  142361. }): void;
  142362. }
  142363. interface XRReferenceSpace extends XRSpace {
  142364. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  142365. onreset: any;
  142366. }
  142367. type XRPlaneSet = Set<XRPlane>;
  142368. type XRAnchorSet = Set<XRAnchor>;
  142369. interface XRFrame {
  142370. session: XRSession;
  142371. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  142372. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  142373. // Anchors
  142374. trackedAnchors?: XRAnchorSet;
  142375. // Planes
  142376. worldInformation: {
  142377. detectedPlanes?: XRPlaneSet;
  142378. };
  142379. }
  142380. interface XRViewerPose extends XRPose {
  142381. views: Array<XRView>;
  142382. }
  142383. interface XRPose {
  142384. transform: XRRigidTransform;
  142385. emulatedPosition: boolean;
  142386. }
  142387. interface XRWebGLLayerOptions {
  142388. antialias?: boolean;
  142389. depth?: boolean;
  142390. stencil?: boolean;
  142391. alpha?: boolean;
  142392. multiview?: boolean;
  142393. framebufferScaleFactor?: number;
  142394. }
  142395. declare var XRWebGLLayer: {
  142396. prototype: XRWebGLLayer;
  142397. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  142398. };
  142399. interface XRWebGLLayer {
  142400. framebuffer: WebGLFramebuffer;
  142401. framebufferWidth: number;
  142402. framebufferHeight: number;
  142403. getViewport: Function;
  142404. }
  142405. declare class XRRigidTransform {
  142406. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  142407. position: DOMPointReadOnly;
  142408. orientation: DOMPointReadOnly;
  142409. matrix: Float32Array;
  142410. inverse: XRRigidTransform;
  142411. }
  142412. interface XRView {
  142413. eye: XREye;
  142414. projectionMatrix: Float32Array;
  142415. transform: XRRigidTransform;
  142416. }
  142417. interface XRInputSourceChangeEvent {
  142418. session: XRSession;
  142419. removed: Array<XRInputSource>;
  142420. added: Array<XRInputSource>;
  142421. }
  142422. interface XRInputSourceEvent extends Event {
  142423. readonly frame: XRFrame;
  142424. readonly inputSource: XRInputSource;
  142425. }
  142426. // Experimental(er) features
  142427. declare class XRRay {
  142428. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  142429. origin: DOMPointReadOnly;
  142430. direction: DOMPointReadOnly;
  142431. matrix: Float32Array;
  142432. }
  142433. interface XRHitResult {
  142434. hitMatrix: Float32Array;
  142435. }
  142436. interface XRAnchor {
  142437. // remove?
  142438. id?: string;
  142439. anchorSpace: XRSpace;
  142440. lastChangedTime: number;
  142441. detach(): void;
  142442. }
  142443. interface XRPlane extends XRAnchorCreator {
  142444. orientation: "Horizontal" | "Vertical";
  142445. planeSpace: XRSpace;
  142446. polygon: Array<DOMPointReadOnly>;
  142447. lastChangedTime: number;
  142448. }
  142449. interface XRAnchorCreator {
  142450. // AR Anchors
  142451. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  142452. }